Add option to auto hide zero status filters
[qBittorrent.git] / src / base / preferences.h
blob57b6e04993b2bbeb5bc42595d77438caa0f1afbc
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 : 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 &smtp_server);
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(const 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 static bool isTorrentFileAssocSet();
294 static bool isMagnetLinkAssocSet();
295 static void setTorrentFileAssoc(bool set);
296 static void setMagnetLinkAssoc(bool set);
297 #endif
298 #ifdef Q_OS_MACOS
299 static bool isTorrentFileAssocSet();
300 static bool isMagnetLinkAssocSet();
301 static void setTorrentFileAssoc();
302 static void setMagnetLinkAssoc();
303 #endif
304 int getTrackerPort() const;
305 void setTrackerPort(int port);
306 bool isTrackerPortForwardingEnabled() const;
307 void setTrackerPortForwardingEnabled(bool enabled);
308 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
309 bool isUpdateCheckEnabled() const;
310 void setUpdateCheckEnabled(bool enabled);
311 #endif
312 bool confirmTorrentDeletion() const;
313 void setConfirmTorrentDeletion(bool enabled);
314 bool confirmTorrentRecheck() const;
315 void setConfirmTorrentRecheck(bool enabled);
316 bool confirmRemoveAllTags() const;
317 void setConfirmRemoveAllTags(bool enabled);
318 #ifndef Q_OS_MACOS
319 bool systemTrayEnabled() const;
320 void setSystemTrayEnabled(bool enabled);
321 bool minimizeToTrayNotified() const;
322 void setMinimizeToTrayNotified(bool b);
323 bool minimizeToTray() const;
324 void setMinimizeToTray(bool b);
325 bool closeToTray() const;
326 void setCloseToTray(bool b);
327 bool closeToTrayNotified() const;
328 void setCloseToTrayNotified(bool b);
329 TrayIcon::Style trayIconStyle() const;
330 void setTrayIconStyle(TrayIcon::Style style);
331 bool iconsInMenusEnabled() const;
332 void setIconsInMenusEnabled(bool enable);
333 #endif // Q_OS_MACOS
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 bool getAcceptedLegal() const;
342 void setAcceptedLegal(bool accepted);
343 QByteArray getMainGeometry() const;
344 void setMainGeometry(const QByteArray &geometry);
345 bool isFiltersSidebarVisible() const;
346 void setFiltersSidebarVisible(bool value);
347 int getFiltersSidebarWidth() const;
348 void setFiltersSidebarWidth(int value);
349 Path getMainLastDir() const;
350 void setMainLastDir(const Path &path);
351 QByteArray getPeerListState() const;
352 void setPeerListState(const QByteArray &state);
353 QString getPropSplitterSizes() const;
354 void setPropSplitterSizes(const QString &sizes);
355 QByteArray getPropFileListState() const;
356 void setPropFileListState(const QByteArray &state);
357 int getPropCurTab() const;
358 void setPropCurTab(int tab);
359 bool getPropVisible() const;
360 void setPropVisible(bool visible);
361 QByteArray getPropTrackerListState() const;
362 void setPropTrackerListState(const QByteArray &state);
363 QStringList getRssOpenFolders() const;
364 void setRssOpenFolders(const QStringList &folders);
365 QByteArray getRssSideSplitterState() const;
366 void setRssSideSplitterState(const QByteArray &state);
367 QByteArray getRssMainSplitterState() const;
368 void setRssMainSplitterState(const QByteArray &state);
369 QByteArray getSearchTabHeaderState() const;
370 void setSearchTabHeaderState(const QByteArray &state);
371 bool getRegexAsFilteringPatternForSearchJob() const;
372 void setRegexAsFilteringPatternForSearchJob(bool checked);
373 QStringList getSearchEngDisabled() const;
374 void setSearchEngDisabled(const QStringList &engines);
375 QString getTorImportLastContentDir() const;
376 void setTorImportLastContentDir(const QString &path);
377 QByteArray getTorImportGeometry() const;
378 void setTorImportGeometry(const QByteArray &geometry);
379 bool getStatusFilterState() const;
380 bool getCategoryFilterState() const;
381 bool getTagFilterState() const;
382 bool getTrackerFilterState() const;
383 int getTransSelFilter() const;
384 void setTransSelFilter(int index);
385 bool getHideZeroStatusFilters() const;
386 void setHideZeroStatusFilters(bool hide);
387 QByteArray getTransHeaderState() const;
388 void setTransHeaderState(const QByteArray &state);
389 bool getRegexAsFilteringPatternForTransferList() const;
390 void setRegexAsFilteringPatternForTransferList(bool checked);
391 int getToolbarTextPosition() const;
392 void setToolbarTextPosition(int position);
394 // From old RssSettings class
395 bool isRSSWidgetEnabled() const;
396 void setRSSWidgetVisible(bool enabled);
398 // Network
399 QList<QNetworkCookie> getNetworkCookies() const;
400 void setNetworkCookies(const QList<QNetworkCookie> &cookies);
402 bool useProxyForBT() const;
403 void setUseProxyForBT(bool value);
404 bool useProxyForRSS() const;
405 void setUseProxyForRSS(bool value);
406 bool useProxyForGeneralPurposes() const;
407 void setUseProxyForGeneralPurposes(bool value);
409 // SpeedWidget
410 bool isSpeedWidgetEnabled() const;
411 void setSpeedWidgetEnabled(bool enabled);
412 int getSpeedWidgetPeriod() const;
413 void setSpeedWidgetPeriod(int period);
414 bool getSpeedWidgetGraphEnable(int id) const;
415 void setSpeedWidgetGraphEnable(int id, bool enable);
417 public slots:
418 void setStatusFilterState(bool checked);
419 void setCategoryFilterState(bool checked);
420 void setTagFilterState(bool checked);
421 void setTrackerFilterState(bool checked);
423 void apply();
425 signals:
426 void changed();
428 private:
429 static Preferences *m_instance;