mirror-chatterino2/widgets/signallabel.h

51 lines
917 B
C
Raw Normal View History

2017-01-18 14:48:42 +01:00
#ifndef SIGNALLABEL_H
#define SIGNALLABEL_H
#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-01-20 06:10:28 +01:00
virtual void
mouseDoubleClickEvent(QMouseEvent *ev) override
{
2017-01-18 14:48:42 +01:00
emit this->mouseDoubleClick(ev);
}
2017-01-20 06:10:28 +01:00
virtual void
mousePressEvent(QMouseEvent *event) override
{
if (event->button() == Qt::LeftButton) {
emit mouseDown();
}
}
void
mouseReleaseEvent(QMouseEvent *event) override
{
if (event->button() == Qt::LeftButton) {
emit mouseUp();
}
}
2017-01-18 14:48:42 +01:00
};
2017-01-20 06:10:28 +01:00
#endif // SIGNALLABEL_H