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 creditsDialog = new CreditsDialog;
29 routeSaveDialog = new RouteSaveDialog;
30 settingsDialog = new SettingsDialog;
31 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
32 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
33 topResultDialog = new TopResultDialog;
34 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
35 connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
38 httpClient = new HttpClient(this);
39 connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
40 connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
42 welcomeDialog = new WelcomeDialog;
43 welcomeDialog->show();
46 ui->pushButtonAccelerate->setAutoFillBackground(true);
47 ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
48 ui->pushButtonRoute->setAutoFillBackground(true);
49 ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
50 ui->pushButtonResults->setAutoFillBackground(true);
51 ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
52 ui->pushButtonSettings->setAutoFillBackground(true);
53 ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
54 ui->pushButtonWWW->setAutoFillBackground(true);
55 ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
58 MainWindow::~MainWindow()
61 delete routeSaveDialog;
67 void MainWindow::changeEvent(QEvent *e)
69 QMainWindow::changeEvent(e);
71 case QEvent::LanguageChange:
72 ui->retranslateUi(this);
79 void MainWindow::on_pushButtonWWW_clicked()
81 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
84 void MainWindow::on_pushButtonCredits_clicked()
86 creditsDialog->show();
89 void MainWindow::on_pushButtonRoute_clicked()
91 routeSaveDialog->show();
94 void MainWindow::on_pushButtonSettings_clicked()
96 settingsDialog->show();
99 void MainWindow::on_pushButtonAccelerate_clicked()
102 accstart = new accelerationstart(this);
106 void MainWindow::on_pushButtonResults_clicked()
108 topResultDialog->show();
112 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
114 void MainWindow::clientRequestCategoryList()
116 httpClient->requestCategories();
120 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
122 void MainWindow::clientRequestTopList(int index)
124 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
125 QString limit = QString::number(topResultDialog->getLimitNr());
126 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
130 *This function is used to set items to category combobox. Top-tab view.
133 void MainWindow::setCategoryCompoBox()
135 qDebug() << "_setCategoryCompoBox";
136 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
140 *This function prcesses UI updating after a new top10List has been received.
141 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
143 void MainWindow::showTop10()
145 qDebug() << "_showTop10";
146 int ind = topResultDialog->getRecentCategoryIndex();
147 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
151 *This function is used to set items to labelTopList. Top-tab view.
153 *@param Size, number of results.
155 void MainWindow::setListViewTopList(QString category, int size)
157 qDebug() << "_setListViewTopList" << category;
159 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
160 topResultDialog->showTopList(topList);
163 void MainWindow::regUserToServer()
165 httpClient->requestRegistration();
168 void MainWindow::userLogin()
170 httpClient->checkLogin();