2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-18 14:48:42 +01:00
|
|
|
|
|
|
|
#include <QFlags>
|
|
|
|
#include <QLabel>
|
2017-01-20 06:10:28 +01:00
|
|
|
#include <QMouseEvent>
|
2017-01-18 14:48:42 +01:00
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class SignalLabel : public QLabel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-01-20 06:10:28 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
public:
|
|
|
|
explicit SignalLabel(QWidget *parent = 0, Qt::WindowFlags f = 0)
|
2017-01-20 06:10:28 +01:00
|
|
|
: QLabel(parent, f)
|
|
|
|
{
|
|
|
|
}
|
2017-01-18 14:48:42 +01:00
|
|
|
virtual ~SignalLabel() = default;
|
2017-01-20 06:10:28 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
signals:
|
|
|
|
void mouseDoubleClick(QMouseEvent *ev);
|
2017-01-20 06:10:28 +01:00
|
|
|
|
|
|
|
void mouseDown();
|
|
|
|
void mouseUp();
|
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
protected:
|
2017-04-12 17:46:44 +02:00
|
|
|
virtual void mouseDoubleClickEvent(QMouseEvent *ev) override
|
2017-01-20 06:10:28 +01:00
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
emit this->mouseDoubleClick(ev);
|
|
|
|
}
|
2017-01-20 06:10:28 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
virtual void mousePressEvent(QMouseEvent *event) override
|
2017-01-20 06:10:28 +01:00
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
|
|
|
emit mouseDown();
|
|
|
|
}
|
2017-01-22 05:58:23 +01:00
|
|
|
|
|
|
|
event->ignore();
|
2017-01-20 06:10:28 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override
|
2017-01-20 06:10:28 +01:00
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
|
|
|
emit mouseUp();
|
|
|
|
}
|
2017-01-22 05:58:23 +01:00
|
|
|
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
virtual void mouseMoveEvent(QMouseEvent *event) override
|
2017-01-22 05:58:23 +01:00
|
|
|
{
|
|
|
|
event->ignore();
|
2017-01-20 06:10:28 +01:00
|
|
|
}
|
2017-01-18 14:48:42 +01:00
|
|
|
};
|