2 * Acceleration start dialog
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
10 #include "accelerationstart.h"
11 #include "ui_accelerationstartdialog.h"
12 #include <QMessageBox>
16 * Constructor of this class.
18 accelerationstart::accelerationstart(QWidget *parent) :
20 ui(new Ui::accelerationstart)
23 ui->buttonStart->setDisabled(true);
25 accRealTimeDialog = NULL;
26 helpAccelerationDialog = NULL;
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");
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)");
45 * Destructor of this class.
46 * Deletes all dynamic objects and sets them to NULL.
48 accelerationstart::~accelerationstart()
52 delete accRealTimeDialog;
58 void accelerationstart::changeEvent(QEvent *e)
60 QDialog::changeEvent(e);
62 case QEvent::LanguageChange:
63 ui->retranslateUi(this);
71 * This slot function called when ever calibration button clicked
73 void accelerationstart::on_buttonCalib_clicked()
75 if(accRealTimeDialog == NULL)
76 accRealTimeDialog = new AccRealTimeDialog(this);
78 connect(accRealTimeDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
80 accRealTimeDialog->Calibrate();
82 ui->buttonStart->setEnabled(true);
86 * This slot function called when ever start button clicked
88 void accelerationstart::on_buttonStart_clicked()
90 if( stopMeasureSpeed == 0 )
93 msgBox.setWindowTitle("Can not start measure!");
94 msgBox.setText("Select category first!");
95 msgBox.setDefaultButton(QMessageBox::Ok);
99 accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
100 accRealTimeDialog->startAccelerationMeasure();
101 accRealTimeDialog->show();
105 * This slot function called when ever category combobox index changed.
109 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
111 stopMeasureSpeed = 0;
113 stopMeasureSpeed = 20;
114 measureCategory = "acceleration-0-20";
116 else if( index == 2 ) {
117 stopMeasureSpeed = 40;
118 measureCategory = "acceleration-0-40";
120 else if( index == 3 ) {
121 stopMeasureSpeed = 100;
122 measureCategory = "acceleration-0-100";
127 * Get measure categoty function.
129 * @return QString measure category
131 QString accelerationstart::getMeasureCategory()
133 return measureCategory;
137 *This slot function emit mainwindow sendresult.
139 * @param double result
141 void accelerationstart::sendResult(double result)
143 emit sendresult(measureCategory, result);
147 * This slot function called when ever info button clicked.
149 void accelerationstart::on_pushButtonInfo_clicked()
151 if(!helpAccelerationDialog)
153 helpAccelerationDialog = new HelpAccelerationDialog;
155 connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
156 helpAccelerationDialog->show();
160 * This slot function called when ever dialog rejected.
162 void accelerationstart::killHelpDialog()
164 if(helpAccelerationDialog)
166 qDebug() << "__Acc kill: helpAccelerationDialog";
167 delete helpAccelerationDialog;
168 helpAccelerationDialog = NULL;