X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fgui%2Fsettingsdialog.cpp;h=11f06495b435fcfda9655402744d83f88941be6d;hb=4a9690bd6f3d972d36976863607f9353a5d62301;hp=f84f8c88e0a8c0c9e16e788031f86c3786b7de73;hpb=72f0ccb17472f83c1cba569879e185eb7cd60e31;p=jenirok diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index f84f8c8..11f0649 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ #include "daemon.h" #include "cache.h" -QMap SettingsDialog::sites_ = Eniro::getSites(); +QMap SettingsDialog::sites_; SettingsDialog::SettingsDialog(QWidget* parent): QDialog(parent), usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0), @@ -41,7 +42,8 @@ autostartSelector_(0) DB::connect(); - QVBoxLayout* left = new QVBoxLayout; + QVBoxLayout* general = new QVBoxLayout; + QVBoxLayout* daemon = new QVBoxLayout; QHBoxLayout* mainLayout = new QHBoxLayout; QHBoxLayout* username = new QHBoxLayout; QHBoxLayout* password = new QHBoxLayout; @@ -52,6 +54,7 @@ autostartSelector_(0) QLabel* passwordLabel = new QLabel(tr("Eniro password")); passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password")); + passwordInput_->setEchoMode(QLineEdit::PasswordEchoOnEdit); QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)")); cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size")); @@ -62,6 +65,12 @@ autostartSelector_(0) siteSelector_ = new ButtonSelector(tr("Eniro site"), this); QString site = Settings::instance()->get("eniro_site"); int i = 0; + + if(sites_.empty()) + { + sites_ = Eniro::getSites(); + } + QMap ::const_iterator it; for(it = sites_.begin(); it != sites_.end(); it++) { @@ -99,6 +108,10 @@ autostartSelector_(0) autostartSelector_->addItem(tr("Disabled"), "0"); autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1); + connectionSelector_ = new ConnectionSelector(tr("Connect automatically on"), this); + QString selectedConnection = Settings::instance()->get("connection"); + connectionSelector_->selectByValue(selectedConnection); + QPushButton* submitButton = new QPushButton(tr("Save"), this); connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings())); @@ -109,17 +122,30 @@ autostartSelector_(0) cache->addWidget(cacheLabel); cache->addWidget(cacheInput_); cache->addWidget(cacheResetButton); - left->addLayout(username); - left->addLayout(password); - left->addLayout(cache); - left->addWidget(siteSelector_); - left->addWidget(autostartSelector_); + general->addLayout(username); + general->addLayout(password); + general->addLayout(cache); + general->addWidget(siteSelector_); + + daemon->addWidget(autostartSelector_); + daemon->addWidget(connectionSelector_); QDialogButtonBox* buttons = new QDialogButtonBox; buttons->setCenterButtons(false); buttons->addButton(submitButton, QDialogButtonBox::AcceptRole); - mainLayout->addLayout(left); + QTabWidget* tabs = new QTabWidget; + + QWidget* generalTab = new QWidget; + generalTab->setLayout(general); + + QWidget* daemonTab = new QWidget; + daemonTab->setLayout(daemon); + + tabs->addTab(generalTab, tr("General")); + tabs->addTab(daemonTab, tr("Daemon")); + + mainLayout->addWidget(tabs); mainLayout->addWidget(buttons); setLayout(mainLayout); @@ -129,6 +155,8 @@ autostartSelector_(0) void SettingsDialog::saveSettings() { + hide(); + DB::connect(); Settings::instance()->set("eniro_username", usernameInput_->text()); @@ -138,11 +166,12 @@ void SettingsDialog::saveSettings() Settings::instance()->set("site", site); QString autostart = autostartSelector_->value().toString(); Settings::instance()->set("autostart", autostart); + QString connection = connectionSelector_->value().toString(); + Settings::instance()->set("connection", connection); + Settings::instance()->set("connection_name", connectionSelector_->text()); DB::disconnect(); - hide(); - if(site != currentSite_ && Daemon::isRunning()) { QMaemo5InformationBox::information(this, tr("Restarting daemon...")); @@ -150,18 +179,6 @@ void SettingsDialog::saveSettings() currentSite_ = site; } - if(autostart != currentAutostart_) - { - bool value = false; - - if(autostart == "1") - { - value = true; - } - - Daemon::setAutostart(value); - } - } void SettingsDialog::setVisible(bool visible) @@ -171,7 +188,7 @@ void SettingsDialog::setVisible(bool visible) if(visible) { currentSite_ = siteSelector_->value().toString(); - currentAutostart_ = autostartSelector_->value().toString(); + currentConnection_ = connectionSelector_->value().toString(); } }