2 * Mainwindow for speedFreak project
4 * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
5 * @author Toni Jussila <toni.jussila@fudeco.com>
6 * @copyright (c) 2010 Speed Freak team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 #include "mainwindow.h"
11 #include "ui_mainwindow.h"
13 #include <QDesktopServices>
18 MainWindow::MainWindow(QWidget *parent) :
20 ui(new Ui::MainWindow)
24 QCoreApplication::setOrganizationName("Fudeco Oy");
25 QCoreApplication::setOrganizationDomain("fudeco.com");
26 QCoreApplication::setApplicationName("Speed Freak");
28 routeDialog = new RouteDialog;
29 creditsDialog = new CreditsDialog;
30 routeSaveDialog = new RouteSaveDialog;
31 settingsDialog = new SettingsDialog;
32 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
33 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
34 topResultDialog = new TopResultDialog;
35 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
36 connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
39 httpClient = new HttpClient(this);
40 connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
41 connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
43 welcomeDialog = new WelcomeDialog;
44 welcomeDialog->show();
47 ui->pushButtonAccelerate->setAutoFillBackground(true);
48 ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
49 ui->pushButtonRoute->setAutoFillBackground(true);
50 ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
51 ui->pushButtonResults->setAutoFillBackground(true);
52 ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
53 ui->pushButtonSettings->setAutoFillBackground(true);
54 ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
55 ui->pushButtonWWW->setAutoFillBackground(true);
56 ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
57 ui->pushButtonCredits->setAutoFillBackground(true);
58 ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
61 MainWindow::~MainWindow()
64 delete routeSaveDialog;
71 void MainWindow::changeEvent(QEvent *e)
73 QMainWindow::changeEvent(e);
75 case QEvent::LanguageChange:
76 ui->retranslateUi(this);
84 * This slot function opens browser to project www page.
86 void MainWindow::on_pushButtonWWW_clicked()
88 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
92 * This slot function opens the credits dialog
94 void MainWindow::on_pushButtonCredits_clicked()
96 creditsDialog->show();
100 * This slot function opens the route save dialog
102 void MainWindow::on_pushButtonRoute_clicked()
104 routeSaveDialog->show();
108 * This slot function opens the settings dialog
110 void MainWindow::on_pushButtonSettings_clicked()
112 settingsDialog->show();
116 * This slot function opens the acceleration dialog
118 void MainWindow::on_pushButtonAccelerate_clicked()
121 accstart = new accelerationstart(this);
126 * This slot function opens the top results dialog
128 void MainWindow::on_pushButtonResults_clicked()
130 topResultDialog->show();
134 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
136 void MainWindow::clientRequestCategoryList()
138 httpClient->requestCategories();
142 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
144 void MainWindow::clientRequestTopList(int index)
146 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
147 QString limit = QString::number(topResultDialog->getLimitNr());
148 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
152 *This function is used to set items to category combobox. Top-tab view.
155 void MainWindow::setCategoryCompoBox()
157 qDebug() << "_setCategoryCompoBox";
158 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
162 *This function prcesses UI updating after a new top10List has been received.
163 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
165 void MainWindow::showTop10()
167 qDebug() << "_showTop10";
168 int ind = topResultDialog->getRecentCategoryIndex();
169 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
173 *This function is used to set items to labelTopList. Top-tab view.
175 *@param Size, number of results.
177 void MainWindow::setListViewTopList(QString category, int size)
179 qDebug() << "_setListViewTopList" << category;
181 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
182 topResultDialog->showTopList(topList);
186 * This function performs registration to server
188 void MainWindow::regUserToServer()
190 httpClient->requestRegistration();
194 * This function performs login to server
196 void MainWindow::userLogin()
198 httpClient->checkLogin();