mirror-chatterino2/src/widgets/helper/signallabel.hpp

54 lines
999 B
C++
Raw Normal View History

#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();
}
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();
}
event->ignore();
}
2017-04-12 17:46:44 +02:00
virtual void mouseMoveEvent(QMouseEvent *event) override
{
event->ignore();
2017-01-20 06:10:28 +01:00
}
2017-01-18 14:48:42 +01:00
};