Enable customizing the save statistics time interval
[qBittorrent.git] / src / base / preferences.h
bloba0ee4d0afa27886f0fb23a0d8ddfa39db336cf0a
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
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 <QtContainerFwd>
33 #include <QtSystemDetection>
34 #include <QObject>
36 #include "base/pathfwd.h"
37 #include "base/utils/net.h"
39 class QDateTime;
40 class QNetworkCookie;
41 class QTime;
43 namespace Scheduler
45 Q_NAMESPACE
47 enum class Days : int
49 EveryDay = 0,
50 Weekday = 1,
51 Weekend = 2,
52 Monday = 3,
53 Tuesday = 4,
54 Wednesday = 5,
55 Thursday = 6,
56 Friday = 7,
57 Saturday = 8,
58 Sunday = 9
60 Q_ENUM_NS(Days)
63 namespace DNS
65 Q_NAMESPACE
67 enum class Service : int
69 DynDNS = 0,
70 NoIP = 1,
71 None = -1
73 Q_ENUM_NS(Service)
76 namespace TrayIcon
78 Q_NAMESPACE
80 enum class Style : int
82 Normal = 0,
83 MonoDark = 1,
84 MonoLight = 2
86 Q_ENUM_NS(Style)
89 class Preferences final : public QObject
91 Q_OBJECT
92 Q_DISABLE_COPY_MOVE(Preferences)
94 Preferences();
96 public:
97 static void initInstance();
98 static void freeInstance();
99 static Preferences *instance();
101 // General options
102 QString getLocale() const;
103 void setLocale(const QString &locale);
104 bool useCustomUITheme() const;
105 void setUseCustomUITheme(bool use);
106 Path customUIThemePath() const;
107 void setCustomUIThemePath(const Path &path);
108 bool removeTorrentContent() const;
109 void setRemoveTorrentContent(bool remove);
110 bool confirmOnExit() const;
111 void setConfirmOnExit(bool confirm);
112 bool speedInTitleBar() const;
113 void showSpeedInTitleBar(bool show);
114 bool useAlternatingRowColors() const;
115 void setAlternatingRowColors(bool b);
116 bool getHideZeroValues() const;
117 void setHideZeroValues(bool b);
118 int getHideZeroComboValues() const;
119 void setHideZeroComboValues(int n);
120 bool isStatusbarDisplayed() const;
121 void setStatusbarDisplayed(bool displayed);
122 bool isToolbarDisplayed() const;
123 void setToolbarDisplayed(bool displayed);
124 bool isSplashScreenDisabled() const;
125 void setSplashScreenDisabled(bool b);
126 bool preventFromSuspendWhenDownloading() const;
127 void setPreventFromSuspendWhenDownloading(bool b);
128 bool preventFromSuspendWhenSeeding() const;
129 void setPreventFromSuspendWhenSeeding(bool b);
130 #ifdef Q_OS_WIN
131 bool WinStartup() const;
132 void setWinStartup(bool b);
133 #endif
135 // Downloads
136 Path getScanDirsLastPath() const;
137 void setScanDirsLastPath(const Path &path);
138 bool isMailNotificationEnabled() const;
139 void setMailNotificationEnabled(bool enabled);
140 QString getMailNotificationSender() const;
141 void setMailNotificationSender(const QString &mail);
142 QString getMailNotificationEmail() const;
143 void setMailNotificationEmail(const QString &mail);
144 QString getMailNotificationSMTP() const;
145 void setMailNotificationSMTP(const QString &smtpServer);
146 bool getMailNotificationSMTPSSL() const;
147 void setMailNotificationSMTPSSL(bool use);
148 bool getMailNotificationSMTPAuth() const;
149 void setMailNotificationSMTPAuth(bool use);
150 QString getMailNotificationSMTPUsername() const;
151 void setMailNotificationSMTPUsername(const QString &username);
152 QString getMailNotificationSMTPPassword() const;
153 void setMailNotificationSMTPPassword(const QString &password);
154 int getActionOnDblClOnTorrentDl() const;
155 void setActionOnDblClOnTorrentDl(int act);
156 int getActionOnDblClOnTorrentFn() const;
157 void setActionOnDblClOnTorrentFn(int act);
159 // Connection options
160 QTime getSchedulerStartTime() const;
161 void setSchedulerStartTime(const QTime &time);
162 QTime getSchedulerEndTime() const;
163 void setSchedulerEndTime(const QTime &time);
164 Scheduler::Days getSchedulerDays() const;
165 void setSchedulerDays(Scheduler::Days days);
167 // Search
168 bool isSearchEnabled() const;
169 void setSearchEnabled(bool enabled);
171 // HTTP Server
172 bool isWebUIEnabled() const;
173 void setWebUIEnabled(bool enabled);
174 QString getServerDomains() const;
175 void setServerDomains(const QString &str);
176 QString getWebUIAddress() const;
177 void setWebUIAddress(const QString &addr);
178 quint16 getWebUIPort() const;
179 void setWebUIPort(quint16 port);
180 bool useUPnPForWebUIPort() const;
181 void setUPnPForWebUIPort(bool enabled);
183 // Authentication
184 bool isWebUILocalAuthEnabled() const;
185 void setWebUILocalAuthEnabled(bool enabled);
186 bool isWebUIAuthSubnetWhitelistEnabled() const;
187 void setWebUIAuthSubnetWhitelistEnabled(bool enabled);
188 QList<Utils::Net::Subnet> getWebUIAuthSubnetWhitelist() const;
189 void setWebUIAuthSubnetWhitelist(QStringList subnets);
190 QString getWebUIUsername() const;
191 void setWebUIUsername(const QString &username);
192 QByteArray getWebUIPassword() const;
193 void setWebUIPassword(const QByteArray &password);
194 int getWebUIMaxAuthFailCount() const;
195 void setWebUIMaxAuthFailCount(int count);
196 std::chrono::seconds getWebUIBanDuration() const;
197 void setWebUIBanDuration(std::chrono::seconds duration);
198 int getWebUISessionTimeout() const;
199 void setWebUISessionTimeout(int timeout);
200 QString getWebAPISessionCookieName() const;
201 void setWebAPISessionCookieName(const QString &cookieName);
203 // WebUI security
204 bool isWebUIClickjackingProtectionEnabled() const;
205 void setWebUIClickjackingProtectionEnabled(bool enabled);
206 bool isWebUICSRFProtectionEnabled() const;
207 void setWebUICSRFProtectionEnabled(bool enabled);
208 bool isWebUISecureCookieEnabled () const;
209 void setWebUISecureCookieEnabled(bool enabled);
210 bool isWebUIHostHeaderValidationEnabled() const;
211 void setWebUIHostHeaderValidationEnabled(bool enabled);
213 // HTTPS
214 bool isWebUIHttpsEnabled() const;
215 void setWebUIHttpsEnabled(bool enabled);
216 Path getWebUIHttpsCertificatePath() const;
217 void setWebUIHttpsCertificatePath(const Path &path);
218 Path getWebUIHttpsKeyPath() const;
219 void setWebUIHttpsKeyPath(const Path &path);
220 bool isAltWebUIEnabled() const;
221 void setAltWebUIEnabled(bool enabled);
222 Path getWebUIRootFolder() const;
223 void setWebUIRootFolder(const Path &path);
225 // WebUI custom HTTP headers
226 bool isWebUICustomHTTPHeadersEnabled() const;
227 void setWebUICustomHTTPHeadersEnabled(bool enabled);
228 QString getWebUICustomHTTPHeaders() const;
229 void setWebUICustomHTTPHeaders(const QString &headers);
231 // Reverse proxy
232 bool isWebUIReverseProxySupportEnabled() const;
233 void setWebUIReverseProxySupportEnabled(bool enabled);
234 QString getWebUITrustedReverseProxiesList() const;
235 void setWebUITrustedReverseProxiesList(const QString &addr);
237 // Dynamic DNS
238 bool isDynDNSEnabled() const;
239 void setDynDNSEnabled(bool enabled);
240 DNS::Service getDynDNSService() const;
241 void setDynDNSService(DNS::Service service);
242 QString getDynDomainName() const;
243 void setDynDomainName(const QString &name);
244 QString getDynDNSUsername() const;
245 void setDynDNSUsername(const QString &username);
246 QString getDynDNSPassword() const;
247 void setDynDNSPassword(const QString &password);
249 // Advanced settings
250 QByteArray getUILockPassword() const;
251 void setUILockPassword(const QByteArray &password);
252 bool isUILocked() const;
253 void setUILocked(bool locked);
255 bool isAutoRunOnTorrentAddedEnabled() const;
256 void setAutoRunOnTorrentAddedEnabled(bool enabled);
257 QString getAutoRunOnTorrentAddedProgram() const;
258 void setAutoRunOnTorrentAddedProgram(const QString &program);
259 bool isAutoRunOnTorrentFinishedEnabled() const;
260 void setAutoRunOnTorrentFinishedEnabled(bool enabled);
261 QString getAutoRunOnTorrentFinishedProgram() const;
262 void setAutoRunOnTorrentFinishedProgram(const QString &program);
263 #if defined(Q_OS_WIN)
264 bool isAutoRunConsoleEnabled() const;
265 void setAutoRunConsoleEnabled(bool enabled);
266 #endif
268 bool shutdownWhenDownloadsComplete() const;
269 void setShutdownWhenDownloadsComplete(bool shutdown);
270 bool suspendWhenDownloadsComplete() const;
271 void setSuspendWhenDownloadsComplete(bool suspend);
272 bool hibernateWhenDownloadsComplete() const;
273 void setHibernateWhenDownloadsComplete(bool hibernate);
274 bool shutdownqBTWhenDownloadsComplete() const;
275 void setShutdownqBTWhenDownloadsComplete(bool shutdown);
276 bool dontConfirmAutoExit() const;
277 void setDontConfirmAutoExit(bool dontConfirmAutoExit);
278 bool recheckTorrentsOnCompletion() const;
279 void recheckTorrentsOnCompletion(bool recheck);
280 bool resolvePeerCountries() const;
281 void resolvePeerCountries(bool resolve);
282 bool resolvePeerHostNames() const;
283 void resolvePeerHostNames(bool resolve);
284 #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
285 bool useSystemIcons() const;
286 void useSystemIcons(bool enabled);
287 #endif
288 bool isRecursiveDownloadEnabled() const;
289 void setRecursiveDownloadEnabled(bool enable);
290 int getTrackerPort() const;
291 void setTrackerPort(int port);
292 bool isTrackerPortForwardingEnabled() const;
293 void setTrackerPortForwardingEnabled(bool enabled);
294 bool isMarkOfTheWebEnabled() const;
295 void setMarkOfTheWebEnabled(bool enabled);
296 Path getPythonExecutablePath() const;
297 void setPythonExecutablePath(const Path &path);
298 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
299 bool isUpdateCheckEnabled() const;
300 void setUpdateCheckEnabled(bool enabled);
301 #endif
302 bool confirmTorrentDeletion() const;
303 void setConfirmTorrentDeletion(bool enabled);
304 bool confirmTorrentRecheck() const;
305 void setConfirmTorrentRecheck(bool enabled);
306 bool confirmRemoveAllTags() const;
307 void setConfirmRemoveAllTags(bool enabled);
308 bool confirmMergeTrackers() const;
309 void setConfirmMergeTrackers(bool enabled);
310 bool confirmRemoveTrackerFromAllTorrents() const;
311 void setConfirmRemoveTrackerFromAllTorrents(bool enabled);
312 #ifndef Q_OS_MACOS
313 bool systemTrayEnabled() const;
314 void setSystemTrayEnabled(bool enabled);
315 bool minimizeToTrayNotified() const;
316 void setMinimizeToTrayNotified(bool b);
317 bool minimizeToTray() const;
318 void setMinimizeToTray(bool b);
319 bool closeToTray() const;
320 void setCloseToTray(bool b);
321 bool closeToTrayNotified() const;
322 void setCloseToTrayNotified(bool b);
323 TrayIcon::Style trayIconStyle() const;
324 void setTrayIconStyle(TrayIcon::Style style);
325 bool iconsInMenusEnabled() const;
326 void setIconsInMenusEnabled(bool enable);
327 #endif // Q_OS_MACOS
328 qint64 getTorrentFileSizeLimit() const;
329 void setTorrentFileSizeLimit(qint64 value);
330 int getBdecodeDepthLimit() const;
331 void setBdecodeDepthLimit(int value);
332 int getBdecodeTokenLimit() const;
333 void setBdecodeTokenLimit(int value);
335 // Stuff that don't appear in the Options GUI but are saved
336 // in the same file.
337 QDateTime getDNSLastUpd() const;
338 void setDNSLastUpd(const QDateTime &date);
339 QString getDNSLastIP() const;
340 void setDNSLastIP(const QString &ip);
341 QByteArray getMainGeometry() const;
342 void setMainGeometry(const QByteArray &geometry);
343 bool isFiltersSidebarVisible() const;
344 void setFiltersSidebarVisible(bool value);
345 int getFiltersSidebarWidth() const;
346 void setFiltersSidebarWidth(int value);
347 Path getMainLastDir() const;
348 void setMainLastDir(const Path &path);
349 QByteArray getPeerListState() const;
350 void setPeerListState(const QByteArray &state);
351 QString getPropSplitterSizes() const;
352 void setPropSplitterSizes(const QString &sizes);
353 QByteArray getPropFileListState() const;
354 void setPropFileListState(const QByteArray &state);
355 int getPropCurTab() const;
356 void setPropCurTab(int tab);
357 bool getPropVisible() const;
358 void setPropVisible(bool visible);
359 QByteArray getTrackerListState() const;
360 void setTrackerListState(const QByteArray &state);
361 QStringList getRssOpenFolders() const;
362 void setRssOpenFolders(const QStringList &folders);
363 QByteArray getRssSideSplitterState() const;
364 void setRssSideSplitterState(const QByteArray &state);
365 QByteArray getRssMainSplitterState() const;
366 void setRssMainSplitterState(const QByteArray &state);
367 QByteArray getSearchTabHeaderState() const;
368 void setSearchTabHeaderState(const QByteArray &state);
369 bool getRegexAsFilteringPatternForSearchJob() const;
370 void setRegexAsFilteringPatternForSearchJob(bool checked);
371 QStringList getSearchEngDisabled() const;
372 void setSearchEngDisabled(const QStringList &engines);
373 QString getTorImportLastContentDir() const;
374 void setTorImportLastContentDir(const QString &path);
375 QByteArray getTorImportGeometry() const;
376 void setTorImportGeometry(const QByteArray &geometry);
377 bool getStatusFilterState() const;
378 bool getCategoryFilterState() const;
379 bool getTagFilterState() const;
380 bool getTrackerFilterState() const;
381 int getTransSelFilter() const;
382 void setTransSelFilter(int index);
383 bool getHideZeroStatusFilters() const;
384 void setHideZeroStatusFilters(bool hide);
385 QByteArray getTransHeaderState() const;
386 void setTransHeaderState(const QByteArray &state);
387 bool getRegexAsFilteringPatternForTransferList() const;
388 void setRegexAsFilteringPatternForTransferList(bool checked);
389 int getToolbarTextPosition() const;
390 void setToolbarTextPosition(int position);
392 // From old RssSettings class
393 bool isRSSWidgetEnabled() const;
394 void setRSSWidgetVisible(bool enabled);
396 // Network
397 QList<QNetworkCookie> getNetworkCookies() const;
398 void setNetworkCookies(const QList<QNetworkCookie> &cookies);
400 bool useProxyForBT() const;
401 void setUseProxyForBT(bool value);
402 bool useProxyForRSS() const;
403 void setUseProxyForRSS(bool value);
404 bool useProxyForGeneralPurposes() const;
405 void setUseProxyForGeneralPurposes(bool value);
407 // SpeedWidget
408 bool isSpeedWidgetEnabled() const;
409 void setSpeedWidgetEnabled(bool enabled);
410 int getSpeedWidgetPeriod() const;
411 void setSpeedWidgetPeriod(int period);
412 bool getSpeedWidgetGraphEnable(int id) const;
413 void setSpeedWidgetGraphEnable(int id, bool enable);
415 // AddNewTorrentDialog
416 bool isAddNewTorrentDialogEnabled() const;
417 void setAddNewTorrentDialogEnabled(bool value);
418 bool isAddNewTorrentDialogTopLevel() const;
419 void setAddNewTorrentDialogTopLevel(bool value);
420 int addNewTorrentDialogSavePathHistoryLength() const;
421 void setAddNewTorrentDialogSavePathHistoryLength(int value);
423 public slots:
424 void setStatusFilterState(bool checked);
425 void setCategoryFilterState(bool checked);
426 void setTagFilterState(bool checked);
427 void setTrackerFilterState(bool checked);
429 void apply();
431 signals:
432 void changed();
434 private:
435 static Preferences *m_instance;