Sync translations from Transifex and run lupdate
[qBittorrent.git] / src / base / preferences.h
blobfe19d930e56428d48c76e0593acd4f9e97c1e659
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 <QtGlobal>
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 deleteTorrentFilesAsDefault() const;
109 void setDeleteTorrentFilesAsDefault(bool del);
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 QVector<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 #ifdef Q_OS_WIN
291 bool neverCheckFileAssoc() const;
292 void setNeverCheckFileAssoc(bool check = true);
293 #endif
295 int getTrackerPort() const;
296 void setTrackerPort(int port);
297 bool isTrackerPortForwardingEnabled() const;
298 void setTrackerPortForwardingEnabled(bool enabled);
299 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
300 bool isUpdateCheckEnabled() const;
301 void setUpdateCheckEnabled(bool enabled);
302 #endif
303 bool confirmTorrentDeletion() const;
304 void setConfirmTorrentDeletion(bool enabled);
305 bool confirmTorrentRecheck() const;
306 void setConfirmTorrentRecheck(bool enabled);
307 bool confirmRemoveAllTags() const;
308 void setConfirmRemoveAllTags(bool enabled);
309 bool confirmPauseAndResumeAll() const;
310 void setConfirmPauseAndResumeAll(bool enabled);
311 bool confirmMergeTrackers() const;
312 void setConfirmMergeTrackers(bool enabled);
313 #ifndef Q_OS_MACOS
314 bool systemTrayEnabled() const;
315 void setSystemTrayEnabled(bool enabled);
316 bool minimizeToTrayNotified() const;
317 void setMinimizeToTrayNotified(bool b);
318 bool minimizeToTray() const;
319 void setMinimizeToTray(bool b);
320 bool closeToTray() const;
321 void setCloseToTray(bool b);
322 bool closeToTrayNotified() const;
323 void setCloseToTrayNotified(bool b);
324 TrayIcon::Style trayIconStyle() const;
325 void setTrayIconStyle(TrayIcon::Style style);
326 bool iconsInMenusEnabled() const;
327 void setIconsInMenusEnabled(bool enable);
328 #endif // Q_OS_MACOS
329 qint64 getTorrentFileSizeLimit() const;
330 void setTorrentFileSizeLimit(qint64 value);
331 int getBdecodeDepthLimit() const;
332 void setBdecodeDepthLimit(int value);
333 int getBdecodeTokenLimit() const;
334 void setBdecodeTokenLimit(int value);
336 // Stuff that don't appear in the Options GUI but are saved
337 // in the same file.
338 QDateTime getDNSLastUpd() const;
339 void setDNSLastUpd(const QDateTime &date);
340 QString getDNSLastIP() const;
341 void setDNSLastIP(const QString &ip);
342 bool getAcceptedLegal() const;
343 void setAcceptedLegal(bool accepted);
344 QByteArray getMainGeometry() const;
345 void setMainGeometry(const QByteArray &geometry);
346 bool isFiltersSidebarVisible() const;
347 void setFiltersSidebarVisible(bool value);
348 int getFiltersSidebarWidth() const;
349 void setFiltersSidebarWidth(int value);
350 Path getMainLastDir() const;
351 void setMainLastDir(const Path &path);
352 QByteArray getPeerListState() const;
353 void setPeerListState(const QByteArray &state);
354 QString getPropSplitterSizes() const;
355 void setPropSplitterSizes(const QString &sizes);
356 QByteArray getPropFileListState() const;
357 void setPropFileListState(const QByteArray &state);
358 int getPropCurTab() const;
359 void setPropCurTab(int tab);
360 bool getPropVisible() const;
361 void setPropVisible(bool visible);
362 QByteArray getPropTrackerListState() const;
363 void setPropTrackerListState(const QByteArray &state);
364 QStringList getRssOpenFolders() const;
365 void setRssOpenFolders(const QStringList &folders);
366 QByteArray getRssSideSplitterState() const;
367 void setRssSideSplitterState(const QByteArray &state);
368 QByteArray getRssMainSplitterState() const;
369 void setRssMainSplitterState(const QByteArray &state);
370 QByteArray getSearchTabHeaderState() const;
371 void setSearchTabHeaderState(const QByteArray &state);
372 bool getRegexAsFilteringPatternForSearchJob() const;
373 void setRegexAsFilteringPatternForSearchJob(bool checked);
374 QStringList getSearchEngDisabled() const;
375 void setSearchEngDisabled(const QStringList &engines);
376 QString getTorImportLastContentDir() const;
377 void setTorImportLastContentDir(const QString &path);
378 QByteArray getTorImportGeometry() const;
379 void setTorImportGeometry(const QByteArray &geometry);
380 bool getStatusFilterState() const;
381 bool getCategoryFilterState() const;
382 bool getTagFilterState() const;
383 bool getTrackerFilterState() const;
384 int getTransSelFilter() const;
385 void setTransSelFilter(int index);
386 bool getHideZeroStatusFilters() const;
387 void setHideZeroStatusFilters(bool hide);
388 QByteArray getTransHeaderState() const;
389 void setTransHeaderState(const QByteArray &state);
390 bool getRegexAsFilteringPatternForTransferList() const;
391 void setRegexAsFilteringPatternForTransferList(bool checked);
392 int getToolbarTextPosition() const;
393 void setToolbarTextPosition(int position);
395 // From old RssSettings class
396 bool isRSSWidgetEnabled() const;
397 void setRSSWidgetVisible(bool enabled);
399 // Network
400 QList<QNetworkCookie> getNetworkCookies() const;
401 void setNetworkCookies(const QList<QNetworkCookie> &cookies);
403 bool useProxyForBT() const;
404 void setUseProxyForBT(bool value);
405 bool useProxyForRSS() const;
406 void setUseProxyForRSS(bool value);
407 bool useProxyForGeneralPurposes() const;
408 void setUseProxyForGeneralPurposes(bool value);
410 // SpeedWidget
411 bool isSpeedWidgetEnabled() const;
412 void setSpeedWidgetEnabled(bool enabled);
413 int getSpeedWidgetPeriod() const;
414 void setSpeedWidgetPeriod(int period);
415 bool getSpeedWidgetGraphEnable(int id) const;
416 void setSpeedWidgetGraphEnable(int id, bool enable);
418 public slots:
419 void setStatusFilterState(bool checked);
420 void setCategoryFilterState(bool checked);
421 void setTagFilterState(bool checked);
422 void setTrackerFilterState(bool checked);
424 void apply();
426 signals:
427 void changed();
429 private:
430 static Preferences *m_instance;