X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=settings.cpp;fp=settings.cpp;h=d8f826ace110d2f8dcb6959d618294d8c03eee16;hb=27420ae2e72651166b87bb62c7aae0df67e11a16;hp=c26a96c556da18a0c17ddba1bd7dae756c0776af;hpb=1a0535a2370cd9350a6f0825d60423fe9c363cfb;p=fapman diff --git a/settings.cpp b/settings.cpp index c26a96c..d8f826a 100644 --- a/settings.cpp +++ b/settings.cpp @@ -17,6 +17,7 @@ (C) Heikki Holstila 2010 */ +#include #include "settings.h" #include "ui_settings.h" #include "mainwindow.h" @@ -61,6 +62,8 @@ void Settings::openWin() ui->checkBox_autoremove->setChecked( iQSettings->value("enable_autoremove", true).toBool() ); ui->checkBox_autoclean->setChecked( iQSettings->value("enable_autoclean", true).toBool() ); ui->checkBox_remove_readfull->setChecked( iQSettings->value("remove_readfull", false).toBool() ); + ui->checkBox_no_catalogs_autoupdate->setChecked( iQSettings->value("no_catalogs_autoupdate",false).toBool() ); + ui->checkBox_always_fetch_changes->setChecked( iQSettings->value("always_fetch_changes",false).toBool() ); ui->checkBox_proxies->setChecked( iQSettings->value("use_proxies", false).toBool() ); ui->lineEdit_http_proxy->setText( iQSettings->value("http_proxy","").toString() ); @@ -88,10 +91,12 @@ void Settings::on_btn_OK_clicked() iQSettings->setValue("enable_autoremove", ui->checkBox_autoremove->isChecked() ); iQSettings->setValue("enable_autoclean", ui->checkBox_autoclean->isChecked() ); iQSettings->setValue("remove_readfull", ui->checkBox_remove_readfull->isChecked() ); + iQSettings->setValue("no_catalogs_autoupdate", ui->checkBox_no_catalogs_autoupdate->isChecked() ); + iQSettings->setValue("always_fetch_changes", ui->checkBox_always_fetch_changes->isChecked() ); iQSettings->setValue("use_proxies", ui->checkBox_proxies->isChecked() ); - iQSettings->setValue("http_proxy", ui->lineEdit_http_proxy->text() ); - iQSettings->setValue("https_proxy", ui->lineEdit_https_proxy->text() ); + iQSettings->setValue("http_proxy", ui->lineEdit_http_proxy->text().trimmed() ); + iQSettings->setValue("https_proxy", ui->lineEdit_https_proxy->text().trimmed() ); iQSettings->setValue("default_sort_order", ui->comboBox_sortorder->currentIndex() ); @@ -145,3 +150,54 @@ void Settings::on_pushButton_searchOptions_clicked() s.searchDescShort(), s.searchDescLong() ); } } + +QNetworkProxy Settings::createProxyFromString(QString proxystr) +{ + proxystr = proxystr.trimmed(); + QString hostname = ""; + quint16 port = 8080; + QString user; + QString pass; + + QString proto; + int pos_proto = proxystr.indexOf("://"); + if( pos_proto != -1 ) + { + proto = proxystr.left(pos_proto+3); + proxystr = proxystr.mid(pos_proto+3); + } + + QString temp; + QString temp2; + int pos_half = proxystr.indexOf('@'); + if( pos_half==-1 ) { + temp = proxystr; + } else { + temp = proxystr.mid(pos_half+1); + temp2 = proxystr.left(pos_half); + } + + if( !temp2.isNull() ) { + int pos_pass = temp2.indexOf(':'); + if( pos_pass==-1 ) { + user = temp2; + } else { + user = temp2.left(pos_pass); + pass = temp2.mid(pos_pass+1); + } + } + + int pos_port = temp.indexOf(':'); + if( pos_port==-1 ) { + hostname = temp; + } else { + hostname = temp.left(pos_port); + port = temp.mid(pos_port+1).remove('/').toInt(); + } + + hostname = proto + hostname; + qDebug() << "creating proxy" << hostname << port << user << pass; + + QNetworkProxy p(QNetworkProxy::HttpProxy, hostname, port, user, pass); + return p; +}