X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fresultdialog.cpp;h=a5f5d324816544d3ac05785e9dc9f539f32ecf92;hp=a9c440c5cef7a7f2db8f0874afb79e4f81916a59;hb=04e7348e047307f792f88b7a3e198a008eef0e8b;hpb=da859c9f595e92183686c12499f8ee59bff3fd3c diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index a9c440c..a5f5d32 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -1,7 +1,8 @@ /* - * CarMainWindow main class + * Result dialog * * @author Janne Änäkkälä + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -12,6 +13,7 @@ #include "math.h" #include #include +#include const int DIAGRAM_WIDTH = 400; const int DIAGRAM_HEIGHT = 300; @@ -29,6 +31,7 @@ const int DIAGRAMGAP100KMH = 30; const int DIAGRAMGAP5S = 80; const int DIAGRAMGAP10S = 40; +const int DIAGRAMGAP16S = 25; const int DIAGRAMGAP20S = 20; const QPoint diagramStemStart(70, 330); @@ -55,6 +58,9 @@ ResultDialog::ResultDialog(QWidget *parent) : ui(new Ui::ResultDialog) { ui->setupUi(this); + + helpAccelerationDialog = NULL; + timeAxelLength = 10; resultString = ""; speedList << "0" << "10" << "20" << "30" << "40" << "50" << "60" << "70" << "80" << "90" << "100" ; @@ -67,6 +73,9 @@ ResultDialog::ResultDialog(QWidget *parent) : timeArray[i] = 0; } + //Clear info label + ui->labelInfoToUser->setText(""); + if (loginSaved()) { ui->pushButtonSend->setEnabled(true); @@ -74,6 +83,7 @@ ResultDialog::ResultDialog(QWidget *parent) : else { ui->pushButtonSend->setEnabled(false); + ui->labelInfoToUser->setText("You're not logged! Please register or log in and accelerate again."); } } @@ -277,19 +287,19 @@ void ResultDialog::setTimesIntoLabels() */ void ResultDialog::setTimeAxelLength(int pChoice) { - if (timeArray[pChoice] <= 5) + if (timeArray[pChoice] <= 5.0) { timeAxelLength = 5; } - else if (timeArray[pChoice] <= 10) + else if (timeArray[pChoice] <= 10.0 && timeArray[pChoice] > 5.0) { timeAxelLength = 10; } - else if (timeArray[pChoice] <= 15) + else if (timeArray[pChoice] <= 16.0 && timeArray[pChoice] > 10.0) { - timeAxelLength = 15; + timeAxelLength = 16; } else @@ -309,17 +319,25 @@ void ResultDialog::on_pushButtonNew_clicked() } resultString = ""; this->close(); + emit rejected(); } /** * This slot function emits sendresult signal for sending results to server when * send results -button has been clicked. + * Emit accrealtimedialog sendresult. */ void ResultDialog::on_pushButtonSend_clicked() { + ui->pushButtonSend->setEnabled(false); emit sendresult(timeArray[this->getTargetChoice()]); } +double ResultDialog::getResult() +{ + return timeArray[this->getTargetChoice()]; +} + /** * This public function sets diagram's stem gap * @param pValue is the speed value which determines diagram gap's value @@ -388,16 +406,21 @@ void ResultDialog::setEnd(int pValue) void ResultDialog::setValue(int pSpeed, double pTime) { //timeArray[0] = 0; - if (floor(pTime) <= 5) + if (pTime <= 5.0) { this->diagramGapHorizontal = DIAGRAMGAP5S; } - else if (floor(pTime) <= 10) + else if (pTime <= 10.0 && pTime > 5.0) { this->diagramGapHorizontal = DIAGRAMGAP10S; } + else if (pTime <= 16.0 && pTime > 10.0) + { + this->diagramGapHorizontal = DIAGRAMGAP16S; + } + else { this->diagramGapHorizontal = DIAGRAMGAP20S; @@ -736,3 +759,43 @@ int ResultDialog::getTargetChoice() } return targetChoice; } + +void ResultDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); +} + +/** + * This function enable send server button. + */ +void ResultDialog::setSendServerButtonEnabled() +{ + ui->pushButtonSend->setEnabled(true); +} + +/** + * This slot function called when ever info button clicked. + */ +void ResultDialog::on_pushButtonInfo_clicked() +{ + if(!helpAccelerationDialog) + { + helpAccelerationDialog = new HelpAccelerationDialog; + } + connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog())); + helpAccelerationDialog->show(); +} + +/** + * This slot function called when ever dialog rejected. + */ +void ResultDialog::killHelpDialog() +{ + if(helpAccelerationDialog) + { + qDebug() << "__Result kill: helpAccelerationDialog"; + delete helpAccelerationDialog; + helpAccelerationDialog = NULL; + } +} +