11dbf8583a645f0fd60d0aa172ac908b72994138
[speedfreak] / Client / accelerationstart.cpp
1 /*
2  * Acceleration start dialog
3  *
4  * @author      Jukka Kurttila <jukka.kurttila@fudeco.com>
5  * @copyright   (c) 2010 Speed Freak team
6  * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
7  */
8 #include "accelerationstart.h"
9 #include "ui_accelerationstartdialog.h"
10 #include <QMessageBox>
11
12 accelerationstart::accelerationstart(QWidget *parent) :
13     QDialog(parent),
14     ui(new Ui::accelerationstart)
15 {
16     ui->setupUi(this);
17     ui->buttonStart->setDisabled(true);
18     accRealTimeDialog = NULL;
19     stopMeasureSpeed = 0;
20
21     ui->categorComboBox->addItem("Select category");
22     //ui->categorComboBox->addItem("-");
23     ui->categorComboBox->addItem("0 - 20 km/h",20);
24     ui->categorComboBox->addItem("0 - 40 km/h");
25     ui->categorComboBox->addItem("0 - 100 km/h");
26
27     //Button settings
28     ui->buttonCalib->setAutoFillBackground(true);
29     ui->buttonCalib->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
30     ui->buttonStart->setAutoFillBackground(true);
31     ui->buttonStart->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
32 }
33
34 accelerationstart::~accelerationstart()
35 {
36     delete ui;
37     if(accRealTimeDialog)
38         delete accRealTimeDialog;
39 }
40
41 void accelerationstart::changeEvent(QEvent *e)
42 {
43     QDialog::changeEvent(e);
44     switch (e->type()) {
45     case QEvent::LanguageChange:
46         ui->retranslateUi(this);
47         break;
48     default:
49         break;
50     }
51 }
52
53 void accelerationstart::on_buttonCalib_clicked()
54 {
55     if(accRealTimeDialog == NULL)
56         accRealTimeDialog = new AccRealTimeDialog(this);
57
58     accRealTimeDialog->Calibrate();
59
60     ui->buttonStart->setEnabled(true);
61 }
62
63 void accelerationstart::on_buttonStart_clicked()
64 {
65     if( stopMeasureSpeed == 0 )
66     {
67         QMessageBox msgBox;
68         msgBox.setWindowTitle("Can not start measure!");
69         msgBox.setText("Select category first!");
70         msgBox.setDefaultButton(QMessageBox::Ok);
71         msgBox.exec();
72         return;
73     }
74     accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
75     accRealTimeDialog->startAccelerationMeasure();
76     accRealTimeDialog->show();
77 }
78
79 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
80 {
81     stopMeasureSpeed = 0;
82     if( index == 1 ) {
83         stopMeasureSpeed = 20;
84         measureCategory = "acceleration-0-20";
85     }
86     else if( index == 2 ) {
87         stopMeasureSpeed = 40;
88         measureCategory = "acceleration-0-40";
89     }
90     else if( index == 3 ) {
91         stopMeasureSpeed = 100;
92         measureCategory = "acceleration-0-100";
93     }
94 }
95
96
97 QString accelerationstart::getMeasureCategory()
98 {
99     return measureCategory;
100 }
101