X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fmainwindow.cpp;h=f86681c265e4cac66a72c79572fb039e6351c6e1;hp=741b1793ecdf97ec1e0edf9a7a532e365339f40e;hb=c9fc4fe3bc02ba4c440e4cb95097a1b8d1b37243;hpb=351a0f90c2b210e80a9ed9055714fd48d406e1f7 diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 741b179..f86681c 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -16,6 +16,9 @@ #include #include "usersettings.h" +/** + * + */ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) @@ -31,10 +34,13 @@ MainWindow::MainWindow(QWidget *parent) : routeSaveDialog = NULL; topResultDialog = NULL; + usersDialog = 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())); @@ -45,35 +51,98 @@ 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); - 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)"); - + //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(); + //Create icon for settings dialog button + icon = new QIcon(); + icon->addFile(QString(":/new/prefix1/Graphics/settings.png"), QSize(125,125), QIcon::Normal, QIcon::Off); + icon->addFile(QString(":/new/prefix1/Graphics/settings_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On); + + //Settings dialog button + + customButtonSettings = new CustomButton(this,icon); + delete icon; + + buttons_x += 140; + customButtonSettings->setGeometry(buttons_x,buttons_y,130,130); + connect(customButtonSettings, SIGNAL(OpenDialog()), this, SLOT(OpenSettingsDialog())); + customButtonSettings->show(); + + //Create icon for www page button + icon = new QIcon(); + icon->addFile(QString(":/new/prefix1/Graphics/applications_internet.png"), QSize(125,125), QIcon::Normal, QIcon::Off); + icon->addFile(QString(":/new/prefix1/Graphics/applications_internet_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On); + + //WWW page button + + customButtonWWW = new CustomButton(this,icon); + delete icon; + + buttons_x += 140; + customButtonWWW->setGeometry(buttons_x,buttons_y,130,130); + connect(customButtonWWW, SIGNAL(OpenDialog()), this, SLOT(OpenWWWPage())); + customButtonWWW->show(); + + //Create icon for help dialog button + icon = new QIcon(); + icon->addFile(QString(":/new/prefix1/Graphics/info.png"), QSize(105,105), QIcon::Normal, QIcon::Off); + icon->addFile(QString(":/new/prefix1/Graphics/info_selected.png"), QSize(105,105), QIcon::Normal, QIcon::On); + + //Help dialog button + + customButtonHelp = new CustomButton(this,icon); + delete icon; + + customButtonHelp->setGeometry(670,10,105,105); + connect(customButtonHelp, SIGNAL(OpenDialog()), this, SLOT(OpenHelpDialog())); + customButtonHelp->show(); } +/** + * + */ MainWindow::~MainWindow() { delete ui; @@ -99,11 +168,26 @@ MainWindow::~MainWindow() if(helpDialog) delete helpDialog; + if(usersDialog) + delete usersDialog; + if(customButtonAccelerate) delete customButtonAccelerate; - + if(customButtonRoute) + delete customButtonRoute; + if(customButtonResults) + delete customButtonResults; + if(customButtonSettings) + delete customButtonSettings; + if(customButtonWWW) + delete customButtonWWW; + if(customButtonHelp) + delete customButtonHelp; } +/** + * + */ void MainWindow::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); @@ -117,62 +201,6 @@ 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() -{ - if(!helpDialog) - helpDialog = new HelpDialog; - - connect(helpDialog, SIGNAL(rejected()), this, SLOT(killDialog())); - helpDialog->show(); -} - -/** - * 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() -{ - settingsDialog->show(); -} - -/** - * 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() @@ -196,7 +224,7 @@ void MainWindow::clientRequestTopList(int index) } /** - *This function is used to set items to category combobox. Top-tab view. + *This function is used to set items to category combobox. *@param */ void MainWindow::setCategoryCompoBox() @@ -260,11 +288,14 @@ void MainWindow::clientUserLogin() /** * This function send route data to server. + * @param QString oldName, old file name + * @param QString newName, new file name + * @param int i */ -void MainWindow::clientSendRoute() +void MainWindow::clientSendRoute(QString oldName, QString newName, int i) { if(httpClient) - httpClient->sendRouteXml(); + httpClient->sendRouteXml(oldName, newName, i); } /** @@ -279,6 +310,7 @@ void MainWindow::clientSendResult(QString category, double result) httpClient->sendResultXml(category, result); } } + /** * This slot function called when ever dialog rejected. */ @@ -292,7 +324,7 @@ void MainWindow::killDialog() } if(routeSaveDialog) { - qDebug() << "__MW kill: routeSaveDialog"; + //qDebug() << "__MW kill: routeSaveDialog"; //delete routeSaveDialog; //routeSaveDialog = NULL; } @@ -314,7 +346,14 @@ void MainWindow::killDialog() delete helpDialog; helpDialog = NULL; } + if(usersDialog) + { + qDebug() << "__MW kill: usersDialog"; + delete usersDialog; + usersDialog = NULL; + } } + /** * */ @@ -341,3 +380,99 @@ 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(QString,QString,int)), this, SLOT(clientSendRoute(QString,QString,int))); + 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 opens the settings dialog + */ +void MainWindow::OpenSettingsDialog() +{ + settingsDialog->show(); +} +/** + * This slot function opens browser to project www page. + */ +void MainWindow::OpenWWWPage() +{ + QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/")); +} +/** + * This slot function opens the main help dialog + */ +void MainWindow::OpenHelpDialog() +{ + if(!helpDialog) + helpDialog = new HelpDialog; + + connect(helpDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + helpDialog->show(); +} + +/** + * This slot function save user profile data to server + */ +void MainWindow::saveProfile() +{ + if(httpClient) + httpClient->sendProfileXml(); +} + +/** + * This slot function calls httpClients requestUserInfo for getting user's information from server. + */ +void MainWindow::requestGetUserInfo(QString name) +{ + qDebug() << "getUserInfo signal " + name; + if(httpClient) + { + httpClient->requestUserInfo(name); + } +} + +/** + * This slot function calls httpClients requestUsers for getting usernames from server. + */ +void MainWindow::requestGetUsers() +{ + qDebug() << "getUsers signal"; + if(httpClient) + { + httpClient->requestUsers(); + } +} + +void MainWindow::on_pushButtonUsers_clicked() +{ + if(!usersDialog) + usersDialog = new UsersDialog; + + connect(usersDialog, SIGNAL(getUserInfo(QString)), this, SLOT(requestGetUserInfo(QString))); + //connect(usersDialog, SIGNAL(getUsers()), this, SLOT(requestGetUsers())); + requestGetUsers(); + connect(usersDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + usersDialog->show(); +}