Merge branch 'master' of https://vcs.maemo.org/git/speedfreak
[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
28 accelerationstart::~accelerationstart()
29 {
30     delete ui;
31     if(accRealTimeDialog)
32         delete accRealTimeDialog;
33 }
34
35 void accelerationstart::changeEvent(QEvent *e)
36 {
37     QDialog::changeEvent(e);
38     switch (e->type()) {
39     case QEvent::LanguageChange:
40         ui->retranslateUi(this);
41         break;
42     default:
43         break;
44     }
45 }
46
47 void accelerationstart::on_buttonCalib_clicked()
48 {
49     if(accRealTimeDialog == NULL)
50         accRealTimeDialog = new AccRealTimeDialog(this);
51
52     accRealTimeDialog->Calibrate();
53
54     ui->buttonStart->setEnabled(true);
55 }
56
57 void accelerationstart::on_buttonStart_clicked()
58 {
59     if( stopMeasureSpeed == 0 )
60     {
61         QMessageBox msgBox;
62         msgBox.setWindowTitle("Can not start measure!");
63         msgBox.setText("Select category first!");
64         msgBox.setDefaultButton(QMessageBox::Ok);
65         msgBox.exec();
66         return;
67     }
68     accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
69     accRealTimeDialog->startAccelerationMeasure();
70     accRealTimeDialog->show();
71 }
72
73 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
74 {
75     stopMeasureSpeed = 0;
76     if( index == 1 ) {
77         stopMeasureSpeed = 10;
78         measureCategory = "acceleration-0-10";
79     }
80     else if( index == 2 ) {
81         stopMeasureSpeed = 40;
82         measureCategory = "acceleration-0-40";
83     }
84     else if( index == 3 ) {
85         stopMeasureSpeed = 100;
86         measureCategory = "acceleration-0-100";
87     }
88 }
89
90
91 QString accelerationstart::getMeasureCategory()
92 {
93     return measureCategory;
94 }
95