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.
32 #include <QtContainerFwd>
33 #include <QtSystemDetection>
36 #include "base/pathfwd.h"
37 #include "base/utils/net.h"
67 enum class Service
: int
80 enum class Style
: int
89 class Preferences final
: public QObject
92 Q_DISABLE_COPY_MOVE(Preferences
)
97 static void initInstance();
98 static void freeInstance();
99 static Preferences
*instance();
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
);
131 bool WinStartup() const;
132 void setWinStartup(bool b
);
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
);
168 bool isSearchEnabled() const;
169 void setSearchEnabled(bool enabled
);
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
);
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
);
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
);
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
);
232 bool isWebUIReverseProxySupportEnabled() const;
233 void setWebUIReverseProxySupportEnabled(bool enabled
);
234 QString
getWebUITrustedReverseProxiesList() const;
235 void setWebUITrustedReverseProxiesList(const QString
&addr
);
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
);
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
);
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
);
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
);
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 confirmPauseAndResumeAll() const;
309 void setConfirmPauseAndResumeAll(bool enabled
);
310 bool confirmMergeTrackers() const;
311 void setConfirmMergeTrackers(bool enabled
);
312 bool confirmRemoveTrackerFromAllTorrents() const;
313 void setConfirmRemoveTrackerFromAllTorrents(bool enabled
);
315 bool systemTrayEnabled() const;
316 void setSystemTrayEnabled(bool enabled
);
317 bool minimizeToTrayNotified() const;
318 void setMinimizeToTrayNotified(bool b
);
319 bool minimizeToTray() const;
320 void setMinimizeToTray(bool b
);
321 bool closeToTray() const;
322 void setCloseToTray(bool b
);
323 bool closeToTrayNotified() const;
324 void setCloseToTrayNotified(bool b
);
325 TrayIcon::Style
trayIconStyle() const;
326 void setTrayIconStyle(TrayIcon::Style style
);
327 bool iconsInMenusEnabled() const;
328 void setIconsInMenusEnabled(bool enable
);
330 qint64
getTorrentFileSizeLimit() const;
331 void setTorrentFileSizeLimit(qint64 value
);
332 int getBdecodeDepthLimit() const;
333 void setBdecodeDepthLimit(int value
);
334 int getBdecodeTokenLimit() const;
335 void setBdecodeTokenLimit(int value
);
337 // Stuff that don't appear in the Options GUI but are saved
339 QDateTime
getDNSLastUpd() const;
340 void setDNSLastUpd(const QDateTime
&date
);
341 QString
getDNSLastIP() const;
342 void setDNSLastIP(const QString
&ip
);
343 bool getAcceptedLegal() const;
344 void setAcceptedLegal(bool accepted
);
345 QByteArray
getMainGeometry() const;
346 void setMainGeometry(const QByteArray
&geometry
);
347 bool isFiltersSidebarVisible() const;
348 void setFiltersSidebarVisible(bool value
);
349 int getFiltersSidebarWidth() const;
350 void setFiltersSidebarWidth(int value
);
351 Path
getMainLastDir() const;
352 void setMainLastDir(const Path
&path
);
353 QByteArray
getPeerListState() const;
354 void setPeerListState(const QByteArray
&state
);
355 QString
getPropSplitterSizes() const;
356 void setPropSplitterSizes(const QString
&sizes
);
357 QByteArray
getPropFileListState() const;
358 void setPropFileListState(const QByteArray
&state
);
359 int getPropCurTab() const;
360 void setPropCurTab(int tab
);
361 bool getPropVisible() const;
362 void setPropVisible(bool visible
);
363 QByteArray
getTrackerListState() const;
364 void setTrackerListState(const QByteArray
&state
);
365 QStringList
getRssOpenFolders() const;
366 void setRssOpenFolders(const QStringList
&folders
);
367 QByteArray
getRssSideSplitterState() const;
368 void setRssSideSplitterState(const QByteArray
&state
);
369 QByteArray
getRssMainSplitterState() const;
370 void setRssMainSplitterState(const QByteArray
&state
);
371 QByteArray
getSearchTabHeaderState() const;
372 void setSearchTabHeaderState(const QByteArray
&state
);
373 bool getRegexAsFilteringPatternForSearchJob() const;
374 void setRegexAsFilteringPatternForSearchJob(bool checked
);
375 QStringList
getSearchEngDisabled() const;
376 void setSearchEngDisabled(const QStringList
&engines
);
377 QString
getTorImportLastContentDir() const;
378 void setTorImportLastContentDir(const QString
&path
);
379 QByteArray
getTorImportGeometry() const;
380 void setTorImportGeometry(const QByteArray
&geometry
);
381 bool getStatusFilterState() const;
382 bool getCategoryFilterState() const;
383 bool getTagFilterState() const;
384 bool getTrackerFilterState() const;
385 int getTransSelFilter() const;
386 void setTransSelFilter(int index
);
387 bool getHideZeroStatusFilters() const;
388 void setHideZeroStatusFilters(bool hide
);
389 QByteArray
getTransHeaderState() const;
390 void setTransHeaderState(const QByteArray
&state
);
391 bool getRegexAsFilteringPatternForTransferList() const;
392 void setRegexAsFilteringPatternForTransferList(bool checked
);
393 int getToolbarTextPosition() const;
394 void setToolbarTextPosition(int position
);
396 // From old RssSettings class
397 bool isRSSWidgetEnabled() const;
398 void setRSSWidgetVisible(bool enabled
);
401 QList
<QNetworkCookie
> getNetworkCookies() const;
402 void setNetworkCookies(const QList
<QNetworkCookie
> &cookies
);
404 bool useProxyForBT() const;
405 void setUseProxyForBT(bool value
);
406 bool useProxyForRSS() const;
407 void setUseProxyForRSS(bool value
);
408 bool useProxyForGeneralPurposes() const;
409 void setUseProxyForGeneralPurposes(bool value
);
412 bool isSpeedWidgetEnabled() const;
413 void setSpeedWidgetEnabled(bool enabled
);
414 int getSpeedWidgetPeriod() const;
415 void setSpeedWidgetPeriod(int period
);
416 bool getSpeedWidgetGraphEnable(int id
) const;
417 void setSpeedWidgetGraphEnable(int id
, bool enable
);
419 // AddNewTorrentDialog
420 bool isAddNewTorrentDialogEnabled() const;
421 void setAddNewTorrentDialogEnabled(bool value
);
422 bool isAddNewTorrentDialogTopLevel() const;
423 void setAddNewTorrentDialogTopLevel(bool value
);
424 int addNewTorrentDialogSavePathHistoryLength() const;
425 void setAddNewTorrentDialogSavePathHistoryLength(int value
);
428 void setStatusFilterState(bool checked
);
429 void setCategoryFilterState(bool checked
);
430 void setTagFilterState(bool checked
);
431 void setTrackerFilterState(bool checked
);
439 static Preferences
*m_instance
;