Move signallabel code out from its header

This commit is contained in:
Rasmus Karlsson 2018-03-30 14:39:33 +02:00
parent 89d7b7db87
commit 1c7f397f1b
3 changed files with 42 additions and 33 deletions

View file

@ -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 \

View file

@ -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();
}

View file

@ -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;
};