Settings dialog changed. Log in/Log out functionality improved.
[speedfreak] / Client / mainwindow.cpp
index 4f32eee..7706106 100644 (file)
@@ -14,6 +14,7 @@
 #include <QUrl>
 #include <QSettings>
 #include <QDebug>
+#include "usersettings.h"
 
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
@@ -36,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
     settingsDialog = new SettingsDialog;
     connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
     connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
+    connect(settingsDialog, SIGNAL(logout()), this, SLOT(setUsernameToMainPanel()));
 
     httpClient = new HttpClient(this);
     connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
@@ -46,6 +48,8 @@ MainWindow::MainWindow(QWidget *parent) :
     welcomeDialog = new WelcomeDialog;
     welcomeDialog->show();
 
+    this->setUsernameToMainPanel();
+
     //Button settings
     ui->pushButtonAccelerate->setAutoFillBackground(true);
     ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
@@ -225,6 +229,7 @@ void MainWindow::clientRegUserToServer()
   */
 void MainWindow::clientUserLogin()
 {
+    connect(httpClient, SIGNAL(loginOK()), this, SLOT(setUsernameToMainPanel()));
     httpClient->checkLogin();
 }
 
@@ -268,3 +273,15 @@ void MainWindow::killDialog()
         accstart = NULL;
     }
 }
+
+void MainWindow::setUsernameToMainPanel()
+{
+    if (loginSaved())
+    {
+        this->setWindowTitle("SpeedFreak - " + settingsDialog->getUserName());
+    }
+    else
+    {
+        this->setWindowTitle("SpeedFreak - Not logged");
+    }
+}