X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fmainwindow.cpp;h=d49507433d866540e1ea49a9a909ea3e7ddf1b19;hp=78e71c98eb404da52d35e1fae05994f1e85715a7;hb=abc31f4c395065825faabba1059792978110836b;hpb=711ece5e3a718c47646650e163d45ed1418664c0 diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 78e71c9..d495074 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -1,7 +1,8 @@ /* * Mainwindow for speedFreak project * - * @author Rikhard Kuutti + * @author Rikhard Kuutti + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -25,32 +26,49 @@ MainWindow::MainWindow(QWidget *parent) : QCoreApplication::setApplicationName("Speed Freak"); routeDialog = new RouteDialog; + accstart = NULL; + creditsDialog = new CreditsDialog; routeSaveDialog = new RouteSaveDialog; + routeDialog = new RouteDialog; + connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute())); settingsDialog = new SettingsDialog; - connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer())); - connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin())); + 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))); - accstart = NULL; - 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()), this, SLOT(clientSendResult())); 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; } @@ -66,26 +84,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) @@ -93,6 +126,9 @@ void MainWindow::on_pushButtonAccelerate_clicked() accstart->show(); } +/** + * This slot function opens the top results dialog + */ void MainWindow::on_pushButtonResults_clicked() { topResultDialog->show(); @@ -111,7 +147,6 @@ void MainWindow::clientRequestCategoryList() */ void MainWindow::clientRequestTopList(int index) { - qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index); QString limit = QString::number(topResultDialog->getLimitNr()); httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit); } @@ -122,7 +157,6 @@ void MainWindow::clientRequestTopList(int index) */ void MainWindow::setCategoryCompoBox() { - qDebug() << "_setCategoryCompoBox"; topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList()); } @@ -132,7 +166,6 @@ void MainWindow::setCategoryCompoBox() */ void MainWindow::showTop10() { - qDebug() << "_showTop10"; int ind = topResultDialog->getRecentCategoryIndex(); setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr()); } @@ -144,18 +177,34 @@ void MainWindow::showTop10() */ void MainWindow::setListViewTopList(QString category, int size) { - qDebug() << "_setListViewTopList" << category; QString topList; topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size)); topResultDialog->showTopList(topList); } -void MainWindow::regUserToServer() +void MainWindow::clientRegUserToServer() { httpClient->requestRegistration(); } -void MainWindow::userLogin() +/** + * This function performs login to server + */ +void MainWindow::clientUserLogin() { httpClient->checkLogin(); } + +void MainWindow::clientSendRoute() +{ + httpClient->sendRouteXml(); +} + +void MainWindow::clientSendResult() +{ + qDebug() << "_clientSendResult"; + if(accstart) { + qDebug() << "_clientSendResult, calling server"; + httpClient->sendResultXml(accstart->getMeasureCategory(), resultDialog->getResult()); + } +}