4 * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
5 * @copyright (c) 2010 Speed Freak team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 #include "settingsdialog.h"
10 #include "ui_settingsdialog.h"
11 #include "usersettings.h"
13 SettingsDialog::SettingsDialog(QWidget *parent) :
15 ui(new Ui::SettingsDialog)
18 this->setWindowTitle("Settings");
19 this->ui->regEMailLineEdit->setText("@meili.fi");
20 instructionsDialog = new InstructionsDialog;
26 getLoginInfo( &uName, &pWord);
27 this->username = uName;
28 this->password = pWord;
30 ui->setUserPasswordLineEdit->setText(this->password);
31 ui->setUserUsernameLineEdit->setText(this->username);
33 // Already someone as user - change button text to "Change"
34 ui->setUserPushButton->setText("Change user");
38 SettingsDialog::~SettingsDialog()
43 void SettingsDialog::changeEvent(QEvent *e)
45 QDialog::changeEvent(e);
47 case QEvent::LanguageChange:
48 ui->retranslateUi(this);
58 void SettingsDialog::on_pushButtonHelp_clicked()
60 instructionsDialog->show();
66 void SettingsDialog::on_registratePushButton_clicked()
68 // Send username, password and email to SpeedFreak server
69 this->regUsername = ui->regUserNameLineEdit->text();
70 this->regPassword = ui->regPasswordLineEdit->text();
71 this->regEmail = ui->regEMailLineEdit->text();
73 emit sendregistration();
78 // Next 6 functions can be removed if Settingsdialog is implemented without
79 // own copy of username, password & email
80 void SettingsDialog::setRegUserName(QString username)
82 this->regUsername = username;
85 void SettingsDialog::setRegPassword(QString password)
87 this->regPassword = password;
90 void SettingsDialog::setRegEmail(QString email)
92 this->regEmail = email;
95 QString SettingsDialog::getRegUserName()
97 return this->regUsername;
100 QString SettingsDialog::getRegPassword()
102 return this->regPassword;
105 QString SettingsDialog::getRegEmail()
107 return this->regEmail;
113 void SettingsDialog::on_setUserPushButton_clicked()
115 this->username = ui->setUserUsernameLineEdit->text();
116 this->password = ui->setUserPasswordLineEdit->text();
118 // Save these also to usersettings
119 saveLogin( this->username, this->password);
121 // Set "Set/Change User" button text
122 if (this->username.length() > 0)
124 ui->setUserPushButton->setText("Change user");
127 { // Username "cleared"
128 ui->setUserPushButton->setText("Set user");
131 emit userNameChanged();
135 // Next 4 functions can be removed if Settingsdialog is implemented without
136 // own copy of username & password
137 void SettingsDialog::setUserName(QString username)
139 this->username = username;
142 void SettingsDialog::setPassword(QString password)
144 this->password = password;
147 QString SettingsDialog::getUserName()
149 return this->username;
152 QString SettingsDialog::getPassword()
154 return this->password;