From 3693ecdd302c83d1f72882a1a1accaa25a36bdfe Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 31 Jan 2010 16:43:19 +0000 Subject: [PATCH] Moved peer resolution settings to advanced settings --- src/advancedsettings.h | 24 +++++++++++++++++++++--- src/options_imp.cpp | 7 ------- src/preferences.h | 31 ++++++++++++++++++++----------- src/ui/options.ui | 26 -------------------------- 4 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/advancedsettings.h b/src/advancedsettings.h index c9cd267de..261371e8f 100644 --- a/src/advancedsettings.h +++ b/src/advancedsettings.h @@ -8,20 +8,21 @@ #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; -enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH }; -#define ROW_COUNT 7 +enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS }; +#define ROW_COUNT 9 class AdvancedSettings: public QTableWidget { Q_OBJECT private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh; - QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed; + QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts; public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { // Set visual appearance setEditTriggers(QAbstractItemView::NoEditTriggers); + setAlternatingRowColors(true); setColumnCount(2); QStringList header; header << tr("Property") << tr("Value"); @@ -42,6 +43,8 @@ public: delete cb_count_overhead; delete cb_recheck_completed; delete spin_list_refresh; + delete cb_resolve_countries; + delete cb_resolve_hosts; } public slots: @@ -59,6 +62,9 @@ public slots: Preferences::recheckTorrentsOnCompletion(cb_recheck_completed->isChecked()); // Transfer list refresh interval Preferences::setRefreshInterval(spin_list_refresh->value()); + // Peer resolution + Preferences::resolvePeerCountries(cb_resolve_countries->isChecked()); + Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked()); } protected slots: @@ -115,6 +121,18 @@ protected slots: spin_list_refresh->setValue(Preferences::getRefreshInterval()); spin_list_refresh->setSuffix(tr(" ms", " milliseconds")); setCellWidget(LIST_REFRESH, VALUE, spin_list_refresh); + // Resolve Peer countries + setItem(RESOLVE_COUNTRIES, PROPERTY, new QTableWidgetItem(tr("Resolve peer countries (GeoIP)"))); + cb_resolve_countries = new QCheckBox(); + connect(cb_resolve_countries, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_resolve_countries->setChecked(Preferences::resolvePeerCountries()); + setCellWidget(RESOLVE_COUNTRIES, VALUE, cb_resolve_countries); + // Resolve peer hosts + setItem(RESOLVE_HOSTS, PROPERTY, new QTableWidgetItem(tr("Resolve peer host names"))); + cb_resolve_hosts = new QCheckBox(); + connect(cb_resolve_hosts, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_resolve_hosts->setChecked(Preferences::resolvePeerHostNames()); + setCellWidget(RESOLVE_HOSTS, VALUE, cb_resolve_hosts); } void emitSettingsChanged() { diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 66825df2f..8ed8b6bd3 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -216,8 +216,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(spinUploadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinDownloadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); - connect(checkResolveCountries, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); - connect(checkResolveHosts, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(check_schedule, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); connect(schedule_to, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); @@ -420,8 +418,6 @@ void options_imp::saveOptions(){ Preferences::setSchedulerStartTime(schedule_from->time()); Preferences::setSchedulerEndTime(schedule_to->time()); Preferences::setSchedulerDays((scheduler_days)schedule_days->currentIndex()); - settings.setValue("ResolvePeerCountries", checkResolveCountries->isChecked()); - settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked()); settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType()); //if(isProxyEnabled()) { settings.beginGroup("Proxy"); @@ -693,9 +689,6 @@ void options_imp::loadOptions(){ schedule_from->setTime(Preferences::getSchedulerStartTime()); schedule_to->setTime(Preferences::getSchedulerEndTime()); schedule_days->setCurrentIndex((int)Preferences::getSchedulerDays()); - // Peer connections - checkResolveCountries->setChecked(Preferences::resolvePeerCountries()); - checkResolveHosts->setChecked(Preferences::resolvePeerHostNames()); intValue = Preferences::getPeerProxyType(); switch(intValue) { diff --git a/src/preferences.h b/src/preferences.h index c4eec6be9..78bcfdff9 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -357,17 +357,6 @@ public: settings.setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days); } - - static bool resolvePeerCountries() { - QSettings settings("qBittorrent", "qBittorrent"); - return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool(); - } - - static bool resolvePeerHostNames() { - QSettings settings("qBittorrent", "qBittorrent"); - return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool(); - } - // Proxy options static bool isHTTPProxyEnabled() { QSettings settings("qBittorrent", "qBittorrent"); @@ -893,6 +882,26 @@ public: settings.setValue(QString::fromUtf8("Preferences/General/RefreshInterval"), interval); } + static bool resolvePeerCountries() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool(); + } + + static void resolvePeerCountries(bool resolve) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), resolve); + } + + static bool resolvePeerHostNames() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool(); + } + + static void resolvePeerHostNames(bool resolve) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), resolve); + } + }; #endif // PREFERENCES_H diff --git a/src/ui/options.ui b/src/ui/options.ui index c8f37e8ec..c250fc164 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -1297,32 +1297,6 @@ QGroupBox { - - - - Peer connections - - - - - - Resolve peer countries - - - true - - - - - - - Resolve peer host names - - - - - -