2 * This file is part of Jenirok.
4 * Jenirok is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Jenirok is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Jenirok. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QDebug>
20 #include <QtGui/QVBoxLayout>
21 #include <QtGui/QHBoxLayout>
22 #include <QtGui/QLabel>
23 #include "eniroguiconfig.h"
26 EniroGuiConfig::EniroGuiConfig(QWidget* parent):
27 SourceGuiConfig(parent), EniroCoreConfig()
31 QVBoxLayout* layout = new QVBoxLayout;
33 QHBoxLayout* username = new QHBoxLayout;
34 QHBoxLayout* password = new QHBoxLayout;
36 QLabel* usernameLabel = new QLabel(tr("Eniro username"));
37 usernameInput_ = new QLineEdit(getUsername());
39 QLabel* passwordLabel = new QLabel(tr("Eniro password"));
40 passwordInput_ = new QLineEdit(getPassword());
41 passwordInput_->setEchoMode(QLineEdit::PasswordEchoOnEdit);
43 QMap <Eniro::Site, Eniro::SiteDetails> sites = Eniro::getSites();
45 siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
46 QString site = getSite();
49 QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
50 for(it = sites.begin(); it != sites.end(); it++)
66 qDebug() << "Unknown site";
70 siteSelector_->addItem(name, it.value().id);
72 if(it.value().id == site)
74 siteSelector_->setCurrentIndex(i);
80 username->addWidget(usernameLabel);
81 username->addWidget(usernameInput_);
82 password->addWidget(passwordLabel);
83 password->addWidget(passwordInput_);
85 layout->addLayout(username);
86 layout->addLayout(password);
87 layout->addWidget(siteSelector_);
92 EniroGuiConfig::~EniroGuiConfig()
96 void EniroGuiConfig::save()
98 setUsername(usernameInput_->text());
99 setPassword(passwordInput_->text());
100 setSite(siteSelector_->value().toString());