Added help for settings dialog.
[speedfreak] / Client / accelerationstart.cpp
1 /*
2  * Acceleration start dialog
3  *
4  * @author      Jukka Kurttila <jukka.kurttila@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
8  */
9 #include "accelerationstart.h"
10 #include "ui_accelerationstartdialog.h"
11 #include <QMessageBox>
12
13 accelerationstart::accelerationstart(QWidget *parent) :
14     QDialog(parent),
15     ui(new Ui::accelerationstart)
16 {
17     ui->setupUi(this);
18     ui->buttonStart->setDisabled(true);
19
20     accRealTimeDialog = NULL;
21
22     stopMeasureSpeed = 0;
23
24     ui->categorComboBox->addItem("Select category");
25     //ui->categorComboBox->addItem("-");
26     ui->categorComboBox->addItem("0 - 20 km/h",20);
27     ui->categorComboBox->addItem("0 - 40 km/h");
28     ui->categorComboBox->addItem("0 - 100 km/h");
29
30     //Button settings
31     ui->buttonCalib->setAutoFillBackground(true);
32     ui->buttonCalib->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
33     ui->buttonStart->setAutoFillBackground(true);
34     ui->buttonStart->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
35 }
36
37 accelerationstart::~accelerationstart()
38 {
39     delete ui;
40     if(accRealTimeDialog)
41         delete accRealTimeDialog;
42 }
43
44 void accelerationstart::changeEvent(QEvent *e)
45 {
46     QDialog::changeEvent(e);
47     switch (e->type()) {
48     case QEvent::LanguageChange:
49         ui->retranslateUi(this);
50         break;
51     default:
52         break;
53     }
54 }
55
56 void accelerationstart::on_buttonCalib_clicked()
57 {
58     if(accRealTimeDialog == NULL)
59         accRealTimeDialog = new AccRealTimeDialog(this);
60
61     connect(accRealTimeDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
62
63     accRealTimeDialog->Calibrate();
64
65     ui->buttonStart->setEnabled(true);
66 }
67
68 void accelerationstart::on_buttonStart_clicked()
69 {
70     if( stopMeasureSpeed == 0 )
71     {
72         QMessageBox msgBox;
73         msgBox.setWindowTitle("Can not start measure!");
74         msgBox.setText("Select category first!");
75         msgBox.setDefaultButton(QMessageBox::Ok);
76         msgBox.exec();
77         return;
78     }
79     accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
80     accRealTimeDialog->startAccelerationMeasure();
81     accRealTimeDialog->show();
82 }
83
84 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
85 {
86     stopMeasureSpeed = 0;
87     if( index == 1 ) {
88         stopMeasureSpeed = 20;
89         measureCategory = "acceleration-0-20";
90     }
91     else if( index == 2 ) {
92         stopMeasureSpeed = 40;
93         measureCategory = "acceleration-0-40";
94     }
95     else if( index == 3 ) {
96         stopMeasureSpeed = 100;
97         measureCategory = "acceleration-0-100";
98     }
99 }
100
101
102 QString accelerationstart::getMeasureCategory()
103 {
104     return measureCategory;
105 }
106
107 /**
108   *This slot function emit mainwindow sendresult.
109   *
110   **/
111 void accelerationstart::sendResult(double result)
112 {
113     emit sendresult(measureCategory, result);
114 }