X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fgui%2Fsettingsdialog.cpp;h=b2f3904ba1c17ebf8e57a367952d0e3dbb32182b;hb=cf883c1283eb6b096592ef875a32696fee9dd6ff;hp=25ba29da4a0624f5504049245a7e995e2977cbbf;hpb=89496ceee9788c2908c27ad4e2535f2728310d76;p=jenirok diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 25ba29d..b2f3904 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -32,118 +32,119 @@ QMap SettingsDialog::sites_ = Eniro::getSites(); SettingsDialog::SettingsDialog(QWidget* parent): QDialog(parent), -usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0), autostartSelector_(0) +usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0), +autostartSelector_(0) { - setWindowTitle(tr("Settings")); - - DB::connect(); - - QVBoxLayout* left = new QVBoxLayout; - QHBoxLayout* mainLayout = new QHBoxLayout; - QHBoxLayout* username = new QHBoxLayout; - QHBoxLayout* password = new QHBoxLayout; - QHBoxLayout* cache = new QHBoxLayout; - - QLabel* usernameLabel = new QLabel(tr("Eniro username")); - usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username")); - - QLabel* passwordLabel = new QLabel(tr("Eniro password")); - passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password")); - - QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)")); - cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size")); - cacheInput_->setValidator(new QIntValidator(0, 10000, this)); - - siteSelector_ = new ButtonSelector(tr("Eniro site"), this); - QString site = Settings::instance()->get("eniro_site"); - int i = 0; - QMap ::const_iterator it; - for(it = sites_.begin(); it != sites_.end(); it++) - { - siteSelector_->addItem(it.value().name, it.value().id); - - if(it.value().id == site) - { - siteSelector_->setCurrentIndex(i); - } - - i++; - } - - autostartSelector_ = new ButtonSelector(tr("Autostart"), this); - QString autostart = Settings::instance()->get("autostart"); - autostartSelector_->addItem(tr("Enabled"), "1"); - autostartSelector_->addItem(tr("Disabled"), "0"); - autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1); - - QPushButton* submitButton = new QPushButton(tr("Save")); - connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings())); - - username->addWidget(usernameLabel); - username->addWidget(usernameInput_); - password->addWidget(passwordLabel); - password->addWidget(passwordInput_); - cache->addWidget(cacheLabel); - cache->addWidget(cacheInput_); - left->addLayout(username); - left->addLayout(password); - left->addLayout(cache); - left->addWidget(siteSelector_); - left->addWidget(autostartSelector_); - - mainLayout->addLayout(left); - mainLayout->addWidget(submitButton); - - setLayout(mainLayout); - - DB::disconnect(); + setWindowTitle(tr("Settings")); + + DB::connect(); + + QVBoxLayout* left = new QVBoxLayout; + QHBoxLayout* mainLayout = new QHBoxLayout; + QHBoxLayout* username = new QHBoxLayout; + QHBoxLayout* password = new QHBoxLayout; + QHBoxLayout* cache = new QHBoxLayout; + + QLabel* usernameLabel = new QLabel(tr("Eniro username")); + usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username")); + + QLabel* passwordLabel = new QLabel(tr("Eniro password")); + passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password")); + + QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)")); + cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size")); + cacheInput_->setValidator(new QIntValidator(0, 10000, this)); + + siteSelector_ = new ButtonSelector(tr("Eniro site"), this); + QString site = Settings::instance()->get("eniro_site"); + int i = 0; + QMap ::const_iterator it; + for(it = sites_.begin(); it != sites_.end(); it++) + { + siteSelector_->addItem(it.value().name, it.value().id); + + if(it.value().id == site) + { + siteSelector_->setCurrentIndex(i); + } + + i++; + } + + autostartSelector_ = new ButtonSelector(tr("Autostart"), this); + QString autostart = Settings::instance()->get("autostart"); + autostartSelector_->addItem(tr("Enabled"), "1"); + autostartSelector_->addItem(tr("Disabled"), "0"); + autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1); + + QPushButton* submitButton = new QPushButton(tr("Save")); + connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings())); + + username->addWidget(usernameLabel); + username->addWidget(usernameInput_); + password->addWidget(passwordLabel); + password->addWidget(passwordInput_); + cache->addWidget(cacheLabel); + cache->addWidget(cacheInput_); + left->addLayout(username); + left->addLayout(password); + left->addLayout(cache); + left->addWidget(siteSelector_); + left->addWidget(autostartSelector_); + + mainLayout->addLayout(left); + mainLayout->addWidget(submitButton); + + setLayout(mainLayout); + + DB::disconnect(); } void SettingsDialog::saveSettings() { - DB::connect(); + DB::connect(); - Settings::instance()->set("eniro_username", usernameInput_->text()); - Settings::instance()->set("eniro_password", passwordInput_->text()); - Settings::instance()->set("cache_size", cacheInput_->text()); - QString site = siteSelector_->value().toString(); - Settings::instance()->set("site", site); - QString autostart = autostartSelector_->value().toString(); - Settings::instance()->set("autostart", autostart); + Settings::instance()->set("eniro_username", usernameInput_->text()); + Settings::instance()->set("eniro_password", passwordInput_->text()); + Settings::instance()->set("cache_size", cacheInput_->text()); + QString site = siteSelector_->value().toString(); + Settings::instance()->set("site", site); + QString autostart = autostartSelector_->value().toString(); + Settings::instance()->set("autostart", autostart); - DB::disconnect(); + DB::disconnect(); - hide(); + hide(); - if(site != currentSite_ && Daemon::isRunning()) - { - QMaemo5InformationBox::information(this, tr("Restarting daemon...")); - Daemon::restart(); - currentSite_ = site; - } + if(site != currentSite_ && Daemon::isRunning()) + { + QMaemo5InformationBox::information(this, tr("Restarting daemon...")); + Daemon::restart(); + currentSite_ = site; + } - if(autostart != currentAutostart_) - { - bool value = false; + if(autostart != currentAutostart_) + { + bool value = false; - if(autostart == "1") - { - value = true; - } + if(autostart == "1") + { + value = true; + } - Daemon::setAutostart(value); - } + Daemon::setAutostart(value); + } } void SettingsDialog::setVisible(bool visible) { - QDialog::setVisible(visible); + QDialog::setVisible(visible); - if(visible) - { - currentSite_ = siteSelector_->value().toString(); - currentAutostart_ = autostartSelector_->value().toString(); - } + if(visible) + { + currentSite_ = siteSelector_->value().toString(); + currentAutostart_ = autostartSelector_->value().toString(); + } }