Browse Source

Moved peer resolution settings to advanced settings

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
3693ecdd30
  1. 24
      src/advancedsettings.h
  2. 7
      src/options_imp.cpp
  3. 31
      src/preferences.h
  4. 26
      src/ui/options.ui

24
src/advancedsettings.h

@ -8,20 +8,21 @@
#include "preferences.h" #include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH }; 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 7 #define ROW_COUNT 9
class AdvancedSettings: public QTableWidget { class AdvancedSettings: public QTableWidget {
Q_OBJECT Q_OBJECT
private: private:
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh; 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: public:
AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { AdvancedSettings(QWidget *parent=0): QTableWidget(parent) {
// Set visual appearance // Set visual appearance
setEditTriggers(QAbstractItemView::NoEditTriggers); setEditTriggers(QAbstractItemView::NoEditTriggers);
setAlternatingRowColors(true);
setColumnCount(2); setColumnCount(2);
QStringList header; QStringList header;
header << tr("Property") << tr("Value"); header << tr("Property") << tr("Value");
@ -42,6 +43,8 @@ public:
delete cb_count_overhead; delete cb_count_overhead;
delete cb_recheck_completed; delete cb_recheck_completed;
delete spin_list_refresh; delete spin_list_refresh;
delete cb_resolve_countries;
delete cb_resolve_hosts;
} }
public slots: public slots:
@ -59,6 +62,9 @@ public slots:
Preferences::recheckTorrentsOnCompletion(cb_recheck_completed->isChecked()); Preferences::recheckTorrentsOnCompletion(cb_recheck_completed->isChecked());
// Transfer list refresh interval // Transfer list refresh interval
Preferences::setRefreshInterval(spin_list_refresh->value()); Preferences::setRefreshInterval(spin_list_refresh->value());
// Peer resolution
Preferences::resolvePeerCountries(cb_resolve_countries->isChecked());
Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked());
} }
protected slots: protected slots:
@ -115,6 +121,18 @@ protected slots:
spin_list_refresh->setValue(Preferences::getRefreshInterval()); spin_list_refresh->setValue(Preferences::getRefreshInterval());
spin_list_refresh->setSuffix(tr(" ms", " milliseconds")); spin_list_refresh->setSuffix(tr(" ms", " milliseconds"));
setCellWidget(LIST_REFRESH, VALUE, spin_list_refresh); 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() { void emitSettingsChanged() {

7
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(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinUploadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinUploadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinDownloadLimit, 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(check_schedule, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton()));
connect(schedule_to, 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::setSchedulerStartTime(schedule_from->time());
Preferences::setSchedulerEndTime(schedule_to->time()); Preferences::setSchedulerEndTime(schedule_to->time());
Preferences::setSchedulerDays((scheduler_days)schedule_days->currentIndex()); Preferences::setSchedulerDays((scheduler_days)schedule_days->currentIndex());
settings.setValue("ResolvePeerCountries", checkResolveCountries->isChecked());
settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked());
settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType()); settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType());
//if(isProxyEnabled()) { //if(isProxyEnabled()) {
settings.beginGroup("Proxy"); settings.beginGroup("Proxy");
@ -693,9 +689,6 @@ void options_imp::loadOptions(){
schedule_from->setTime(Preferences::getSchedulerStartTime()); schedule_from->setTime(Preferences::getSchedulerStartTime());
schedule_to->setTime(Preferences::getSchedulerEndTime()); schedule_to->setTime(Preferences::getSchedulerEndTime());
schedule_days->setCurrentIndex((int)Preferences::getSchedulerDays()); schedule_days->setCurrentIndex((int)Preferences::getSchedulerDays());
// Peer connections
checkResolveCountries->setChecked(Preferences::resolvePeerCountries());
checkResolveHosts->setChecked(Preferences::resolvePeerHostNames());
intValue = Preferences::getPeerProxyType(); intValue = Preferences::getPeerProxyType();
switch(intValue) { switch(intValue) {

31
src/preferences.h

@ -357,17 +357,6 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days); 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 // Proxy options
static bool isHTTPProxyEnabled() { static bool isHTTPProxyEnabled() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
@ -893,6 +882,26 @@ public:
settings.setValue(QString::fromUtf8("Preferences/General/RefreshInterval"), interval); 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 #endif // PREFERENCES_H

26
src/ui/options.ui

@ -1297,32 +1297,6 @@ QGroupBox {
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Peer connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
<item>
<widget class="QCheckBox" name="checkResolveCountries">
<property name="text">
<string>Resolve peer countries</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkResolveHosts">
<property name="text">
<string>Resolve peer host names</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_7"> <spacer name="verticalSpacer_7">
<property name="orientation"> <property name="orientation">

Loading…
Cancel
Save