Sync translations from Transifex and run lupdate
[qBittorrent.git] / src / gui / optionsdialog.h
blob35a9280ce1f34380a87e263c6782fbcca18e42fc
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
29 #pragma once
31 #include <QDialog>
33 #include "base/settingvalue.h"
35 class QCloseEvent;
36 class QListWidgetItem;
38 class AdvancedSettings;
40 // actions on double-click on torrents
41 enum DoubleClickAction
43 TOGGLE_PAUSE,
44 OPEN_DEST,
45 PREVIEW_FILE,
46 NO_ACTION
49 namespace Net
51 enum class ProxyType;
54 namespace Ui
56 class OptionsDialog;
59 class OptionsDialog final : public QDialog
61 Q_OBJECT
62 Q_DISABLE_COPY_MOVE(OptionsDialog)
64 using ThisType = OptionsDialog;
66 enum Tabs
68 TAB_UI,
69 TAB_DOWNLOADS,
70 TAB_CONNECTION,
71 TAB_SPEED,
72 TAB_BITTORRENT,
73 TAB_RSS,
74 TAB_WEBUI,
75 TAB_ADVANCED
78 enum class ShowError
80 NotShow,
81 Show
84 public:
85 // Constructor / Destructor
86 OptionsDialog(QWidget *parent = nullptr);
87 ~OptionsDialog() override;
89 public slots:
90 void showConnectionTab();
92 private slots:
93 void enableProxy(int index);
94 void on_buttonBox_accepted();
95 void closeEvent(QCloseEvent *e) override;
96 void on_buttonBox_rejected();
97 void applySettings();
98 void enableApplyButton();
99 void toggleComboRatioLimitAct();
100 void changePage(QListWidgetItem *, QListWidgetItem *);
101 void loadSplitterState();
102 void handleWatchedFolderViewSelectionChanged();
103 void editWatchedFolderOptions(const QModelIndex &index);
104 void on_IpFilterRefreshBtn_clicked();
105 void handleIPFilterParsed(bool error, int ruleCount);
106 void on_banListButton_clicked();
107 void on_IPSubnetWhitelistButton_clicked();
108 void on_randomButton_clicked();
109 void on_addWatchedFolderButton_clicked();
110 void on_editWatchedFolderButton_clicked();
111 void on_removeWatchedFolderButton_clicked();
112 void on_registerDNSBtn_clicked();
113 void setLocale(const QString &localeStr);
114 void webUIHttpsCertChanged(const QString &path, ShowError showError);
115 void webUIHttpsKeyChanged(const QString &path, ShowError showError);
117 private:
118 // Methods
119 void saveOptions();
120 void loadOptions();
121 void initializeLanguageCombo();
122 // General options
123 QString getLocale() const;
124 #ifndef Q_OS_MACOS
125 bool systrayIntegration() const;
126 bool minimizeToTray() const;
127 bool closeToTray() const;
128 #endif
129 bool startMinimized() const;
130 bool isSplashScreenDisabled() const;
131 #ifdef Q_OS_WIN
132 bool WinStartup() const;
133 #endif
134 // Downloads
135 bool preAllocateAllFiles() const;
136 bool useAdditionDialog() const;
137 bool addTorrentsInPause() const;
138 QString getTorrentExportDir() const;
139 QString getFinishedTorrentExportDir() const;
140 QString askForExportDir(const QString &currentExportPath);
141 int getActionOnDblClOnTorrentDl() const;
142 int getActionOnDblClOnTorrentFn() const;
143 // Connection options
144 int getPort() const;
145 bool isUPnPEnabled() const;
146 // Bittorrent options
147 int getMaxConnecs() const;
148 int getMaxConnecsPerTorrent() const;
149 int getMaxUploads() const;
150 int getMaxUploadsPerTorrent() const;
151 bool isDHTEnabled() const;
152 bool isLSDEnabled() const;
153 int getEncryptionSetting() const;
154 qreal getMaxRatio() const;
155 int getMaxSeedingMinutes() const;
156 // Proxy options
157 bool isProxyEnabled() const;
158 bool isProxyAuthEnabled() const;
159 QString getProxyIp() const;
160 unsigned short getProxyPort() const;
161 QString getProxyUsername() const;
162 QString getProxyPassword() const;
163 Net::ProxyType getProxyType() const;
164 // IP Filter
165 bool isIPFilteringEnabled() const;
166 QString getFilter() const;
167 // Queueing system
168 bool isQueueingSystemEnabled() const;
169 int getMaxActiveDownloads() const;
170 int getMaxActiveUploads() const;
171 int getMaxActiveTorrents() const;
172 // WebUI
173 bool isWebUiEnabled() const;
174 QString webUiUsername() const;
175 QString webUiPassword() const;
176 bool webUIAuthenticationOk();
177 bool isAlternativeWebUIPathValid();
179 bool schedTimesOk();
181 Ui::OptionsDialog *m_ui;
182 SettingValue<QSize> m_storeDialogSize;
183 SettingValue<QStringList> m_storeHSplitterSize;
184 SettingValue<int> m_storeLastViewedPage;
186 QPushButton *m_applyButton;
188 AdvancedSettings *m_advancedSettings;
190 bool m_refreshingIpFilter = false;