X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fgui%2Feniroguiconfig.cpp;h=be41339c76cb24515ecac0d5403636743e0f73cb;hb=3637f101f5223d24de435c5edaa44d9d5cc8dd1f;hp=126d0591aa21a968d6509e22c446d554448aa7c2;hpb=9f12310c5e8648fa0f2f80a85a5f068892afb971;p=jenirok diff --git a/src/gui/eniroguiconfig.cpp b/src/gui/eniroguiconfig.cpp index 126d059..be41339 100644 --- a/src/gui/eniroguiconfig.cpp +++ b/src/gui/eniroguiconfig.cpp @@ -24,26 +24,59 @@ #include "eniro.h" EniroGuiConfig::EniroGuiConfig(QWidget* parent): -SourceGuiConfig(parent), EniroCoreConfig() +SourceGuiConfig(parent), EniroCoreConfig(), layout_(0), usernameInput_(0), +passwordInput_(0), siteSelector_(0), usernameLabel_(0), passwordLabel_(0) { load(); + loadLayout(getSite()); +} + +EniroGuiConfig::~EniroGuiConfig() +{ +} + +void EniroGuiConfig::save() +{ + if(usernameInput_ && passwordInput_) + { + setUsername(usernameInput_->text()); + setPassword(passwordInput_->text()); + } + + setSite(siteSelector_->value().toString()); + + store(); +} + +void EniroGuiConfig::loadLayout(QString const& site) +{ + if(layout()) + { + siteSelector_->hide(); + siteSelector_ = 0; - QVBoxLayout* layout = new QVBoxLayout; + if(usernameLabel_ && passwordLabel_) + { + usernameLabel_->hide(); + usernameLabel_ = 0; + usernameInput_->hide(); + usernameInput_ = 0; + passwordLabel_->hide(); + passwordLabel_ = 0; + passwordInput_->hide(); + passwordInput_ = 0; + } - QHBoxLayout* username = new QHBoxLayout; - QHBoxLayout* password = new QHBoxLayout; + delete layout(); + layout_ = 0; - QLabel* usernameLabel = new QLabel(tr("Eniro username")); - usernameInput_ = new QLineEdit(getUsername()); + } - QLabel* passwordLabel = new QLabel(tr("Eniro password")); - passwordInput_ = new QLineEdit(getPassword()); - passwordInput_->setEchoMode(QLineEdit::PasswordEchoOnEdit); + layout_ = new QVBoxLayout; QMap sites = Eniro::getSites(); siteSelector_ = new ButtonSelector(tr("Eniro site"), this); - QString site = getSite(); int i = 0; QMap ::const_iterator it; @@ -77,27 +110,40 @@ SourceGuiConfig(parent), EniroCoreConfig() i++; } - username->addWidget(usernameLabel); - username->addWidget(usernameInput_); - password->addWidget(passwordLabel); - password->addWidget(passwordInput_); + connect(siteSelector_, SIGNAL(selected(unsigned int, QString const&, QVariant const&)), + this, SLOT(siteChanged(unsigned int, QString const&, QVariant const&))); - layout->addLayout(username); - layout->addLayout(password); - layout->addWidget(siteSelector_); + layout_->addWidget(siteSelector_); - setLayout(layout); -} + if(site == "fi") + { + QHBoxLayout* username = new QHBoxLayout; + QHBoxLayout* password = new QHBoxLayout; -EniroGuiConfig::~EniroGuiConfig() -{ + usernameLabel_ = new QLabel(tr("Eniro username")); + usernameInput_ = new QLineEdit(getUsername()); + + passwordLabel_ = new QLabel(tr("Eniro password")); + passwordInput_ = new QLineEdit(getPassword()); + passwordInput_->setEchoMode(QLineEdit::PasswordEchoOnEdit); + + username->addWidget(usernameLabel_); + username->addWidget(usernameInput_); + password->addWidget(passwordLabel_); + password->addWidget(passwordInput_); + + layout_->addLayout(username); + layout_->addLayout(password); + } + + setLayout(layout_); } -void EniroGuiConfig::save() +void EniroGuiConfig::siteChanged(unsigned int index, + QString const& text, + QVariant const& value) { - setUsername(usernameInput_->text()); - setPassword(passwordInput_->text()); - setSite(siteSelector_->value().toString()); - - store(); + Q_UNUSED(index); + Q_UNUSED(text); + loadLayout(value.toString()); }