summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2020-11-19 21:07:47 +0100
committerDaniel Schürmann <daschuer@mixxx.org>2020-11-19 21:07:47 +0100
commita989e9a764eb8e662deb7b720b4cdbe3bc6a2af6 (patch)
tree905d52f99ca8d6e3dbc89e298d8fd04f1308189d
parenta76433f45f2d87c2dfedb23181940582370d5491 (diff)
Avoid hotcue buttons from being stucked in the pressed state
-rw-r--r--src/widget/whotcuebutton.cpp15
-rw-r--r--src/widget/whotcuebutton.h1
-rw-r--r--src/widget/wpushbutton.cpp14
3 files changed, 30 insertions, 0 deletions
diff --git a/src/widget/whotcuebutton.cpp b/src/widget/whotcuebutton.cpp
index 667984c40e..c78b131c6c 100644
--- a/src/widget/whotcuebutton.cpp
+++ b/src/widget/whotcuebutton.cpp
@@ -83,6 +83,12 @@ void WHotcueButton::setup(const QDomNode& node, const SkinContext& context) {
void WHotcueButton::mousePressEvent(QMouseEvent* e) {
const bool rightClick = e->button() == Qt::RightButton;
if (rightClick) {
+ if (isPressed()) {
+ // Discard right clicks when already left clicked.
+ // Otherwise the pop up menu receives the release event and the
+ // button stucks in the pressed stage.
+ return;
+ }
if (readDisplayValue() == 1) {
// hot cue is set
TrackPointer pTrack = PlayerInfo::instance().getTrackInfo(m_group);
@@ -116,6 +122,15 @@ void WHotcueButton::mousePressEvent(QMouseEvent* e) {
WPushButton::mousePressEvent(e);
}
+void WHotcueButton::mouseReleaseEvent(QMouseEvent* e) {
+ const bool rightClick = e->button() == Qt::RightButton;
+ if (rightClick) {
+ // Don't handle stray release events
+ return;
+ }
+ WPushButton::mouseReleaseEvent(e);
+}
+
ConfigKey WHotcueButton::createConfigKey(const QString& name) {
ConfigKey key;
key.group = m_group;
diff --git a/src/widget/whotcuebutton.h b/src/widget/whotcuebutton.h
index d7a3d218d4..1f3ecd7bdb 100644
--- a/src/widget/whotcuebutton.h
+++ b/src/widget/whotcuebutton.h
@@ -21,6 +21,7 @@ class WHotcueButton : public WPushButton {
protected:
void mousePressEvent(QMouseEvent* e) override;
+ void mouseReleaseEvent(QMouseEvent* e) override;
void restyleAndRepaint() override;
private slots:
diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp
index dface204ba..7233d954fb 100644
--- a/src/widget/wpushbutton.cpp
+++ b/src/widget/wpushbutton.cpp
@@ -436,6 +436,20 @@ bool WPushButton::event(QEvent* e) {
m_bHovered = true;
restyleAndRepaint();
} else if (e->type() == QEvent::Leave) {
+ if (m_bPressed) {
+ // A Leave event is send instead of a mouseReleaseEvent()
+ // fake it to get not stucked in pressed state
+ QMouseEvent mouseEvent = QMouseEvent(
+ QEvent::MouseButtonRelease,
+ QPointF(),
+ QPointF(),
+ QPointF(),
+ Qt::LeftButton,
+ Qt::NoButton,
+ 0,
+ Qt::MouseEventSynthesizedByApplication);
+ mouseReleaseEvent(&mouseEvent);
+ }
m_bHovered = false;
restyleAndRepaint();
}