X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=Client%2Fsettingsdialog.cpp;h=935b88d47069c21a6e70732ee5cf3ea7af5f0c57;hb=2cff5ca17d324f817ff283782e5a4bd242a27cbc;hp=fb5d7c075550f43be7159cbcfc23195bd9ea800a;hpb=188021aca5821b74cc990bbd1f9b8c4ff75cb29e;p=speedfreak diff --git a/Client/settingsdialog.cpp b/Client/settingsdialog.cpp index fb5d7c0..935b88d 100644 --- a/Client/settingsdialog.cpp +++ b/Client/settingsdialog.cpp @@ -1,23 +1,28 @@ /* * SettingsDialog class * - * @author Olavi Pulkkinen - * @copyright (c) 2010 Speed Freak team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @author Olavi Pulkkinen + * @author Toni Jussila + * @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" #include +#include -SettingsDialog::SettingsDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::SettingsDialog) +/** + * Constructor of this class + */ +SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) { ui->setupUi(this); + + helpSettingsDialog = NULL; + registerDialog = NULL; this->setWindowTitle("Settings"); - this->ui->regEMailLineEdit->setText("@"); if (loginSaved()) { @@ -27,19 +32,38 @@ SettingsDialog::SettingsDialog(QWidget *parent) : this->username = uName; this->password = pWord; + // Set line edit ui->setUserPasswordLineEdit->setText(this->password); ui->setUserUsernameLineEdit->setText(this->username); + ui->setUserPasswordLineEdit->setDisabled(1); // Disable because user logged + ui->setUserUsernameLineEdit->setDisabled(1); // Disable because user logged // Already someone as user - change button text to "Change" ui->setUserPushButton->setText("Log out"); + + // Button settings + ui->pushButtonProfile->setAutoFillBackground(true); + ui->pushButtonProfile->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + ui->pushButtonProfile->setDisabled(false); + ui->pushButtonProfile->setVisible(false); } + // Button settings + ui->pushButtonInfo->setAutoFillBackground(true); + ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + ui->pushButtonProfile->setVisible(false); } +/** + * Destructor of this class + */ SettingsDialog::~SettingsDialog() { delete ui; } +/** + * + */ void SettingsDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); @@ -52,56 +76,23 @@ void SettingsDialog::changeEvent(QEvent *e) } } -// -// Registrate -// +/** + * This slot function called when ever "register new user" -button clicked. + */ 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; + if(!registerDialog) + { + registerDialog = new RegisterDialog(this); + } + connect(registerDialog, SIGNAL(registrate()), this, SLOT(registrate())); + connect(registerDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + registerDialog->show(); } -// -// Set / Change user -// +/** + * Set / Change user + */ void SettingsDialog::on_setUserPushButton_clicked() { if (!ui->setUserPushButton->text().compare("Log out")) @@ -116,6 +107,7 @@ void SettingsDialog::on_setUserPushButton_clicked() this->password = ui->setUserPasswordLineEdit->text(); ui->setUserPushButton->setText("Log in"); saveLogin( this->username, this->password); + ui->pushButtonProfile->setDisabled(true); emit logout(); } else @@ -140,8 +132,6 @@ void SettingsDialog::on_setUserPushButton_clicked() // Save these also to usersettings //saveLogin( this->username, this->password); - - /* // Set "Set/Change User" button text if (this->username.length() > 0) @@ -160,31 +150,49 @@ void SettingsDialog::on_setUserPushButton_clicked() // 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) { this->ui->labelInfoToUser->setText(infoText); } +/** + * + */ void SettingsDialog::usernameOk(bool isOk) { if (isOk) @@ -192,6 +200,7 @@ void SettingsDialog::usernameOk(bool isOk) ui->setUserPushButton->setText("Log out"); ui->setUserUsernameLineEdit->setDisabled(true); ui->setUserPasswordLineEdit->setDisabled(true); + ui->pushButtonProfile->setDisabled(false); } else @@ -202,5 +211,46 @@ void SettingsDialog::usernameOk(bool isOk) this->username = ui->setUserUsernameLineEdit->text(); this->password = ui->setUserPasswordLineEdit->text(); saveLogin( this->username, this->password); + ui->pushButtonProfile->setDisabled(true); } } + +/** + * This slot function called when ever info button clicked. + */ +void SettingsDialog::on_pushButtonInfo_clicked() +{ + if(!helpSettingsDialog) + { + helpSettingsDialog = new HelpSettingsDialog; + } + connect(helpSettingsDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + helpSettingsDialog->show(); +} + +/** + * This slot function called when ever dialog rejected. + */ +void SettingsDialog::killDialog() +{ + if(helpSettingsDialog) + { + qDebug() << "__Settings kill: helpSettingsDialog"; + delete helpSettingsDialog; + helpSettingsDialog = NULL; + } + if(registerDialog) + { + qDebug() << "__Settings kill: registerDialog"; + delete registerDialog; + registerDialog = NULL; + } +} + +/** + * This slot function called when + */ +void SettingsDialog::registrate() +{ + emit sendregistration(); +}