From 5ec97811d88f21a191ff09a57e029aeee3991b7f Mon Sep 17 00:00:00 2001 From: PlutonicOverkill Date: Fri, 12 May 2017 20:22:18 +1200 Subject: [PATCH] Don't switch pages when right-clicking on list --- apps/opencs/view/prefs/contextmenulist.cpp | 12 ++++++++++++ apps/opencs/view/prefs/contextmenulist.hpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/apps/opencs/view/prefs/contextmenulist.cpp b/apps/opencs/view/prefs/contextmenulist.cpp index 71527d8c6a..8115c3ecc5 100644 --- a/apps/opencs/view/prefs/contextmenulist.cpp +++ b/apps/opencs/view/prefs/contextmenulist.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "../../model/prefs/state.hpp" @@ -21,6 +22,17 @@ void CSVPrefs::ContextMenuList::contextMenuEvent(QContextMenuEvent* e) delete menu; } +void CSVPrefs::ContextMenuList::mousePressEvent(QMouseEvent* e) +{ + // enable all buttons except right click + // This means that when right-clicking to enable the + // context menu, the page doesn't switch at the same time. + if (!(e->buttons() & Qt::RightButton)) + { + QListWidget::mousePressEvent(e); + } +} + void CSVPrefs::ContextMenuList::resetCategory() { CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString()); diff --git a/apps/opencs/view/prefs/contextmenulist.hpp b/apps/opencs/view/prefs/contextmenulist.hpp index 222cfea6bb..6aa187ca42 100644 --- a/apps/opencs/view/prefs/contextmenulist.hpp +++ b/apps/opencs/view/prefs/contextmenulist.hpp @@ -4,6 +4,7 @@ #include class QContextMenuEvent; +class QMouseEvent; namespace CSVPrefs { @@ -18,6 +19,8 @@ namespace CSVPrefs protected: void contextMenuEvent(QContextMenuEvent* e); + + void mousePressEvent(QMouseEvent* e); private slots: