diff --git a/chatterino.pro b/chatterino.pro index c3dc988f2..b7c10c64b 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -177,7 +177,8 @@ SOURCES += \ src/providers/irc/ircserver.cpp \ src/providers/irc/ircchannel2.cpp \ src/util/streamlink.cpp \ - src/providers/twitch/twitchhelpers.cpp + src/providers/twitch/twitchhelpers.cpp \ + src/widgets/helper/signallabel.cpp HEADERS += \ src/precompiled_header.hpp \ diff --git a/src/widgets/helper/signallabel.cpp b/src/widgets/helper/signallabel.cpp new file mode 100644 index 000000000..c7bb87940 --- /dev/null +++ b/src/widgets/helper/signallabel.cpp @@ -0,0 +1,34 @@ +#include "widgets/helper/signallabel.hpp" + +SignalLabel::SignalLabel(QWidget *parent, Qt::WindowFlags f) + : QLabel(parent, f) +{ +} + +void SignalLabel::mouseDoubleClickEvent(QMouseEvent *ev) +{ + emit this->mouseDoubleClick(ev); +} + +void SignalLabel::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + emit mouseDown(); + } + + event->ignore(); +} + +void SignalLabel::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + emit mouseUp(); + } + + event->ignore(); +} + +void SignalLabel::mouseMoveEvent(QMouseEvent *event) +{ + event->ignore(); +} diff --git a/src/widgets/helper/signallabel.hpp b/src/widgets/helper/signallabel.hpp index e479b5695..513fdbabc 100644 --- a/src/widgets/helper/signallabel.hpp +++ b/src/widgets/helper/signallabel.hpp @@ -10,11 +10,8 @@ class SignalLabel : public QLabel Q_OBJECT public: - explicit SignalLabel(QWidget *parent = 0, Qt::WindowFlags f = 0) - : QLabel(parent, f) - { - } - virtual ~SignalLabel() = default; + explicit SignalLabel(QWidget *parent = nullptr, Qt::WindowFlags f = 0); + ~SignalLabel() override = default; signals: void mouseDoubleClick(QMouseEvent *ev); @@ -23,31 +20,8 @@ signals: void mouseUp(); protected: - virtual void mouseDoubleClickEvent(QMouseEvent *ev) override - { - emit this->mouseDoubleClick(ev); - } - - virtual void mousePressEvent(QMouseEvent *event) override - { - if (event->button() == Qt::LeftButton) { - emit mouseDown(); - } - - event->ignore(); - } - - void mouseReleaseEvent(QMouseEvent *event) override - { - if (event->button() == Qt::LeftButton) { - emit mouseUp(); - } - - event->ignore(); - } - - virtual void mouseMoveEvent(QMouseEvent *event) override - { - event->ignore(); - } + void mouseDoubleClickEvent(QMouseEvent *ev) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; };