From 9fd7c271e4911674dabdc13a94deb9992f263ae6 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 5 Oct 2015 22:41:20 +0200 Subject: [PATCH] ToolButton: Fix showing both context menu and button menu on right click --- src/lib/tools/toolbutton.cpp | 9 +++++++++ src/lib/tools/toolbutton.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/lib/tools/toolbutton.cpp b/src/lib/tools/toolbutton.cpp index 2ac983814..ff25df97f 100644 --- a/src/lib/tools/toolbutton.cpp +++ b/src/lib/tools/toolbutton.cpp @@ -203,6 +203,15 @@ void ToolButton::mouseDoubleClickEvent(QMouseEvent* e) } } +void ToolButton::contextMenuEvent(QContextMenuEvent *e) +{ + // Block to prevent showing both context menu and button menu + if (menu()) + return; + + QToolButton::contextMenuEvent(e); +} + void ToolButton::paintEvent(QPaintEvent* e) { if (!(m_options & MultiIconOption)) { diff --git a/src/lib/tools/toolbutton.h b/src/lib/tools/toolbutton.h index 07fabd058..9e31d7048 100644 --- a/src/lib/tools/toolbutton.h +++ b/src/lib/tools/toolbutton.h @@ -81,6 +81,7 @@ protected: void mousePressEvent(QMouseEvent* e); void mouseReleaseEvent(QMouseEvent* e); void mouseDoubleClickEvent(QMouseEvent* e); + void contextMenuEvent(QContextMenuEvent *e); void paintEvent(QPaintEvent* e); private: