Some work about adaptive color scheme for Web UI (PR #19901)
http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1819 lines
80 KiB
1819 lines
80 KiB
18 years ago
|
/*
|
||
7 years ago
|
* Bittorrent Client using Qt and libtorrent.
|
||
|
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||
18 years ago
|
*
|
||
18 years ago
|
* 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.
|
||
18 years ago
|
*
|
||
|
* 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
|
||
18 years ago
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
16 years ago
|
* 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.
|
||
18 years ago
|
*/
|
||
10 years ago
|
|
||
7 years ago
|
#include "optionsdialog.h"
|
||
9 years ago
|
|
||
|
#include <cstdlib>
|
||
|
|
||
18 years ago
|
#include <QApplication>
|
||
18 years ago
|
#include <QCloseEvent>
|
||
9 years ago
|
#include <QDebug>
|
||
|
#include <QDesktopServices>
|
||
16 years ago
|
#include <QDesktopWidget>
|
||
9 years ago
|
#include <QDialogButtonBox>
|
||
7 years ago
|
#include <QEvent>
|
||
9 years ago
|
#include <QFileDialog>
|
||
|
#include <QMessageBox>
|
||
|
#include <QSystemTrayIcon>
|
||
14 years ago
|
#include <QTranslator>
|
||
18 years ago
|
|
||
9 years ago
|
#ifndef QT_NO_OPENSSL
|
||
|
#include <QSslCertificate>
|
||
|
#include <QSslKey>
|
||
|
#endif
|
||
9 years ago
|
|
||
9 years ago
|
#include "base/bittorrent/session.h"
|
||
7 years ago
|
#include "base/global.h"
|
||
9 years ago
|
#include "base/net/dnsupdater.h"
|
||
9 years ago
|
#include "base/net/portforwarder.h"
|
||
9 years ago
|
#include "base/net/proxyconfigurationmanager.h"
|
||
9 years ago
|
#include "base/preferences.h"
|
||
8 years ago
|
#include "base/rss/rss_autodownloader.h"
|
||
|
#include "base/rss/rss_session.h"
|
||
9 years ago
|
#include "base/scanfoldersmodel.h"
|
||
9 years ago
|
#include "base/torrentfileguard.h"
|
||
9 years ago
|
#include "base/unicodestrings.h"
|
||
|
#include "base/utils/fs.h"
|
||
8 years ago
|
#include "base/utils/random.h"
|
||
9 years ago
|
#include "addnewtorrentdialog.h"
|
||
9 years ago
|
#include "advancedsettings.h"
|
||
7 years ago
|
#include "app/application.h"
|
||
7 years ago
|
#include "banlistoptionsdialog.h"
|
||
7 years ago
|
#include "ipsubnetwhitelistoptionsdialog.h"
|
||
9 years ago
|
#include "guiiconprovider.h"
|
||
7 years ago
|
#include "rss/automatedrssdownloader.h"
|
||
9 years ago
|
#include "scanfoldersdelegate.h"
|
||
7 years ago
|
#include "ui_optionsdialog.h"
|
||
7 years ago
|
#include "utils.h"
|
||
14 years ago
|
|
||
7 years ago
|
class WheelEventEater : public QObject
|
||
|
{
|
||
|
public:
|
||
|
using QObject::QObject;
|
||
|
|
||
|
private:
|
||
|
bool eventFilter(QObject *, QEvent *event) override
|
||
|
{
|
||
|
return (event->type() == QEvent::Wheel);
|
||
|
}
|
||
|
};
|
||
|
|
||
18 years ago
|
// Constructor
|
||
9 years ago
|
OptionsDialog::OptionsDialog(QWidget *parent)
|
||
9 years ago
|
: QDialog(parent)
|
||
|
, m_refreshingIpFilter(false)
|
||
9 years ago
|
, m_ui(new Ui::OptionsDialog)
|
||
9 years ago
|
{
|
||
|
qDebug("-> Constructing Options");
|
||
9 years ago
|
m_ui->setupUi(this);
|
||
9 years ago
|
setAttribute(Qt::WA_DeleteOnClose);
|
||
|
setModal(true);
|
||
9 years ago
|
|
||
8 years ago
|
#if (defined(Q_OS_UNIX))
|
||
|
setWindowTitle(tr("Preferences"));
|
||
|
#endif
|
||
7 years ago
|
|
||
9 years ago
|
// Icons
|
||
9 years ago
|
m_ui->tabSelection->item(TAB_UI)->setIcon(GuiIconProvider::instance()->getIcon("preferences-desktop"));
|
||
|
m_ui->tabSelection->item(TAB_BITTORRENT)->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
|
||
|
m_ui->tabSelection->item(TAB_CONNECTION)->setIcon(GuiIconProvider::instance()->getIcon("network-wired"));
|
||
8 years ago
|
m_ui->tabSelection->item(TAB_DOWNLOADS)->setIcon(GuiIconProvider::instance()->getIcon("folder-download"));
|
||
|
m_ui->tabSelection->item(TAB_SPEED)->setIcon(GuiIconProvider::instance()->getIcon("speedometer", "chronometer"));
|
||
8 years ago
|
m_ui->tabSelection->item(TAB_RSS)->setIcon(GuiIconProvider::instance()->getIcon("rss-config", "application-rss+xml"));
|
||
10 years ago
|
#ifndef DISABLE_WEBUI
|
||
9 years ago
|
m_ui->tabSelection->item(TAB_WEBUI)->setIcon(GuiIconProvider::instance()->getIcon("network-server"));
|
||
10 years ago
|
#else
|
||
9 years ago
|
m_ui->tabSelection->item(TAB_WEBUI)->setHidden(true);
|
||
10 years ago
|
#endif
|
||
9 years ago
|
m_ui->tabSelection->item(TAB_ADVANCED)->setIcon(GuiIconProvider::instance()->getIcon("preferences-other"));
|
||
7 years ago
|
|
||
|
// set uniform size for all icons
|
||
|
int maxHeight = -1;
|
||
|
for (int i = 0; i < m_ui->tabSelection->count(); ++i)
|
||
|
maxHeight = std::max(maxHeight, m_ui->tabSelection->visualItemRect(m_ui->tabSelection->item(i)).size().height());
|
||
9 years ago
|
for (int i = 0; i < m_ui->tabSelection->count(); ++i) {
|
||
7 years ago
|
const QSize size(std::numeric_limits<int>::max(), static_cast<int>(maxHeight * 1.2));
|
||
|
m_ui->tabSelection->item(i)->setSizeHint(size);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
m_ui->IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
|
||
9 years ago
|
|
||
7 years ago
|
m_ui->labelGlobalRate->setPixmap(Utils::Gui::scaledPixmap(":/icons/slow_off.png", this, 16));
|
||
|
m_ui->labelAltRate->setPixmap(Utils::Gui::scaledPixmap(":/icons/slow.png", this, 16));
|
||
|
|
||
9 years ago
|
m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16));
|
||
|
m_ui->deleteTorrentWarningIcon->hide();
|
||
|
m_ui->deleteTorrentWarningLabel->hide();
|
||
|
m_ui->deleteTorrentWarningLabel->setToolTip(QLatin1String("<html><body><p>") +
|
||
9 years ago
|
tr("By enabling these options, you can <strong>irrevocably lose</strong> your .torrent files!") +
|
||
|
QLatin1String("</p><p>") +
|
||
|
tr("When these options are enabled, qBittorent will <strong>delete</strong> .torrent files "
|
||
|
"after they were successfully (the first option) or not (the second option) added to its "
|
||
|
"download queue. This will be applied <strong>not only</strong> to the files opened via "
|
||
|
"“Add torrent” menu action but to those opened via <strong>file type association</strong> as well") +
|
||
|
QLatin1String("</p><p>") +
|
||
|
tr("If you enable the second option (“Also when addition is cancelled”) the "
|
||
|
".torrent file <strong>will be deleted</strong> even if you press “<strong>Cancel</strong>” in "
|
||
|
"the “Add torrent” dialog") +
|
||
|
QLatin1String("</p></body></html>"));
|
||
|
|
||
9 years ago
|
m_ui->hsplitter->setCollapsible(0, false);
|
||
|
m_ui->hsplitter->setCollapsible(1, false);
|
||
9 years ago
|
// Get apply button in button box
|
||
9 years ago
|
QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
|
||
9 years ago
|
foreach (QAbstractButton *button, buttons) {
|
||
9 years ago
|
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
||
9 years ago
|
applyButton = button;
|
||
|
break;
|
||
|
}
|
||
18 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||
|
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
|
||
|
m_ui->scanFoldersView->setItemDelegate(new ScanFoldersDelegate(this, m_ui->scanFoldersView));
|
||
8 years ago
|
connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->scanFoldersView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ThisType::handleScanFolderViewSelectionChanged);
|
||
9 years ago
|
|
||
7 years ago
|
connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &OptionsDialog::applySettings);
|
||
9 years ago
|
// Languages supported
|
||
|
initializeLanguageCombo();
|
||
|
|
||
|
// Load week days (scheduler)
|
||
|
for (uint i = 1; i <= 7; ++i)
|
||
9 years ago
|
m_ui->schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat));
|
||
9 years ago
|
|
||
|
// Load options
|
||
|
loadOptions();
|
||
8 years ago
|
#ifdef Q_OS_MAC
|
||
|
m_ui->checkShowSystray->setVisible(false);
|
||
|
#else
|
||
9 years ago
|
// Disable systray integration if it is not supported by the system
|
||
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||
9 years ago
|
m_ui->checkShowSystray->setChecked(false);
|
||
|
m_ui->checkShowSystray->setEnabled(false);
|
||
|
m_ui->label_trayIconStyle->setVisible(false);
|
||
|
m_ui->comboTrayIcon->setVisible(false);
|
||
9 years ago
|
}
|
||
8 years ago
|
#endif
|
||
10 years ago
|
|
||
14 years ago
|
#if defined(QT_NO_OPENSSL)
|
||
9 years ago
|
m_ui->checkWebUiHttps->setVisible(false);
|
||
8 years ago
|
m_ui->checkSmtpSSL->setVisible(false);
|
||
14 years ago
|
#endif
|
||
13 years ago
|
|
||
11 years ago
|
#ifndef Q_OS_WIN
|
||
9 years ago
|
m_ui->checkStartup->setVisible(false);
|
||
9 years ago
|
#endif
|
||
|
|
||
|
#if !(defined(Q_OS_WIN) || defined(Q_OS_MAC))
|
||
9 years ago
|
m_ui->groupFileAssociation->setVisible(false);
|
||
13 years ago
|
#endif
|
||
|
|
||
7 years ago
|
m_ui->textWebUIRootFolder->setMode(FileSystemPathEdit::Mode::DirectoryOpen);
|
||
|
m_ui->textWebUIRootFolder->setDialogCaption(tr("Choose Alternative UI files location"));
|
||
|
|
||
9 years ago
|
// Connect signals / slots
|
||
8 years ago
|
// Shortcuts for frequently used signals that have more than one overload. They would require
|
||
|
// type casts and that is why we declare required member pointer here instead.
|
||
|
void (QComboBox::*qComboBoxCurrentIndexChanged)(int) = &QComboBox::currentIndexChanged;
|
||
|
void (QSpinBox::*qSpinBoxValueChanged)(int) = &QSpinBox::valueChanged;
|
||
|
|
||
7 years ago
|
connect(m_ui->checkForceProxy, &QAbstractButton::toggled, this, &ThisType::enableForceProxy);
|
||
8 years ago
|
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy);
|
||
|
connect(m_ui->checkRandomPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled);
|
||
9 years ago
|
|
||
|
// Apply button is activated when a value is changed
|
||
|
// General tab
|
||
8 years ago
|
connect(m_ui->comboI18n, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkHideZero, &QAbstractButton::toggled, m_ui->comboHideZero, &QWidget::setEnabled);
|
||
|
connect(m_ui->comboHideZero, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkShowSystray, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkCloseToSystray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMinimizeToSysTray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkStartMinimized, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
11 years ago
|
#ifdef Q_OS_WIN
|
||
8 years ago
|
connect(m_ui->checkStartup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
12 years ago
|
#endif
|
||
8 years ago
|
connect(m_ui->checkShowSplash, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkProgramExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkProgramAutoExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkPreventFromSuspend, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboTrayIcon, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
11 years ago
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && !defined(QT_DBUS_LIB)
|
||
9 years ago
|
m_ui->checkPreventFromSuspend->setDisabled(true);
|
||
13 years ago
|
#endif
|
||
9 years ago
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||
8 years ago
|
connect(m_ui->checkAssociateTorrents, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAssociateMagnetLinks, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
14 years ago
|
#endif
|
||
8 years ago
|
connect(m_ui->checkFileLog, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textFileLogPath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkFileLogBackup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkFileLogBackup, &QAbstractButton::toggled, m_ui->spinFileLogSize, &QWidget::setEnabled);
|
||
|
connect(m_ui->checkFileLogDelete, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkFileLogDelete, &QAbstractButton::toggled, m_ui->spinFileLogAge, &QWidget::setEnabled);
|
||
|
connect(m_ui->checkFileLogDelete, &QAbstractButton::toggled, m_ui->comboFileLogAgeType, &QWidget::setEnabled);
|
||
|
connect(m_ui->spinFileLogSize, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinFileLogAge, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboFileLogAgeType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
// Downloads tab
|
||
8 years ago
|
connect(m_ui->textSavePath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkUseSubcategories, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboSavingMode, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboTorrentCategoryChanged, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboCategoryDefaultPathChanged, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboCategoryChanged, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textTempPath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAppendqB, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkPreallocateAll, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAdditionDialog, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAdditionDialogFront, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkStartPaused, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkCreateSubfolder, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->deleteTorrentBox, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->deleteCancelledTorrentBox, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkExportDir, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkExportDir, &QAbstractButton::toggled, m_ui->textExportDir, &QWidget::setEnabled);
|
||
|
connect(m_ui->checkExportDirFin, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkExportDirFin, &QAbstractButton::toggled, m_ui->textExportDirFin, &QWidget::setEnabled);
|
||
|
connect(m_ui->textExportDir, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textExportDirFin, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->actionTorrentDlOnDblClBox, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->actionTorrentFnOnDblClBox, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkTempFolder, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkTempFolder, &QAbstractButton::toggled, m_ui->textTempPath, &QWidget::setEnabled);
|
||
|
connect(m_ui->addScanFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->removeScanFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->groupMailNotification, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->senderEmailTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->dest_email_txt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->smtp_server_txt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkSmtpSSL, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->groupMailNotifAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->mailNotifUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->mailNotifPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->autoRunBox, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->autoRun_txt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
|
||
7 years ago
|
const QString autoRunStr = QString("%1\n %2\n %3\n %4\n %5\n %6\n %7\n %8\n %9\n %10\n %11\n%12")
|
||
7 years ago
|
.arg(tr("Supported parameters (case sensitive):")
|
||
|
, tr("%N: Torrent name")
|
||
|
, tr("%L: Category")
|
||
7 years ago
|
, tr("%G: Tags (seperated by comma)")
|
||
7 years ago
|
, tr("%F: Content path (same as root path for multifile torrent)")
|
||
|
, tr("%R: Root path (first torrent subdirectory path)")
|
||
|
, tr("%D: Save path")
|
||
|
, tr("%C: Number of files")
|
||
7 years ago
|
, tr("%Z: Torrent size (bytes)"))
|
||
|
.arg(tr("%T: Current tracker")
|
||
|
, tr("%I: Info hash")
|
||
7 years ago
|
, tr("Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., \"%N\")"));
|
||
9 years ago
|
m_ui->autoRun_param->setText(autoRunStr);
|
||
9 years ago
|
|
||
|
// Connection tab
|
||
7 years ago
|
connect(m_ui->comboProtocol, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->spinPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkRandomPort, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkUPnP, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkUploadLimit, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkDownloadLimit, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkUploadLimitAlt, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkDownloadLimitAlt, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinUploadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinDownloadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinUploadLimitAlt, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinDownloadLimitAlt, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->check_schedule, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->schedule_from, &QDateTimeEdit::timeChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->schedule_to, &QDateTimeEdit::timeChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->schedule_days, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkLimituTPConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkLimitTransportOverhead, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkLimitLocalPeerRate, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
// Bittorrent tab
|
||
8 years ago
|
connect(m_ui->checkMaxConnecs, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMaxConnecsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxConnec, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkDHT, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkAnonymousMode, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkPeX, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkLSD, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboEncryption, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
connect(m_ui->checkMaxRatio, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
|
||
8 years ago
|
connect(m_ui->spinMaxRatio, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||
|
this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboRatioLimitAct, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
|
||
8 years ago
|
connect(m_ui->spinMaxSeedingMinutes, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
// Proxy tab
|
||
8 years ago
|
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinProxyPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkProxyPeerConnecs, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkForceProxy, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->isProxyOnlyForTorrents, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkProxyAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textProxyUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textProxyPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
// Misc tab
|
||
8 years ago
|
connect(m_ui->checkIPFilter, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkIPFilter, &QAbstractButton::toggled, m_ui->textFilterPath, &QWidget::setEnabled);
|
||
|
connect(m_ui->checkIPFilter, &QAbstractButton::toggled, m_ui->IpFilterRefreshBtn, &QWidget::setEnabled);
|
||
|
connect(m_ui->checkIpFilterTrackers, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textFilterPath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkEnableQueueing, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxActiveDownloads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxActiveUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinMaxActiveTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->checkIgnoreSlowTorrentsForQueueing, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinDownloadRateForSlowTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinUploadRateForSlowTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->spinSlowTorrentsInactivityTimer, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
|
||
|
const QString slowTorrentsExplanation = QLatin1String("<html><body><p>")
|
||
|
+ tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds")
|
||
|
+ QLatin1String("</p></body></html>");
|
||
|
m_ui->labelDownloadRateForSlowTorrents->setToolTip(slowTorrentsExplanation);
|
||
|
m_ui->labelUploadRateForSlowTorrents->setToolTip(slowTorrentsExplanation);
|
||
|
m_ui->labelSlowTorrentInactivityTimer->setToolTip(slowTorrentsExplanation);
|
||
|
|
||
10 years ago
|
#ifndef DISABLE_WEBUI
|
||
9 years ago
|
// Web UI tab
|
||
7 years ago
|
connect(m_ui->textServerDomains, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->checkWebUi, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->textWebUiAddress, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->spinWebUiPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkWebUIUPnP, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkWebUiHttps, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->btnWebUiKey, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->btnWebUiCrt, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textWebUiUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textWebUiPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkBypassLocalAuth, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->checkBypassAuthSubnetWhitelist, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->checkBypassAuthSubnetWhitelist, &QAbstractButton::toggled, m_ui->IPSubnetWhitelistButton, &QPushButton::setEnabled);
|
||
7 years ago
|
connect(m_ui->checkClickjacking, &QCheckBox::toggled, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->checkCSRFProtection, &QCheckBox::toggled, this, &ThisType::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->checkDynDNS, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->comboDNSService, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->domainNameTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->DNSUsernameTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->DNSPasswordTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->groupAltWebUI, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||
|
connect(m_ui->textWebUIRootFolder, &FileSystemPathLineEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
|
||
7 years ago
|
#endif // DISABLE_WEBUI
|
||
8 years ago
|
|
||
|
// RSS tab
|
||
|
connect(m_ui->checkRSSEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
|
||
|
connect(m_ui->checkRSSAutoDownloaderEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->textSmartEpisodeFilters, &QPlainTextEdit::textChanged, this, &OptionsDialog::enableApplyButton);
|
||
8 years ago
|
connect(m_ui->spinRSSRefreshInterval, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
|
||
|
connect(m_ui->spinRSSMaxArticlesPerFeed, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
|
||
7 years ago
|
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
|
||
8 years ago
|
|
||
9 years ago
|
// Disable apply Button
|
||
|
applyButton->setEnabled(false);
|
||
|
// Tab selection mechanism
|
||
8 years ago
|
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
|
||
9 years ago
|
// Load Advanced settings
|
||
9 years ago
|
advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
||
|
m_ui->advPageLayout->addWidget(advancedSettings);
|
||
8 years ago
|
connect(advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
||
9 years ago
|
|
||
9 years ago
|
m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory"));
|
||
|
m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||
|
|
||
|
m_ui->textExportDir->setDialogCaption(tr("Choose export directory"));
|
||
|
m_ui->textExportDir->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||
|
|
||
|
m_ui->textExportDirFin->setDialogCaption(tr("Choose export directory"));
|
||
|
m_ui->textExportDirFin->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||
|
|
||
|
m_ui->textFilterPath->setDialogCaption(tr("Choose an IP filter file"));
|
||
|
m_ui->textFilterPath->setFileNameFilter(tr("All supported filters")
|
||
|
+ QLatin1String(" (*.dat *.p2p *.p2b);;.dat (*.dat);;.p2p (*.p2p);;.p2b (*.p2b)"));
|
||
|
|
||
|
m_ui->textSavePath->setDialogCaption(tr("Choose a save directory"));
|
||
|
m_ui->textSavePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||
|
|
||
|
m_ui->textTempPath->setDialogCaption(tr("Choose a save directory"));
|
||
|
m_ui->textTempPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||
|
|
||
7 years ago
|
// disable mouse wheel event on widgets to avoid mis-selection
|
||
|
WheelEventEater *wheelEventEater = new WheelEventEater(this);
|
||
|
for (QComboBox *widget : copyAsConst(findChildren<QComboBox *>()))
|
||
|
widget->installEventFilter(wheelEventEater);
|
||
|
for (QSpinBox *widget : copyAsConst(findChildren<QSpinBox *>()))
|
||
|
widget->installEventFilter(wheelEventEater);
|
||
|
|
||
9 years ago
|
loadWindowState();
|
||
7 years ago
|
show();
|
||
|
// Have to be called after show(), because splitter width needed
|
||
|
loadSplitterState();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::initializeLanguageCombo()
|
||
14 years ago
|
{
|
||
9 years ago
|
// List language files
|
||
9 years ago
|
const QDir langDir(":/lang");
|
||
|
const QStringList langFiles = langDir.entryList(QStringList("qbittorrent_*.qm"), QDir::Files);
|
||
|
foreach (const QString langFile, langFiles) {
|
||
|
QString localeStr = langFile.mid(12); // remove "qbittorrent_"
|
||
9 years ago
|
localeStr.chop(3); // Remove ".qm"
|
||
9 years ago
|
QString languageName;
|
||
9 years ago
|
if (localeStr.startsWith("eo", Qt::CaseInsensitive)) {
|
||
9 years ago
|
// QLocale doesn't work with that locale. Esperanto isn't a "real" language.
|
||
|
languageName = QString::fromUtf8(C_LOCALE_ESPERANTO);
|
||
|
}
|
||
|
else {
|
||
|
QLocale locale(localeStr);
|
||
|
languageName = languageToLocalizedString(locale);
|
||
|
}
|
||
7 years ago
|
m_ui->comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".svg"), */ languageName, localeStr);
|
||
9 years ago
|
qDebug() << "Supported locale:" << localeStr;
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
// Main destructor
|
||
9 years ago
|
OptionsDialog::~OptionsDialog()
|
||
9 years ago
|
{
|
||
|
qDebug("-> destructing Options");
|
||
7 years ago
|
|
||
|
saveWindowState();
|
||
|
|
||
9 years ago
|
foreach (const QString &path, addedScanDirs)
|
||
|
ScanFoldersModel::instance()->removePath(path);
|
||
9 years ago
|
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
|
||
9 years ago
|
delete m_ui;
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||
9 years ago
|
{
|
||
|
if (!current)
|
||
|
current = previous;
|
||
9 years ago
|
m_ui->tabOption->setCurrentIndex(m_ui->tabSelection->row(current));
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::loadWindowState()
|
||
9 years ago
|
{
|
||
7 years ago
|
Utils::Gui::resize(this, Preferences::instance()->getPrefSize());
|
||
7 years ago
|
}
|
||
|
|
||
|
void OptionsDialog::loadSplitterState()
|
||
|
{
|
||
7 years ago
|
const QStringList sizesStr = Preferences::instance()->getPrefHSplitterSizes();
|
||
|
|
||
|
// width has been modified, use height as width reference instead
|
||
|
const int width = Utils::Gui::scaledSize(this
|
||
|
, (m_ui->tabSelection->item(TAB_UI)->sizeHint().height() * 2));
|
||
|
QList<int> sizes {width, (m_ui->hsplitter->width() - width)};
|
||
|
if (sizesStr.size() == 2)
|
||
|
sizes = {sizesStr.first().toInt(), sizesStr.last().toInt()};
|
||
9 years ago
|
m_ui->hsplitter->setSizes(sizes);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::saveWindowState() const
|
||
9 years ago
|
{
|
||
7 years ago
|
Preferences *const pref = Preferences::instance();
|
||
9 years ago
|
|
||
|
// window size
|
||
9 years ago
|
pref->setPrefSize(size());
|
||
9 years ago
|
|
||
9 years ago
|
// Splitter size
|
||
|
QStringList sizes_str;
|
||
9 years ago
|
sizes_str << QString::number(m_ui->hsplitter->sizes().first());
|
||
|
sizes_str << QString::number(m_ui->hsplitter->sizes().last());
|
||
9 years ago
|
pref->setPrefHSplitterSizes(sizes_str);
|
||
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::saveOptions()
|
||
9 years ago
|
{
|
||
|
applyButton->setEnabled(false);
|
||
7 years ago
|
Preferences *const pref = Preferences::instance();
|
||
9 years ago
|
// Load the translation
|
||
|
QString locale = getLocale();
|
||
|
if (pref->getLocale() != locale) {
|
||
|
QTranslator *translator = new QTranslator;
|
||
7 years ago
|
if (translator->load(QLatin1String(":/lang/qbittorrent_") + locale))
|
||
7 years ago
|
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
|
||
9 years ago
|
else
|
||
7 years ago
|
qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale));
|
||
9 years ago
|
qApp->installTranslator(translator);
|
||
|
}
|
||
|
|
||
|
// General preferences
|
||
|
pref->setLocale(locale);
|
||
9 years ago
|
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
|
||
|
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
|
||
|
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
|
||
|
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());
|
||
8 years ago
|
#ifndef Q_OS_MAC
|
||
9 years ago
|
pref->setSystrayIntegration(systrayIntegration());
|
||
9 years ago
|
pref->setTrayIconStyle(TrayIcon::Style(m_ui->comboTrayIcon->currentIndex()));
|
||
9 years ago
|
pref->setCloseToTray(closeToTray());
|
||
|
pref->setMinimizeToTray(minimizeToTray());
|
||
|
pref->setStartMinimized(startMinimized());
|
||
8 years ago
|
#endif
|
||
7 years ago
|
pref->setSplashScreenDisabled(isSplashScreenDisabled());
|
||
9 years ago
|
pref->setConfirmOnExit(m_ui->checkProgramExitConfirm->isChecked());
|
||
|
pref->setDontConfirmAutoExit(!m_ui->checkProgramAutoExitConfirm->isChecked());
|
||
9 years ago
|
pref->setPreventFromSuspend(preventFromSuspend());
|
||
11 years ago
|
#ifdef Q_OS_WIN
|
||
9 years ago
|
pref->setWinStartup(WinStartup());
|
||
|
// Windows: file association settings
|
||
9 years ago
|
Preferences::setTorrentFileAssoc(m_ui->checkAssociateTorrents->isChecked());
|
||
|
Preferences::setMagnetLinkAssoc(m_ui->checkAssociateMagnetLinks->isChecked());
|
||
9 years ago
|
#endif
|
||
|
#ifdef Q_OS_MAC
|
||
9 years ago
|
if (m_ui->checkAssociateTorrents->isChecked()) {
|
||
9 years ago
|
Preferences::setTorrentFileAssoc();
|
||
9 years ago
|
m_ui->checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
|
||
|
m_ui->checkAssociateTorrents->setEnabled(!m_ui->checkAssociateTorrents->isChecked());
|
||
9 years ago
|
}
|
||
9 years ago
|
if (m_ui->checkAssociateMagnetLinks->isChecked()) {
|
||
9 years ago
|
Preferences::setMagnetLinkAssoc();
|
||
9 years ago
|
m_ui->checkAssociateMagnetLinks->setChecked(Preferences::isMagnetLinkAssocSet());
|
||
|
m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked());
|
||
9 years ago
|
}
|
||
13 years ago
|
#endif
|
||
7 years ago
|
Application *const app = static_cast<Application*>(QCoreApplication::instance());
|
||
9 years ago
|
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
||
9 years ago
|
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
||
7 years ago
|
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
|
||
9 years ago
|
app->setFileLoggerAge(m_ui->spinFileLogAge->value());
|
||
|
app->setFileLoggerAgeType(m_ui->comboFileLogAgeType->currentIndex());
|
||
|
app->setFileLoggerDeleteOld(m_ui->checkFileLogDelete->isChecked());
|
||
|
app->setFileLoggerEnabled(m_ui->checkFileLog->isChecked());
|
||
9 years ago
|
// End General preferences
|
||
|
|
||
8 years ago
|
RSS::Session::instance()->setRefreshInterval(m_ui->spinRSSRefreshInterval->value());
|
||
|
RSS::Session::instance()->setMaxArticlesPerFeed(m_ui->spinRSSMaxArticlesPerFeed->value());
|
||
|
RSS::Session::instance()->setProcessingEnabled(m_ui->checkRSSEnable->isChecked());
|
||
|
RSS::AutoDownloader::instance()->setProcessingEnabled(m_ui->checkRSSAutoDownloaderEnable->isChecked());
|
||
7 years ago
|
RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', QString::SplitBehavior::SkipEmptyParts));
|
||
8 years ago
|
|
||
9 years ago
|
auto session = BitTorrent::Session::instance();
|
||
|
|
||
9 years ago
|
// Downloads preferences
|
||
9 years ago
|
session->setDefaultSavePath(Utils::Fs::expandPathAbs(m_ui->textSavePath->selectedPath()));
|
||
9 years ago
|
session->setSubcategoriesEnabled(m_ui->checkUseSubcategories->isChecked());
|
||
|
session->setAutoTMMDisabledByDefault(m_ui->comboSavingMode->currentIndex() == 0);
|
||
|
session->setDisableAutoTMMWhenCategoryChanged(m_ui->comboTorrentCategoryChanged->currentIndex() == 1);
|
||
|
session->setDisableAutoTMMWhenCategorySavePathChanged(m_ui->comboCategoryChanged->currentIndex() == 1);
|
||
|
session->setDisableAutoTMMWhenDefaultSavePathChanged(m_ui->comboCategoryDefaultPathChanged->currentIndex() == 1);
|
||
|
session->setTempPathEnabled(m_ui->checkTempFolder->isChecked());
|
||
9 years ago
|
session->setTempPath(Utils::Fs::expandPathAbs(m_ui->textTempPath->selectedPath()));
|
||
9 years ago
|
session->setAppendExtensionEnabled(m_ui->checkAppendqB->isChecked());
|
||
|
session->setPreallocationEnabled(preAllocateAllFiles());
|
||
9 years ago
|
AddNewTorrentDialog::setEnabled(useAdditionDialog());
|
||
9 years ago
|
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
|
||
9 years ago
|
session->setAddTorrentPaused(addTorrentsInPause());
|
||
8 years ago
|
session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
|
||
9 years ago
|
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
|
||
9 years ago
|
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
|
||
9 years ago
|
ScanFoldersModel::instance()->makePersistent();
|
||
9 years ago
|
removedScanDirs.clear();
|
||
9 years ago
|
addedScanDirs.clear();
|
||
9 years ago
|
session->setTorrentExportDirectory(getTorrentExportDir());
|
||
|
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
||
9 years ago
|
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
|
||
7 years ago
|
pref->setMailNotificationSender(m_ui->senderEmailTxt->text());
|
||
9 years ago
|
pref->setMailNotificationEmail(m_ui->dest_email_txt->text());
|
||
|
pref->setMailNotificationSMTP(m_ui->smtp_server_txt->text());
|
||
|
pref->setMailNotificationSMTPSSL(m_ui->checkSmtpSSL->isChecked());
|
||
|
pref->setMailNotificationSMTPAuth(m_ui->groupMailNotifAuth->isChecked());
|
||
|
pref->setMailNotificationSMTPUsername(m_ui->mailNotifUsername->text());
|
||
|
pref->setMailNotificationSMTPPassword(m_ui->mailNotifPassword->text());
|
||
|
pref->setAutoRunEnabled(m_ui->autoRunBox->isChecked());
|
||
7 years ago
|
pref->setAutoRunProgram(m_ui->autoRun_txt->text().trimmed());
|
||
9 years ago
|
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
|
||
|
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
|
||
9 years ago
|
TorrentFileGuard::setAutoDeleteMode(!m_ui->deleteTorrentBox->isChecked() ? TorrentFileGuard::Never
|
||
|
: !m_ui->deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded
|
||
9 years ago
|
: TorrentFileGuard::Always);
|
||
9 years ago
|
// End Downloads preferences
|
||
|
|
||
|
// Connection preferences
|
||
7 years ago
|
session->setBTProtocol(static_cast<BitTorrent::BTProtocol>(m_ui->comboProtocol->currentIndex()));
|
||
9 years ago
|
session->setPort(getPort());
|
||
|
session->setUseRandomPort(m_ui->checkRandomPort->isChecked());
|
||
9 years ago
|
Net::PortForwarder::instance()->setEnabled(isUPnPEnabled());
|
||
9 years ago
|
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
|
||
9 years ago
|
session->setGlobalDownloadSpeedLimit(down_up_limit.first);
|
||
|
session->setGlobalUploadSpeedLimit(down_up_limit.second);
|
||
|
session->setUTPRateLimited(m_ui->checkLimituTPConnections->isChecked());
|
||
|
session->setIncludeOverheadInLimits(m_ui->checkLimitTransportOverhead->isChecked());
|
||
|
session->setIgnoreLimitsOnLAN(!m_ui->checkLimitLocalPeerRate->isChecked());
|
||
9 years ago
|
const QPair<int, int> alt_down_up_limit = getAltGlobalBandwidthLimits();
|
||
9 years ago
|
session->setAltGlobalDownloadSpeedLimit(alt_down_up_limit.first);
|
||
|
session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second);
|
||
9 years ago
|
pref->setSchedulerStartTime(m_ui->schedule_from->time());
|
||
|
pref->setSchedulerEndTime(m_ui->schedule_to->time());
|
||
7 years ago
|
pref->setSchedulerDays(static_cast<SchedulerDays>(m_ui->schedule_days->currentIndex()));
|
||
7 years ago
|
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
|
||
9 years ago
|
|
||
7 years ago
|
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||
9 years ago
|
Net::ProxyConfiguration proxyConf;
|
||
|
proxyConf.type = getProxyType();
|
||
|
proxyConf.ip = getProxyIp();
|
||
|
proxyConf.port = getProxyPort();
|
||
|
proxyConf.username = getProxyUsername();
|
||
|
proxyConf.password = getProxyPassword();
|
||
8 years ago
|
proxyConfigManager->setProxyOnlyForTorrents(m_ui->isProxyOnlyForTorrents->isChecked());
|
||
9 years ago
|
proxyConfigManager->setProxyConfiguration(proxyConf);
|
||
|
|
||
|
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked());
|
||
|
session->setForceProxyEnabled(m_ui->checkForceProxy->isChecked());
|
||
9 years ago
|
// End Connection preferences
|
||
9 years ago
|
|
||
9 years ago
|
// Bittorrent preferences
|
||
9 years ago
|
session->setMaxConnections(getMaxConnecs());
|
||
|
session->setMaxConnectionsPerTorrent(getMaxConnecsPerTorrent());
|
||
|
session->setMaxUploads(getMaxUploads());
|
||
|
session->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
|
||
|
session->setDHTEnabled(isDHTEnabled());
|
||
|
session->setPeXEnabled(m_ui->checkPeX->isChecked());
|
||
|
session->setLSDEnabled(isLSDEnabled());
|
||
|
session->setEncryption(getEncryptionSetting());
|
||
|
session->setAnonymousModeEnabled(m_ui->checkAnonymousMode->isChecked());
|
||
|
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||
|
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
||
|
session->setGlobalMaxRatio(getMaxRatio());
|
||
9 years ago
|
session->setGlobalMaxSeedingMinutes(getMaxSeedingMinutes());
|
||
9 years ago
|
session->setMaxRatioAction(static_cast<MaxRatioAction>(m_ui->comboRatioLimitAct->currentIndex()));
|
||
9 years ago
|
// End Bittorrent preferences
|
||
9 years ago
|
|
||
9 years ago
|
// Misc preferences
|
||
|
// * IPFilter
|
||
8 years ago
|
session->setIPFilteringEnabled(isIPFilteringEnabled());
|
||
9 years ago
|
session->setTrackerFilteringEnabled(m_ui->checkIpFilterTrackers->isChecked());
|
||
9 years ago
|
session->setIPFilterFile(m_ui->textFilterPath->selectedPath());
|
||
9 years ago
|
// End IPFilter preferences
|
||
|
// Queueing system
|
||
9 years ago
|
session->setQueueingSystemEnabled(isQueueingSystemEnabled());
|
||
|
session->setMaxActiveDownloads(m_ui->spinMaxActiveDownloads->value());
|
||
|
session->setMaxActiveUploads(m_ui->spinMaxActiveUploads->value());
|
||
|
session->setMaxActiveTorrents(m_ui->spinMaxActiveTorrents->value());
|
||
|
session->setIgnoreSlowTorrentsForQueueing(m_ui->checkIgnoreSlowTorrentsForQueueing->isChecked());
|
||
7 years ago
|
session->setDownloadRateForSlowTorrents(m_ui->spinDownloadRateForSlowTorrents->value());
|
||
|
session->setUploadRateForSlowTorrents(m_ui->spinUploadRateForSlowTorrents->value());
|
||
|
session->setSlowTorrentsInactivityTimer(m_ui->spinSlowTorrentsInactivityTimer->value());
|
||
9 years ago
|
// End Queueing system preferences
|
||
|
// Web UI
|
||
|
pref->setWebUiEnabled(isWebUiEnabled());
|
||
|
if (isWebUiEnabled()) {
|
||
7 years ago
|
pref->setServerDomains(m_ui->textServerDomains->text());
|
||
7 years ago
|
pref->setWebUiAddress(m_ui->textWebUiAddress->text());
|
||
|
pref->setWebUiPort(m_ui->spinWebUiPort->value());
|
||
9 years ago
|
pref->setUPnPForWebUIPort(m_ui->checkWebUIUPnP->isChecked());
|
||
|
pref->setWebUiHttpsEnabled(m_ui->checkWebUiHttps->isChecked());
|
||
7 years ago
|
// HTTPS
|
||
9 years ago
|
if (m_ui->checkWebUiHttps->isChecked()) {
|
||
9 years ago
|
pref->setWebUiHttpsCertificate(m_sslCert);
|
||
|
pref->setWebUiHttpsKey(m_sslKey);
|
||
|
}
|
||
7 years ago
|
// Authentication
|
||
9 years ago
|
pref->setWebUiUsername(webUiUsername());
|
||
|
pref->setWebUiPassword(webUiPassword());
|
||
9 years ago
|
pref->setWebUiLocalAuthEnabled(!m_ui->checkBypassLocalAuth->isChecked());
|
||
7 years ago
|
pref->setWebUiAuthSubnetWhitelistEnabled(m_ui->checkBypassAuthSubnetWhitelist->isChecked());
|
||
7 years ago
|
// Security
|
||
|
pref->setWebUiClickjackingProtectionEnabled(m_ui->checkClickjacking->isChecked());
|
||
7 years ago
|
pref->setWebUiCSRFProtectionEnabled(m_ui->checkCSRFProtection->isChecked());
|
||
9 years ago
|
// DynDNS
|
||
9 years ago
|
pref->setDynDNSEnabled(m_ui->checkDynDNS->isChecked());
|
||
|
pref->setDynDNSService(m_ui->comboDNSService->currentIndex());
|
||
|
pref->setDynDomainName(m_ui->domainNameTxt->text());
|
||
|
pref->setDynDNSUsername(m_ui->DNSUsernameTxt->text());
|
||
|
pref->setDynDNSPassword(m_ui->DNSPasswordTxt->text());
|
||
7 years ago
|
// Alternative UI
|
||
|
pref->setAltWebUiEnabled(m_ui->groupAltWebUI->isChecked());
|
||
|
pref->setWebUiRootFolder(m_ui->textWebUIRootFolder->selectedPath());
|
||
15 years ago
|
}
|
||
9 years ago
|
// End Web UI
|
||
|
// End preferences
|
||
|
// Save advanced settings
|
||
|
advancedSettings->saveAdvancedSettings();
|
||
|
// Assume that user changed multiple settings
|
||
|
// so it's best to save immediately
|
||
|
pref->apply();
|
||
14 years ago
|
}
|
||
18 years ago
|
|
||
8 years ago
|
bool OptionsDialog::isIPFilteringEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkIPFilter->isChecked();
|
||
9 years ago
|
}
|
||
10 years ago
|
|
||
9 years ago
|
Net::ProxyType OptionsDialog::getProxyType() const
|
||
9 years ago
|
{
|
||
9 years ago
|
switch (m_ui->comboProxyType->currentIndex()) {
|
||
9 years ago
|
case 1:
|
||
9 years ago
|
return Net::ProxyType::SOCKS4;
|
||
9 years ago
|
break;
|
||
|
case 2:
|
||
|
if (isProxyAuthEnabled())
|
||
9 years ago
|
return Net::ProxyType::SOCKS5_PW;
|
||
|
return Net::ProxyType::SOCKS5;
|
||
9 years ago
|
case 3:
|
||
|
if (isProxyAuthEnabled())
|
||
9 years ago
|
return Net::ProxyType::HTTP_PW;
|
||
|
return Net::ProxyType::HTTP;
|
||
9 years ago
|
default:
|
||
9 years ago
|
return Net::ProxyType::None;
|
||
9 years ago
|
}
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
void OptionsDialog::loadOptions()
|
||
9 years ago
|
{
|
||
|
int intValue;
|
||
|
QString strValue;
|
||
9 years ago
|
bool fileLogBackup = true;
|
||
|
bool fileLogDelete = true;
|
||
7 years ago
|
const Preferences *const pref = Preferences::instance();
|
||
9 years ago
|
|
||
|
// General preferences
|
||
|
setLocale(pref->getLocale());
|
||
9 years ago
|
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
|
||
|
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
|
||
|
m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
|
||
|
m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked());
|
||
|
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
|
||
|
|
||
|
m_ui->checkShowSplash->setChecked(!pref->isSplashScreenDisabled());
|
||
|
m_ui->checkStartMinimized->setChecked(pref->startMinimized());
|
||
|
m_ui->checkProgramExitConfirm->setChecked(pref->confirmOnExit());
|
||
|
m_ui->checkProgramAutoExitConfirm->setChecked(!pref->dontConfirmAutoExit());
|
||
|
|
||
8 years ago
|
#ifndef Q_OS_MAC
|
||
9 years ago
|
m_ui->checkShowSystray->setChecked(pref->systrayIntegration());
|
||
|
if (m_ui->checkShowSystray->isChecked()) {
|
||
|
m_ui->checkMinimizeToSysTray->setChecked(pref->minimizeToTray());
|
||
|
m_ui->checkCloseToSystray->setChecked(pref->closeToTray());
|
||
|
m_ui->comboTrayIcon->setCurrentIndex(pref->trayIconStyle());
|
||
9 years ago
|
}
|
||
8 years ago
|
#endif
|
||
10 years ago
|
|
||
9 years ago
|
m_ui->checkPreventFromSuspend->setChecked(pref->preventFromSuspend());
|
||
10 years ago
|
|
||
11 years ago
|
#ifdef Q_OS_WIN
|
||
9 years ago
|
m_ui->checkStartup->setChecked(pref->WinStartup());
|
||
|
m_ui->checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
|
||
|
m_ui->checkAssociateMagnetLinks->setChecked(Preferences::isMagnetLinkAssocSet());
|
||
13 years ago
|
#endif
|
||
9 years ago
|
#ifdef Q_OS_MAC
|
||
9 years ago
|
m_ui->checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
|
||
|
m_ui->checkAssociateTorrents->setEnabled(!m_ui->checkAssociateTorrents->isChecked());
|
||
|
m_ui->checkAssociateMagnetLinks->setChecked(Preferences::isMagnetLinkAssocSet());
|
||
|
m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked());
|
||
13 years ago
|
#endif
|
||
9 years ago
|
|
||
7 years ago
|
const Application *const app = static_cast<Application*>(QCoreApplication::instance());
|
||
9 years ago
|
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
||
9 years ago
|
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
||
9 years ago
|
fileLogBackup = app->isFileLoggerBackup();
|
||
9 years ago
|
m_ui->checkFileLogBackup->setChecked(fileLogBackup);
|
||
|
m_ui->spinFileLogSize->setEnabled(fileLogBackup);
|
||
9 years ago
|
fileLogDelete = app->isFileLoggerDeleteOld();
|
||
9 years ago
|
m_ui->checkFileLogDelete->setChecked(fileLogDelete);
|
||
|
m_ui->spinFileLogAge->setEnabled(fileLogDelete);
|
||
|
m_ui->comboFileLogAgeType->setEnabled(fileLogDelete);
|
||
7 years ago
|
m_ui->spinFileLogSize->setValue(app->fileLoggerMaxSize() / 1024);
|
||
9 years ago
|
m_ui->spinFileLogAge->setValue(app->fileLoggerAge());
|
||
|
m_ui->comboFileLogAgeType->setCurrentIndex(app->fileLoggerAgeType());
|
||
9 years ago
|
// End General preferences
|
||
|
|
||
8 years ago
|
m_ui->checkRSSEnable->setChecked(RSS::Session::instance()->isProcessingEnabled());
|
||
|
m_ui->checkRSSAutoDownloaderEnable->setChecked(RSS::AutoDownloader::instance()->isProcessingEnabled());
|
||
7 years ago
|
m_ui->textSmartEpisodeFilters->setPlainText(RSS::AutoDownloader::instance()->smartEpisodeFilters().join('\n'));
|
||
|
|
||
8 years ago
|
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
|
||
|
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
|
||
|
|
||
9 years ago
|
auto session = BitTorrent::Session::instance();
|
||
9 years ago
|
|
||
9 years ago
|
// Downloads preferences
|
||
9 years ago
|
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
||
|
m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
|
||
|
m_ui->checkStartPaused->setChecked(session->isAddTorrentPaused());
|
||
8 years ago
|
m_ui->checkCreateSubfolder->setChecked(session->isCreateTorrentSubfolder());
|
||
9 years ago
|
const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode();
|
||
9 years ago
|
m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never);
|
||
|
m_ui->deleteCancelledTorrentBox->setChecked(autoDeleteMode == TorrentFileGuard::Always);
|
||
|
|
||
9 years ago
|
m_ui->textSavePath->setSelectedPath(session->defaultSavePath());
|
||
9 years ago
|
m_ui->checkUseSubcategories->setChecked(session->isSubcategoriesEnabled());
|
||
|
m_ui->comboSavingMode->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||
|
m_ui->comboTorrentCategoryChanged->setCurrentIndex(session->isDisableAutoTMMWhenCategoryChanged());
|
||
|
m_ui->comboCategoryChanged->setCurrentIndex(session->isDisableAutoTMMWhenCategorySavePathChanged());
|
||
|
m_ui->comboCategoryDefaultPathChanged->setCurrentIndex(session->isDisableAutoTMMWhenDefaultSavePathChanged());
|
||
|
m_ui->checkTempFolder->setChecked(session->isTempPathEnabled());
|
||
|
m_ui->textTempPath->setEnabled(m_ui->checkTempFolder->isChecked());
|
||
9 years ago
|
m_ui->textTempPath->setEnabled(m_ui->checkTempFolder->isChecked());
|
||
|
m_ui->textTempPath->setSelectedPath(Utils::Fs::toNativePath(session->tempPath()));
|
||
9 years ago
|
m_ui->checkAppendqB->setChecked(session->isAppendExtensionEnabled());
|
||
|
m_ui->checkPreallocateAll->setChecked(session->isPreallocationEnabled());
|
||
9 years ago
|
|
||
9 years ago
|
strValue = session->torrentExportDirectory();
|
||
9 years ago
|
if (strValue.isEmpty()) {
|
||
|
// Disable
|
||
9 years ago
|
m_ui->checkExportDir->setChecked(false);
|
||
|
m_ui->textExportDir->setEnabled(false);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Enable
|
||
9 years ago
|
m_ui->checkExportDir->setChecked(true);
|
||
|
m_ui->textExportDir->setEnabled(true);
|
||
9 years ago
|
m_ui->textExportDir->setSelectedPath(strValue);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
strValue = session->finishedTorrentExportDirectory();
|
||
9 years ago
|
if (strValue.isEmpty()) {
|
||
|
// Disable
|
||
9 years ago
|
m_ui->checkExportDirFin->setChecked(false);
|
||
|
m_ui->textExportDirFin->setEnabled(false);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Enable
|
||
9 years ago
|
m_ui->checkExportDirFin->setChecked(true);
|
||
|
m_ui->textExportDirFin->setEnabled(true);
|
||
9 years ago
|
m_ui->textExportDirFin->setSelectedPath(strValue);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
m_ui->groupMailNotification->setChecked(pref->isMailNotificationEnabled());
|
||
7 years ago
|
m_ui->senderEmailTxt->setText(pref->getMailNotificationSender());
|
||
9 years ago
|
m_ui->dest_email_txt->setText(pref->getMailNotificationEmail());
|
||
|
m_ui->smtp_server_txt->setText(pref->getMailNotificationSMTP());
|
||
|
m_ui->checkSmtpSSL->setChecked(pref->getMailNotificationSMTPSSL());
|
||
|
m_ui->groupMailNotifAuth->setChecked(pref->getMailNotificationSMTPAuth());
|
||
|
m_ui->mailNotifUsername->setText(pref->getMailNotificationSMTPUsername());
|
||
|
m_ui->mailNotifPassword->setText(pref->getMailNotificationSMTPPassword());
|
||
9 years ago
|
|
||
9 years ago
|
m_ui->autoRunBox->setChecked(pref->isAutoRunEnabled());
|
||
7 years ago
|
m_ui->autoRun_txt->setText(pref->getAutoRunProgram());
|
||
9 years ago
|
intValue = pref->getActionOnDblClOnTorrentDl();
|
||
9 years ago
|
if (intValue >= m_ui->actionTorrentDlOnDblClBox->count())
|
||
9 years ago
|
intValue = 0;
|
||
9 years ago
|
m_ui->actionTorrentDlOnDblClBox->setCurrentIndex(intValue);
|
||
9 years ago
|
intValue = pref->getActionOnDblClOnTorrentFn();
|
||
9 years ago
|
if (intValue >= m_ui->actionTorrentFnOnDblClBox->count())
|
||
9 years ago
|
intValue = 1;
|
||
9 years ago
|
m_ui->actionTorrentFnOnDblClBox->setCurrentIndex(intValue);
|
||
9 years ago
|
// End Downloads preferences
|
||
|
|
||
|
// Connection preferences
|
||
7 years ago
|
m_ui->comboProtocol->setCurrentIndex(static_cast<int>(session->btProtocol()));
|
||
9 years ago
|
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
|
||
9 years ago
|
m_ui->checkRandomPort->setChecked(session->useRandomPort());
|
||
|
m_ui->spinPort->setValue(session->port());
|
||
9 years ago
|
m_ui->spinPort->setDisabled(m_ui->checkRandomPort->isChecked());
|
||
9 years ago
|
|
||
9 years ago
|
intValue = session->maxConnections();
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// enable
|
||
9 years ago
|
m_ui->checkMaxConnecs->setChecked(true);
|
||
|
m_ui->spinMaxConnec->setEnabled(true);
|
||
|
m_ui->spinMaxConnec->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// disable
|
||
9 years ago
|
m_ui->checkMaxConnecs->setChecked(false);
|
||
|
m_ui->spinMaxConnec->setEnabled(false);
|
||
9 years ago
|
}
|
||
9 years ago
|
intValue = session->maxConnectionsPerTorrent();
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// enable
|
||
9 years ago
|
m_ui->checkMaxConnecsPerTorrent->setChecked(true);
|
||
|
m_ui->spinMaxConnecPerTorrent->setEnabled(true);
|
||
|
m_ui->spinMaxConnecPerTorrent->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// disable
|
||
9 years ago
|
m_ui->checkMaxConnecsPerTorrent->setChecked(false);
|
||
|
m_ui->spinMaxConnecPerTorrent->setEnabled(false);
|
||
9 years ago
|
}
|
||
9 years ago
|
intValue = session->maxUploads();
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// enable
|
||
9 years ago
|
m_ui->checkMaxUploads->setChecked(true);
|
||
|
m_ui->spinMaxUploads->setEnabled(true);
|
||
|
m_ui->spinMaxUploads->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// disable
|
||
9 years ago
|
m_ui->checkMaxUploads->setChecked(false);
|
||
|
m_ui->spinMaxUploads->setEnabled(false);
|
||
9 years ago
|
}
|
||
9 years ago
|
intValue = session->maxUploadsPerTorrent();
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// enable
|
||
9 years ago
|
m_ui->checkMaxUploadsPerTorrent->setChecked(true);
|
||
|
m_ui->spinMaxUploadsPerTorrent->setEnabled(true);
|
||
|
m_ui->spinMaxUploadsPerTorrent->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// disable
|
||
9 years ago
|
m_ui->checkMaxUploadsPerTorrent->setChecked(false);
|
||
|
m_ui->spinMaxUploadsPerTorrent->setEnabled(false);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||
|
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
||
|
using Net::ProxyType;
|
||
|
bool useProxyAuth = false;
|
||
|
switch (proxyConf.type) {
|
||
|
case ProxyType::SOCKS4:
|
||
9 years ago
|
m_ui->comboProxyType->setCurrentIndex(1);
|
||
9 years ago
|
break;
|
||
8 years ago
|
|
||
9 years ago
|
case ProxyType::SOCKS5_PW:
|
||
|
useProxyAuth = true;
|
||
8 years ago
|
// fallthrough
|
||
9 years ago
|
case ProxyType::SOCKS5:
|
||
9 years ago
|
m_ui->comboProxyType->setCurrentIndex(2);
|
||
9 years ago
|
break;
|
||
8 years ago
|
|
||
9 years ago
|
case ProxyType::HTTP_PW:
|
||
|
useProxyAuth = true;
|
||
8 years ago
|
// fallthrough
|
||
9 years ago
|
case ProxyType::HTTP:
|
||
9 years ago
|
m_ui->comboProxyType->setCurrentIndex(3);
|
||
9 years ago
|
break;
|
||
8 years ago
|
|
||
9 years ago
|
default:
|
||
9 years ago
|
m_ui->comboProxyType->setCurrentIndex(0);
|
||
9 years ago
|
}
|
||
9 years ago
|
m_ui->textProxyIP->setText(proxyConf.ip);
|
||
|
m_ui->spinProxyPort->setValue(proxyConf.port);
|
||
|
m_ui->checkProxyAuth->setChecked(useProxyAuth);
|
||
|
m_ui->textProxyUsername->setText(proxyConf.username);
|
||
|
m_ui->textProxyPassword->setText(proxyConf.password);
|
||
|
|
||
|
m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled());
|
||
|
m_ui->checkForceProxy->setChecked(session->isForceProxyEnabled());
|
||
7 years ago
|
enableForceProxy(session->isForceProxyEnabled());
|
||
8 years ago
|
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents());
|
||
8 years ago
|
enableProxy(m_ui->comboProxyType->currentIndex());
|
||
9 years ago
|
|
||
8 years ago
|
m_ui->checkIPFilter->setChecked(session->isIPFilteringEnabled());
|
||
8 years ago
|
m_ui->textFilterPath->setEnabled(m_ui->checkIPFilter->isChecked());
|
||
9 years ago
|
m_ui->textFilterPath->setSelectedPath(session->IPFilterFile());
|
||
8 years ago
|
m_ui->IpFilterRefreshBtn->setEnabled(m_ui->checkIPFilter->isChecked());
|
||
|
m_ui->checkIpFilterTrackers->setChecked(session->isTrackerFilteringEnabled());
|
||
9 years ago
|
// End Connection preferences
|
||
|
|
||
|
// Speed preferences
|
||
8 years ago
|
intValue = session->globalDownloadSpeedLimit() / 1024;
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// Enabled
|
||
9 years ago
|
m_ui->checkDownloadLimit->setChecked(true);
|
||
|
m_ui->spinDownloadLimit->setEnabled(true);
|
||
|
m_ui->spinDownloadLimit->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Disabled
|
||
9 years ago
|
m_ui->checkDownloadLimit->setChecked(false);
|
||
|
m_ui->spinDownloadLimit->setEnabled(false);
|
||
9 years ago
|
}
|
||
8 years ago
|
intValue = session->globalUploadSpeedLimit() / 1024;
|
||
9 years ago
|
if (intValue > 0) {
|
||
9 years ago
|
// Enabled
|
||
9 years ago
|
m_ui->checkUploadLimit->setChecked(true);
|
||
|
m_ui->spinUploadLimit->setEnabled(true);
|
||
|
m_ui->spinUploadLimit->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Disabled
|
||
9 years ago
|
m_ui->checkUploadLimit->setChecked(false);
|
||
|
m_ui->spinUploadLimit->setEnabled(false);
|
||
9 years ago
|
}
|
||
|
|
||
8 years ago
|
intValue = session->altGlobalDownloadSpeedLimit() / 1024;
|
||
9 years ago
|
if (intValue > 0) {
|
||
|
// Enabled
|
||
9 years ago
|
m_ui->checkDownloadLimitAlt->setChecked(true);
|
||
|
m_ui->spinDownloadLimitAlt->setEnabled(true);
|
||
|
m_ui->spinDownloadLimitAlt->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Disabled
|
||
9 years ago
|
m_ui->checkDownloadLimitAlt->setChecked(false);
|
||
|
m_ui->spinDownloadLimitAlt->setEnabled(false);
|
||
9 years ago
|
}
|
||
8 years ago
|
intValue = session->altGlobalUploadSpeedLimit() / 1024;
|
||
9 years ago
|
if (intValue > 0) {
|
||
9 years ago
|
// Enabled
|
||
9 years ago
|
m_ui->checkUploadLimitAlt->setChecked(true);
|
||
|
m_ui->spinUploadLimitAlt->setEnabled(true);
|
||
|
m_ui->spinUploadLimitAlt->setValue(intValue);
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Disabled
|
||
9 years ago
|
m_ui->checkUploadLimitAlt->setChecked(false);
|
||
|
m_ui->spinUploadLimitAlt->setEnabled(false);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
m_ui->checkLimituTPConnections->setChecked(session->isUTPRateLimited());
|
||
|
m_ui->checkLimitTransportOverhead->setChecked(session->includeOverheadInLimits());
|
||
|
m_ui->checkLimitLocalPeerRate->setChecked(!session->ignoreLimitsOnLAN());
|
||
9 years ago
|
|
||
9 years ago
|
m_ui->check_schedule->setChecked(session->isBandwidthSchedulerEnabled());
|
||
9 years ago
|
m_ui->schedule_from->setTime(pref->getSchedulerStartTime());
|
||
|
m_ui->schedule_to->setTime(pref->getSchedulerEndTime());
|
||
8 years ago
|
m_ui->schedule_days->setCurrentIndex(static_cast<int>(pref->getSchedulerDays()));
|
||
9 years ago
|
// End Speed preferences
|
||
|
|
||
|
// Bittorrent preferences
|
||
9 years ago
|
m_ui->checkDHT->setChecked(session->isDHTEnabled());
|
||
|
m_ui->checkPeX->setChecked(session->isPeXEnabled());
|
||
|
m_ui->checkLSD->setChecked(session->isLSDEnabled());
|
||
|
m_ui->comboEncryption->setCurrentIndex(session->encryption());
|
||
|
m_ui->checkAnonymousMode->setChecked(session->isAnonymousModeEnabled());
|
||
|
m_ui->checkEnableAddTrackers->setChecked(session->isAddTrackersEnabled());
|
||
|
m_ui->textTrackers->setPlainText(session->additionalTrackers());
|
||
|
|
||
|
m_ui->checkEnableQueueing->setChecked(session->isQueueingSystemEnabled());
|
||
|
m_ui->spinMaxActiveDownloads->setValue(session->maxActiveDownloads());
|
||
|
m_ui->spinMaxActiveUploads->setValue(session->maxActiveUploads());
|
||
|
m_ui->spinMaxActiveTorrents->setValue(session->maxActiveTorrents());
|
||
|
m_ui->checkIgnoreSlowTorrentsForQueueing->setChecked(session->ignoreSlowTorrentsForQueueing());
|
||
7 years ago
|
m_ui->spinDownloadRateForSlowTorrents->setValue(session->downloadRateForSlowTorrents());
|
||
|
m_ui->spinUploadRateForSlowTorrents->setValue(session->uploadRateForSlowTorrents());
|
||
|
m_ui->spinSlowTorrentsInactivityTimer->setValue(session->slowTorrentsInactivityTimer());
|
||
9 years ago
|
|
||
|
if (session->globalMaxRatio() >= 0.) {
|
||
9 years ago
|
// Enable
|
||
9 years ago
|
m_ui->checkMaxRatio->setChecked(true);
|
||
|
m_ui->spinMaxRatio->setEnabled(true);
|
||
|
m_ui->comboRatioLimitAct->setEnabled(true);
|
||
9 years ago
|
m_ui->spinMaxRatio->setValue(session->globalMaxRatio());
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
// Disable
|
||
9 years ago
|
m_ui->checkMaxRatio->setChecked(false);
|
||
|
m_ui->spinMaxRatio->setEnabled(false);
|
||
9 years ago
|
}
|
||
9 years ago
|
if (session->globalMaxSeedingMinutes() >= 0) {
|
||
|
// Enable
|
||
|
m_ui->checkMaxSeedingMinutes->setChecked(true);
|
||
|
m_ui->spinMaxSeedingMinutes->setEnabled(true);
|
||
|
m_ui->spinMaxSeedingMinutes->setValue(session->globalMaxSeedingMinutes());
|
||
|
}
|
||
|
else {
|
||
|
// Disable
|
||
|
m_ui->checkMaxSeedingMinutes->setChecked(false);
|
||
|
m_ui->spinMaxSeedingMinutes->setEnabled(false);
|
||
|
}
|
||
|
m_ui->comboRatioLimitAct->setEnabled((session->globalMaxSeedingMinutes() >= 0) || (session->globalMaxRatio() >= 0.));
|
||
9 years ago
|
m_ui->comboRatioLimitAct->setCurrentIndex(session->maxRatioAction());
|
||
9 years ago
|
// End Bittorrent preferences
|
||
|
|
||
|
// Web UI preferences
|
||
7 years ago
|
m_ui->textServerDomains->setText(pref->getServerDomains());
|
||
9 years ago
|
m_ui->checkWebUi->setChecked(pref->isWebUiEnabled());
|
||
7 years ago
|
m_ui->textWebUiAddress->setText(pref->getWebUiAddress());
|
||
9 years ago
|
m_ui->spinWebUiPort->setValue(pref->getWebUiPort());
|
||
|
m_ui->checkWebUIUPnP->setChecked(pref->useUPnPForWebUIPort());
|
||
|
m_ui->checkWebUiHttps->setChecked(pref->isWebUiHttpsEnabled());
|
||
8 years ago
|
setSslCertificate(pref->getWebUiHttpsCertificate());
|
||
|
setSslKey(pref->getWebUiHttpsKey());
|
||
9 years ago
|
m_ui->textWebUiUsername->setText(pref->getWebUiUsername());
|
||
|
m_ui->textWebUiPassword->setText(pref->getWebUiPassword());
|
||
|
m_ui->checkBypassLocalAuth->setChecked(!pref->isWebUiLocalAuthEnabled());
|
||
7 years ago
|
m_ui->checkBypassAuthSubnetWhitelist->setChecked(pref->isWebUiAuthSubnetWhitelistEnabled());
|
||
|
m_ui->IPSubnetWhitelistButton->setEnabled(m_ui->checkBypassAuthSubnetWhitelist->isChecked());
|
||
9 years ago
|
|
||
7 years ago
|
// Security
|
||
|
m_ui->checkClickjacking->setChecked(pref->isWebUiClickjackingProtectionEnabled());
|
||
7 years ago
|
m_ui->checkCSRFProtection->setChecked(pref->isWebUiCSRFProtectionEnabled());
|
||
7 years ago
|
|
||
9 years ago
|
m_ui->checkDynDNS->setChecked(pref->isDynDNSEnabled());
|
||
8 years ago
|
m_ui->comboDNSService->setCurrentIndex(static_cast<int>(pref->getDynDNSService()));
|
||
9 years ago
|
m_ui->domainNameTxt->setText(pref->getDynDomainName());
|
||
|
m_ui->DNSUsernameTxt->setText(pref->getDynDNSUsername());
|
||
|
m_ui->DNSPasswordTxt->setText(pref->getDynDNSPassword());
|
||
7 years ago
|
|
||
|
m_ui->groupAltWebUI->setChecked(pref->isAltWebUiEnabled());
|
||
|
m_ui->textWebUIRootFolder->setSelectedPath(pref->getWebUiRootFolder());
|
||
9 years ago
|
// End Web UI preferences
|
||
14 years ago
|
}
|
||
|
|
||
|
// return min & max ports
|
||
|
// [min, max]
|
||
9 years ago
|
int OptionsDialog::getPort() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->spinPort->value();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::on_randomButton_clicked()
|
||
9 years ago
|
{
|
||
|
// Range [1024: 65535]
|
||
8 years ago
|
m_ui->spinPort->setValue(Utils::Random::rand(1024, 65535));
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
int OptionsDialog::getEncryptionSetting() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->comboEncryption->currentIndex();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
int OptionsDialog::getMaxActiveDownloads() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->spinMaxActiveDownloads->value();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
int OptionsDialog::getMaxActiveUploads() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->spinMaxActiveUploads->value();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
int OptionsDialog::getMaxActiveTorrents() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->spinMaxActiveTorrents->value();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::isQueueingSystemEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkEnableQueueing->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::isDHTEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkDHT->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::isLSDEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkLSD->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::isUPnPEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkUPnP->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
|
// Return Download & Upload limits in kbps
|
||
|
// [download,upload]
|
||
9 years ago
|
QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const
|
||
9 years ago
|
{
|
||
8 years ago
|
int DL = 0, UP = 0;
|
||
9 years ago
|
if (m_ui->checkDownloadLimit->isChecked())
|
||
8 years ago
|
DL = m_ui->spinDownloadLimit->value() * 1024;
|
||
9 years ago
|
if (m_ui->checkUploadLimit->isChecked())
|
||
8 years ago
|
UP = m_ui->spinUploadLimit->value() * 1024;
|
||
9 years ago
|
return qMakePair(DL, UP);
|
||
14 years ago
|
}
|
||
|
|
||
10 years ago
|
// Return alternate Download & Upload limits in kbps
|
||
|
// [download,upload]
|
||
9 years ago
|
QPair<int, int> OptionsDialog::getAltGlobalBandwidthLimits() const
|
||
9 years ago
|
{
|
||
8 years ago
|
int DL = 0, UP = 0;
|
||
9 years ago
|
if (m_ui->checkDownloadLimitAlt->isChecked())
|
||
8 years ago
|
DL = m_ui->spinDownloadLimitAlt->value() * 1024;
|
||
9 years ago
|
if (m_ui->checkUploadLimitAlt->isChecked())
|
||
8 years ago
|
UP = m_ui->spinUploadLimitAlt->value() * 1024;
|
||
9 years ago
|
return qMakePair(DL, UP);
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::startMinimized() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkStartMinimized->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
8 years ago
|
#ifndef Q_OS_MAC
|
||
9 years ago
|
bool OptionsDialog::systrayIntegration() const
|
||
9 years ago
|
{
|
||
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
||
9 years ago
|
return m_ui->checkShowSystray->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
8 years ago
|
bool OptionsDialog::minimizeToTray() const
|
||
|
{
|
||
|
if (!m_ui->checkShowSystray->isChecked()) return false;
|
||
|
return m_ui->checkMinimizeToSysTray->isChecked();
|
||
|
}
|
||
|
|
||
|
bool OptionsDialog::closeToTray() const
|
||
|
{
|
||
|
if (!m_ui->checkShowSystray->isChecked()) return false;
|
||
|
return m_ui->checkCloseToSystray->isChecked();
|
||
|
}
|
||
7 years ago
|
#endif // Q_OS_MAC
|
||
8 years ago
|
|
||
14 years ago
|
// Return Share ratio
|
||
9 years ago
|
qreal OptionsDialog::getMaxRatio() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->checkMaxRatio->isChecked())
|
||
|
return m_ui->spinMaxRatio->value();
|
||
9 years ago
|
return -1;
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
// Return Seeding Minutes
|
||
|
int OptionsDialog::getMaxSeedingMinutes() const
|
||
|
{
|
||
|
if (m_ui->checkMaxSeedingMinutes->isChecked())
|
||
|
return m_ui->spinMaxSeedingMinutes->value();
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
14 years ago
|
// Return max connections number
|
||
9 years ago
|
int OptionsDialog::getMaxConnecs() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (!m_ui->checkMaxConnecs->isChecked())
|
||
9 years ago
|
return -1;
|
||
|
else
|
||
9 years ago
|
return m_ui->spinMaxConnec->value();
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
int OptionsDialog::getMaxConnecsPerTorrent() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (!m_ui->checkMaxConnecsPerTorrent->isChecked())
|
||
9 years ago
|
return -1;
|
||
|
else
|
||
9 years ago
|
return m_ui->spinMaxConnecPerTorrent->value();
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
int OptionsDialog::getMaxUploads() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (!m_ui->checkMaxUploads->isChecked())
|
||
9 years ago
|
return -1;
|
||
|
else
|
||
9 years ago
|
return m_ui->spinMaxUploads->value();
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
int OptionsDialog::getMaxUploadsPerTorrent() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (!m_ui->checkMaxUploadsPerTorrent->isChecked())
|
||
9 years ago
|
return -1;
|
||
|
else
|
||
9 years ago
|
return m_ui->spinMaxUploadsPerTorrent->value();
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
void OptionsDialog::on_buttonBox_accepted()
|
||
9 years ago
|
{
|
||
|
if (applyButton->isEnabled()) {
|
||
|
if (!schedTimesOk()) {
|
||
9 years ago
|
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||
9 years ago
|
return;
|
||
|
}
|
||
9 years ago
|
if (!webUIAuthenticationOk()) {
|
||
9 years ago
|
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||
9 years ago
|
return;
|
||
|
}
|
||
9 years ago
|
applyButton->setEnabled(false);
|
||
|
this->hide();
|
||
9 years ago
|
saveOptions();
|
||
11 years ago
|
}
|
||
7 years ago
|
|
||
9 years ago
|
accept();
|
||
|
}
|
||
|
|
||
7 years ago
|
void OptionsDialog::applySettings(QAbstractButton *button)
|
||
9 years ago
|
{
|
||
|
if (button == applyButton) {
|
||
|
if (!schedTimesOk()) {
|
||
9 years ago
|
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||
9 years ago
|
return;
|
||
|
}
|
||
9 years ago
|
if (!webUIAuthenticationOk()) {
|
||
9 years ago
|
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||
9 years ago
|
return;
|
||
|
}
|
||
9 years ago
|
saveOptions();
|
||
11 years ago
|
}
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
void OptionsDialog::closeEvent(QCloseEvent *e)
|
||
9 years ago
|
{
|
||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||
|
e->accept();
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
void OptionsDialog::on_buttonBox_rejected()
|
||
9 years ago
|
{
|
||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||
|
reject();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::useAdditionDialog() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkAdditionDialog->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::enableApplyButton()
|
||
9 years ago
|
{
|
||
|
applyButton->setEnabled(true);
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::toggleComboRatioLimitAct()
|
||
|
{
|
||
|
// Verify if the share action button must be enabled
|
||
|
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked());
|
||
|
}
|
||
|
|
||
7 years ago
|
void OptionsDialog::enableForceProxy(bool enable)
|
||
|
{
|
||
|
m_ui->checkUPnP->setEnabled(!enable);
|
||
|
m_ui->checkDHT->setEnabled(!enable);
|
||
|
m_ui->checkLSD->setEnabled(!enable);
|
||
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::enableProxy(int index)
|
||
9 years ago
|
{
|
||
|
if (index) {
|
||
|
//enable
|
||
9 years ago
|
m_ui->lblProxyIP->setEnabled(true);
|
||
|
m_ui->textProxyIP->setEnabled(true);
|
||
|
m_ui->lblProxyPort->setEnabled(true);
|
||
|
m_ui->spinProxyPort->setEnabled(true);
|
||
|
m_ui->checkProxyPeerConnecs->setEnabled(true);
|
||
|
m_ui->checkForceProxy->setEnabled(true);
|
||
9 years ago
|
if (index > 1) {
|
||
9 years ago
|
m_ui->checkProxyAuth->setEnabled(true);
|
||
8 years ago
|
m_ui->isProxyOnlyForTorrents->setEnabled(true);
|
||
9 years ago
|
}
|
||
|
else {
|
||
9 years ago
|
m_ui->checkProxyAuth->setEnabled(false);
|
||
|
m_ui->checkProxyAuth->setChecked(false);
|
||
8 years ago
|
m_ui->isProxyOnlyForTorrents->setEnabled(false);
|
||
|
m_ui->isProxyOnlyForTorrents->setChecked(true);
|
||
9 years ago
|
}
|
||
7 years ago
|
enableForceProxy(m_ui->checkForceProxy->isChecked());
|
||
9 years ago
|
}
|
||
|
else {
|
||
|
//disable
|
||
9 years ago
|
m_ui->lblProxyIP->setEnabled(false);
|
||
|
m_ui->textProxyIP->setEnabled(false);
|
||
|
m_ui->lblProxyPort->setEnabled(false);
|
||
|
m_ui->spinProxyPort->setEnabled(false);
|
||
|
m_ui->checkProxyPeerConnecs->setEnabled(false);
|
||
|
m_ui->checkForceProxy->setEnabled(false);
|
||
|
m_ui->isProxyOnlyForTorrents->setEnabled(false);
|
||
|
m_ui->checkProxyAuth->setEnabled(false);
|
||
|
m_ui->checkProxyAuth->setChecked(false);
|
||
7 years ago
|
enableForceProxy(false);
|
||
15 years ago
|
}
|
||
14 years ago
|
}
|
||
|
|
||
7 years ago
|
bool OptionsDialog::isSplashScreenDisabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return !m_ui->checkShowSplash->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
11 years ago
|
#ifdef Q_OS_WIN
|
||
9 years ago
|
bool OptionsDialog::WinStartup() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkStartup->isChecked();
|
||
12 years ago
|
}
|
||
|
#endif
|
||
|
|
||
9 years ago
|
bool OptionsDialog::preventFromSuspend() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkPreventFromSuspend->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::preAllocateAllFiles() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkPreallocateAll->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::addTorrentsInPause() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkStartPaused->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
|
// Proxy settings
|
||
9 years ago
|
bool OptionsDialog::isProxyEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->comboProxyType->currentIndex();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
bool OptionsDialog::isProxyAuthEnabled() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->checkProxyAuth->isChecked();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
QString OptionsDialog::getProxyIp() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->textProxyIP->text().trimmed();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
unsigned short OptionsDialog::getProxyPort() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->spinProxyPort->value();
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
QString OptionsDialog::getProxyUsername() const
|
||
9 years ago
|
{
|
||
9 years ago
|
QString username = m_ui->textProxyUsername->text().trimmed();
|
||
9 years ago
|
return username;
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
QString OptionsDialog::getProxyPassword() const
|
||
9 years ago
|
{
|
||
9 years ago
|
QString password = m_ui->textProxyPassword->text();
|
||
9 years ago
|
password = password.trimmed();
|
||
|
return password;
|
||
14 years ago
|
}
|
||
|
|
||
|
// Locale Settings
|
||
9 years ago
|
QString OptionsDialog::getLocale() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->comboI18n->itemData(m_ui->comboI18n->currentIndex(), Qt::UserRole).toString();
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::setLocale(const QString &localeStr)
|
||
9 years ago
|
{
|
||
9 years ago
|
QString name;
|
||
9 years ago
|
if (localeStr.startsWith("eo", Qt::CaseInsensitive)) {
|
||
9 years ago
|
name = "eo";
|
||
|
}
|
||
|
else {
|
||
|
QLocale locale(localeStr);
|
||
8 years ago
|
if (locale.language() == QLocale::Uzbek)
|
||
|
name = "uz@Latn";
|
||
|
else
|
||
|
name = locale.name();
|
||
9 years ago
|
}
|
||
9 years ago
|
// Attempt to find exact match
|
||
9 years ago
|
int index = m_ui->comboI18n->findData(name, Qt::UserRole);
|
||
9 years ago
|
if (index < 0) {
|
||
|
//Attempt to find a language match without a country
|
||
|
int pos = name.indexOf('_');
|
||
|
if (pos > -1) {
|
||
|
QString lang = name.left(pos);
|
||
9 years ago
|
index = m_ui->comboI18n->findData(lang, Qt::UserRole);
|
||
9 years ago
|
}
|
||
|
}
|
||
|
if (index < 0) {
|
||
|
// Unrecognized, use US English
|
||
8 years ago
|
index = m_ui->comboI18n->findData("en", Qt::UserRole);
|
||
9 years ago
|
Q_ASSERT(index >= 0);
|
||
|
}
|
||
9 years ago
|
m_ui->comboI18n->setCurrentIndex(index);
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
QString OptionsDialog::getTorrentExportDir() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->checkExportDir->isChecked())
|
||
9 years ago
|
return Utils::Fs::expandPathAbs(m_ui->textExportDir->selectedPath());
|
||
9 years ago
|
return QString();
|
||
|
}
|
||
|
|
||
9 years ago
|
QString OptionsDialog::getFinishedTorrentExportDir() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->checkExportDirFin->isChecked())
|
||
9 years ago
|
return Utils::Fs::expandPathAbs(m_ui->textExportDirFin->selectedPath());
|
||
9 years ago
|
return QString();
|
||
12 years ago
|
}
|
||
|
|
||
14 years ago
|
// Return action on double-click on a downloading torrent set in options
|
||
9 years ago
|
int OptionsDialog::getActionOnDblClOnTorrentDl() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->actionTorrentDlOnDblClBox->currentIndex() < 1)
|
||
9 years ago
|
return 0;
|
||
9 years ago
|
return m_ui->actionTorrentDlOnDblClBox->currentIndex();
|
||
14 years ago
|
}
|
||
|
|
||
|
// Return action on double-click on a finished torrent set in options
|
||
9 years ago
|
int OptionsDialog::getActionOnDblClOnTorrentFn() const
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->actionTorrentFnOnDblClBox->currentIndex() < 1)
|
||
9 years ago
|
return 0;
|
||
9 years ago
|
return m_ui->actionTorrentFnOnDblClBox->currentIndex();
|
||
9 years ago
|
}
|
||
15 years ago
|
|
||
9 years ago
|
void OptionsDialog::on_addScanFolderButton_clicked()
|
||
9 years ago
|
{
|
||
7 years ago
|
Preferences *const pref = Preferences::instance();
|
||
9 years ago
|
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder to monitor"),
|
||
9 years ago
|
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||
|
if (!dir.isEmpty()) {
|
||
9 years ago
|
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, ScanFoldersModel::DEFAULT_LOCATION, QString(), false);
|
||
9 years ago
|
QString error;
|
||
|
switch (status) {
|
||
|
case ScanFoldersModel::AlreadyInList:
|
||
9 years ago
|
error = tr("Folder is already being monitored:");
|
||
9 years ago
|
break;
|
||
|
case ScanFoldersModel::DoesNotExist:
|
||
9 years ago
|
error = tr("Folder does not exist:");
|
||
9 years ago
|
break;
|
||
|
case ScanFoldersModel::CannotRead:
|
||
9 years ago
|
error = tr("Folder is not readable:");
|
||
9 years ago
|
break;
|
||
|
default:
|
||
|
pref->setScanDirsLastPath(dir);
|
||
|
addedScanDirs << dir;
|
||
9 years ago
|
for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i)
|
||
9 years ago
|
m_ui->scanFoldersView->resizeColumnToContents(i);
|
||
9 years ago
|
enableApplyButton();
|
||
|
}
|
||
|
|
||
|
if (!error.isEmpty())
|
||
7 years ago
|
QMessageBox::critical(this, tr("Adding entry failed"), QString("%1\n%2").arg(error, dir));
|
||
15 years ago
|
}
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::on_removeScanFolderButton_clicked()
|
||
9 years ago
|
{
|
||
|
const QModelIndexList selected
|
||
9 years ago
|
= m_ui->scanFoldersView->selectionModel()->selectedIndexes();
|
||
9 years ago
|
if (selected.isEmpty())
|
||
|
return;
|
||
|
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
||
9 years ago
|
foreach (const QModelIndex &index, selected) {
|
||
|
if (index.column() == ScanFoldersModel::WATCH)
|
||
|
removedScanDirs << index.data().toString();
|
||
|
}
|
||
|
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::handleScanFolderViewSelectionChanged()
|
||
9 years ago
|
{
|
||
9 years ago
|
m_ui->removeScanFolderButton->setEnabled(!m_ui->scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
||
14 years ago
|
}
|
||
|
|
||
7 years ago
|
QString OptionsDialog::askForExportDir(const QString ¤tExportPath)
|
||
12 years ago
|
{
|
||
9 years ago
|
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
||
|
QString dir;
|
||
|
if (!currentExportPath.isEmpty() && currentExportDir.exists())
|
||
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||
|
else
|
||
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
||
|
return dir;
|
||
12 years ago
|
}
|
||
|
|
||
14 years ago
|
// Return Filter object to apply to BT session
|
||
9 years ago
|
QString OptionsDialog::getFilter() const
|
||
9 years ago
|
{
|
||
9 years ago
|
return m_ui->textFilterPath->selectedPath();
|
||
14 years ago
|
}
|
||
18 years ago
|
|
||
14 years ago
|
// Web UI
|
||
17 years ago
|
|
||
9 years ago
|
bool OptionsDialog::isWebUiEnabled() const
|
||
14 years ago
|
{
|
||
9 years ago
|
return m_ui->checkWebUi->isChecked();
|
||
14 years ago
|
}
|
||
17 years ago
|
|
||
9 years ago
|
QString OptionsDialog::webUiUsername() const
|
||
14 years ago
|
{
|
||
9 years ago
|
return m_ui->textWebUiUsername->text();
|
||
14 years ago
|
}
|
||
17 years ago
|
|
||
9 years ago
|
QString OptionsDialog::webUiPassword() const
|
||
14 years ago
|
{
|
||
9 years ago
|
return m_ui->textWebUiPassword->text();
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
9 years ago
|
void OptionsDialog::showConnectionTab()
|
||
14 years ago
|
{
|
||
9 years ago
|
m_ui->tabSelection->setCurrentRow(TAB_CONNECTION);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
9 years ago
|
void OptionsDialog::on_btnWebUiCrt_clicked()
|
||
9 years ago
|
{
|
||
8 years ago
|
const QString filename = QFileDialog::getOpenFileName(this, tr("Import SSL certificate"), QString(), tr("SSL Certificate") + QLatin1String(" (*.crt *.pem)"));
|
||
|
if (filename.isEmpty())
|
||
9 years ago
|
return;
|
||
8 years ago
|
|
||
|
QFile cert(filename);
|
||
|
if (!cert.open(QIODevice::ReadOnly))
|
||
|
return;
|
||
|
|
||
|
bool success = setSslCertificate(cert.read(1024 * 1024));
|
||
|
if (!success)
|
||
|
QMessageBox::warning(this, tr("Invalid certificate"), tr("This is not a valid SSL certificate."));
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::on_btnWebUiKey_clicked()
|
||
9 years ago
|
{
|
||
8 years ago
|
const QString filename = QFileDialog::getOpenFileName(this, tr("Import SSL key"), QString(), tr("SSL key") + QLatin1String(" (*.key *.pem)"));
|
||
|
if (filename.isEmpty())
|
||
9 years ago
|
return;
|
||
8 years ago
|
|
||
|
QFile key(filename);
|
||
|
if (!key.open(QIODevice::ReadOnly))
|
||
|
return;
|
||
|
|
||
|
bool success = setSslKey(key.read(1024 * 1024));
|
||
|
if (!success)
|
||
|
QMessageBox::warning(this, tr("Invalid key"), tr("This is not a valid SSL key."));
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::on_registerDNSBtn_clicked()
|
||
9 years ago
|
{
|
||
9 years ago
|
QDesktopServices::openUrl(Net::DNSUpdater::getRegistrationUrl(m_ui->comboDNSService->currentIndex()));
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::on_IpFilterRefreshBtn_clicked()
|
||
9 years ago
|
{
|
||
|
if (m_refreshingIpFilter) return;
|
||
|
m_refreshingIpFilter = true;
|
||
|
// Updating program preferences
|
||
9 years ago
|
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||
8 years ago
|
session->setIPFilteringEnabled(true);
|
||
9 years ago
|
session->setIPFilterFile(""); // forcing Session reload filter file
|
||
|
session->setIPFilterFile(getFilter());
|
||
7 years ago
|
connect(session, &BitTorrent::Session::IPFilterParsed, this, &OptionsDialog::handleIPFilterParsed);
|
||
9 years ago
|
setCursor(QCursor(Qt::WaitCursor));
|
||
14 years ago
|
}
|
||
|
|
||
9 years ago
|
void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount)
|
||
14 years ago
|
{
|
||
9 years ago
|
setCursor(QCursor(Qt::ArrowCursor));
|
||
|
if (error)
|
||
|
QMessageBox::warning(this, tr("Parsing error"), tr("Failed to parse the provided IP filter"));
|
||
|
else
|
||
|
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
|
||
|
m_refreshingIpFilter = false;
|
||
7 years ago
|
disconnect(BitTorrent::Session::instance(), &BitTorrent::Session::IPFilterParsed, this, &OptionsDialog::handleIPFilterParsed);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
9 years ago
|
QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
|
||
14 years ago
|
{
|
||
9 years ago
|
switch (locale.language()) {
|
||
|
case QLocale::English: {
|
||
|
if (locale.country() == QLocale::Australia)
|
||
|
return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
|
||
|
else if (locale.country() == QLocale::UnitedKingdom)
|
||
|
return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM);
|
||
|
return QString::fromUtf8(C_LOCALE_ENGLISH);
|
||
|
}
|
||
|
case QLocale::French: return QString::fromUtf8(C_LOCALE_FRENCH);
|
||
|
case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN);
|
||
|
case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);
|
||
8 years ago
|
case QLocale::Icelandic: return QString::fromUtf8(C_LOCALE_ICELANDIC);
|
||
9 years ago
|
case QLocale::Indonesian: return QString::fromUtf8(C_LOCALE_INDONESIAN);
|
||
|
case QLocale::Italian: return QString::fromUtf8(C_LOCALE_ITALIAN);
|
||
|
case QLocale::Dutch: return QString::fromUtf8(C_LOCALE_DUTCH);
|
||
|
case QLocale::Spanish: return QString::fromUtf8(C_LOCALE_SPANISH);
|
||
|
case QLocale::Catalan: return QString::fromUtf8(C_LOCALE_CATALAN);
|
||
|
case QLocale::Galician: return QString::fromUtf8(C_LOCALE_GALICIAN);
|
||
8 years ago
|
case QLocale::Occitan: return QString::fromUtf8(C_LOCALE_OCCITAN);
|
||
9 years ago
|
case QLocale::Portuguese: {
|
||
|
if (locale.country() == QLocale::Brazil)
|
||
|
return QString::fromUtf8(C_LOCALE_PORTUGUESE_BRAZIL);
|
||
|
return QString::fromUtf8(C_LOCALE_PORTUGUESE);
|
||
|
}
|
||
|
case QLocale::Polish: return QString::fromUtf8(C_LOCALE_POLISH);
|
||
8 years ago
|
case QLocale::Latvian: return QString::fromUtf8(C_LOCALE_LATVIAN);
|
||
9 years ago
|
case QLocale::Lithuanian: return QString::fromUtf8(C_LOCALE_LITHUANIAN);
|
||
8 years ago
|
case QLocale::Malay: return QString::fromUtf8(C_LOCALE_MALAY);
|
||
9 years ago
|
case QLocale::Czech: return QString::fromUtf8(C_LOCALE_CZECH);
|
||
|
case QLocale::Slovak: return QString::fromUtf8(C_LOCALE_SLOVAK);
|
||
|
case QLocale::Slovenian: return QString::fromUtf8(C_LOCALE_SLOVENIAN);
|
||
|
case QLocale::Serbian: return QString::fromUtf8(C_LOCALE_SERBIAN);
|
||
|
case QLocale::Croatian: return QString::fromUtf8(C_LOCALE_CROATIAN);
|
||
|
case QLocale::Armenian: return QString::fromUtf8(C_LOCALE_ARMENIAN);
|
||
|
case QLocale::Romanian: return QString::fromUtf8(C_LOCALE_ROMANIAN);
|
||
|
case QLocale::Turkish: return QString::fromUtf8(C_LOCALE_TURKISH);
|
||
|
case QLocale::Greek: return QString::fromUtf8(C_LOCALE_GREEK);
|
||
|
case QLocale::Swedish: return QString::fromUtf8(C_LOCALE_SWEDISH);
|
||
|
case QLocale::Finnish: return QString::fromUtf8(C_LOCALE_FINNISH);
|
||
|
case QLocale::Norwegian: return QString::fromUtf8(C_LOCALE_NORWEGIAN);
|
||
|
case QLocale::Danish: return QString::fromUtf8(C_LOCALE_DANISH);
|
||
|
case QLocale::Bulgarian: return QString::fromUtf8(C_LOCALE_BULGARIAN);
|
||
|
case QLocale::Ukrainian: return QString::fromUtf8(C_LOCALE_UKRAINIAN);
|
||
8 years ago
|
case QLocale::Uzbek: return QString::fromUtf8(C_LOCALE_UZBEK);
|
||
9 years ago
|
case QLocale::Russian: return QString::fromUtf8(C_LOCALE_RUSSIAN);
|
||
|
case QLocale::Japanese: return QString::fromUtf8(C_LOCALE_JAPANESE);
|
||
|
case QLocale::Hebrew: return QString::fromUtf8(C_LOCALE_HEBREW);
|
||
|
case QLocale::Hindi: return QString::fromUtf8(C_LOCALE_HINDI);
|
||
|
case QLocale::Arabic: return QString::fromUtf8(C_LOCALE_ARABIC);
|
||
|
case QLocale::Georgian: return QString::fromUtf8(C_LOCALE_GEORGIAN);
|
||
|
case QLocale::Byelorussian: return QString::fromUtf8(C_LOCALE_BYELORUSSIAN);
|
||
|
case QLocale::Basque: return QString::fromUtf8(C_LOCALE_BASQUE);
|
||
|
case QLocale::Vietnamese: return QString::fromUtf8(C_LOCALE_VIETNAMESE);
|
||
|
case QLocale::Chinese: {
|
||
|
switch (locale.country()) {
|
||
|
case QLocale::China:
|
||
|
return QString::fromUtf8(C_LOCALE_CHINESE_SIMPLIFIED);
|
||
|
case QLocale::HongKong:
|
||
|
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_HK);
|
||
|
default:
|
||
|
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_TW);
|
||
|
}
|
||
|
}
|
||
|
case QLocale::Korean: return QString::fromUtf8(C_LOCALE_KOREAN);
|
||
|
default: {
|
||
|
// Fallback to English
|
||
7 years ago
|
const QString engLang = QLocale::languageToString(locale.language());
|
||
|
qWarning() << "Unrecognized language name: " << engLang;
|
||
|
return engLang;
|
||
9 years ago
|
}
|
||
|
}
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
8 years ago
|
bool OptionsDialog::setSslKey(const QByteArray &key)
|
||
14 years ago
|
{
|
||
|
#ifndef QT_NO_OPENSSL
|
||
8 years ago
|
// try different formats
|
||
|
const bool isKeyValid = (!QSslKey(key, QSsl::Rsa).isNull() || !QSslKey(key, QSsl::Ec).isNull());
|
||
|
if (isKeyValid) {
|
||
7 years ago
|
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-high.png", this, 24));
|
||
9 years ago
|
m_sslKey = key;
|
||
|
}
|
||
|
else {
|
||
7 years ago
|
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-low.png", this, 24));
|
||
9 years ago
|
m_sslKey.clear();
|
||
|
}
|
||
8 years ago
|
return isKeyValid;
|
||
8 years ago
|
#else
|
||
|
Q_UNUSED(key);
|
||
8 years ago
|
return false;
|
||
14 years ago
|
#endif
|
||
|
}
|
||
|
|
||
8 years ago
|
bool OptionsDialog::setSslCertificate(const QByteArray &cert)
|
||
14 years ago
|
{
|
||
|
#ifndef QT_NO_OPENSSL
|
||
8 years ago
|
const bool isCertValid = !QSslCertificate(cert).isNull();
|
||
|
if (isCertValid) {
|
||
7 years ago
|
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-high.png", this, 24));
|
||
9 years ago
|
m_sslCert = cert;
|
||
|
}
|
||
|
else {
|
||
7 years ago
|
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-low.png", this, 24));
|
||
9 years ago
|
m_sslCert.clear();
|
||
|
}
|
||
8 years ago
|
return isCertValid;
|
||
8 years ago
|
#else
|
||
|
Q_UNUSED(cert);
|
||
8 years ago
|
return false;
|
||
14 years ago
|
#endif
|
||
|
}
|
||
13 years ago
|
|
||
9 years ago
|
bool OptionsDialog::schedTimesOk()
|
||
9 years ago
|
{
|
||
9 years ago
|
if (m_ui->schedule_from->time() == m_ui->schedule_to->time()) {
|
||
9 years ago
|
QMessageBox::warning(this, tr("Time Error"), tr("The start time and the end time can't be the same."));
|
||
9 years ago
|
return false;
|
||
|
}
|
||
9 years ago
|
return true;
|
||
|
}
|
||
11 years ago
|
|
||
9 years ago
|
bool OptionsDialog::webUIAuthenticationOk()
|
||
9 years ago
|
{
|
||
|
if (webUiUsername().length() < 3) {
|
||
|
QMessageBox::warning(this, tr("Length Error"), tr("The Web UI username must be at least 3 characters long."));
|
||
|
return false;
|
||
|
}
|
||
|
if (webUiPassword().length() < 6) {
|
||
|
QMessageBox::warning(this, tr("Length Error"), tr("The Web UI password must be at least 6 characters long."));
|
||
|
return false;
|
||
|
}
|
||
9 years ago
|
return true;
|
||
11 years ago
|
}
|
||
8 years ago
|
|
||
|
void OptionsDialog::on_banListButton_clicked()
|
||
|
{
|
||
7 years ago
|
// call dialog window
|
||
7 years ago
|
if (BanListOptionsDialog(this).exec() == QDialog::Accepted)
|
||
7 years ago
|
enableApplyButton();
|
||
7 years ago
|
}
|
||
|
|
||
|
void OptionsDialog::on_IPSubnetWhitelistButton_clicked()
|
||
|
{
|
||
|
// call dialog window
|
||
|
if (IPSubnetWhitelistOptionsDialog(this).exec() == QDialog::Accepted)
|
||
|
enableApplyButton();
|
||
8 years ago
|
}
|