Youtube video and text (draft).
[speedfreak] / Client / mainwindow.cpp
index 1844859..8dbfc79 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Mainwindow for speedFreak project
  *
- * @author      Rikhard Kuutti <rikhard.kuutti@fudeco.com>
+ * @author      Rikhard Kuutti         <rikhard.kuutti@fudeco.com>
+ * @author      Toni Jussila   <toni.jussila@fudeco.com>
  * @copyright   (c) 2010 Speed Freak team
  * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
@@ -24,35 +25,55 @@ MainWindow::MainWindow(QWidget *parent) :
     QCoreApplication::setOrganizationDomain("fudeco.com");
     QCoreApplication::setApplicationName("Speed Freak");
 
-    accstart = NULL;
-
-    creditsDialog = new CreditsDialog;
-    routeSaveDialog = new RouteSaveDialog;
     routeDialog = new RouteDialog;
     connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute()));
+
+    routeSaveDialog = new RouteSaveDialog;
+
     settingsDialog = new SettingsDialog;
     connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
     connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
+
     topResultDialog = new TopResultDialog;
     connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
     connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
+
     httpClient = new HttpClient(this);
     connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
     connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
+
     resultDialog = new ResultDialog;
-    connect(resultDialog, SIGNAL(sendResult(double)), this, SLOT(clientSendResult(double)));
+    connect(resultDialog, SIGNAL(sendresult()), this, SLOT(clientSendResult()));
+
+    accstart = NULL;
+
+    creditsDialog = new CreditsDialog;
 
     welcomeDialog = new WelcomeDialog;
     welcomeDialog->show();
+
+    //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);
+    ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+    ui->pushButtonCredits->setAutoFillBackground(true);
+    ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
 }
 
 MainWindow::~MainWindow()
 {
     delete ui;
-
     delete routeSaveDialog;
+    delete routeDialog;
 
-    if(!accstart)
+    if(accstart)
         delete accstart;
 }
 
@@ -68,26 +89,41 @@ void MainWindow::changeEvent(QEvent *e)
     }
 }
 
+/**
+  * This slot function opens browser to project www page.
+  */
 void MainWindow::on_pushButtonWWW_clicked()
 {
     QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
 }
 
+/**
+  * This slot function opens the credits dialog
+  */
 void MainWindow::on_pushButtonCredits_clicked()
 {
     creditsDialog->show();
 }
 
+/**
+  * This slot function opens the route save dialog
+  */
 void MainWindow::on_pushButtonRoute_clicked()
 {
     routeSaveDialog->show();
 }
 
+/**
+  * This slot function opens the settings dialog
+  */
 void MainWindow::on_pushButtonSettings_clicked()
 {
     settingsDialog->show();
 }
 
+/**
+  * This slot function opens the acceleration dialog
+  */
 void MainWindow::on_pushButtonAccelerate_clicked()
 {
     if(!accstart)
@@ -95,6 +131,9 @@ void MainWindow::on_pushButtonAccelerate_clicked()
     accstart->show();
 }
 
+/**
+  * This slot function opens the top results dialog
+  */
 void MainWindow::on_pushButtonResults_clicked()
 {
     topResultDialog->show();
@@ -153,19 +192,30 @@ void MainWindow::clientRegUserToServer()
     httpClient->requestRegistration();
 }
 
+/**
+  * This function performs login to server
+  */
 void MainWindow::clientUserLogin()
 {
     httpClient->checkLogin();
 }
 
+/**
+  * This function send route to server
+  */
 void MainWindow::clientSendRoute()
 {
     httpClient->sendRouteXml();
 }
 
-void MainWindow::clientSendResult(double result)
+/**
+  * This function send acceleration data to server
+  */
+void MainWindow::clientSendResult()
 {
+    qDebug() << "_clientSendResult";
     if(accstart) {
-        httpClient->sendResultXml(accstart->getMeasureCategory(), result);
+        qDebug() << "_clientSendResult, calling server";
+        httpClient->sendResultXml(accstart->getMeasureCategory(), resultDialog->getResult());
     }
 }