Youtube video and text (draft).
[speedfreak] / Client / settingsdialog.cpp
index e44580d..b619576 100644 (file)
@@ -1,5 +1,14 @@
+/*
+ * SettingsDialog class
+ *
+ * @author     Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
+ * @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,23 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
 {
     ui->setupUi(this);
     this->setWindowTitle("Settings");
+    this->ui->regEMailLineEdit->setText("@");
     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()
@@ -45,9 +70,9 @@ void SettingsDialog::on_registratePushButton_clicked()
     this->regPassword = ui->regPasswordLineEdit->text();
     this->regEmail = ui->regEMailLineEdit->text();
 
-    //emit sendregistration();
+    emit sendregistration();
 
-    close();
+    //close();      //using close() hides popup-window which reports error from server
 }
 
 // Next 6 functions can be removed if Settingsdialog is implemented without
@@ -90,8 +115,22 @@ void SettingsDialog::on_setUserPushButton_clicked()
     this->username = ui->setUserUsernameLineEdit->text();
     this->password = ui->setUserPasswordLineEdit->text();
 
-    //emit userNameChanged();
-    close();
+    // 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
@@ -116,3 +155,7 @@ QString SettingsDialog::getPassword()
     return this->password;
 }
 
+void SettingsDialog::setLabelInfoToUser(QString infoText)
+{
+    this->ui->labelInfoToUser->setText(infoText);
+}