Moved peer resolution settings to advanced settings

This commit is contained in:
Christophe Dumez 2010-01-31 16:43:19 +00:00
parent ddc66e6005
commit 3693ecdd30
4 changed files with 41 additions and 47 deletions

View file

@ -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() {

View file

@ -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) {

View file

@ -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

View file

@ -1297,32 +1297,6 @@ QGroupBox {
</layout>
</widget>
</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>
<spacer name="verticalSpacer_7">
<property name="orientation">