X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=Client%2Fsettingsdialog.cpp;h=3ded2bba221418030fd8b4a9242ce722fcf6ebe1;hb=ef6573877133287171c02d2e7b1232ff44ab804e;hp=84bb5fc7afe0e05be545369eea2f80b08ee67dab;hpb=75e2328492951629d43639bbc6dd63ed76185218;p=speedfreak diff --git a/Client/settingsdialog.cpp b/Client/settingsdialog.cpp index 84bb5fc..3ded2bb 100644 --- a/Client/settingsdialog.cpp +++ b/Client/settingsdialog.cpp @@ -1,5 +1,14 @@ +/* + * SettingsDialog class + * + * @author Olavi Pulkkinen + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include "settingsdialog.h" #include "ui_settingsdialog.h" +#include "usersettings.h" SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), @@ -7,7 +16,22 @@ SettingsDialog::SettingsDialog(QWidget *parent) : { ui->setupUi(this); this->setWindowTitle("Settings"); - instructionsDialog = new InstructionsDialog; + this->ui->regEMailLineEdit->setText("@"); + + if (loginSaved()) + { + QString uName, pWord; + + getLoginInfo( &uName, &pWord); + this->username = uName; + this->password = pWord; + + ui->setUserPasswordLineEdit->setText(this->password); + ui->setUserUsernameLineEdit->setText(this->username); + + // Already someone as user - change button text to "Change" + ui->setUserPushButton->setText("Change user"); + } } SettingsDialog::~SettingsDialog() @@ -27,7 +51,102 @@ void SettingsDialog::changeEvent(QEvent *e) } } -void SettingsDialog::on_pushButtonHelp_clicked() +// +// Registrate +// +void SettingsDialog::on_registratePushButton_clicked() +{ + // Send username, password and email to SpeedFreak server + this->regUsername = ui->regUserNameLineEdit->text(); + this->regPassword = ui->regPasswordLineEdit->text(); + this->regEmail = ui->regEMailLineEdit->text(); + + emit sendregistration(); + + //close(); //using close() hides popup-window which reports error from server +} + +// Next 6 functions can be removed if Settingsdialog is implemented without +// own copy of username, password & email +void SettingsDialog::setRegUserName(QString username) +{ + this->regUsername = username; +} + +void SettingsDialog::setRegPassword(QString password) +{ + this->regPassword = password; +} + +void SettingsDialog::setRegEmail(QString email) +{ + this->regEmail = email; +} + +QString SettingsDialog::getRegUserName() +{ + return this->regUsername; +} + +QString SettingsDialog::getRegPassword() +{ + return this->regPassword; +} + +QString SettingsDialog::getRegEmail() +{ + return this->regEmail; +} + +// +// Set / Change user +// +void SettingsDialog::on_setUserPushButton_clicked() +{ + this->username = ui->setUserUsernameLineEdit->text(); + this->password = ui->setUserPasswordLineEdit->text(); + + // Save these also to usersettings + saveLogin( this->username, this->password); + + // Set "Set/Change User" button text + if (this->username.length() > 0) + { + ui->setUserPushButton->setText("Change user"); + } + else + { // Username "cleared" + ui->setUserPushButton->setText("Set user"); + } + + emit userNameChanged(); + + //close(); //using close() hides popup-window which reports error from server +} + +// Next 4 functions can be removed if Settingsdialog is implemented without +// own copy of username & password +void SettingsDialog::setUserName(QString username) +{ + this->username = username; +} + +void SettingsDialog::setPassword(QString password) +{ + this->password = password; +} + +QString SettingsDialog::getUserName() +{ + return this->username; +} + +QString SettingsDialog::getPassword() +{ + return this->password; +} + +void SettingsDialog::setLabelInfoToUser(QString infoText) { - instructionsDialog->show(); + this->ui->labelInfoToUser->setText(infoText); }