2011-09-27 20:37:04 +04:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
|
|
|
* Contact : chris@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PREFERENCES_H
|
|
|
|
#define PREFERENCES_H
|
|
|
|
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QTime>
|
|
|
|
#include <QList>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <libtorrent/version.hpp>
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI
|
|
|
|
#include <QApplication>
|
|
|
|
#else
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "misc.h"
|
2012-05-16 22:19:05 +04:00
|
|
|
#include "fs_utils.h"
|
2011-09-27 20:37:04 +04:00
|
|
|
#include "qinisettings.h"
|
|
|
|
|
|
|
|
#define QBT_REALM "Web UI Access"
|
|
|
|
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
|
|
|
|
enum maxRatioAction {PAUSE_ACTION, REMOVE_ACTION};
|
|
|
|
namespace Proxy {
|
|
|
|
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
|
|
|
|
}
|
|
|
|
namespace TrayIcon {
|
|
|
|
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
|
|
|
|
}
|
|
|
|
namespace DNS {
|
|
|
|
enum Service { DYNDNS, NOIP, NONE = -1 };
|
|
|
|
}
|
|
|
|
|
2013-02-16 21:30:44 +04:00
|
|
|
class Preferences : private QIniSettings {
|
2011-10-02 18:56:00 +04:00
|
|
|
Q_DISABLE_COPY(Preferences)
|
2011-09-27 20:37:04 +04:00
|
|
|
|
|
|
|
public:
|
2013-02-16 21:30:44 +04:00
|
|
|
Preferences()
|
|
|
|
: QIniSettings("qBittorrent", "qBittorrent")
|
|
|
|
{
|
2011-09-27 20:37:04 +04:00
|
|
|
qDebug() << "Preferences constructor";
|
|
|
|
}
|
|
|
|
|
2013-02-16 21:30:44 +04:00
|
|
|
void sync()
|
|
|
|
{
|
|
|
|
QIniSettings::sync();
|
|
|
|
}
|
|
|
|
|
2012-09-02 01:03:28 +04:00
|
|
|
// General options
|
2011-09-27 20:37:04 +04:00
|
|
|
QString getLocale() const {
|
2013-07-26 03:10:10 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/General/Locale")).toString();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setLocale(const QString &locale) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
|
|
|
}
|
2012-09-02 01:03:28 +04:00
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
bool useProgramNotification() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ProgramNotification"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void useProgramNotification(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ProgramNotification"), use);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool deleteTorrentFilesAsDefault() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDeleteTorrentFilesAsDefault(bool del) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), del);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setConfirmOnExit(bool confirm) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ExitConfirm"), confirm);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool confirmOnExit() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void showSpeedInTitleBar(bool show) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), show);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool speedInTitleBar() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool useAlternatingRowColors() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/AlternatingRowColors"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAlternatingRowColors(bool b) {
|
|
|
|
setValue("Preferences/General/AlternatingRowColors", b);
|
|
|
|
}
|
|
|
|
|
2012-08-29 02:55:08 +04:00
|
|
|
bool useRandomPort() const {
|
2012-09-02 01:03:28 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/General/UseRandomPort"), false).toBool();
|
2012-08-29 02:55:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setRandomPort(bool b) {
|
2012-09-02 01:03:28 +04:00
|
|
|
setValue("Preferences/General/UseRandomPort", b);
|
2012-08-29 02:55:08 +04:00
|
|
|
}
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
bool systrayIntegration() const {
|
2012-02-22 22:06:11 +04:00
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
return false;
|
|
|
|
#else
|
2011-09-27 20:37:04 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
2012-02-22 22:06:11 +04:00
|
|
|
#endif
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setSystrayIntegration(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/SystrayEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setToolbarDisplayed(bool displayed) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), displayed);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isToolbarDisplayed() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool minimizeToTray() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMinimizeToTray(bool b) {
|
|
|
|
setValue("Preferences/General/MinimizeToTray", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool closeToTray() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setCloseToTray(bool b) {
|
|
|
|
setValue("Preferences/General/CloseToTray", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool startMinimized() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setStartMinimized(bool b) {
|
|
|
|
setValue("Preferences/General/StartMinimized", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSlashScreenDisabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSplashScreenDisabled(bool b) {
|
|
|
|
setValue("Preferences/General/NoSplashScreen", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Preventing from system suspend while active torrents are presented.
|
|
|
|
bool preventFromSuspend() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/PreventFromSuspend"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPreventFromSuspend(bool b) {
|
|
|
|
setValue("Preferences/General/PreventFromSuspend", b);
|
|
|
|
}
|
|
|
|
|
2012-10-08 00:05:33 +04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
bool Startup() const {
|
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
|
|
|
return settings.contains("qBittorrent");
|
|
|
|
}
|
|
|
|
|
|
|
|
void setStartup(bool b) {
|
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
|
|
|
if (b) {
|
2014-02-03 21:12:47 +04:00
|
|
|
const QString bin_path = "\"" + fsutils::toNativePath(qApp->applicationFilePath()) + "\"";
|
2012-10-08 00:05:33 +04:00
|
|
|
settings.setValue("qBittorrent", bin_path);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
settings.remove("qBittorrent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
// Downloads
|
2011-09-27 22:16:29 +04:00
|
|
|
QString getSavePath() const {
|
2011-10-02 18:56:00 +04:00
|
|
|
QString save_path = value(QString::fromUtf8("Preferences/Downloads/SavePath")).toString();
|
|
|
|
if (!save_path.isEmpty())
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(save_path);
|
2012-05-16 22:19:05 +04:00
|
|
|
return fsutils::QDesktopServicesDownloadLocation();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setSavePath(const QString &save_path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), fsutils::fromNativePath(save_path));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isTempPathEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTempPathEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getTempPath() const {
|
|
|
|
const QString temp = QDir(getSavePath()).absoluteFilePath("temp");
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTempPath(const QString &path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), fsutils::fromNativePath(path));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool useIncompleteFilesExtension() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void useIncompleteFilesExtension(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool appendTorrentLabel() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AppendLabel"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAppendTorrentLabel(bool b) {
|
|
|
|
setValue("Preferences/Downloads/AppendLabel", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString lastLocationPath() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setLastLocationPath(const QString &path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), fsutils::fromNativePath(path));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool preAllocateAllFiles() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void preAllocateAllFiles(bool enabled) {
|
|
|
|
return setValue(QString::fromUtf8("Preferences/Downloads/PreAllocation"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool useAdditionDialog() const {
|
2012-05-15 20:57:31 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/NewAdditionDialog"), true).toBool();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void useAdditionDialog(bool b) {
|
2012-05-15 20:57:31 +04:00
|
|
|
setValue("Preferences/Downloads/NewAdditionDialog", b);
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
2013-10-06 19:42:56 +04:00
|
|
|
bool AdditionDialogFront() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/NewAdditionDialogFront"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdditionDialogFront(bool b) {
|
|
|
|
setValue("Preferences/Downloads/NewAdditionDialogFront", b);
|
|
|
|
}
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
bool addTorrentsInPause() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/StartInPause"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void addTorrentsInPause(bool b) {
|
|
|
|
setValue("Preferences/Downloads/StartInPause", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList getScanDirs() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
QStringList originalList = value(QString::fromUtf8("Preferences/Downloads/ScanDirs"), QStringList()).toStringList();
|
|
|
|
if (originalList.isEmpty())
|
|
|
|
return originalList;
|
|
|
|
|
|
|
|
QStringList newList;
|
|
|
|
foreach (const QString& s, originalList) {
|
|
|
|
newList << fsutils::fromNativePath(s);
|
|
|
|
}
|
|
|
|
return newList;
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This must be called somewhere with data from the model
|
|
|
|
void setScanDirs(const QStringList &dirs) {
|
2013-11-09 19:45:01 +04:00
|
|
|
QStringList newList;
|
|
|
|
if (!dirs.isEmpty()) {
|
|
|
|
foreach (const QString& s, dirs) {
|
|
|
|
newList << fsutils::fromNativePath(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), newList);
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QList<bool> getDownloadInScanDirs() const {
|
|
|
|
return misc::boolListfromStringList(value(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs")).toStringList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDownloadInScanDirs(const QList<bool> &list) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), misc::toStringList(list));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isTorrentExportEnabled() const {
|
2012-08-21 11:16:49 +04:00
|
|
|
return !value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString().isEmpty();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
2012-08-21 11:16:49 +04:00
|
|
|
QString getTorrentExportDir() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
2012-08-21 11:16:49 +04:00
|
|
|
void setTorrentExportDir(QString path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), fsutils::fromNativePath(path.trimmed()));
|
2012-08-21 11:16:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isFinishedTorrentExportEnabled() const {
|
|
|
|
return !value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getFinishedTorrentExportDir() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString());
|
2012-08-21 11:16:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setFinishedTorrentExportDir(QString path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), fsutils::fromNativePath(path.trimmed()));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isMailNotificationEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/enabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationEmail() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/email"), "").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationEmail(const QString &mail) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/email"), mail);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationSMTP() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/smtp_server"), "smtp.changeme.com").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTP(const QString &smtp_server) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/smtp_server"), smtp_server);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getMailNotificationSMTPSSL() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/req_ssl"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPSSL(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/req_ssl"), use);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getMailNotificationSMTPAuth() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/req_auth"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPAuth(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/req_auth"), use);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationSMTPUsername() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/username")).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPUsername(const QString &username) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/username"), username);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationSMTPPassword() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/password")).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPPassword(const QString &password) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/password"), password);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getActionOnDblClOnTorrentDl() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DblClOnTorDl"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setActionOnDblClOnTorrentDl(int act) {
|
|
|
|
setValue("Preferences/Downloads/DblClOnTorDl", act);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getActionOnDblClOnTorrentFn() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DblClOnTorFn"), 1).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setActionOnDblClOnTorrentFn(int act) {
|
|
|
|
setValue("Preferences/Downloads/DblClOnTorFn", act);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Connection options
|
|
|
|
int getSessionPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/PortRangeMin"), 6881).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSessionPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/PortRangeMin"), port);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isUPnPEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/UPnP"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUPnPEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/UPnP"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getGlobalDownloadLimit() const {
|
|
|
|
return value("Preferences/Connection/GlobalDLLimit", -1).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setGlobalDownloadLimit(int limit) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (limit <= 0) limit = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/Connection/GlobalDLLimit", limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getGlobalUploadLimit() const {
|
|
|
|
return value("Preferences/Connection/GlobalUPLimit", 50).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setGlobalUploadLimit(int limit) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (limit <= 0) limit = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/Connection/GlobalUPLimit", limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getAltGlobalDownloadLimit() const {
|
|
|
|
int ret = value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (ret <= 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
ret = 10;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAltGlobalDownloadLimit(int limit) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (limit <= 0) limit = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/Connection/GlobalDLLimitAlt", limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getAltGlobalUploadLimit() const {
|
|
|
|
int ret = value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (ret <= 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
ret = 10;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAltGlobalUploadLimit(int limit) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (limit <= 0) limit = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/Connection/GlobalUPLimitAlt", limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAltBandwidthEnabled() const {
|
|
|
|
return value("Preferences/Connection/alt_speeds_on", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAltBandwidthEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Connection/alt_speeds_on", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSchedulerEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/Enabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSchedulerEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/Enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
QTime getSchedulerStartTime() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/start_time"), QTime(8,0)).toTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSchedulerStartTime(const QTime &time) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/start_time"), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTime getSchedulerEndTime() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/end_time"), QTime(20,0)).toTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSchedulerEndTime(const QTime &time) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/end_time"), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
scheduler_days getSchedulerDays() const {
|
|
|
|
return (scheduler_days)value(QString::fromUtf8("Preferences/Scheduler/days"), EVERY_DAY).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSchedulerDays(scheduler_days days) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Proxy options
|
|
|
|
bool isProxyEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isProxyAuthEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyAuthEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getProxyIp() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyIp(const QString &ip) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short getProxyPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyPort(unsigned short port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), port);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getProxyUsername() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyUsername(const QString &username) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), username);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getProxyPassword() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyPassword(const QString &password) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), password);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getProxyType() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyType(int type) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setProxyPeerConnections(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ProxyPeerConnections"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool proxyPeerConnections() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyPeerConnections"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bittorrent options
|
|
|
|
int getMaxConnecs() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), 500).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxConnecs(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val <= 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxConnecsPerTorrent() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), 100).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxConnecsPerTorrent(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val <= 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val);
|
|
|
|
}
|
|
|
|
|
2013-07-22 02:20:48 +04:00
|
|
|
int getMaxUploads() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploads"), 8).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxUploads(int val) {
|
|
|
|
if (val <= 0) val = -1;
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploads"), val);
|
|
|
|
}
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
int getMaxUploadsPerTorrent() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxUploadsPerTorrent(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val <= 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isuTPEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/uTP"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setuTPEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Bittorrent/uTP", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isuTPRateLimited() const {
|
2012-08-21 18:49:23 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/uTP_rate_limited"), true).toBool();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setuTPRateLimited(bool enabled) {
|
2012-08-21 18:49:23 +04:00
|
|
|
setValue("Preferences/Bittorrent/uTP_rate_limited", enabled);
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isDHTEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDHTEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/DHT"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPeXEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/PeX"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPeXEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/PeX"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDHTPortSameAsBT() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDHTPortSameAsBT(bool same) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), same);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getDHTPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDHTPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), port);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLSDEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setLSDEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/LSD"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getEncryptionSetting() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/Encryption"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setEncryptionSetting(int val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal getGlobalMaxRatio() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setGlobalMaxRatio(qreal ratio) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxRatioAction(int act) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), act);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxRatioAction() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), PAUSE_ACTION).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
// IP Filter
|
|
|
|
bool isFilteringEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/IPFilter/Enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFilteringEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/IPFilter/Enabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getFilter() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setFilter(const QString &path) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/IPFilter/File"), fsutils::fromNativePath(path));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void banIP(const QString &ip) {
|
|
|
|
QStringList banned_ips = value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (!banned_ips.contains(ip)) {
|
2011-09-27 20:37:04 +04:00
|
|
|
banned_ips << ip;
|
|
|
|
setValue("Preferences/IPFilter/BannedIPs", banned_ips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList bannedIPs() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search
|
|
|
|
bool isSearchEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Search/SearchEnabled"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSearchEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Search/SearchEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Execution Log
|
|
|
|
|
|
|
|
bool isExecutionLogEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/ExecutionLog/enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setExecutionLogEnabled(bool b) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/ExecutionLog/enabled"), b);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Queueing system
|
|
|
|
bool isQueueingSystemEnabled() const {
|
|
|
|
return value("Preferences/Queueing/QueueingEnabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setQueueingSystemEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Queueing/QueueingEnabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxActiveDownloads() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), 3).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxActiveDownloads(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val < 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxActiveUploads() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), 3).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxActiveUploads(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val < 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxActiveTorrents() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), 5).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxActiveTorrents(int val) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val < 0) val = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIgnoreSlowTorrentsForQueueing(bool ignore) {
|
|
|
|
setValue("Preferences/Queueing/IgnoreSlowTorrents", ignore);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ignoreSlowTorrentsForQueueing() const {
|
|
|
|
return value("Preferences/Queueing/IgnoreSlowTorrents", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWebUiEnabled() const {
|
|
|
|
return value("Preferences/WebUI/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/Enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiLocalAuthEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/LocalHostAuth", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWebUiLocalAuthEnabled() const {
|
|
|
|
return value("Preferences/WebUI/LocalHostAuth", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 getWebUiPort() const {
|
|
|
|
return value("Preferences/WebUI/Port", 8080).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiPort(quint16 port) {
|
|
|
|
setValue("Preferences/WebUI/Port", port);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool useUPnPForWebUIPort() const {
|
|
|
|
return value("Preferences/WebUI/UseUPnP", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUPnPForWebUIPort(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/UseUPnP", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getWebUiUsername() const {
|
|
|
|
return value("Preferences/WebUI/Username", "admin").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiUsername(const QString &username) {
|
|
|
|
setValue("Preferences/WebUI/Username", username);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiPassword(const QString &new_password) {
|
|
|
|
// Get current password md5
|
|
|
|
QString current_pass_md5 = getWebUiPassword();
|
|
|
|
// Check if password did not change
|
2012-02-20 21:30:53 +04:00
|
|
|
if (current_pass_md5 == new_password) return;
|
2011-09-27 20:37:04 +04:00
|
|
|
// Encode to md5 and save
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
|
|
|
md5.addData(getWebUiUsername().toLocal8Bit()+":"+QBT_REALM+":");
|
|
|
|
md5.addData(new_password.toLocal8Bit());
|
|
|
|
|
|
|
|
setValue("Preferences/WebUI/Password_ha1", md5.result().toHex());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getWebUiPassword() const {
|
|
|
|
QString pass_ha1 = value("Preferences/WebUI/Password_ha1", "").toString();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (pass_ha1.isEmpty()) {
|
2011-09-27 20:37:04 +04:00
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
|
|
|
md5.addData(getWebUiUsername().toLocal8Bit()+":"+QBT_REALM+":");
|
|
|
|
md5.addData("adminadmin");
|
|
|
|
pass_ha1 = md5.result().toHex();
|
|
|
|
}
|
|
|
|
return pass_ha1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWebUiHttpsEnabled() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiHttpsEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray getWebUiHttpsCertificate() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Certificate").toByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiHttpsCertificate(const QByteArray &data) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Certificate", data);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray getWebUiHttpsKey() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Key").toByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiHttpsKey(const QByteArray &data) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Key", data);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDynDNSEnabled() const {
|
|
|
|
return value("Preferences/DynDNS/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/DynDNS/Enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
DNS::Service getDynDNSService() const {
|
|
|
|
return DNS::Service(value("Preferences/DynDNS/Service", DNS::DYNDNS).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSService(int service) {
|
|
|
|
setValue("Preferences/DynDNS/Service", service);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDomainName() const {
|
|
|
|
return value("Preferences/DynDNS/DomainName", "changeme.dyndns.org").toString();
|
|
|
|
}
|
|
|
|
|
2014-01-05 16:06:29 +04:00
|
|
|
void setDynDomainName(const QString &name) {
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/DynDNS/DomainName", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDNSUsername() const {
|
|
|
|
return value("Preferences/DynDNS/Username").toString();
|
|
|
|
}
|
|
|
|
|
2014-01-05 16:06:29 +04:00
|
|
|
void setDynDNSUsername(const QString &username) {
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/DynDNS/Username", username);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDNSPassword() const {
|
|
|
|
return value("Preferences/DynDNS/Password").toString();
|
|
|
|
}
|
|
|
|
|
2014-01-05 16:06:29 +04:00
|
|
|
void setDynDNSPassword(const QString &password) {
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue("Preferences/DynDNS/Password", password);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advanced settings
|
|
|
|
|
|
|
|
void setUILockPassword(const QString &clear_password) {
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
|
|
|
md5.addData(clear_password.toLocal8Bit());
|
|
|
|
QString md5_password = md5.result().toHex();
|
|
|
|
setValue("Locking/password", md5_password);
|
|
|
|
}
|
|
|
|
|
2013-10-25 00:23:56 +04:00
|
|
|
void clearUILockPassword() {
|
|
|
|
remove("Locking/password");
|
|
|
|
}
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
QString getUILockPasswordMD5() const {
|
|
|
|
return value("Locking/password", QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isUILocked() const {
|
|
|
|
return value("Locking/locked", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUILocked(bool locked) {
|
|
|
|
return setValue("Locking/locked", locked);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAutoRunEnabled() const {
|
|
|
|
return value("AutoRun/enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAutoRunEnabled(bool enabled) {
|
|
|
|
return setValue("AutoRun/enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAutoRunProgram(const QString &program) {
|
2013-11-09 19:45:01 +04:00
|
|
|
setValue("AutoRun/program", fsutils::fromNativePath(program));
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString getAutoRunProgram() const {
|
2013-11-09 19:45:01 +04:00
|
|
|
return fsutils::fromNativePath(value("AutoRun/program", QString()).toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool shutdownWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setShutdownWhenDownloadsComplete(bool shutdown) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), shutdown);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool suspendWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoSuspendOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSuspendWhenDownloadsComplete(bool suspend) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoSuspendOnCompletion"), suspend);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool shutdownqBTWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setShutdownqBTWhenDownloadsComplete(bool shutdown) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), shutdown);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint diskCacheSize() const {
|
2013-03-18 13:13:20 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 0).toUInt();
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setDiskCacheSize(uint size) {
|
2012-10-07 20:14:53 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), size);
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
|
2013-03-18 13:45:30 +04:00
|
|
|
uint diskCacheTTL() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheTTL"), 60).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDiskCacheTTL(uint ttl) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheTTL"), ttl);
|
|
|
|
}
|
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
uint outgoingPortsMin() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOutgoingPortsMin(uint val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint outgoingPortsMax() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), 0).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOutgoingPortsMax(uint val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ignoreLimitsOnLAN() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ignoreLimitsOnLAN(bool ignore) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), ignore);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool includeOverheadInLimits() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void includeOverheadInLimits(bool include) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), include);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool trackerExchangeEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/LtTrackerExchange"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTrackerExchangeEnabled(bool enable) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/LtTrackerExchange"), enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool recheckTorrentsOnCompletion() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void recheckTorrentsOnCompletion(bool recheck) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), recheck);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int getRefreshInterval() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/RefreshInterval"), 1500).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setRefreshInterval(uint interval) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/RefreshInterval"), interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool resolvePeerCountries() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void resolvePeerCountries(bool resolve) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), resolve);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool resolvePeerHostNames() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void resolvePeerHostNames(bool resolve) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), resolve);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getMaxHalfOpenConnections() const {
|
|
|
|
const int val = value(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), 50).toInt();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (val <= 0) return -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMaxHalfOpenConnections(int value) {
|
2012-02-20 21:30:53 +04:00
|
|
|
if (value <= 0) value = -1;
|
2011-09-27 20:37:04 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), value);
|
|
|
|
}
|
|
|
|
|
2012-09-02 01:03:28 +04:00
|
|
|
|
2011-09-27 20:37:04 +04:00
|
|
|
void setNetworkInterface(const QString& iface) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Interface"), iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getNetworkInterface() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
|
|
|
|
}
|
2013-01-13 17:44:14 +04:00
|
|
|
|
|
|
|
void setNetworkInterfaceName(const QString& iface) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getNetworkInterfaceName() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/InterfaceName"), QString()).toString();
|
|
|
|
}
|
2011-09-27 20:37:04 +04:00
|
|
|
|
|
|
|
void setNetworkAddress(const QString& addr) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/InetAddress"), addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getNetworkAddress() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/InetAddress"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAnonymousModeEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void enableAnonymousMode(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSuperSeedingEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void enableSuperSeeding(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool announceToAllTrackers() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAnnounceToAllTrackers(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), enabled);
|
|
|
|
}
|
|
|
|
|
2012-02-25 22:20:11 +04:00
|
|
|
#if defined(Q_WS_X11)
|
2011-09-27 20:37:04 +04:00
|
|
|
bool useSystemIconTheme() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void useSystemIconTheme(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QStringList getTorrentLabels() const {
|
|
|
|
return value("TransferListFilters/customLabels").toStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void addTorrentLabel(const QString& label) {
|
|
|
|
QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (!labels.contains(label))
|
2011-09-27 20:37:04 +04:00
|
|
|
labels << label;
|
|
|
|
setValue("TransferListFilters/customLabels", labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeTorrentLabel(const QString& label) {
|
|
|
|
QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (labels.contains(label))
|
2011-09-27 20:37:04 +04:00
|
|
|
labels.removeOne(label);
|
|
|
|
setValue("TransferListFilters/customLabels", labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool recursiveDownloadDisabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void disableRecursiveDownload(bool disable=true) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
static QString getPythonPath() {
|
|
|
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
|
|
|
QStringList versions = reg_python.childGroups();
|
|
|
|
qDebug("Python versions nb: %d", versions.size());
|
|
|
|
//versions = versions.filter(QRegExp("2\\..*"));
|
|
|
|
versions.sort();
|
|
|
|
while(!versions.empty()) {
|
|
|
|
const QString version = versions.takeLast();
|
|
|
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
2013-11-09 19:45:01 +04:00
|
|
|
QString path = reg_python.value(version+"/InstallPath/Default", "").toString();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (!path.isEmpty() && QDir(path).exists("python.exe")) {
|
2011-09-27 20:37:04 +04:00
|
|
|
qDebug("Found python.exe at %s", qPrintable(path));
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Fallback: Detect python from default locations
|
|
|
|
QStringList supported_versions;
|
|
|
|
supported_versions << "32" << "31" << "30" << "27" << "26" << "25";
|
2012-02-20 21:30:53 +04:00
|
|
|
foreach (const QString &v, supported_versions) {
|
|
|
|
if (QFile::exists("C:/Python"+v+"/python.exe")) {
|
2013-11-09 19:45:01 +04:00
|
|
|
reg_python.setValue(v[0]+"."+v[1]+"/InstallPath/Default", QString("C:/Python"+v));
|
|
|
|
return "C:/Python"+v;
|
2011-09-27 20:37:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString::null;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool neverCheckFileAssoc() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setNeverCheckFileAssoc(bool check = true) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), check);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isTorrentFileAssocSet() {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
2012-02-20 21:30:53 +04:00
|
|
|
if (settings.value(".torrent/Default").toString() != "qBittorrent") {
|
2011-09-27 20:37:04 +04:00
|
|
|
qDebug(".torrent != qBittorrent");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
qDebug("Checking shell command");
|
2013-11-09 19:45:01 +04:00
|
|
|
QString shell_command = fsutils::toNativePath(settings.value("qBittorrent/shell/open/command/Default", "").toString());
|
2011-09-27 20:37:04 +04:00
|
|
|
qDebug("Shell command is: %s", qPrintable(shell_command));
|
|
|
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
2012-02-20 21:30:53 +04:00
|
|
|
if (exe_reg.indexIn(shell_command) < 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
return false;
|
|
|
|
QString assoc_exe = exe_reg.cap(1);
|
|
|
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
2013-11-09 19:45:01 +04:00
|
|
|
if (assoc_exe.compare(fsutils::toNativePath(qApp->applicationFilePath()), Qt::CaseInsensitive) != 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
return false;
|
|
|
|
// Icon
|
2013-11-09 19:45:01 +04:00
|
|
|
const QString icon_str = "\""+fsutils::toNativePath(qApp->applicationFilePath())+"\",1";
|
2012-02-20 21:30:53 +04:00
|
|
|
if (settings.value("qBittorrent/DefaultIcon/Default", icon_str).toString().compare(icon_str, Qt::CaseInsensitive) != 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMagnetLinkAssocSet() {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
|
|
|
|
|
|
|
// Check magnet link assoc
|
|
|
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
2013-11-09 19:45:01 +04:00
|
|
|
QString shell_command = fsutils::toNativePath(settings.value("Magnet/shell/open/command/Default", "").toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (exe_reg.indexIn(shell_command) < 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
return false;
|
|
|
|
QString assoc_exe = exe_reg.cap(1);
|
|
|
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
2013-11-09 19:45:01 +04:00
|
|
|
if (assoc_exe.compare(fsutils::toNativePath(qApp->applicationFilePath()), Qt::CaseInsensitive) != 0)
|
2011-09-27 20:37:04 +04:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setTorrentFileAssoc(bool set) {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
// .Torrent association
|
|
|
|
if (set) {
|
2013-11-09 19:45:01 +04:00
|
|
|
const QString command_str = "\""+qApp->applicationFilePath()+"\" \"%1\"";
|
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath()+"\",1";
|
2011-09-27 20:37:04 +04:00
|
|
|
|
|
|
|
settings.setValue(".torrent/Default", "qBittorrent");
|
|
|
|
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
|
|
|
|
settings.setValue("qBittorrent/shell/Default", "open");
|
2014-01-26 15:09:37 +04:00
|
|
|
settings.setValue("qBittorrent/shell/open/command/Default", fsutils::toNativePath(command_str));
|
2011-09-27 20:37:04 +04:00
|
|
|
settings.setValue("qBittorrent/Content Type/Default", "application/x-bittorrent");
|
2014-01-26 15:09:37 +04:00
|
|
|
settings.setValue("qBittorrent/DefaultIcon/Default", fsutils::toNativePath(icon_str));
|
2013-10-24 01:15:22 +04:00
|
|
|
} else if (isTorrentFileAssocSet()) {
|
2011-09-27 20:37:04 +04:00
|
|
|
settings.remove(".torrent/Default");
|
|
|
|
settings.remove(".torrent/Content Type");
|
|
|
|
settings.remove("qBittorrent/shell/Default");
|
|
|
|
settings.remove("qBittorrent/shell/open/command/Default");
|
|
|
|
settings.remove("qBittorrent/Content Type/Default");
|
|
|
|
settings.remove("qBittorrent/DefaultIcon/Default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setMagnetLinkAssoc(bool set) {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
// Magnet association
|
|
|
|
if (set) {
|
2013-11-09 19:45:01 +04:00
|
|
|
const QString command_str = "\""+qApp->applicationFilePath()+"\" \"%1\"";
|
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath()+"\",1";
|
2011-09-27 20:37:04 +04:00
|
|
|
|
|
|
|
settings.setValue("Magnet/Default", "Magnet URI");
|
|
|
|
settings.setValue("Magnet/Content Type", "application/x-magnet");
|
|
|
|
settings.setValue("Magnet/URL Protocol", "");
|
2014-01-26 15:09:37 +04:00
|
|
|
settings.setValue("Magnet/DefaultIcon/Default", fsutils::toNativePath(icon_str));
|
2011-09-27 20:37:04 +04:00
|
|
|
settings.setValue("Magnet/shell/Default", "open");
|
2014-01-26 15:09:37 +04:00
|
|
|
settings.setValue("Magnet/shell/open/command/Default", fsutils::toNativePath(command_str));
|
2013-10-24 01:15:22 +04:00
|
|
|
} else if (isMagnetLinkAssocSet()) {
|
2011-09-27 20:37:04 +04:00
|
|
|
settings.remove("Magnet/Default");
|
|
|
|
settings.remove("Magnet/Content Type");
|
|
|
|
settings.remove("Magnet/URL Protocol");
|
|
|
|
settings.remove("Magnet/DefaultIcon/Default");
|
|
|
|
settings.remove("Magnet/shell/Default");
|
|
|
|
settings.remove("Magnet/shell/open/command/Default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool isTrackerEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/trackerEnabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTrackerEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/trackerEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTrackerPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/trackerPort"), 9000).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTrackerPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/trackerPort"), port);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
|
|
|
bool isUpdateCheckEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUpdateCheckEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/updateCheck"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bool confirmTorrentDeletion() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), true).toBool();
|
|
|
|
}
|
|
|
|
void setConfirmTorrentDeletion(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TrayIcon::Style trayIconStyle() const {
|
|
|
|
return TrayIcon::Style(value(QString::fromUtf8("Preferences/Advanced/TrayIconStyle"), TrayIcon::NORMAL).toInt());
|
|
|
|
}
|
|
|
|
void setTrayIconStyle(TrayIcon::Style style) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/TrayIconStyle"), style);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PREFERENCES_H
|