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
9 #include "accelerationstart.h"
10 #include "ui_accelerationstartdialog.h"
11 #include <QMessageBox>
14 accelerationstart::accelerationstart(QWidget *parent) :
16 ui(new Ui::accelerationstart)
19 ui->buttonStart->setDisabled(true);
21 accRealTimeDialog = NULL;
22 helpAccelerationDialog = NULL;
26 ui->categorComboBox->addItem("Select category");
27 //ui->categorComboBox->addItem("-");
28 ui->categorComboBox->addItem("0 - 20 km/h",20);
29 ui->categorComboBox->addItem("0 - 40 km/h");
30 ui->categorComboBox->addItem("0 - 100 km/h");
33 ui->buttonCalib->setAutoFillBackground(true);
34 ui->buttonCalib->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
35 ui->buttonStart->setAutoFillBackground(true);
36 ui->buttonStart->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
37 ui->pushButtonInfo->setAutoFillBackground(true);
38 ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
41 accelerationstart::~accelerationstart()
45 delete accRealTimeDialog;
48 void accelerationstart::changeEvent(QEvent *e)
50 QDialog::changeEvent(e);
52 case QEvent::LanguageChange:
53 ui->retranslateUi(this);
60 void accelerationstart::on_buttonCalib_clicked()
62 if(accRealTimeDialog == NULL)
63 accRealTimeDialog = new AccRealTimeDialog(this);
65 connect(accRealTimeDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
67 accRealTimeDialog->Calibrate();
69 ui->buttonStart->setEnabled(true);
72 void accelerationstart::on_buttonStart_clicked()
74 if( stopMeasureSpeed == 0 )
77 msgBox.setWindowTitle("Can not start measure!");
78 msgBox.setText("Select category first!");
79 msgBox.setDefaultButton(QMessageBox::Ok);
83 accRealTimeDialog->SetStopMeasureSpeed( stopMeasureSpeed );
84 accRealTimeDialog->startAccelerationMeasure();
85 accRealTimeDialog->show();
88 void accelerationstart::on_categorComboBox_currentIndexChanged( int index )
92 stopMeasureSpeed = 20;
93 measureCategory = "acceleration-0-20";
95 else if( index == 2 ) {
96 stopMeasureSpeed = 40;
97 measureCategory = "acceleration-0-40";
99 else if( index == 3 ) {
100 stopMeasureSpeed = 100;
101 measureCategory = "acceleration-0-100";
106 QString accelerationstart::getMeasureCategory()
108 return measureCategory;
112 *This slot function emit mainwindow sendresult.
115 void accelerationstart::sendResult(double result)
117 emit sendresult(measureCategory, result);
121 * This slot function called when ever info button clicked.
123 void accelerationstart::on_pushButtonInfo_clicked()
125 if(!helpAccelerationDialog)
127 helpAccelerationDialog = new HelpAccelerationDialog;
129 connect(helpAccelerationDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
130 helpAccelerationDialog->show();
134 * This slot function called when ever dialog rejected.
136 void accelerationstart::killHelpDialog()
138 if(helpAccelerationDialog)
140 qDebug() << "__Acc kill: helpAccelerationDialog";
141 delete helpAccelerationDialog;
142 helpAccelerationDialog = NULL;