Remove the max half-open connections option from GUI
[qBittorrent.git] / src / gui / optionsdialog.h
blob4e3a2d84122edac31040e4775e6c38435073c439
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 #ifndef OPTIONSDIALOG_H
30 #define OPTIONSDIALOG_H
32 #include <QButtonGroup>
33 #include <QDialog>
35 class QAbstractButton;
36 class QCloseEvent;
37 class QListWidgetItem;
38 class AdvancedSettings;
40 // actions on double-click on torrents
41 enum DoubleClickAction
43 TOGGLE_PAUSE,
44 OPEN_DEST,
45 NO_ACTION
48 namespace Net
50 enum class ProxyType;
53 namespace Ui
55 class OptionsDialog;
58 class OptionsDialog : public QDialog
60 Q_OBJECT
61 using ThisType = OptionsDialog;
63 enum Tabs
65 TAB_UI,
66 TAB_DOWNLOADS,
67 TAB_CONNECTION,
68 TAB_SPEED,
69 TAB_BITTORRENT,
70 TAB_RSS,
71 TAB_WEBUI,
72 TAB_ADVANCED
75 enum class ShowError
77 NotShow,
78 Show
81 public:
82 // Constructor / Destructor
83 OptionsDialog(QWidget *parent = nullptr);
84 ~OptionsDialog();
86 public slots:
87 void showConnectionTab();
89 private slots:
90 void enableForceProxy(bool enable);
91 void enableProxy(int index);
92 void on_buttonBox_accepted();
93 void closeEvent(QCloseEvent *e) override;
94 void on_buttonBox_rejected();
95 void applySettings(QAbstractButton *button);
96 void enableApplyButton();
97 void toggleComboRatioLimitAct();
98 void changePage(QListWidgetItem *, QListWidgetItem *);
99 void loadWindowState();
100 void loadSplitterState();
101 void saveWindowState() const;
102 void handleScanFolderViewSelectionChanged();
103 void on_IpFilterRefreshBtn_clicked();
104 void handleIPFilterParsed(bool error, int ruleCount);
105 void on_banListButton_clicked();
106 void on_IPSubnetWhitelistButton_clicked();
107 void on_randomButton_clicked();
108 void on_addScanFolderButton_clicked();
109 void on_removeScanFolderButton_clicked();
110 void on_registerDNSBtn_clicked();
111 void setLocale(const QString &localeStr);
112 void webUIHttpsCertChanged(const QString &path, ShowError showError);
113 void webUIHttpsKeyChanged(const QString &path, ShowError showError);
115 private:
116 // Methods
117 void saveOptions();
118 void loadOptions();
119 void initializeLanguageCombo();
120 static QString languageToLocalizedString(const QLocale &locale);
121 // General options
122 QString getLocale() const;
123 #ifndef Q_OS_MAC
124 bool systrayIntegration() const;
125 bool minimizeToTray() const;
126 bool closeToTray() const;
127 #endif
128 bool startMinimized() const;
129 bool isSplashScreenDisabled() const;
130 #ifdef Q_OS_WIN
131 bool WinStartup() const;
132 #endif
133 // Downloads
134 bool preAllocateAllFiles() const;
135 bool useAdditionDialog() const;
136 bool addTorrentsInPause() const;
137 QString getTorrentExportDir() const;
138 QString getFinishedTorrentExportDir() const;
139 QString askForExportDir(const QString &currentExportPath);
140 int getActionOnDblClOnTorrentDl() const;
141 int getActionOnDblClOnTorrentFn() const;
142 // Connection options
143 int getPort() const;
144 bool isUPnPEnabled() const;
145 // Bittorrent options
146 int getMaxConnecs() const;
147 int getMaxConnecsPerTorrent() const;
148 int getMaxUploads() const;
149 int getMaxUploadsPerTorrent() const;
150 bool isDHTEnabled() const;
151 bool isLSDEnabled() const;
152 int getEncryptionSetting() const;
153 qreal getMaxRatio() const;
154 int getMaxSeedingMinutes() const;
155 // Proxy options
156 bool isProxyEnabled() const;
157 bool isProxyAuthEnabled() const;
158 QString getProxyIp() const;
159 unsigned short getProxyPort() const;
160 QString getProxyUsername() const;
161 QString getProxyPassword() const;
162 Net::ProxyType getProxyType() const;
163 // IP Filter
164 bool isIPFilteringEnabled() const;
165 QString getFilter() const;
166 bool m_refreshingIpFilter;
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 QAbstractButton *m_applyButton;
183 AdvancedSettings *m_advancedSettings;
184 QList<QString> m_addedScanDirs;
185 QList<QString> m_removedScanDirs;
188 #endif // OPTIONSDIALOG_H