Profile dialog development
[speedfreak] / Client / mainwindow.cpp
index 741b179..56c7238 100644 (file)
@@ -16,6 +16,9 @@
 #include <QDebug>
 #include "usersettings.h"
 
+/**
+  *
+  */
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
     ui(new Ui::MainWindow)
@@ -32,9 +35,10 @@ MainWindow::MainWindow(QWidget *parent) :
     topResultDialog = NULL;
 
     settingsDialog = new SettingsDialog;
-    connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
-    connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
-    connect(settingsDialog, SIGNAL(logout()), this, SLOT(setUsernameToMainPanel()));
+    connect(settingsDialog, SIGNAL(sendregistration()), this, SLOT(clientRegUserToServer()));
+    connect(settingsDialog, SIGNAL(userNameChanged()),  this, SLOT(clientUserLogin()));
+    connect(settingsDialog, SIGNAL(logout()),           this, SLOT(setUsernameToMainPanel()));
+    connect(settingsDialog, SIGNAL(saveprofile()),      this, SLOT(saveProfile()));
 
     httpClient = new HttpClient(this);
     connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
@@ -46,12 +50,6 @@ MainWindow::MainWindow(QWidget *parent) :
     this->setUsernameToMainPanel();
 
     //Button settings
-    //ui->pushButtonAccelerate->setAutoFillBackground(true);
-    //ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
-    ui->pushButtonRoute->setAutoFillBackground(true);
-    ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
-    ui->pushButtonResults->setAutoFillBackground(true);
-    ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
     ui->pushButtonSettings->setAutoFillBackground(true);
     ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
     ui->pushButtonWWW->setAutoFillBackground(true);
@@ -59,21 +57,55 @@ MainWindow::MainWindow(QWidget *parent) :
     ui->pushButtonCredits->setAutoFillBackground(true);
     ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
 
+    //Create icon for acceleration start button
     QIcon* icon = new QIcon();
     icon->addFile(QString(":/new/prefix1/Graphics/Speedometer.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
     icon->addFile(QString(":/new/prefix1/Graphics/Speedometer2.png"), QSize(125,125), QIcon::Normal, QIcon::On);
 
+    //Acceleration start button
+
     customButtonAccelerate = new CustomButton(this,icon);
     delete icon;
 
     int buttons_x = 50,buttons_y = 165;
     customButtonAccelerate->setGeometry(buttons_x,buttons_y,130,130);
     connect(customButtonAccelerate, SIGNAL(OpenDialog()), this, SLOT(OpenAccStartDialog()));
-
     customButtonAccelerate->show();
 
+    //Create icon for route dialog button
+    icon = new QIcon();
+    icon->addFile(QString(":/new/prefix1/Graphics/route.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
+    icon->addFile(QString(":/new/prefix1/Graphics/route_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);
+
+    //Route dialog button
+
+    customButtonRoute = new CustomButton(this,icon);
+    delete icon;
+
+    buttons_x += 140;
+    customButtonRoute->setGeometry(buttons_x,buttons_y,130,130);
+    connect(customButtonRoute, SIGNAL(OpenDialog()), this, SLOT(OpenRouteDialog()));
+    customButtonRoute->show();
+
+    //Create icon for results dialog button
+    icon = new QIcon();
+    icon->addFile(QString(":/new/prefix1/Graphics/trophy_gold.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
+    icon->addFile(QString(":/new/prefix1/Graphics/trophy_gold_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);
+
+    //Results dialog button
+
+    customButtonResults = new CustomButton(this,icon);
+    delete icon;
+
+    buttons_x += 140;
+    customButtonResults->setGeometry(buttons_x,buttons_y,130,130);
+    connect(customButtonResults, SIGNAL(OpenDialog()), this, SLOT(OpenResultDialog()));
+    customButtonResults->show();
 }
 
+/**
+  *
+  */
 MainWindow::~MainWindow()
 {
     delete ui;
@@ -101,9 +133,16 @@ MainWindow::~MainWindow()
 
     if(customButtonAccelerate)
         delete customButtonAccelerate;
+    if(customButtonRoute)
+        delete customButtonRoute;
+    if(customButtonResults)
+        delete customButtonResults;
 
 }
 
+/**
+  *
+  */
 void MainWindow::changeEvent(QEvent *e)
 {
     QMainWindow::changeEvent(e);
@@ -137,19 +176,6 @@ void MainWindow::on_pushButtonCredits_clicked()
 }
 
 /**
-  * This slot function opens the route save dialog
-  */
-void MainWindow::on_pushButtonRoute_clicked()
-{
-    if(!routeSaveDialog)
-        routeSaveDialog = new RouteSaveDialog;
-
-    connect(routeSaveDialog, SIGNAL(sendroute()), this, SLOT(clientSendRoute()));
-    connect(routeSaveDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
-    routeSaveDialog->show();
-}
-
-/**
   * This slot function opens the settings dialog
   */
 void MainWindow::on_pushButtonSettings_clicked()
@@ -158,21 +184,6 @@ void MainWindow::on_pushButtonSettings_clicked()
 }
 
 /**
-  * This slot function opens the top results dialog
-  */
-void MainWindow::on_pushButtonResults_clicked()
-{
-    if (!topResultDialog)
-        topResultDialog = new TopResultDialog;
-
-    clientRequestCategoryList();
-    connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
-    connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
-    connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
-    topResultDialog->show();
-}
-
-/**
   *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
   */
 void MainWindow::clientRequestCategoryList()
@@ -279,6 +290,7 @@ void MainWindow::clientSendResult(QString category, double result)
             httpClient->sendResultXml(category, result);
     }
 }
+
 /**
   * This slot function called when ever dialog rejected.
   */
@@ -315,6 +327,7 @@ void MainWindow::killDialog()
         helpDialog = NULL;
     }
 }
+
 /**
   *
   */
@@ -341,3 +354,38 @@ void MainWindow::OpenAccStartDialog()
     connect(accstart, SIGNAL(rejected()), this, SLOT(killDialog()));
     accstart->show();
 }
+/**
+  * This slot function opens the route save dialog
+  */
+void MainWindow::OpenRouteDialog()
+{
+    if(!routeSaveDialog)
+        routeSaveDialog = new RouteSaveDialog;
+
+    connect(routeSaveDialog, SIGNAL(sendroute()), this, SLOT(clientSendRoute()));
+    connect(routeSaveDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
+    routeSaveDialog->show();
+}
+/**
+  * This slot function opens the top results dialog
+  */
+void MainWindow::OpenResultDialog()
+{
+    if (!topResultDialog)
+        topResultDialog = new TopResultDialog;
+
+    clientRequestCategoryList();
+    connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
+    connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
+    connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
+    topResultDialog->show();
+}
+
+/**
+  * This slot function save user profile data to server
+  */
+void MainWindow::saveProfile()
+{
+    if(httpClient)
+        httpClient->sendProfileXml();
+}