From: Olavi Pulkkinen Date: Wed, 31 Mar 2010 07:28:12 +0000 (+0300) Subject: Added functionality to change user in settingsdialog. X-Git-Tag: v0.2-RC1~20 X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=5241ec75463415bf6e08caa763699dbb118135de Added functionality to change user in settingsdialog. --- diff --git a/Client/settingsdialog.cpp b/Client/settingsdialog.cpp index e19e4e6..51d3565 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), @@ -9,6 +18,21 @@ SettingsDialog::SettingsDialog(QWidget *parent) : this->setWindowTitle("Settings"); this->ui->regEMailLineEdit->setText("@meili.fi"); instructionsDialog = new InstructionsDialog; + + 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() @@ -91,6 +115,19 @@ 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(); } diff --git a/Client/settingsdialog.h b/Client/settingsdialog.h index 09e76f4..b6fdd8b 100644 --- a/Client/settingsdialog.h +++ b/Client/settingsdialog.h @@ -1,3 +1,11 @@ +/* + * SettingsDialog class + * + * @author Olavi Pulkkinen + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H diff --git a/Client/usersettings.cpp b/Client/usersettings.cpp index fa6527f..20046cc 100644 --- a/Client/usersettings.cpp +++ b/Client/usersettings.cpp @@ -47,6 +47,12 @@ void UserSettings::writeLoginSettings( QString userName, QString password) settings.setValue("password", password); } +void getLoginInfo(QString *userName, QString *password) +{ + UserSettings myLogin; + myLogin.readLoginSettings( userName, password); +} + void saveLogin( QString userName, QString password) { UserSettings myLogin; diff --git a/Client/usersettings.h b/Client/usersettings.h index 6465fb6..e19341f 100644 --- a/Client/usersettings.h +++ b/Client/usersettings.h @@ -21,5 +21,6 @@ public: bool loginSaved( void); void saveLogin( QString userName, QString password); +void getLoginInfo( QString *userName, QString *password); #endif // USERSETTINGS_H