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("@");
25 getLoginInfo( &uName, &pWord);
26 this->username = uName;
27 this->password = pWord;
29 ui->setUserPasswordLineEdit->setText(this->password);
30 ui->setUserUsernameLineEdit->setText(this->username);
32 // Already someone as user - change button text to "Change"
33 ui->setUserPushButton->setText("Change user");
37 SettingsDialog::~SettingsDialog()
42 void SettingsDialog::changeEvent(QEvent *e)
44 QDialog::changeEvent(e);
46 case QEvent::LanguageChange:
47 ui->retranslateUi(this);
57 void SettingsDialog::on_registratePushButton_clicked()
59 // Send username, password and email to SpeedFreak server
60 this->regUsername = ui->regUserNameLineEdit->text();
61 this->regPassword = ui->regPasswordLineEdit->text();
62 this->regEmail = ui->regEMailLineEdit->text();
64 emit sendregistration();
66 //close(); //using close() hides popup-window which reports error from server
69 // Next 6 functions can be removed if Settingsdialog is implemented without
70 // own copy of username, password & email
71 void SettingsDialog::setRegUserName(QString username)
73 this->regUsername = username;
76 void SettingsDialog::setRegPassword(QString password)
78 this->regPassword = password;
81 void SettingsDialog::setRegEmail(QString email)
83 this->regEmail = email;
86 QString SettingsDialog::getRegUserName()
88 return this->regUsername;
91 QString SettingsDialog::getRegPassword()
93 return this->regPassword;
96 QString SettingsDialog::getRegEmail()
98 return this->regEmail;
104 void SettingsDialog::on_setUserPushButton_clicked()
106 this->username = ui->setUserUsernameLineEdit->text();
107 this->password = ui->setUserPasswordLineEdit->text();
109 // Save these also to usersettings
110 saveLogin( this->username, this->password);
112 // Set "Set/Change User" button text
113 if (this->username.length() > 0)
115 ui->setUserPushButton->setText("Change user");
118 { // Username "cleared"
119 ui->setUserPushButton->setText("Set user");
122 emit userNameChanged();
124 //close(); //using close() hides popup-window which reports error from server
127 // Next 4 functions can be removed if Settingsdialog is implemented without
128 // own copy of username & password
129 void SettingsDialog::setUserName(QString username)
131 this->username = username;
134 void SettingsDialog::setPassword(QString password)
136 this->password = password;
139 QString SettingsDialog::getUserName()
141 return this->username;
144 QString SettingsDialog::getPassword()
146 return this->password;
149 void SettingsDialog::setLabelInfoToUser(QString infoText)
151 this->ui->labelInfoToUser->setText(infoText);