helpForUsers files added.
[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
10 #include "accelerationstart.h"
11 #include "ui_accelerationstartdialog.h"
12 #include <QMessageBox>
13 #include <QDebug>
14
15 /**
16   * Constructor of this class.
17   */
18 accelerationstart::accelerationstart(QWidget *parent) :
19     QDialog(parent),
20     ui(new Ui::accelerationstart)
21 {
22     ui->setupUi(this);
23     ui->buttonStart->setDisabled(true);
24
25     accRealTimeDialog = NULL;
26     helpAccelerationDialog = NULL;
27
28     stopMeasureSpeed = 0;
29
30     ui->categorComboBox->addItem("Select category");
31     ui->categorComboBox->addItem("0 - 20 km/h",20);
32     ui->categorComboBox->addItem("0 - 40 km/h");
33     ui->categorComboBox->addItem("0 - 100 km/h");
34
35     //Button settings
36     ui->buttonCalib->setAutoFillBackground(true);
37     ui->buttonCalib->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
38     ui->buttonStart->setAutoFillBackground(true);
39     ui->buttonStart->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
40     ui->pushButtonInfo->setAutoFillBackground(true);
41     ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
42 }
43
44 /**
45   * Destructor of this class.
46   * Deletes all dynamic objects and sets them to NULL.
47   */
48 accelerationstart::~accelerationstart()
49 {
50     delete ui;
51     if(accRealTimeDialog)
52         delete accRealTimeDialog;
53 }
54
55 /**
56   *
57   */
58 void accelerationstart::changeEvent(QEvent *e)
59 {
60     QDialog::changeEvent(e);
61     switch (e->type()) {
62     case QEvent::LanguageChange:
63         ui->retranslateUi(this);
64         break;
65     default:
66         break;
67     }
68 }
69
70 /**
71   * This slot function called when ever calibration button clicked
72   */
73 void accelerationstart::on_buttonCalib_clicked()
74 {
75     if(accRealTimeDialog == NULL)
76         accRealTimeDialog = new AccRealTimeDialog(this);
77
78     connect(accRealTimeDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
79
80     accRealTimeDialog->Calibrate();
81
82     ui->buttonStart->setEnabled(true);
83 }
84
85 /**
86   * This slot function called when ever start button clicked
87   */
88 void accelerationstart::on_buttonStart_clicked()
89 {
90     if( stopMeasureSpeed == 0 )
91     {
92         QMessageBox msgBox;
93         msgBox.setWindowTitle("Can not start measure!");
94         msgBox.setText("Select category first!");
95         msgBox.setDefaultButton(QMessageBox::Ok);
96         msgBox.exec();
97         return;
98     }
99     accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
100     accRealTimeDialog->startAccelerationMeasure();
101     accRealTimeDialog->show();
102 }
103
104 /**
105   * This slot function called when ever category combobox index changed.
106   *
107   * @param int index
108   */
109 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
110 {
111     stopMeasureSpeed = 0;
112     if( index == 1 ) {
113         stopMeasureSpeed = 20;
114         measureCategory = "acceleration-0-20";
115     }
116     else if( index == 2 ) {
117         stopMeasureSpeed = 40;
118         measureCategory = "acceleration-0-40";
119     }
120     else if( index == 3 ) {
121         stopMeasureSpeed = 100;
122         measureCategory = "acceleration-0-100";
123     }
124 }
125
126 /**
127   * Get measure categoty function.
128   *
129   * @return QString measure category
130   */
131 QString accelerationstart::getMeasureCategory()
132 {
133     return measureCategory;
134 }
135
136 /**
137   *This slot function emit mainwindow sendresult.
138   *
139   * @param double result
140   */
141 void accelerationstart::sendResult(double result)
142 {
143     emit sendresult(measureCategory, result);
144 }
145
146 /**
147   * This slot function called when ever info button clicked.
148   */
149 void accelerationstart::on_pushButtonInfo_clicked()
150 {
151     if(!helpAccelerationDialog)
152     {
153         helpAccelerationDialog = new HelpAccelerationDialog;
154     }
155     connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
156     helpAccelerationDialog->show();
157 }
158
159 /**
160   * This slot function called when ever dialog rejected.
161   */
162 void accelerationstart::killHelpDialog()
163 {
164     if(helpAccelerationDialog)
165     {
166         qDebug() << "__Acc kill: helpAccelerationDialog";
167         delete helpAccelerationDialog;
168         helpAccelerationDialog = NULL;
169     }
170 }