#include <QDBusPendingReply>
#define kFilteringFactor 0.2
-#define kIterations 1024
+#define kIterations 100
/**
* Default constructor for Accelerometer class
if(!resultDialog)
{
resultDialog = new ResultDialog(this);
+ connect(resultDialog, SIGNAL(rejected()), this, SLOT(killResultDialog()));
+ connect(resultDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
}
- connect(resultDialog, SIGNAL(sendresult(double)), this, SLOT(sendResult(double)));
- resultDialog->setEnd(stopMeasureSpeed);
-
- //Put all times from all speeds
- QMap<int,double> tempMap = calculate->getValuesMap();
-
- for( int i = 1 ; i <= tempMap.count() ; i++ )
+ if(resultDialog)
{
- resultDialog->setValue(i*10,tempMap[i*10]);
+ resultDialog->setEnd(stopMeasureSpeed);
+ //Put all times from all speeds
+ QMap<int,double> tempMap = calculate->getValuesMap();
+
+ for( int i = 1 ; i <= tempMap.count() ; i++ )
+ {
+ resultDialog->setValue(i*10,tempMap[i*10]);
+ }
+ resultDialog->show();
+ this->hide();
}
- resultDialog->show();
- this->hide();
}
}
{
emit sendresult(result);
}
+
+/**
+ *This slot function kills resultDialog.
+ *
+ **/
+void AccRealTimeDialog::killResultDialog()
+{
+ if(resultDialog)
+ {
+ delete resultDialog;
+ resultDialog = NULL;
+ }
+}
void on_buttonAbort_clicked();
void readAccelerometerData();
void sendResult(double);
+ void killResultDialog();
signals:
void sendresult(double);
--- /dev/null
+/*
+ * Custom button class for customized button.
+ *
+ * @author Jukka Kurttila <jktla@suomi24.fi>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#include "custombutton.h"
+
+#include <QPainter>
+#include <QIcon>
+
+/**
+ *Constructor of this class.
+ */
+CustomButton::CustomButton(QWidget *parent, QIcon *icon) : QWidget(parent)
+{
+ bPressed = false;
+ if( icon )
+ {
+ pict1 = new QPixmap(icon->pixmap(125,125,QIcon::Normal,QIcon::On));
+ pict2 = new QPixmap(icon->pixmap(125,125,QIcon::Normal,QIcon::Off));
+ }
+}
+/**
+ *Destructor of this class.
+ */
+CustomButton::~CustomButton()
+{
+ if(!pict1)
+ delete pict1;
+ if(!pict2)
+ delete pict2;
+}
+
+void CustomButton::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+
+ if(!bPressed)
+ painter.drawPixmap(0,0,*pict2);
+ else
+ painter.drawPixmap(0,0,*pict1);
+
+ //Debug print
+ //painter.drawText(50,50,"y: "+QString::number(mY));
+}
+void CustomButton::mousePressEvent(QMouseEvent* me)
+{
+ bPressed = true;
+ repaint();
+}
+void CustomButton::mouseReleaseEvent(QMouseEvent* me)
+{
+ mX = me->x();
+ mY = me->y();
+ //Emit open dialog signal if mouse is still over button
+ if( mY < this->height() && mY > 0 && mX < this->width() && mX > 0 )
+ emit OpenDialog();
+
+ bPressed = false;
+ repaint();
+}
+void CustomButton::mouseMoveEvent(QMouseEvent* me)
+{
+ mX = me->x();
+ mY = me->y();
+ //Is mouse moved outside button?
+ if( mY > this->height() || mY < 0 || mX > this->width() || mX < 0 )
+ bPressed = false;
+ else
+ bPressed = true;
+ repaint();
+}
--- /dev/null
+/*
+ * Custom button class for customized button.
+ *
+ * @author Jukka Kurttila <jktla@suomi24.fi>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#ifndef CUSTOMBUTTON_H
+#define CUSTOMBUTTON_H
+
+#include <QPushButton>
+#include <QPixmap>
+#include <QMouseEvent>
+
+class CustomButton : public QWidget
+{
+ Q_OBJECT
+public:
+ CustomButton(QWidget *parent = 0, QIcon* iconParam = 0);
+ ~CustomButton();
+
+signals:
+ void OpenDialog();
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent* me);
+ void mouseReleaseEvent(QMouseEvent* me);
+ void mouseMoveEvent(QMouseEvent* me);
+
+private:
+ QPixmap* pict1;
+ QPixmap* pict2;
+ bool bPressed;
+ int mX,mY;
+};
+
+#endif // CUSTOMBUTTON_H
ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
ui->pushButtonCredits->setAutoFillBackground(true);
ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ /*
+ QIcon* icon = new QIcon();
+ icon->addFile(QString(":/new/prefix1/Graphics/Speedometer.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
+ icon->addFile(QString(":/new/prefix1/Graphics/Speedometer2.png"), QSize(125,125), QIcon::Normal, QIcon::On);
+
+ customButtonAccelerate = new CustomButton(this,icon);
+ delete icon;
+
+ int buttons_x = 50,buttons_y = 165;
+ customButtonAccelerate->setGeometry(buttons_x,buttons_y,130,130);
+ connect(customButtonAccelerate, SIGNAL(OpenDialog()), this, SLOT(OpenAccStartDialog()));
+
+ customButtonAccelerate->show();
+ */
}
MainWindow::~MainWindow()
if(helpDialog)
delete helpDialog;
+/*
+ if(customButtonAccelerate)
+ delete customButtonAccelerate;
+*/
}
void MainWindow::changeEvent(QEvent *e)
if(!helpDialog)
helpDialog = new HelpDialog;
+ connect(helpDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
helpDialog->show();
}
this->setWindowTitle("SpeedFreak - Not logged");
}
}
+/**
+ * This slot function opens acceleration start dialog.
+ */
+void MainWindow::OpenAccStartDialog()
+{
+ if(!accstart)
+ accstart = new accelerationstart(this);
+ connect(accstart, SIGNAL(sendresult(QString, double)), this, SLOT(clientSendResult(QString, double)));
+ connect(accstart, SIGNAL(rejected()), this, SLOT(killDialog()));
+ accstart->show();
+}
#include "routedialog.h"
#include "resultdialog.h"
#include "helpdialog.h"
+#include "custombutton.h"
namespace Ui {
Ui::MainWindow *ui;
void setListViewTopList(QString category, int size);
+ CustomButton* customButtonAccelerate;
+
private slots:
void on_pushButtonResults_clicked();
void on_pushButtonAccelerate_clicked();
void showTop10();
void killDialog();
void setUsernameToMainPanel();
+ void OpenAccStartDialog();
};
}
resultString = "";
this->close();
+ emit rejected();
}
/**
/*!40000 ALTER TABLE `categories` DISABLE KEYS */;
INSERT INTO `categories` (`id`,`slug`,`description`,`unit`)
VALUES
- (1,'acceleration-0-10','Acceleration from 0km/h to 100km/h','km/h'),
- (2,'acceleration-0-40','Acceleration from 0km/h to 100km/h','km/h'),
- (3,'acceleration-0-100','Acceleration from 0km/h to 100km/h','km/h');
+ (1,'acceleration-0-10','Acceleration from 0km/h to 10km/h','km/h'),
+ (2,'acceleration-0-40','Acceleration from 0km/h to 40km/h','km/h'),
+ (3,'acceleration-0-100','Acceleration from 0km/h to 100km/h','km/h');
/*!40000 ALTER TABLE `categories` ENABLE KEYS */;
UNLOCK TABLES;