Implementd user name in window title
authorOlavi Pulkkinen <olavi.pulkkinen@webinfo.fi>
Tue, 9 Mar 2010 11:35:36 +0000 (13:35 +0200)
committerOlavi Pulkkinen <olavi.pulkkinen@webinfo.fi>
Tue, 9 Mar 2010 11:35:36 +0000 (13:35 +0200)
Client/carmainwindow.cpp
Client/carmainwindow.h
Client/loginwindow.cpp
Client/loginwindow.h

index ee146ff..5ec9688 100644 (file)
@@ -47,9 +47,12 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca
     timer->setInterval(300);
 
     connect(this->timer, SIGNAL(timeout()), this, SLOT(after_timeout()));
+    connect(myLogin, SIGNAL( userNameChanged()), this, SLOT(updateUserName()));
 
     ui->labelMeasureTabResult->hide();
 
+    this->setWindowTitle("Speed bfreak");
+
 }
 
 /**
@@ -233,10 +236,7 @@ void CarMainWindow::on_pushButton_clicked()
   */
 void CarMainWindow::on_loginLogoutButton_clicked()
 {
-    //LoginWindow myLogin;
-
     myLogin->show();
-    //ui->loginLogoutButton->setText("logout");
 }
 
 /**
@@ -589,3 +589,22 @@ void CarMainWindow::on_pushButtonSendResult_clicked()
 {
     emit sendresult();
 }
+
+void CarMainWindow::updateUserName()
+{
+    QString newUserName;
+
+    newUserName = myLogin->getUserName();
+    ui->userNameLabel->setText( "User: " + newUserName);
+
+    if (newUserName.length())
+    {
+       ui->setUserPushButton->setText( "Change User");
+       this->setWindowTitle("Speed freak - " + newUserName);
+    }
+    else
+    {
+        ui->setUserPushButton->setText( "Set User");
+        this->setWindowTitle("Speed freak");
+    }
+}
index dcf047e..95b95a5 100644 (file)
@@ -83,6 +83,7 @@ private:
 signals:
 void speedAchieved();
 void sendresult();
+void userNameChanged();
 
 private slots:
     void on_pushButtonSendResult_clicked();
@@ -108,6 +109,7 @@ private slots:
     void errorFromServer(QNetworkReply* reply);
 
     void after_timeout();
+    void updateUserName();
 };
 
 #endif // CARMAINWINDOW_H
index faa535d..330b782 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "loginwindow.h"
 #include "ui_loginwindow.h"
-#include <QMessageBox>
 
 LoginWindow::LoginWindow(QWidget *parent) :
     QDialog(parent),
@@ -47,6 +46,8 @@ void LoginWindow::on_loginPushButton_clicked()
 {
     this->username = ui->userNameLineEdit->text();
     this->password = ui->passwordLineEdit->text();
+
+    emit userNameChanged();
     close();
 }
 
index 1ffb7ff..08fb43a 100644 (file)
@@ -36,6 +36,8 @@ private:
 private slots:
     void on_loginPushButton_clicked();
     void on_cancelPushButton_clicked();
+signals:
+    void userNameChanged();
 };
 
 #endif // LOGINWINDOW_H