Migrate everything to use the new Preferences class and not access directly the qbittorrent.ini file.

This commit is contained in:
sledgehammer999
2014-07-05 15:44:13 +03:00
parent da6ce859c0
commit d8d95d2195
44 changed files with 748 additions and 908 deletions

View File

@@ -37,6 +37,7 @@
#include <QDesktopWidget>
#include <QTranslator>
#include <QDesktopServices>
#include <QDebug>
#include <libtorrent/version.hpp>
@@ -45,7 +46,6 @@
#include "fs_utils.h"
#include "advancedsettings.h"
#include "scannedfoldersmodel.h"
#include "qinisettings.h"
#include "qbtsession.h"
#include "iconprovider.h"
#include "dnsupdater.h"
@@ -289,14 +289,14 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous
}
void options_imp::loadWindowState() {
QIniSettings settings;
resize(settings.value(QString::fromUtf8("Preferences/State/size"), sizeFittingScreen()).toSize());
QPoint p = settings.value(QString::fromUtf8("Preferences/State/pos"), QPoint()).toPoint();
const Preferences* const pref = Preferences::instance();
resize(pref->getPrefSize(sizeFittingScreen()));
QPoint p = pref->getPrefPos();
QRect scr_rect = qApp->desktop()->screenGeometry();
if (!p.isNull() && scr_rect.contains(p))
move(p);
// Load slider size
const QStringList sizes_str = settings.value("Preferences/State/hSplitterSizes", QStringList()).toStringList();
const QStringList sizes_str = pref->getPrefHSplitterSizes();
// Splitter size
QList<int> sizes;
if (sizes_str.size() == 2) {
@@ -310,14 +310,14 @@ void options_imp::loadWindowState() {
}
void options_imp::saveWindowState() const {
QIniSettings settings;
settings.setValue(QString::fromUtf8("Preferences/State/size"), size());
settings.setValue(QString::fromUtf8("Preferences/State/pos"), pos());
Preferences* const pref = Preferences::instance();
pref->setPrefSize(size());
pref->setPrefPos(pos());
// Splitter size
QStringList sizes_str;
sizes_str << QString::number(hsplitter->sizes().first());
sizes_str << QString::number(hsplitter->sizes().last());
settings.setValue(QString::fromUtf8("Preferences/State/hSplitterSizes"), sizes_str);
pref->setPrefHSplitterSizes(sizes_str);
}
QSize options_imp::sizeFittingScreen() const {
@@ -341,10 +341,10 @@ QSize options_imp::sizeFittingScreen() const {
void options_imp::saveOptions() {
applyButton->setEnabled(false);
Preferences pref;
Preferences* const pref = Preferences::instance();
// Load the translation
QString locale = getLocale();
if (pref.getLocale() != locale) {
if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
@@ -355,18 +355,18 @@ void options_imp::saveOptions() {
}
// General preferences
pref.setLocale(locale);
pref.setAlternatingRowColors(checkAltRowColors->isChecked());
pref.setSystrayIntegration(systrayIntegration());
pref.setTrayIconStyle(TrayIcon::Style(comboTrayIcon->currentIndex()));
pref.setCloseToTray(closeToTray());
pref.setMinimizeToTray(minimizeToTray());
pref.setStartMinimized(startMinimized());
pref.setSplashScreenDisabled(isSlashScreenDisabled());
pref.setConfirmOnExit(checkProgramExitConfirm->isChecked());
pref.setPreventFromSuspend(preventFromSuspend());
pref->setLocale(locale);
pref->setAlternatingRowColors(checkAltRowColors->isChecked());
pref->setSystrayIntegration(systrayIntegration());
pref->setTrayIconStyle(TrayIcon::Style(comboTrayIcon->currentIndex()));
pref->setCloseToTray(closeToTray());
pref->setMinimizeToTray(minimizeToTray());
pref->setStartMinimized(startMinimized());
pref->setSplashScreenDisabled(isSlashScreenDisabled());
pref->setConfirmOnExit(checkProgramExitConfirm->isChecked());
pref->setPreventFromSuspend(preventFromSuspend());
#ifdef Q_OS_WIN
pref.setStartup(Startup());
pref->setWinStartup(WinStartup());
// Windows: file association settings
Preferences::setTorrentFileAssoc(checkAssociateTorrents->isChecked());
Preferences::setMagnetLinkAssoc(checkAssociateMagnetLinks->isChecked());
@@ -374,108 +374,111 @@ void options_imp::saveOptions() {
// End General preferences
// Downloads preferences
pref.setSavePath(getSavePath());
pref.setTempPathEnabled(isTempPathEnabled());
pref.setTempPath(getTempPath());
pref.setAppendTorrentLabel(checkAppendLabel->isChecked());
pref.useIncompleteFilesExtension(checkAppendqB->isChecked());
pref.preAllocateAllFiles(preAllocateAllFiles());
pref.useAdditionDialog(useAdditionDialog());
pref.AdditionDialogFront(checkAdditionDialogFront->isChecked());
pref.addTorrentsInPause(addTorrentsInPause());
pref->setSavePath(getSavePath());
pref->setTempPathEnabled(isTempPathEnabled());
pref->setTempPath(getTempPath());
pref->setAppendTorrentLabel(checkAppendLabel->isChecked());
pref->useIncompleteFilesExtension(checkAppendqB->isChecked());
pref->preAllocateAllFiles(preAllocateAllFiles());
pref->useAdditionDialog(useAdditionDialog());
pref->additionDialogFront(checkAdditionDialogFront->isChecked());
pref->addTorrentsInPause(addTorrentsInPause());
ScanFoldersModel::instance()->makePersistent();
addedScanDirs.clear();
pref.setTorrentExportDir(getTorrentExportDir());
pref.setFinishedTorrentExportDir(getFinishedTorrentExportDir());
pref.setMailNotificationEnabled(groupMailNotification->isChecked());
pref.setMailNotificationEmail(dest_email_txt->text());
pref.setMailNotificationSMTP(smtp_server_txt->text());
pref.setMailNotificationSMTPSSL(checkSmtpSSL->isChecked());
pref.setMailNotificationSMTPAuth(groupMailNotifAuth->isChecked());
pref.setMailNotificationSMTPUsername(mailNotifUsername->text());
pref.setMailNotificationSMTPPassword(mailNotifPassword->text());
pref.setAutoRunEnabled(autoRunBox->isChecked());
pref.setAutoRunProgram(autoRun_txt->text());
pref.setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
pref.setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
pref->setTorrentExportDir(getTorrentExportDir());
pref->setFinishedTorrentExportDir(getFinishedTorrentExportDir());
pref->setMailNotificationEnabled(groupMailNotification->isChecked());
pref->setMailNotificationEmail(dest_email_txt->text());
pref->setMailNotificationSMTP(smtp_server_txt->text());
pref->setMailNotificationSMTPSSL(checkSmtpSSL->isChecked());
pref->setMailNotificationSMTPAuth(groupMailNotifAuth->isChecked());
pref->setMailNotificationSMTPUsername(mailNotifUsername->text());
pref->setMailNotificationSMTPPassword(mailNotifPassword->text());
pref->setAutoRunEnabled(autoRunBox->isChecked());
pref->setAutoRunProgram(autoRun_txt->text());
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
// End Downloads preferences
// Connection preferences
pref.setSessionPort(getPort());
pref.setRandomPort(checkRandomPort->isChecked());
pref.setUPnPEnabled(isUPnPEnabled());
pref->setSessionPort(getPort());
pref->setRandomPort(checkRandomPort->isChecked());
pref->setUPnPEnabled(isUPnPEnabled());
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
pref.setGlobalDownloadLimit(down_up_limit.first);
pref.setGlobalUploadLimit(down_up_limit.second);
pref.setuTPEnabled(checkuTP->isChecked());
pref.setuTPRateLimited(checkLimituTPConnections->isChecked());
pref.includeOverheadInLimits(checkLimitTransportOverhead->isChecked());
pref.setAltGlobalDownloadLimit(spinDownloadLimitAlt->value());
pref.setAltGlobalUploadLimit(spinUploadLimitAlt->value());
pref.setSchedulerEnabled(check_schedule->isChecked());
pref.setSchedulerStartTime(schedule_from->time());
pref.setSchedulerEndTime(schedule_to->time());
pref.setSchedulerDays((scheduler_days)schedule_days->currentIndex());
pref.setProxyType(getProxyType());
pref.setProxyIp(getProxyIp());
pref.setProxyPort(getProxyPort());
pref.setProxyPeerConnections(checkProxyPeerConnecs->isChecked());
pref.setProxyAuthEnabled(isProxyAuthEnabled());
pref.setProxyUsername(getProxyUsername());
pref.setProxyPassword(getProxyPassword());
pref->setGlobalDownloadLimit(down_up_limit.first);
pref->setGlobalUploadLimit(down_up_limit.second);
pref->setuTPEnabled(checkuTP->isChecked());
pref->setuTPRateLimited(checkLimituTPConnections->isChecked());
pref->includeOverheadInLimits(checkLimitTransportOverhead->isChecked());
pref->setAltGlobalDownloadLimit(spinDownloadLimitAlt->value());
pref->setAltGlobalUploadLimit(spinUploadLimitAlt->value());
pref->setSchedulerEnabled(check_schedule->isChecked());
pref->setSchedulerStartTime(schedule_from->time());
pref->setSchedulerEndTime(schedule_to->time());
pref->setSchedulerDays((scheduler_days)schedule_days->currentIndex());
pref->setProxyType(getProxyType());
pref->setProxyIp(getProxyIp());
pref->setProxyPort(getProxyPort());
pref->setProxyPeerConnections(checkProxyPeerConnecs->isChecked());
pref->setProxyAuthEnabled(isProxyAuthEnabled());
pref->setProxyUsername(getProxyUsername());
pref->setProxyPassword(getProxyPassword());
// End Connection preferences
// Bittorrent preferences
pref.setMaxConnecs(getMaxConnecs());
pref.setMaxConnecsPerTorrent(getMaxConnecsPerTorrent());
pref.setMaxUploads(getMaxUploads());
pref.setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
pref.setDHTEnabled(isDHTEnabled());
pref.setPeXEnabled(checkPeX->isChecked());
pref.setLSDEnabled(isLSDEnabled());
pref.setEncryptionSetting(getEncryptionSetting());
pref.enableAnonymousMode(checkAnonymousMode->isChecked());
pref.setGlobalMaxRatio(getMaxRatio());
pref.setMaxRatioAction(comboRatioLimitAct->currentIndex());
pref->setMaxConnecs(getMaxConnecs());
pref->setMaxConnecsPerTorrent(getMaxConnecsPerTorrent());
pref->setMaxUploads(getMaxUploads());
pref->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
pref->setDHTEnabled(isDHTEnabled());
pref->setPeXEnabled(checkPeX->isChecked());
pref->setLSDEnabled(isLSDEnabled());
pref->setEncryptionSetting(getEncryptionSetting());
pref->enableAnonymousMode(checkAnonymousMode->isChecked());
pref->setGlobalMaxRatio(getMaxRatio());
pref->setMaxRatioAction(comboRatioLimitAct->currentIndex());
// End Bittorrent preferences
// Misc preferences
// * IPFilter
pref.setFilteringEnabled(isFilteringEnabled());
pref->setFilteringEnabled(isFilteringEnabled());
if (isFilteringEnabled())
pref.setFilter(textFilterPath->text());
pref->setFilter(textFilterPath->text());
// End IPFilter preferences
// Queueing system
pref.setQueueingSystemEnabled(isQueueingSystemEnabled());
pref.setMaxActiveDownloads(spinMaxActiveDownloads->value());
pref.setMaxActiveUploads(spinMaxActiveUploads->value());
pref.setMaxActiveTorrents(spinMaxActiveTorrents->value());
pref.setIgnoreSlowTorrentsForQueueing(checkIgnoreSlowTorrentsForQueueing->isChecked());
pref->setQueueingSystemEnabled(isQueueingSystemEnabled());
pref->setMaxActiveDownloads(spinMaxActiveDownloads->value());
pref->setMaxActiveUploads(spinMaxActiveUploads->value());
pref->setMaxActiveTorrents(spinMaxActiveTorrents->value());
pref->setIgnoreSlowTorrentsForQueueing(checkIgnoreSlowTorrentsForQueueing->isChecked());
// End Queueing system preferences
// Web UI
pref.setWebUiEnabled(isWebUiEnabled());
pref->setWebUiEnabled(isWebUiEnabled());
if (isWebUiEnabled())
{
pref.setWebUiPort(webUiPort());
pref.setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
pref.setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
pref->setWebUiPort(webUiPort());
pref->setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
pref->setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
if (checkWebUiHttps->isChecked())
{
pref.setWebUiHttpsCertificate(m_sslCert);
pref.setWebUiHttpsKey(m_sslKey);
pref->setWebUiHttpsCertificate(m_sslCert);
pref->setWebUiHttpsKey(m_sslKey);
}
pref.setWebUiUsername(webUiUsername());
pref->setWebUiUsername(webUiUsername());
// FIXME: Check that the password is valid (not empty at least)
pref.setWebUiPassword(webUiPassword());
pref.setWebUiLocalAuthEnabled(!checkBypassLocalAuth->isChecked());
pref->setWebUiPassword(webUiPassword());
pref->setWebUiLocalAuthEnabled(!checkBypassLocalAuth->isChecked());
// DynDNS
pref.setDynDNSEnabled(checkDynDNS->isChecked());
pref.setDynDNSService(comboDNSService->currentIndex());
pref.setDynDomainName(domainNameTxt->text());
pref.setDynDNSUsername(DNSUsernameTxt->text());
pref.setDynDNSPassword(DNSPasswordTxt->text());
pref->setDynDNSEnabled(checkDynDNS->isChecked());
pref->setDynDNSService(comboDNSService->currentIndex());
pref->setDynDomainName(domainNameTxt->text());
pref->setDynDNSUsername(DNSUsernameTxt->text());
pref->setDynDNSPassword(DNSPasswordTxt->text());
}
// End Web UI
// End preferences
// Save advanced settings
advancedSettings->saveAdvancedSettings();
// Assume that user changed multiple settings
// so it's best to save immediately
pref->save();
}
bool options_imp::isFilteringEnabled() const {
@@ -507,43 +510,43 @@ void options_imp::loadOptions() {
qreal floatValue;
QString strValue;
// General preferences
const Preferences pref;
setLocale(pref.getLocale());
checkAltRowColors->setChecked(pref.useAlternatingRowColors());
checkShowSystray->setChecked(pref.systrayIntegration());
checkShowSplash->setChecked(!pref.isSlashScreenDisabled());
const Preferences* const pref = Preferences::instance();
setLocale(pref->getLocale());
checkAltRowColors->setChecked(pref->useAlternatingRowColors());
checkShowSystray->setChecked(pref->systrayIntegration());
checkShowSplash->setChecked(!pref->isSlashScreenDisabled());
if (checkShowSystray->isChecked()) {
checkCloseToSystray->setChecked(pref.closeToTray());
checkMinimizeToSysTray->setChecked(pref.minimizeToTray());
checkStartMinimized->setChecked(pref.startMinimized());
checkCloseToSystray->setChecked(pref->closeToTray());
checkMinimizeToSysTray->setChecked(pref->minimizeToTray());
checkStartMinimized->setChecked(pref->startMinimized());
}
comboTrayIcon->setCurrentIndex(pref.trayIconStyle());
checkProgramExitConfirm->setChecked(pref.confirmOnExit());
checkPreventFromSuspend->setChecked(pref.preventFromSuspend());
comboTrayIcon->setCurrentIndex(pref->trayIconStyle());
checkProgramExitConfirm->setChecked(pref->confirmOnExit());
checkPreventFromSuspend->setChecked(pref->preventFromSuspend());
#ifdef Q_OS_WIN
checkStartup->setChecked(pref.Startup());
checkStartup->setChecked(pref->WinStartup());
// Windows: file association settings
checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
checkAssociateMagnetLinks->setChecked(Preferences::isMagnetLinkAssocSet());
#endif
// End General preferences
// Downloads preferences
textSavePath->setText(fsutils::toNativePath(pref.getSavePath()));
if (pref.isTempPathEnabled()) {
textSavePath->setText(fsutils::toNativePath(pref->getSavePath()));
if (pref->isTempPathEnabled()) {
// enable
checkTempFolder->setChecked(true);
} else {
checkTempFolder->setChecked(false);
}
textTempPath->setText(fsutils::toNativePath(pref.getTempPath()));
checkAppendLabel->setChecked(pref.appendTorrentLabel());
checkAppendqB->setChecked(pref.useIncompleteFilesExtension());
checkPreallocateAll->setChecked(pref.preAllocateAllFiles());
checkAdditionDialog->setChecked(pref.useAdditionDialog());
checkAdditionDialogFront->setChecked(pref.AdditionDialogFront());
checkStartPaused->setChecked(pref.addTorrentsInPause());
textTempPath->setText(fsutils::toNativePath(pref->getTempPath()));
checkAppendLabel->setChecked(pref->appendTorrentLabel());
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
checkPreallocateAll->setChecked(pref->preAllocateAllFiles());
checkAdditionDialog->setChecked(pref->useAdditionDialog());
checkAdditionDialogFront->setChecked(pref->additionDialogFront());
checkStartPaused->setChecked(pref->addTorrentsInPause());
strValue = fsutils::toNativePath(pref.getTorrentExportDir());
strValue = fsutils::toNativePath(pref->getTorrentExportDir());
if (strValue.isEmpty()) {
// Disable
checkExportDir->setChecked(false);
@@ -552,7 +555,7 @@ void options_imp::loadOptions() {
textExportDir->setText(strValue);
}
strValue = fsutils::toNativePath(pref.getFinishedTorrentExportDir());
strValue = fsutils::toNativePath(pref->getFinishedTorrentExportDir());
if (strValue.isEmpty()) {
// Disable
checkExportDirFin->setChecked(false);
@@ -561,30 +564,30 @@ void options_imp::loadOptions() {
checkExportDirFin->setChecked(true);
textExportDirFin->setText(strValue);
}
groupMailNotification->setChecked(pref.isMailNotificationEnabled());
dest_email_txt->setText(pref.getMailNotificationEmail());
smtp_server_txt->setText(pref.getMailNotificationSMTP());
checkSmtpSSL->setChecked(pref.getMailNotificationSMTPSSL());
groupMailNotifAuth->setChecked(pref.getMailNotificationSMTPAuth());
mailNotifUsername->setText(pref.getMailNotificationSMTPUsername());
mailNotifPassword->setText(pref.getMailNotificationSMTPPassword());
autoRunBox->setChecked(pref.isAutoRunEnabled());
autoRun_txt->setText(pref.getAutoRunProgram());
intValue = pref.getActionOnDblClOnTorrentDl();
groupMailNotification->setChecked(pref->isMailNotificationEnabled());
dest_email_txt->setText(pref->getMailNotificationEmail());
smtp_server_txt->setText(pref->getMailNotificationSMTP());
checkSmtpSSL->setChecked(pref->getMailNotificationSMTPSSL());
groupMailNotifAuth->setChecked(pref->getMailNotificationSMTPAuth());
mailNotifUsername->setText(pref->getMailNotificationSMTPUsername());
mailNotifPassword->setText(pref->getMailNotificationSMTPPassword());
autoRunBox->setChecked(pref->isAutoRunEnabled());
autoRun_txt->setText(pref->getAutoRunProgram());
intValue = pref->getActionOnDblClOnTorrentDl();
if (intValue >= actionTorrentDlOnDblClBox->count())
intValue = 0;
actionTorrentDlOnDblClBox->setCurrentIndex(intValue);
intValue = pref.getActionOnDblClOnTorrentFn();
intValue = pref->getActionOnDblClOnTorrentFn();
if (intValue >= actionTorrentFnOnDblClBox->count())
intValue = 1;
actionTorrentFnOnDblClBox->setCurrentIndex(intValue);
// End Downloads preferences
// Connection preferences
spinPort->setValue(pref.getSessionPort());
checkUPnP->setChecked(pref.isUPnPEnabled());
checkRandomPort->setChecked(pref.useRandomPort());
spinPort->setValue(pref->getSessionPort());
checkUPnP->setChecked(pref->isUPnPEnabled());
checkRandomPort->setChecked(pref->useRandomPort());
spinPort->setDisabled(checkRandomPort->isChecked());
intValue = pref.getGlobalDownloadLimit();
intValue = pref->getGlobalDownloadLimit();
if (intValue > 0) {
// Enabled
checkDownloadLimit->setChecked(true);
@@ -595,7 +598,7 @@ void options_imp::loadOptions() {
checkDownloadLimit->setChecked(false);
spinDownloadLimit->setEnabled(false);
}
intValue = pref.getGlobalUploadLimit();
intValue = pref->getGlobalUploadLimit();
if (intValue != -1) {
// Enabled
checkUploadLimit->setChecked(true);
@@ -606,19 +609,19 @@ void options_imp::loadOptions() {
checkUploadLimit->setChecked(false);
spinUploadLimit->setEnabled(false);
}
spinUploadLimitAlt->setValue(pref.getAltGlobalUploadLimit());
spinDownloadLimitAlt->setValue(pref.getAltGlobalDownloadLimit());
spinUploadLimitAlt->setValue(pref->getAltGlobalUploadLimit());
spinDownloadLimitAlt->setValue(pref->getAltGlobalDownloadLimit());
// Options
checkuTP->setChecked(pref.isuTPEnabled());
checkLimituTPConnections->setChecked(pref.isuTPRateLimited());
checkLimitTransportOverhead->setChecked(pref.includeOverheadInLimits());
checkuTP->setChecked(pref->isuTPEnabled());
checkLimituTPConnections->setChecked(pref->isuTPRateLimited());
checkLimitTransportOverhead->setChecked(pref->includeOverheadInLimits());
// Scheduler
check_schedule->setChecked(pref.isSchedulerEnabled());
schedule_from->setTime(pref.getSchedulerStartTime());
schedule_to->setTime(pref.getSchedulerEndTime());
schedule_days->setCurrentIndex((int)pref.getSchedulerDays());
check_schedule->setChecked(pref->isSchedulerEnabled());
schedule_from->setTime(pref->getSchedulerStartTime());
schedule_to->setTime(pref->getSchedulerEndTime());
schedule_days->setCurrentIndex((int)pref->getSchedulerDays());
intValue = pref.getProxyType();
intValue = pref->getProxyType();
switch(intValue) {
case Proxy::SOCKS4:
comboProxyType->setCurrentIndex(1);
@@ -637,16 +640,16 @@ void options_imp::loadOptions() {
enableProxy(comboProxyType->currentIndex());
//if (isProxyEnabled()) {
// Proxy is enabled, save settings
textProxyIP->setText(pref.getProxyIp());
spinProxyPort->setValue(pref.getProxyPort());
checkProxyPeerConnecs->setChecked(pref.proxyPeerConnections());
checkProxyAuth->setChecked(pref.isProxyAuthEnabled());
textProxyUsername->setText(pref.getProxyUsername());
textProxyPassword->setText(pref.getProxyPassword());
textProxyIP->setText(pref->getProxyIp());
spinProxyPort->setValue(pref->getProxyPort());
checkProxyPeerConnecs->setChecked(pref->proxyPeerConnections());
checkProxyAuth->setChecked(pref->isProxyAuthEnabled());
textProxyUsername->setText(pref->getProxyUsername());
textProxyPassword->setText(pref->getProxyPassword());
//}
// End Connection preferences
// Bittorrent preferences
intValue = pref.getMaxConnecs();
intValue = pref->getMaxConnecs();
if (intValue > 0) {
// enable
checkMaxConnecs->setChecked(true);
@@ -657,7 +660,7 @@ void options_imp::loadOptions() {
checkMaxConnecs->setChecked(false);
spinMaxConnec->setEnabled(false);
}
intValue = pref.getMaxConnecsPerTorrent();
intValue = pref->getMaxConnecsPerTorrent();
if (intValue > 0) {
// enable
checkMaxConnecsPerTorrent->setChecked(true);
@@ -668,7 +671,7 @@ void options_imp::loadOptions() {
checkMaxConnecsPerTorrent->setChecked(false);
spinMaxConnecPerTorrent->setEnabled(false);
}
intValue = pref.getMaxUploads();
intValue = pref->getMaxUploads();
if (intValue > 0) {
// enable
checkMaxUploads->setChecked(true);
@@ -679,7 +682,7 @@ void options_imp::loadOptions() {
checkMaxUploads->setChecked(false);
spinMaxUploads->setEnabled(false);
}
intValue = pref.getMaxUploadsPerTorrent();
intValue = pref->getMaxUploadsPerTorrent();
if (intValue > 0) {
// enable
checkMaxUploadsPerTorrent->setChecked(true);
@@ -690,15 +693,15 @@ void options_imp::loadOptions() {
checkMaxUploadsPerTorrent->setChecked(false);
spinMaxUploadsPerTorrent->setEnabled(false);
}
checkDHT->setChecked(pref.isDHTEnabled());
checkPeX->setChecked(pref.isPeXEnabled());
checkLSD->setChecked(pref.isLSDEnabled());
comboEncryption->setCurrentIndex(pref.getEncryptionSetting());
checkAnonymousMode->setChecked(pref.isAnonymousModeEnabled());
checkDHT->setChecked(pref->isDHTEnabled());
checkPeX->setChecked(pref->isPeXEnabled());
checkLSD->setChecked(pref->isLSDEnabled());
comboEncryption->setCurrentIndex(pref->getEncryptionSetting());
checkAnonymousMode->setChecked(pref->isAnonymousModeEnabled());
/* make sure ui matches options */
toggleAnonymousMode(checkAnonymousMode->isChecked());
// Ratio limit
floatValue = pref.getGlobalMaxRatio();
floatValue = pref->getGlobalMaxRatio();
if (floatValue >= 0.) {
// Enable
checkMaxRatio->setChecked(true);
@@ -711,36 +714,36 @@ void options_imp::loadOptions() {
spinMaxRatio->setEnabled(false);
comboRatioLimitAct->setEnabled(false);
}
comboRatioLimitAct->setCurrentIndex(pref.getMaxRatioAction());
comboRatioLimitAct->setCurrentIndex(pref->getMaxRatioAction());
// End Bittorrent preferences
// Misc preferences
// * IP Filter
checkIPFilter->setChecked(pref.isFilteringEnabled());
textFilterPath->setText(fsutils::toNativePath(pref.getFilter()));
checkIPFilter->setChecked(pref->isFilteringEnabled());
textFilterPath->setText(fsutils::toNativePath(pref->getFilter()));
// End IP Filter
// Queueing system preferences
checkEnableQueueing->setChecked(pref.isQueueingSystemEnabled());
spinMaxActiveDownloads->setValue(pref.getMaxActiveDownloads());
spinMaxActiveUploads->setValue(pref.getMaxActiveUploads());
spinMaxActiveTorrents->setValue(pref.getMaxActiveTorrents());
checkIgnoreSlowTorrentsForQueueing->setChecked(pref.ignoreSlowTorrentsForQueueing());
checkEnableQueueing->setChecked(pref->isQueueingSystemEnabled());
spinMaxActiveDownloads->setValue(pref->getMaxActiveDownloads());
spinMaxActiveUploads->setValue(pref->getMaxActiveUploads());
spinMaxActiveTorrents->setValue(pref->getMaxActiveTorrents());
checkIgnoreSlowTorrentsForQueueing->setChecked(pref->ignoreSlowTorrentsForQueueing());
// End Queueing system preferences
// Web UI
checkWebUi->setChecked(pref.isWebUiEnabled());
spinWebUiPort->setValue(pref.getWebUiPort());
checkWebUIUPnP->setChecked(pref.useUPnPForWebUIPort());
checkWebUiHttps->setChecked(pref.isWebUiHttpsEnabled());
setSslCertificate(pref.getWebUiHttpsCertificate(), false);
setSslKey(pref.getWebUiHttpsKey(), false);
textWebUiUsername->setText(pref.getWebUiUsername());
textWebUiPassword->setText(pref.getWebUiPassword());
checkBypassLocalAuth->setChecked(!pref.isWebUiLocalAuthEnabled());
checkWebUi->setChecked(pref->isWebUiEnabled());
spinWebUiPort->setValue(pref->getWebUiPort());
checkWebUIUPnP->setChecked(pref->useUPnPForWebUIPort());
checkWebUiHttps->setChecked(pref->isWebUiHttpsEnabled());
setSslCertificate(pref->getWebUiHttpsCertificate(), false);
setSslKey(pref->getWebUiHttpsKey(), false);
textWebUiUsername->setText(pref->getWebUiUsername());
textWebUiPassword->setText(pref->getWebUiPassword());
checkBypassLocalAuth->setChecked(!pref->isWebUiLocalAuthEnabled());
// Dynamic DNS
checkDynDNS->setChecked(pref.isDynDNSEnabled());
comboDNSService->setCurrentIndex((int)pref.getDynDNSService());
domainNameTxt->setText(pref.getDynDomainName());
DNSUsernameTxt->setText(pref.getDynDNSUsername());
DNSPasswordTxt->setText(pref.getDynDNSPassword());
checkDynDNS->setChecked(pref->isDynDNSEnabled());
comboDNSService->setCurrentIndex((int)pref->getDynDNSService());
domainNameTxt->setText(pref->getDynDomainName());
DNSUsernameTxt->setText(pref->getDynDNSUsername());
DNSPasswordTxt->setText(pref->getDynDNSPassword());
// End Web UI
}
@@ -830,7 +833,7 @@ qreal options_imp::getMaxRatio() const {
// Return Save Path
QString options_imp::getSavePath() const {
if (textSavePath->text().trimmed().isEmpty()) {
QString save_path = Preferences().getSavePath();
QString save_path = Preferences::instance()->getSavePath();
textSavePath->setText(fsutils::toNativePath(save_path));
}
return fsutils::expandPathAbs(textSavePath->text());
@@ -952,7 +955,7 @@ bool options_imp::isSlashScreenDisabled() const {
}
#ifdef Q_OS_WIN
bool options_imp::Startup() const {
bool options_imp::WinStartup() const {
return checkStartup->isChecked();
}
#endif
@@ -1042,9 +1045,9 @@ int options_imp::getActionOnDblClOnTorrentFn() const {
}
void options_imp::on_addScanFolderButton_clicked() {
Preferences pref;
Preferences* const pref = Preferences::instance();
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
fsutils::toNativePath(fsutils::folderName(pref.getScanDirsLastPath())));
fsutils::toNativePath(fsutils::folderName(pref->getScanDirsLastPath())));
if (!dir.isEmpty()) {
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
QString error;
@@ -1059,7 +1062,7 @@ void options_imp::on_addScanFolderButton_clicked() {
error = tr("Folder is not readable.");
break;
default:
pref.setScanDirsLastPath(dir);
pref->setScanDirsLastPath(dir);
addedScanDirs << dir;
scanFoldersView->resizeColumnsToContents();
enableApplyButton();
@@ -1210,9 +1213,9 @@ void options_imp::on_IpFilterRefreshBtn_clicked() {
if (m_refreshingIpFilter) return;
m_refreshingIpFilter = true;
// Updating program preferences
Preferences pref;
pref.setFilteringEnabled(true);
pref.setFilter(getFilter());
Preferences* const pref = Preferences::instance();
pref->setFilteringEnabled(true);
pref->setFilter(getFilter());
// Force refresh
connect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
setCursor(QCursor(Qt::WaitCursor));