mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
c27aa7723e
commit
e0935fe14f
2 changed files with 1289 additions and 1209 deletions
|
@ -57,8 +57,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
options_imp::options_imp(QWidget *parent):
|
options_imp::options_imp(QWidget *parent)
|
||||||
QDialog(parent), m_refreshingIpFilter(false) {
|
: QDialog(parent),
|
||||||
|
m_refreshingIpFilter(false)
|
||||||
|
{
|
||||||
qDebug("-> Constructing Options");
|
qDebug("-> Constructing Options");
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -102,9 +104,8 @@ options_imp::options_imp(QWidget *parent):
|
||||||
initializeLanguageCombo();
|
initializeLanguageCombo();
|
||||||
|
|
||||||
// Load week days (scheduler)
|
// Load week days (scheduler)
|
||||||
for (uint i=1; i<=7; ++i) {
|
for (uint i = 1; i <= 7; ++i)
|
||||||
schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat));
|
schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat));
|
||||||
}
|
|
||||||
|
|
||||||
// Load options
|
// Load options
|
||||||
loadOptions();
|
loadOptions();
|
||||||
|
@ -297,7 +298,8 @@ void options_imp::initializeLanguageCombo()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main destructor
|
// Main destructor
|
||||||
options_imp::~options_imp() {
|
options_imp::~options_imp()
|
||||||
|
{
|
||||||
qDebug("-> destructing Options");
|
qDebug("-> destructing Options");
|
||||||
foreach (const QString &path, addedScanDirs)
|
foreach (const QString &path, addedScanDirs)
|
||||||
ScanFoldersModel::instance()->removePath(path);
|
ScanFoldersModel::instance()->removePath(path);
|
||||||
|
@ -305,13 +307,15 @@ options_imp::~options_imp() {
|
||||||
delete advancedSettings;
|
delete advancedSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
|
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
|
{
|
||||||
if (!current)
|
if (!current)
|
||||||
current = previous;
|
current = previous;
|
||||||
tabOption->setCurrentIndex(tabSelection->row(current));
|
tabOption->setCurrentIndex(tabSelection->row(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::loadWindowState() {
|
void options_imp::loadWindowState()
|
||||||
|
{
|
||||||
const Preferences* const pref = Preferences::instance();
|
const Preferences* const pref = Preferences::instance();
|
||||||
resize(pref->getPrefSize(sizeFittingScreen()));
|
resize(pref->getPrefSize(sizeFittingScreen()));
|
||||||
QPoint p = pref->getPrefPos();
|
QPoint p = pref->getPrefPos();
|
||||||
|
@ -325,14 +329,16 @@ void options_imp::loadWindowState() {
|
||||||
if (sizes_str.size() == 2) {
|
if (sizes_str.size() == 2) {
|
||||||
sizes << sizes_str.first().toInt();
|
sizes << sizes_str.first().toInt();
|
||||||
sizes << sizes_str.last().toInt();
|
sizes << sizes_str.last().toInt();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sizes << 116;
|
sizes << 116;
|
||||||
sizes << hsplitter->width() - 116;
|
sizes << hsplitter->width() - 116;
|
||||||
}
|
}
|
||||||
hsplitter->setSizes(sizes);
|
hsplitter->setSizes(sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::saveWindowState() const {
|
void options_imp::saveWindowState() const
|
||||||
|
{
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
pref->setPrefSize(size());
|
pref->setPrefSize(size());
|
||||||
pref->setPrefPos(pos());
|
pref->setPrefPos(pos());
|
||||||
|
@ -343,7 +349,8 @@ void options_imp::saveWindowState() const {
|
||||||
pref->setPrefHSplitterSizes(sizes_str);
|
pref->setPrefHSplitterSizes(sizes_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize options_imp::sizeFittingScreen() const {
|
QSize options_imp::sizeFittingScreen() const
|
||||||
|
{
|
||||||
int scrn = 0;
|
int scrn = 0;
|
||||||
QWidget *w = this->topLevelWidget();
|
QWidget *w = this->topLevelWidget();
|
||||||
|
|
||||||
|
@ -355,25 +362,24 @@ QSize options_imp::sizeFittingScreen() const {
|
||||||
scrn = QApplication::desktop()->screenNumber(this);
|
scrn = QApplication::desktop()->screenNumber(this);
|
||||||
|
|
||||||
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
||||||
if (width() > desk.width() || height() > desk.height()) {
|
if (width() > desk.width() || height() > desk.height())
|
||||||
if (desk.width() > 0 && desk.height() > 0)
|
if (desk.width() > 0 && desk.height() > 0)
|
||||||
return QSize(desk.width(), desk.height());
|
return QSize(desk.width(), desk.height());
|
||||||
}
|
|
||||||
return size();
|
return size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::saveOptions() {
|
void options_imp::saveOptions()
|
||||||
|
{
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
// Load the translation
|
// Load the translation
|
||||||
QString locale = getLocale();
|
QString locale = getLocale();
|
||||||
if (pref->getLocale() != locale) {
|
if (pref->getLocale() != locale) {
|
||||||
QTranslator *translator = new QTranslator;
|
QTranslator *translator = new QTranslator;
|
||||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale))
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
else
|
||||||
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
||||||
}
|
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,13 +488,11 @@ void options_imp::saveOptions() {
|
||||||
// End Queueing system preferences
|
// End Queueing system preferences
|
||||||
// Web UI
|
// Web UI
|
||||||
pref->setWebUiEnabled(isWebUiEnabled());
|
pref->setWebUiEnabled(isWebUiEnabled());
|
||||||
if (isWebUiEnabled())
|
if (isWebUiEnabled()) {
|
||||||
{
|
|
||||||
pref->setWebUiPort(webUiPort());
|
pref->setWebUiPort(webUiPort());
|
||||||
pref->setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
|
pref->setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
|
||||||
pref->setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
|
pref->setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
|
||||||
if (checkWebUiHttps->isChecked())
|
if (checkWebUiHttps->isChecked()) {
|
||||||
{
|
|
||||||
pref->setWebUiHttpsCertificate(m_sslCert);
|
pref->setWebUiHttpsCertificate(m_sslCert);
|
||||||
pref->setWebUiHttpsKey(m_sslKey);
|
pref->setWebUiHttpsKey(m_sslKey);
|
||||||
}
|
}
|
||||||
|
@ -512,31 +516,32 @@ void options_imp::saveOptions() {
|
||||||
pref->apply();
|
pref->apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isFilteringEnabled() const {
|
bool options_imp::isFilteringEnabled() const
|
||||||
|
{
|
||||||
return checkIPFilter->isChecked();
|
return checkIPFilter->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getProxyType() const {
|
int options_imp::getProxyType() const
|
||||||
|
{
|
||||||
switch (comboProxyType->currentIndex()) {
|
switch (comboProxyType->currentIndex()) {
|
||||||
case 1:
|
case 1:
|
||||||
return Proxy::SOCKS4;
|
return Proxy::SOCKS4;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (isProxyAuthEnabled()) {
|
if (isProxyAuthEnabled())
|
||||||
return Proxy::SOCKS5_PW;
|
return Proxy::SOCKS5_PW;
|
||||||
}
|
|
||||||
return Proxy::SOCKS5;
|
return Proxy::SOCKS5;
|
||||||
case 3:
|
case 3:
|
||||||
if (isProxyAuthEnabled()) {
|
if (isProxyAuthEnabled())
|
||||||
return Proxy::HTTP_PW;
|
return Proxy::HTTP_PW;
|
||||||
}
|
|
||||||
return Proxy::HTTP;
|
return Proxy::HTTP;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::loadOptions() {
|
void options_imp::loadOptions()
|
||||||
|
{
|
||||||
int intValue;
|
int intValue;
|
||||||
qreal floatValue;
|
qreal floatValue;
|
||||||
QString strValue;
|
QString strValue;
|
||||||
|
@ -573,11 +578,10 @@ void options_imp::loadOptions() {
|
||||||
checkStartPaused->setChecked(pref->addTorrentsInPause());
|
checkStartPaused->setChecked(pref->addTorrentsInPause());
|
||||||
|
|
||||||
textSavePath->setText(Utils::Fs::toNativePath(pref->getSavePath()));
|
textSavePath->setText(Utils::Fs::toNativePath(pref->getSavePath()));
|
||||||
if (pref->isTempPathEnabled()) {
|
if (pref->isTempPathEnabled())
|
||||||
checkTempFolder->setChecked(true);
|
checkTempFolder->setChecked(true);
|
||||||
} else {
|
else
|
||||||
checkTempFolder->setChecked(false);
|
checkTempFolder->setChecked(false);
|
||||||
}
|
|
||||||
textTempPath->setText(Utils::Fs::toNativePath(pref->getTempPath()));
|
textTempPath->setText(Utils::Fs::toNativePath(pref->getTempPath()));
|
||||||
checkAppendLabel->setChecked(pref->appendTorrentLabel());
|
checkAppendLabel->setChecked(pref->appendTorrentLabel());
|
||||||
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
||||||
|
@ -587,7 +591,8 @@ void options_imp::loadOptions() {
|
||||||
if (strValue.isEmpty()) {
|
if (strValue.isEmpty()) {
|
||||||
// Disable
|
// Disable
|
||||||
checkExportDir->setChecked(false);
|
checkExportDir->setChecked(false);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Enable
|
// Enable
|
||||||
checkExportDir->setChecked(true);
|
checkExportDir->setChecked(true);
|
||||||
textExportDir->setText(strValue);
|
textExportDir->setText(strValue);
|
||||||
|
@ -597,7 +602,8 @@ void options_imp::loadOptions() {
|
||||||
if (strValue.isEmpty()) {
|
if (strValue.isEmpty()) {
|
||||||
// Disable
|
// Disable
|
||||||
checkExportDirFin->setChecked(false);
|
checkExportDirFin->setChecked(false);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Enable
|
// Enable
|
||||||
checkExportDirFin->setChecked(true);
|
checkExportDirFin->setChecked(true);
|
||||||
textExportDirFin->setText(strValue);
|
textExportDirFin->setText(strValue);
|
||||||
|
@ -635,7 +641,8 @@ void options_imp::loadOptions() {
|
||||||
checkMaxConnecs->setChecked(true);
|
checkMaxConnecs->setChecked(true);
|
||||||
spinMaxConnec->setEnabled(true);
|
spinMaxConnec->setEnabled(true);
|
||||||
spinMaxConnec->setValue(intValue);
|
spinMaxConnec->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// disable
|
// disable
|
||||||
checkMaxConnecs->setChecked(false);
|
checkMaxConnecs->setChecked(false);
|
||||||
spinMaxConnec->setEnabled(false);
|
spinMaxConnec->setEnabled(false);
|
||||||
|
@ -646,7 +653,8 @@ void options_imp::loadOptions() {
|
||||||
checkMaxConnecsPerTorrent->setChecked(true);
|
checkMaxConnecsPerTorrent->setChecked(true);
|
||||||
spinMaxConnecPerTorrent->setEnabled(true);
|
spinMaxConnecPerTorrent->setEnabled(true);
|
||||||
spinMaxConnecPerTorrent->setValue(intValue);
|
spinMaxConnecPerTorrent->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// disable
|
// disable
|
||||||
checkMaxConnecsPerTorrent->setChecked(false);
|
checkMaxConnecsPerTorrent->setChecked(false);
|
||||||
spinMaxConnecPerTorrent->setEnabled(false);
|
spinMaxConnecPerTorrent->setEnabled(false);
|
||||||
|
@ -657,7 +665,8 @@ void options_imp::loadOptions() {
|
||||||
checkMaxUploads->setChecked(true);
|
checkMaxUploads->setChecked(true);
|
||||||
spinMaxUploads->setEnabled(true);
|
spinMaxUploads->setEnabled(true);
|
||||||
spinMaxUploads->setValue(intValue);
|
spinMaxUploads->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// disable
|
// disable
|
||||||
checkMaxUploads->setChecked(false);
|
checkMaxUploads->setChecked(false);
|
||||||
spinMaxUploads->setEnabled(false);
|
spinMaxUploads->setEnabled(false);
|
||||||
|
@ -668,7 +677,8 @@ void options_imp::loadOptions() {
|
||||||
checkMaxUploadsPerTorrent->setChecked(true);
|
checkMaxUploadsPerTorrent->setChecked(true);
|
||||||
spinMaxUploadsPerTorrent->setEnabled(true);
|
spinMaxUploadsPerTorrent->setEnabled(true);
|
||||||
spinMaxUploadsPerTorrent->setValue(intValue);
|
spinMaxUploadsPerTorrent->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// disable
|
// disable
|
||||||
checkMaxUploadsPerTorrent->setChecked(false);
|
checkMaxUploadsPerTorrent->setChecked(false);
|
||||||
spinMaxUploadsPerTorrent->setEnabled(false);
|
spinMaxUploadsPerTorrent->setEnabled(false);
|
||||||
|
@ -712,7 +722,8 @@ void options_imp::loadOptions() {
|
||||||
checkDownloadLimit->setChecked(true);
|
checkDownloadLimit->setChecked(true);
|
||||||
spinDownloadLimit->setEnabled(true);
|
spinDownloadLimit->setEnabled(true);
|
||||||
spinDownloadLimit->setValue(intValue);
|
spinDownloadLimit->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Disabled
|
// Disabled
|
||||||
checkDownloadLimit->setChecked(false);
|
checkDownloadLimit->setChecked(false);
|
||||||
spinDownloadLimit->setEnabled(false);
|
spinDownloadLimit->setEnabled(false);
|
||||||
|
@ -723,7 +734,8 @@ void options_imp::loadOptions() {
|
||||||
checkUploadLimit->setChecked(true);
|
checkUploadLimit->setChecked(true);
|
||||||
spinUploadLimit->setEnabled(true);
|
spinUploadLimit->setEnabled(true);
|
||||||
spinUploadLimit->setValue(intValue);
|
spinUploadLimit->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Disabled
|
// Disabled
|
||||||
checkUploadLimit->setChecked(false);
|
checkUploadLimit->setChecked(false);
|
||||||
spinUploadLimit->setEnabled(false);
|
spinUploadLimit->setEnabled(false);
|
||||||
|
@ -735,7 +747,8 @@ void options_imp::loadOptions() {
|
||||||
checkDownloadLimitAlt->setChecked(true);
|
checkDownloadLimitAlt->setChecked(true);
|
||||||
spinDownloadLimitAlt->setEnabled(true);
|
spinDownloadLimitAlt->setEnabled(true);
|
||||||
spinDownloadLimitAlt->setValue(intValue);
|
spinDownloadLimitAlt->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Disabled
|
// Disabled
|
||||||
checkDownloadLimitAlt->setChecked(false);
|
checkDownloadLimitAlt->setChecked(false);
|
||||||
spinDownloadLimitAlt->setEnabled(false);
|
spinDownloadLimitAlt->setEnabled(false);
|
||||||
|
@ -746,7 +759,8 @@ void options_imp::loadOptions() {
|
||||||
checkUploadLimitAlt->setChecked(true);
|
checkUploadLimitAlt->setChecked(true);
|
||||||
spinUploadLimitAlt->setEnabled(true);
|
spinUploadLimitAlt->setEnabled(true);
|
||||||
spinUploadLimitAlt->setValue(intValue);
|
spinUploadLimitAlt->setValue(intValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Disabled
|
// Disabled
|
||||||
checkUploadLimitAlt->setChecked(false);
|
checkUploadLimitAlt->setChecked(false);
|
||||||
spinUploadLimitAlt->setEnabled(false);
|
spinUploadLimitAlt->setEnabled(false);
|
||||||
|
@ -783,7 +797,8 @@ void options_imp::loadOptions() {
|
||||||
spinMaxRatio->setEnabled(true);
|
spinMaxRatio->setEnabled(true);
|
||||||
comboRatioLimitAct->setEnabled(true);
|
comboRatioLimitAct->setEnabled(true);
|
||||||
spinMaxRatio->setValue(floatValue);
|
spinMaxRatio->setValue(floatValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Disable
|
// Disable
|
||||||
checkMaxRatio->setChecked(false);
|
checkMaxRatio->setChecked(false);
|
||||||
spinMaxRatio->setEnabled(false);
|
spinMaxRatio->setEnabled(false);
|
||||||
|
@ -813,102 +828,115 @@ void options_imp::loadOptions() {
|
||||||
|
|
||||||
// return min & max ports
|
// return min & max ports
|
||||||
// [min, max]
|
// [min, max]
|
||||||
int options_imp::getPort() const {
|
int options_imp::getPort() const
|
||||||
|
{
|
||||||
return spinPort->value();
|
return spinPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_randomButton_clicked() {
|
void options_imp::on_randomButton_clicked()
|
||||||
|
{
|
||||||
// Range [1024: 65535]
|
// Range [1024: 65535]
|
||||||
spinPort->setValue(rand() % 64512 + 1024);
|
spinPort->setValue(rand() % 64512 + 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getEncryptionSetting() const {
|
int options_imp::getEncryptionSetting() const
|
||||||
|
{
|
||||||
return comboEncryption->currentIndex();
|
return comboEncryption->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveDownloads() const {
|
int options_imp::getMaxActiveDownloads() const
|
||||||
|
{
|
||||||
return spinMaxActiveDownloads->value();
|
return spinMaxActiveDownloads->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveUploads() const {
|
int options_imp::getMaxActiveUploads() const
|
||||||
|
{
|
||||||
return spinMaxActiveUploads->value();
|
return spinMaxActiveUploads->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveTorrents() const {
|
int options_imp::getMaxActiveTorrents() const
|
||||||
|
{
|
||||||
return spinMaxActiveTorrents->value();
|
return spinMaxActiveTorrents->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::minimizeToTray() const {
|
bool options_imp::minimizeToTray() const
|
||||||
|
{
|
||||||
if (!checkShowSystray->isChecked()) return false;
|
if (!checkShowSystray->isChecked()) return false;
|
||||||
return checkMinimizeToSysTray->isChecked();
|
return checkMinimizeToSysTray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::closeToTray() const {
|
bool options_imp::closeToTray() const
|
||||||
|
{
|
||||||
if (!checkShowSystray->isChecked()) return false;
|
if (!checkShowSystray->isChecked()) return false;
|
||||||
return checkCloseToSystray->isChecked();
|
return checkCloseToSystray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isQueueingSystemEnabled() const {
|
bool options_imp::isQueueingSystemEnabled() const
|
||||||
|
{
|
||||||
return checkEnableQueueing->isChecked();
|
return checkEnableQueueing->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isDHTEnabled() const {
|
bool options_imp::isDHTEnabled() const
|
||||||
|
{
|
||||||
return checkDHT->isChecked();
|
return checkDHT->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isLSDEnabled() const {
|
bool options_imp::isLSDEnabled() const
|
||||||
|
{
|
||||||
return checkLSD->isChecked();
|
return checkLSD->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isUPnPEnabled() const {
|
bool options_imp::isUPnPEnabled() const
|
||||||
|
{
|
||||||
return checkUPnP->isChecked();
|
return checkUPnP->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Download & Upload limits in kbps
|
// Return Download & Upload limits in kbps
|
||||||
// [download,upload]
|
// [download,upload]
|
||||||
QPair<int,int> options_imp::getGlobalBandwidthLimits() const {
|
QPair<int, int> options_imp::getGlobalBandwidthLimits() const
|
||||||
|
{
|
||||||
int DL = -1, UP = -1;
|
int DL = -1, UP = -1;
|
||||||
if (checkDownloadLimit->isChecked()) {
|
if (checkDownloadLimit->isChecked())
|
||||||
DL = spinDownloadLimit->value();
|
DL = spinDownloadLimit->value();
|
||||||
}
|
if (checkUploadLimit->isChecked())
|
||||||
if (checkUploadLimit->isChecked()) {
|
|
||||||
UP = spinUploadLimit->value();
|
UP = spinUploadLimit->value();
|
||||||
}
|
|
||||||
return qMakePair(DL, UP);
|
return qMakePair(DL, UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return alternate Download & Upload limits in kbps
|
// Return alternate Download & Upload limits in kbps
|
||||||
// [download,upload]
|
// [download,upload]
|
||||||
QPair<int,int> options_imp::getAltGlobalBandwidthLimits() const {
|
QPair<int, int> options_imp::getAltGlobalBandwidthLimits() const
|
||||||
|
{
|
||||||
int DL = -1, UP = -1;
|
int DL = -1, UP = -1;
|
||||||
if (checkDownloadLimitAlt->isChecked()) {
|
if (checkDownloadLimitAlt->isChecked())
|
||||||
DL = spinDownloadLimitAlt->value();
|
DL = spinDownloadLimitAlt->value();
|
||||||
}
|
if (checkUploadLimitAlt->isChecked())
|
||||||
if (checkUploadLimitAlt->isChecked()) {
|
|
||||||
UP = spinUploadLimitAlt->value();
|
UP = spinUploadLimitAlt->value();
|
||||||
}
|
|
||||||
return qMakePair(DL, UP);
|
return qMakePair(DL, UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::startMinimized() const {
|
bool options_imp::startMinimized() const
|
||||||
|
{
|
||||||
return checkStartMinimized->isChecked();
|
return checkStartMinimized->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::systrayIntegration() const {
|
bool options_imp::systrayIntegration() const
|
||||||
|
{
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
||||||
return checkShowSystray->isChecked();
|
return checkShowSystray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Share ratio
|
// Return Share ratio
|
||||||
qreal options_imp::getMaxRatio() const {
|
qreal options_imp::getMaxRatio() const
|
||||||
if (checkMaxRatio->isChecked()) {
|
{
|
||||||
|
if (checkMaxRatio->isChecked())
|
||||||
return spinMaxRatio->value();
|
return spinMaxRatio->value();
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Save Path
|
// Return Save Path
|
||||||
QString options_imp::getSavePath() const {
|
QString options_imp::getSavePath() const
|
||||||
|
{
|
||||||
if (textSavePath->text().trimmed().isEmpty()) {
|
if (textSavePath->text().trimmed().isEmpty()) {
|
||||||
QString save_path = Preferences::instance()->getSavePath();
|
QString save_path = Preferences::instance()->getSavePath();
|
||||||
textSavePath->setText(Utils::Fs::toNativePath(save_path));
|
textSavePath->setText(Utils::Fs::toNativePath(save_path));
|
||||||
|
@ -916,48 +944,51 @@ QString options_imp::getSavePath() const {
|
||||||
return Utils::Fs::expandPathAbs(textSavePath->text());
|
return Utils::Fs::expandPathAbs(textSavePath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getTempPath() const {
|
QString options_imp::getTempPath() const
|
||||||
|
{
|
||||||
return Utils::Fs::expandPathAbs(textTempPath->text());
|
return Utils::Fs::expandPathAbs(textTempPath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isTempPathEnabled() const {
|
bool options_imp::isTempPathEnabled() const
|
||||||
|
{
|
||||||
return checkTempFolder->isChecked();
|
return checkTempFolder->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return max connections number
|
// Return max connections number
|
||||||
int options_imp::getMaxConnecs() const {
|
int options_imp::getMaxConnecs() const
|
||||||
if (!checkMaxConnecs->isChecked()) {
|
{
|
||||||
|
if (!checkMaxConnecs->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
else
|
||||||
return spinMaxConnec->value();
|
return spinMaxConnec->value();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int options_imp::getMaxConnecsPerTorrent() const {
|
int options_imp::getMaxConnecsPerTorrent() const
|
||||||
if (!checkMaxConnecsPerTorrent->isChecked()) {
|
{
|
||||||
|
if (!checkMaxConnecsPerTorrent->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
else
|
||||||
return spinMaxConnecPerTorrent->value();
|
return spinMaxConnecPerTorrent->value();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int options_imp::getMaxUploads() const {
|
int options_imp::getMaxUploads() const
|
||||||
if (!checkMaxUploads->isChecked()) {
|
{
|
||||||
|
if (!checkMaxUploads->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
else
|
||||||
return spinMaxUploads->value();
|
return spinMaxUploads->value();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int options_imp::getMaxUploadsPerTorrent() const {
|
int options_imp::getMaxUploadsPerTorrent() const
|
||||||
if (!checkMaxUploadsPerTorrent->isChecked()) {
|
{
|
||||||
|
if (!checkMaxUploadsPerTorrent->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
else
|
||||||
return spinMaxUploadsPerTorrent->value();
|
return spinMaxUploadsPerTorrent->value();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void options_imp::on_buttonBox_accepted() {
|
void options_imp::on_buttonBox_accepted()
|
||||||
|
{
|
||||||
if (applyButton->isEnabled()) {
|
if (applyButton->isEnabled()) {
|
||||||
if (!schedTimesOk()) {
|
if (!schedTimesOk()) {
|
||||||
tabSelection->setCurrentRow(TAB_SPEED);
|
tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
|
@ -972,7 +1003,8 @@ void options_imp::on_buttonBox_accepted() {
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::applySettings(QAbstractButton* button) {
|
void options_imp::applySettings(QAbstractButton* button)
|
||||||
|
{
|
||||||
if (button == applyButton) {
|
if (button == applyButton) {
|
||||||
if (!schedTimesOk()) {
|
if (!schedTimesOk()) {
|
||||||
tabSelection->setCurrentRow(TAB_SPEED);
|
tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
|
@ -983,25 +1015,30 @@ void options_imp::applySettings(QAbstractButton* button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::closeEvent(QCloseEvent *e) {
|
void options_imp::closeEvent(QCloseEvent *e)
|
||||||
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_buttonBox_rejected() {
|
void options_imp::on_buttonBox_rejected()
|
||||||
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::useAdditionDialog() const {
|
bool options_imp::useAdditionDialog() const
|
||||||
|
{
|
||||||
return checkAdditionDialog->isChecked();
|
return checkAdditionDialog->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableApplyButton() {
|
void options_imp::enableApplyButton()
|
||||||
|
{
|
||||||
applyButton->setEnabled(true);
|
applyButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableProxy(int index) {
|
void options_imp::enableProxy(int index)
|
||||||
|
{
|
||||||
if (index) {
|
if (index) {
|
||||||
//enable
|
//enable
|
||||||
lblProxyIP->setEnabled(true);
|
lblProxyIP->setEnabled(true);
|
||||||
|
@ -1013,11 +1050,13 @@ void options_imp::enableProxy(int index) {
|
||||||
isProxyOnlyForTorrents->setEnabled(true);
|
isProxyOnlyForTorrents->setEnabled(true);
|
||||||
if (index > 1) {
|
if (index > 1) {
|
||||||
checkProxyAuth->setEnabled(true);
|
checkProxyAuth->setEnabled(true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
checkProxyAuth->setEnabled(false);
|
checkProxyAuth->setEnabled(false);
|
||||||
checkProxyAuth->setChecked(false);
|
checkProxyAuth->setChecked(false);
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
//disable
|
//disable
|
||||||
lblProxyIP->setEnabled(false);
|
lblProxyIP->setEnabled(false);
|
||||||
textProxyIP->setEnabled(false);
|
textProxyIP->setEnabled(false);
|
||||||
|
@ -1031,63 +1070,76 @@ void options_imp::enableProxy(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isSlashScreenDisabled() const {
|
bool options_imp::isSlashScreenDisabled() const
|
||||||
|
{
|
||||||
return !checkShowSplash->isChecked();
|
return !checkShowSplash->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool options_imp::WinStartup() const {
|
bool options_imp::WinStartup() const
|
||||||
|
{
|
||||||
return checkStartup->isChecked();
|
return checkStartup->isChecked();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool options_imp::preventFromSuspend() const {
|
bool options_imp::preventFromSuspend() const
|
||||||
|
{
|
||||||
return checkPreventFromSuspend->isChecked();
|
return checkPreventFromSuspend->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::preAllocateAllFiles() const {
|
bool options_imp::preAllocateAllFiles() const
|
||||||
|
{
|
||||||
return checkPreallocateAll->isChecked();
|
return checkPreallocateAll->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::addTorrentsInPause() const {
|
bool options_imp::addTorrentsInPause() const
|
||||||
|
{
|
||||||
return checkStartPaused->isChecked();
|
return checkStartPaused->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy settings
|
// Proxy settings
|
||||||
bool options_imp::isProxyEnabled() const {
|
bool options_imp::isProxyEnabled() const
|
||||||
|
{
|
||||||
return comboProxyType->currentIndex();
|
return comboProxyType->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isProxyAuthEnabled() const {
|
bool options_imp::isProxyAuthEnabled() const
|
||||||
|
{
|
||||||
return checkProxyAuth->isChecked();
|
return checkProxyAuth->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getProxyIp() const {
|
QString options_imp::getProxyIp() const
|
||||||
|
{
|
||||||
return textProxyIP->text().trimmed();
|
return textProxyIP->text().trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short options_imp::getProxyPort() const {
|
unsigned short options_imp::getProxyPort() const
|
||||||
|
{
|
||||||
return spinProxyPort->value();
|
return spinProxyPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getProxyUsername() const {
|
QString options_imp::getProxyUsername() const
|
||||||
|
{
|
||||||
QString username = textProxyUsername->text();
|
QString username = textProxyUsername->text();
|
||||||
username = username.trimmed();
|
username = username.trimmed();
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getProxyPassword() const {
|
QString options_imp::getProxyPassword() const
|
||||||
|
{
|
||||||
QString password = textProxyPassword->text();
|
QString password = textProxyPassword->text();
|
||||||
password = password.trimmed();
|
password = password.trimmed();
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locale Settings
|
// Locale Settings
|
||||||
QString options_imp::getLocale() const {
|
QString options_imp::getLocale() const
|
||||||
|
{
|
||||||
return comboI18n->itemData(comboI18n->currentIndex(), Qt::UserRole).toString();
|
return comboI18n->itemData(comboI18n->currentIndex(), Qt::UserRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::setLocale(const QString &localeStr) {
|
void options_imp::setLocale(const QString &localeStr)
|
||||||
|
{
|
||||||
QLocale locale(localeStr);
|
QLocale locale(localeStr);
|
||||||
QString name = locale.name();
|
QString name = locale.name();
|
||||||
// Attempt to find exact match
|
// Attempt to find exact match
|
||||||
|
@ -1108,33 +1160,38 @@ void options_imp::setLocale(const QString &localeStr) {
|
||||||
comboI18n->setCurrentIndex(index);
|
comboI18n->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getTorrentExportDir() const {
|
QString options_imp::getTorrentExportDir() const
|
||||||
|
{
|
||||||
if (checkExportDir->isChecked())
|
if (checkExportDir->isChecked())
|
||||||
return Utils::Fs::expandPathAbs(textExportDir->text());
|
return Utils::Fs::expandPathAbs(textExportDir->text());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getFinishedTorrentExportDir() const {
|
QString options_imp::getFinishedTorrentExportDir() const
|
||||||
|
{
|
||||||
if (checkExportDirFin->isChecked())
|
if (checkExportDirFin->isChecked())
|
||||||
return Utils::Fs::expandPathAbs(textExportDirFin->text());
|
return Utils::Fs::expandPathAbs(textExportDirFin->text());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return action on double-click on a downloading torrent set in options
|
// Return action on double-click on a downloading torrent set in options
|
||||||
int options_imp::getActionOnDblClOnTorrentDl() const {
|
int options_imp::getActionOnDblClOnTorrentDl() const
|
||||||
|
{
|
||||||
if (actionTorrentDlOnDblClBox->currentIndex() < 1)
|
if (actionTorrentDlOnDblClBox->currentIndex() < 1)
|
||||||
return 0;
|
return 0;
|
||||||
return actionTorrentDlOnDblClBox->currentIndex();
|
return actionTorrentDlOnDblClBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return action on double-click on a finished torrent set in options
|
// Return action on double-click on a finished torrent set in options
|
||||||
int options_imp::getActionOnDblClOnTorrentFn() const {
|
int options_imp::getActionOnDblClOnTorrentFn() const
|
||||||
|
{
|
||||||
if (actionTorrentFnOnDblClBox->currentIndex() < 1)
|
if (actionTorrentFnOnDblClBox->currentIndex() < 1)
|
||||||
return 0;
|
return 0;
|
||||||
return actionTorrentFnOnDblClBox->currentIndex();
|
return actionTorrentFnOnDblClBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_addScanFolderButton_clicked() {
|
void options_imp::on_addScanFolderButton_clicked()
|
||||||
|
{
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
||||||
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||||||
|
@ -1158,13 +1215,13 @@ void options_imp::on_addScanFolderButton_clicked() {
|
||||||
enableApplyButton();
|
enableApplyButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty())
|
||||||
QMessageBox::warning(this, tr("Failure"), tr("Failed to add Scan Folder '%1': %2").arg(dir).arg(error));
|
QMessageBox::warning(this, tr("Failure"), tr("Failed to add Scan Folder '%1': %2").arg(dir).arg(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void options_imp::on_removeScanFolderButton_clicked() {
|
void options_imp::on_removeScanFolderButton_clicked()
|
||||||
|
{
|
||||||
const QModelIndexList selected
|
const QModelIndexList selected
|
||||||
= scanFoldersView->selectionModel()->selectedIndexes();
|
= scanFoldersView->selectionModel()->selectedIndexes();
|
||||||
if (selected.isEmpty())
|
if (selected.isEmpty())
|
||||||
|
@ -1173,7 +1230,8 @@ void options_imp::on_removeScanFolderButton_clicked() {
|
||||||
ScanFoldersModel::instance()->removePath(selected.first().row());
|
ScanFoldersModel::instance()->removePath(selected.first().row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::handleScanFolderViewSelectionChanged() {
|
void options_imp::handleScanFolderViewSelectionChanged()
|
||||||
|
{
|
||||||
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,68 +1239,70 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||||
{
|
{
|
||||||
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
if (!currentExportPath.isEmpty() && currentExportDir.exists())
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||||
} else {
|
else
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
||||||
}
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseExportDirButton_clicked() {
|
void options_imp::on_browseExportDirButton_clicked()
|
||||||
|
{
|
||||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||||
if (!newExportDir.isNull())
|
if (!newExportDir.isNull())
|
||||||
textExportDir->setText(Utils::Fs::toNativePath(newExportDir));
|
textExportDir->setText(Utils::Fs::toNativePath(newExportDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
void options_imp::on_browseExportDirFinButton_clicked()
|
||||||
|
{
|
||||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||||
if (!newExportDir.isNull())
|
if (!newExportDir.isNull())
|
||||||
textExportDirFin->setText(Utils::Fs::toNativePath(newExportDir));
|
textExportDirFin->setText(Utils::Fs::toNativePath(newExportDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseFilterButton_clicked() {
|
void options_imp::on_browseFilterButton_clicked()
|
||||||
|
{
|
||||||
const QString filter_path = Utils::Fs::expandPathAbs(textFilterPath->text());
|
const QString filter_path = Utils::Fs::expandPathAbs(textFilterPath->text());
|
||||||
QDir filterDir(filter_path);
|
QDir filterDir(filter_path);
|
||||||
QString ipfilter;
|
QString ipfilter;
|
||||||
if (!filter_path.isEmpty() && filterDir.exists()) {
|
if (!filter_path.isEmpty() && filterDir.exists())
|
||||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), filterDir.absolutePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), filterDir.absolutePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
||||||
} else {
|
else
|
||||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), QDir::homePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), QDir::homePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
||||||
}
|
|
||||||
if (!ipfilter.isNull())
|
if (!ipfilter.isNull())
|
||||||
textFilterPath->setText(Utils::Fs::toNativePath(ipfilter));
|
textFilterPath->setText(Utils::Fs::toNativePath(ipfilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display dialog to choose save dir
|
// Display dialog to choose save dir
|
||||||
void options_imp::on_browseSaveDirButton_clicked() {
|
void options_imp::on_browseSaveDirButton_clicked()
|
||||||
|
{
|
||||||
const QString save_path = Utils::Fs::expandPathAbs(textSavePath->text());
|
const QString save_path = Utils::Fs::expandPathAbs(textSavePath->text());
|
||||||
QDir saveDir(save_path);
|
QDir saveDir(save_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!save_path.isEmpty() && saveDir.exists()) {
|
if (!save_path.isEmpty() && saveDir.exists())
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), saveDir.absolutePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), saveDir.absolutePath());
|
||||||
} else {
|
else
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
|
||||||
if (!dir.isNull())
|
if (!dir.isNull())
|
||||||
textSavePath->setText(Utils::Fs::toNativePath(dir));
|
textSavePath->setText(Utils::Fs::toNativePath(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseTempDirButton_clicked() {
|
void options_imp::on_browseTempDirButton_clicked()
|
||||||
|
{
|
||||||
const QString temp_path = Utils::Fs::expandPathAbs(textTempPath->text());
|
const QString temp_path = Utils::Fs::expandPathAbs(textTempPath->text());
|
||||||
QDir tempDir(temp_path);
|
QDir tempDir(temp_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!temp_path.isEmpty() && tempDir.exists()) {
|
if (!temp_path.isEmpty() && tempDir.exists())
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), tempDir.absolutePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), tempDir.absolutePath());
|
||||||
} else {
|
else
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
|
||||||
if (!dir.isNull())
|
if (!dir.isNull())
|
||||||
textTempPath->setText(Utils::Fs::toNativePath(dir));
|
textTempPath->setText(Utils::Fs::toNativePath(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Filter object to apply to BT session
|
// Return Filter object to apply to BT session
|
||||||
QString options_imp::getFilter() const {
|
QString options_imp::getFilter() const
|
||||||
|
{
|
||||||
return Utils::Fs::fromNativePath(textFilterPath->text());
|
return Utils::Fs::fromNativePath(textFilterPath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1273,7 +1333,8 @@ void options_imp::showConnectionTab()
|
||||||
tabSelection->setCurrentRow(TAB_CONNECTION);
|
tabSelection->setCurrentRow(TAB_CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_btnWebUiCrt_clicked() {
|
void options_imp::on_btnWebUiCrt_clicked()
|
||||||
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate") + QString(" (*.crt *.pem)"));
|
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate") + QString(" (*.crt *.pem)"));
|
||||||
if (filename.isNull())
|
if (filename.isNull())
|
||||||
return;
|
return;
|
||||||
|
@ -1284,7 +1345,8 @@ void options_imp::on_btnWebUiCrt_clicked() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_btnWebUiKey_clicked() {
|
void options_imp::on_btnWebUiKey_clicked()
|
||||||
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key") + QString(" (*.key *.pem)"));
|
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key") + QString(" (*.key *.pem)"));
|
||||||
if (filename.isNull())
|
if (filename.isNull())
|
||||||
return;
|
return;
|
||||||
|
@ -1295,11 +1357,13 @@ void options_imp::on_btnWebUiKey_clicked() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_registerDNSBtn_clicked() {
|
void options_imp::on_registerDNSBtn_clicked()
|
||||||
|
{
|
||||||
QDesktopServices::openUrl(Net::DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
|
QDesktopServices::openUrl(Net::DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_IpFilterRefreshBtn_clicked() {
|
void options_imp::on_IpFilterRefreshBtn_clicked()
|
||||||
|
{
|
||||||
if (m_refreshingIpFilter) return;
|
if (m_refreshingIpFilter) return;
|
||||||
m_refreshingIpFilter = true;
|
m_refreshingIpFilter = true;
|
||||||
// Updating program preferences
|
// Updating program preferences
|
||||||
|
@ -1315,11 +1379,10 @@ void options_imp::on_IpFilterRefreshBtn_clicked() {
|
||||||
void options_imp::handleIPFilterParsed(bool error, int ruleCount)
|
void options_imp::handleIPFilterParsed(bool error, int ruleCount)
|
||||||
{
|
{
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
if (error) {
|
if (error)
|
||||||
QMessageBox::warning(this, tr("Parsing error"), tr("Failed to parse the provided IP filter"));
|
QMessageBox::warning(this, tr("Parsing error"), tr("Failed to parse the provided IP filter"));
|
||||||
} else {
|
else
|
||||||
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
|
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;
|
m_refreshingIpFilter = false;
|
||||||
disconnect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
disconnect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1464,8 @@ void options_imp::setSslKey(const QByteArray &key, bool interactive)
|
||||||
if (!key.isEmpty() && !QSslKey(key, QSsl::Rsa).isNull()) {
|
if (!key.isEmpty() && !QSslKey(key, QSsl::Rsa).isNull()) {
|
||||||
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||||
m_sslKey = key;
|
m_sslKey = key;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||||
m_sslKey.clear();
|
m_sslKey.clear();
|
||||||
if (interactive)
|
if (interactive)
|
||||||
|
@ -1416,7 +1480,8 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
|
||||||
if (!cert.isEmpty() && !QSslCertificate(cert).isNull()) {
|
if (!cert.isEmpty() && !QSslCertificate(cert).isNull()) {
|
||||||
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||||
m_sslCert = cert;
|
m_sslCert = cert;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||||
m_sslCert.clear();
|
m_sslCert.clear();
|
||||||
if (interactive)
|
if (interactive)
|
||||||
|
@ -1425,7 +1490,8 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::schedTimesOk() {
|
bool options_imp::schedTimesOk()
|
||||||
|
{
|
||||||
QString msg;
|
QString msg;
|
||||||
|
|
||||||
if (schedule_from->time() == schedule_to->time())
|
if (schedule_from->time() == schedule_to->time())
|
||||||
|
|
|
@ -34,7 +34,12 @@
|
||||||
#include "ui_options.h"
|
#include "ui_options.h"
|
||||||
|
|
||||||
// actions on double-click on torrents
|
// actions on double-click on torrents
|
||||||
enum DoubleClickAction {TOGGLE_PAUSE, OPEN_DEST, NO_ACTION};
|
enum DoubleClickAction
|
||||||
|
{
|
||||||
|
TOGGLE_PAUSE,
|
||||||
|
OPEN_DEST,
|
||||||
|
NO_ACTION
|
||||||
|
};
|
||||||
|
|
||||||
class AdvancedSettings;
|
class AdvancedSettings;
|
||||||
|
|
||||||
|
@ -42,10 +47,20 @@ QT_BEGIN_NAMESPACE
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class options_imp : public QDialog, private Ui_Preferences {
|
class options_imp: public QDialog, private Ui_Preferences
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
enum Tabs {TAB_UI, TAB_DOWNLOADS, TAB_CONNECTION, TAB_SPEED, TAB_BITTORRENT, TAB_WEBUI, TAB_ADVANCED};
|
enum Tabs
|
||||||
|
{
|
||||||
|
TAB_UI,
|
||||||
|
TAB_DOWNLOADS,
|
||||||
|
TAB_CONNECTION,
|
||||||
|
TAB_SPEED,
|
||||||
|
TAB_BITTORRENT,
|
||||||
|
TAB_WEBUI,
|
||||||
|
TAB_ADVANCED
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor / Destructor
|
// Constructor / Destructor
|
||||||
|
@ -163,7 +178,6 @@ private:
|
||||||
QList<QString> addedScanDirs;
|
QList<QString> addedScanDirs;
|
||||||
// SSL Cert / key
|
// SSL Cert / key
|
||||||
QByteArray m_sslCert, m_sslKey;
|
QByteArray m_sslCert, m_sslKey;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue