qBittorrent
optionsdialog.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2006 Christophe Dumez <[email protected]>
4  *
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.
9  *
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.
14  *
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.
18  *
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.
27  */
28 
29 #pragma once
30 
31 #include <QDialog>
32 
33 #include "base/settingvalue.h"
34 
35 class QCloseEvent;
36 class QListWidgetItem;
37 
38 class AdvancedSettings;
39 
40 // actions on double-click on torrents
42 {
44  OPEN_DEST = 1,
46  NO_ACTION = 3,
47  SHOW_OPTIONS = 4
48 };
49 
50 namespace Net
51 {
52  enum class ProxyType;
53 }
54 
55 namespace Ui
56 {
57  class OptionsDialog;
58 }
59 
60 class OptionsDialog final : public QDialog
61 {
62  Q_OBJECT
63  Q_DISABLE_COPY_MOVE(OptionsDialog)
64 
66 
67  enum Tabs
68  {
77  };
78 
79  enum class ShowError
80  {
81  NotShow,
82  Show
83  };
84 
85 public:
86  // Constructor / Destructor
87  OptionsDialog(QWidget *parent = nullptr);
88  ~OptionsDialog() override;
89 
90 public slots:
91  void showConnectionTab();
92 
93 private slots:
94  void enableProxy(int index);
95  void on_buttonBox_accepted();
96  void closeEvent(QCloseEvent *e) override;
97  void on_buttonBox_rejected();
98  void applySettings();
99  void enableApplyButton();
101  void changePage(QListWidgetItem *, QListWidgetItem *);
102  void loadSplitterState();
104  void editWatchedFolderOptions(const QModelIndex &index);
106  void handleIPFilterParsed(bool error, int ruleCount);
114  void setLocale(const QString &localeStr);
115  void webUIHttpsCertChanged(const QString &path, ShowError showError);
116  void webUIHttpsKeyChanged(const QString &path, ShowError showError);
117 
118 private:
119  // Methods
120  void saveOptions();
121  void loadOptions();
123  // General options
124  QString getLocale() const;
125 #ifndef Q_OS_MACOS
126  bool systemTrayEnabled() const;
127  bool minimizeToTray() const;
128  bool closeToTray() const;
129 #endif
130  bool startMinimized() const;
131  bool isSplashScreenDisabled() const;
132 #ifdef Q_OS_WIN
133  bool WinStartup() const;
134 #endif
135  // Downloads
136  bool preAllocateAllFiles() const;
137  bool useAdditionDialog() const;
138  bool addTorrentsInPause() const;
139  QString getTorrentExportDir() const;
140  QString getFinishedTorrentExportDir() const;
141  QString askForExportDir(const QString &currentExportPath);
142  // Connection options
143  int getPort() const;
144  bool isUPnPEnabled() const;
145  // Bittorrent options
146  int getMaxConnections() const;
147  int getMaxConnectionsPerTorrent() 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;
163  // IP Filter
164  bool isIPFilteringEnabled() const;
165  QString getFilter() const;
166  // Queueing system
167  bool isQueueingSystemEnabled() const;
168  int getMaxActiveDownloads() const;
169  int getMaxActiveUploads() const;
170  int getMaxActiveTorrents() const;
171  // WebUI
172  bool isWebUiEnabled() const;
173  QString webUiUsername() const;
174  QString webUiPassword() const;
175  bool webUIAuthenticationOk();
177 
178  bool schedTimesOk();
179 
180  Ui::OptionsDialog *m_ui;
184 
185  QPushButton *m_applyButton;
186 
188 
189  bool m_refreshingIpFilter = false;
190 };
bool isAlternativeWebUIPathValid()
int getPort() const
bool addTorrentsInPause() const
QString getTorrentExportDir() const
void on_IpFilterRefreshBtn_clicked()
void initializeLanguageCombo()
bool isWebUiEnabled() const
void handleWatchedFolderViewSelectionChanged()
void on_banListButton_clicked()
bool isProxyEnabled() const
void setLocale(const QString &localeStr)
QString getLocale() const
void on_removeWatchedFolderButton_clicked()
int getMaxConnectionsPerTorrent() const
int getMaxUploadsPerTorrent() const
void changePage(QListWidgetItem *, QListWidgetItem *)
QString getProxyUsername() const
int getMaxConnections() const
bool isSplashScreenDisabled() const
QString getFinishedTorrentExportDir() const
bool systemTrayEnabled() const
bool isQueueingSystemEnabled() const
bool closeToTray() const
void on_randomButton_clicked()
int getMaxSeedingMinutes() const
QString getFilter() const
bool isDHTEnabled() const
void webUIHttpsKeyChanged(const QString &path, ShowError showError)
bool isLSDEnabled() const
~OptionsDialog() override
OptionsDialog(QWidget *parent=nullptr)
QString askForExportDir(const QString &currentExportPath)
void toggleComboRatioLimitAct()
bool isIPFilteringEnabled() const
void on_buttonBox_rejected()
AdvancedSettings * m_advancedSettings
int getMaxUploads() const
bool preAllocateAllFiles() const
void handleIPFilterParsed(bool error, int ruleCount)
void on_buttonBox_accepted()
bool useAdditionDialog() const
void on_IPSubnetWhitelistButton_clicked()
unsigned short getProxyPort() const
void showConnectionTab()
QString webUiUsername() const
void webUIHttpsCertChanged(const QString &path, ShowError showError)
Ui::OptionsDialog * m_ui
bool startMinimized() const
void on_addWatchedFolderButton_clicked()
int getMaxActiveTorrents() const
void on_registerDNSBtn_clicked()
qreal getMaxRatio() const
bool m_refreshingIpFilter
void enableApplyButton()
SettingValue< int > m_storeLastViewedPage
bool minimizeToTray() const
void on_editWatchedFolderButton_clicked()
void editWatchedFolderOptions(const QModelIndex &index)
void loadSplitterState()
SettingValue< QStringList > m_storeHSplitterSize
void closeEvent(QCloseEvent *e) override
bool isUPnPEnabled() const
QPushButton * m_applyButton
void enableProxy(int index)
QString webUiPassword() const
int getEncryptionSetting() const
SettingValue< QSize > m_storeDialogSize
int getMaxActiveUploads() const
QString getProxyPassword() const
int getMaxActiveDownloads() const
Net::ProxyType getProxyType() const
bool webUIAuthenticationOk()
bool isProxyAuthEnabled() const
QString getProxyIp() const
Definition: session.h:86
DoubleClickAction
Definition: optionsdialog.h:42
@ NO_ACTION
Definition: optionsdialog.h:46
@ TOGGLE_PAUSE
Definition: optionsdialog.h:43
@ OPEN_DEST
Definition: optionsdialog.h:44
@ PREVIEW_FILE
Definition: optionsdialog.h:45
@ SHOW_OPTIONS
Definition: optionsdialog.h:47