Avoid using QDateTime for announce timestamps
[qBittorrent.git] / src / gui / optionsdialog.h
blob534ca4078ef81a82ca9dd79649c63423baf425b3
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2023-2024 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
30 #pragma once
32 #include <QDialog>
34 #include "base/pathfwd.h"
35 #include "base/settingvalue.h"
36 #include "guiapplicationcomponent.h"
38 class QListWidgetItem;
40 class AdvancedSettings;
42 // actions on double-click on torrents
43 enum DoubleClickAction
45 TOGGLE_STOP = 0,
46 OPEN_DEST = 1,
47 PREVIEW_FILE = 2,
48 NO_ACTION = 3,
49 SHOW_OPTIONS = 4
52 namespace Net
54 enum class ProxyType;
57 namespace Ui
59 class OptionsDialog;
62 class OptionsDialog final : public GUIApplicationComponent<QDialog>
64 Q_OBJECT
65 Q_DISABLE_COPY_MOVE(OptionsDialog)
67 using ThisType = OptionsDialog;
69 enum Tabs
71 TAB_UI,
72 TAB_DOWNLOADS,
73 TAB_CONNECTION,
74 TAB_SPEED,
75 TAB_BITTORRENT,
76 TAB_RSS,
77 TAB_WEBUI,
78 TAB_ADVANCED
81 public:
82 explicit OptionsDialog(IGUIApplication *app, QWidget *parent = nullptr);
83 ~OptionsDialog() override;
85 public slots:
86 void showConnectionTab();
88 private slots:
89 void adjustProxyOptions();
90 void on_buttonBox_accepted();
91 void on_buttonBox_rejected();
92 void enableApplyButton();
93 void toggleComboRatioLimitAct();
94 void changePage(QListWidgetItem *, QListWidgetItem *);
95 void loadSplitterState();
96 void handleWatchedFolderViewSelectionChanged();
97 void editWatchedFolderOptions(const QModelIndex &index);
98 void on_IpFilterRefreshBtn_clicked();
99 void handleIPFilterParsed(bool error, int ruleCount);
100 void on_banListButton_clicked();
101 void on_IPSubnetWhitelistButton_clicked();
102 void on_randomButton_clicked();
103 void on_addWatchedFolderButton_clicked();
104 void on_editWatchedFolderButton_clicked();
105 void on_removeWatchedFolderButton_clicked();
106 void setLocale(const QString &localeStr);
108 #ifndef DISABLE_WEBUI
109 void webUIHttpsCertChanged(const Path &path);
110 void webUIHttpsKeyChanged(const Path &path);
111 void on_registerDNSBtn_clicked();
112 #endif
114 private:
115 void showEvent(QShowEvent *e) override;
117 // Methods
118 bool applySettings();
119 void saveOptions() const;
121 void loadBehaviorTabOptions();
122 void saveBehaviorTabOptions() const;
124 void loadDownloadsTabOptions();
125 void saveDownloadsTabOptions() const;
127 void loadConnectionTabOptions();
128 void saveConnectionTabOptions() const;
130 void loadSpeedTabOptions();
131 void saveSpeedTabOptions() const;
133 void loadBittorrentTabOptions();
134 void saveBittorrentTabOptions() const;
136 void loadRSSTabOptions();
137 void saveRSSTabOptions() const;
139 #ifndef DISABLE_WEBUI
140 void loadWebUITabOptions();
141 void saveWebUITabOptions() const;
142 #endif // DISABLE_WEBUI
144 // General options
145 void initializeLanguageCombo();
146 void initializeStyleCombo();
147 void initializeColorSchemeOptions();
148 QString getLocale() const;
149 bool isSplashScreenDisabled() const;
150 #ifdef Q_OS_WIN
151 bool WinStartup() const;
152 #endif
153 // Downloads
154 bool preAllocateAllFiles() const;
155 bool useAdditionDialog() const;
156 bool addTorrentsStopped() const;
157 Path getTorrentExportDir() const;
158 Path getFinishedTorrentExportDir() const;
159 // Connection options
160 int getPort() const;
161 bool isUPnPEnabled() const;
162 // Bittorrent options
163 int getMaxConnections() const;
164 int getMaxConnectionsPerTorrent() const;
165 int getMaxUploads() const;
166 int getMaxUploadsPerTorrent() const;
167 bool isDHTEnabled() const;
168 bool isLSDEnabled() const;
169 int getEncryptionSetting() const;
170 qreal getMaxRatio() const;
171 int getMaxSeedingMinutes() const;
172 int getMaxInactiveSeedingMinutes() const;
173 // Proxy options
174 bool isProxyEnabled() const;
175 QString getProxyIp() const;
176 unsigned short getProxyPort() const;
177 QString getProxyUsername() const;
178 QString getProxyPassword() const;
179 Net::ProxyType getProxyType() const;
180 // IP Filter
181 bool isIPFilteringEnabled() const;
182 Path getFilter() const;
183 // Queueing system
184 bool isQueueingSystemEnabled() const;
185 int getMaxActiveDownloads() const;
186 int getMaxActiveUploads() const;
187 int getMaxActiveTorrents() const;
188 // WebUI
189 #ifndef DISABLE_WEBUI
190 bool isWebUIEnabled() const;
191 QString webUIUsername() const;
192 QString webUIPassword() const;
193 bool webUIAuthenticationOk();
194 bool isAlternativeWebUIPathValid();
195 #endif
197 bool schedTimesOk();
199 Ui::OptionsDialog *m_ui = nullptr;
200 SettingValue<QSize> m_storeDialogSize;
201 SettingValue<QStringList> m_storeHSplitterSize;
202 SettingValue<int> m_storeLastViewedPage;
204 QPushButton *m_applyButton = nullptr;
206 AdvancedSettings *m_advancedSettings = nullptr;
208 bool m_refreshingIpFilter = false;