Browse Source

thermostat: zoneitem: implement long_clicked signal

master
Richard Genoud 5 years ago
parent
commit
3e33972288
2 changed files with 18 additions and 2 deletions
  1. +4
    -0
      soft/thermostat/inc/zoneitem.h
  2. +14
    -2
      soft/thermostat/src/zoneitem.cpp

+ 4
- 0
soft/thermostat/inc/zoneitem.h View File

@ -11,6 +11,7 @@
#include <QObject>
#include <QLabel>
#include <QElapsedTimer>
#include "boost_dlg.h"
@ -34,9 +35,12 @@ public:
signals:
void clicked();
void long_clicked();
protected:
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
QElapsedTimer m_click_chrono;
};
#endif // ZONEITEM_H


+ 14
- 2
soft/thermostat/src/zoneitem.cpp View File

@ -46,9 +46,21 @@ ZoneItem::~ZoneItem()
{
}
void ZoneItem::mousePressEvent(QMouseEvent* event)
{
Q_UNUSED(event);
m_click_chrono.start();
}
void ZoneItem::mouseReleaseEvent(QMouseEvent* event) {
(void)event;
emit clicked();
Q_UNUSED(event);
if (m_click_chrono.elapsed() > 1000) {
emit long_clicked();
} else {
emit clicked();
}
}
void ZoneItem::refresh(void)


Loading…
Cancel
Save