Don't switch pages when right-clicking on list

pull/216/head
PlutonicOverkill 8 years ago
parent 7281e8b888
commit 5ec97811d8

@ -2,6 +2,7 @@
#include <QMenu> #include <QMenu>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMouseEvent>
#include "../../model/prefs/state.hpp" #include "../../model/prefs/state.hpp"
@ -21,6 +22,17 @@ void CSVPrefs::ContextMenuList::contextMenuEvent(QContextMenuEvent* e)
delete menu; 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() void CSVPrefs::ContextMenuList::resetCategory()
{ {
CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString()); CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString());

@ -4,6 +4,7 @@
#include <QListWidget> #include <QListWidget>
class QContextMenuEvent; class QContextMenuEvent;
class QMouseEvent;
namespace CSVPrefs namespace CSVPrefs
{ {
@ -19,6 +20,8 @@ namespace CSVPrefs
void contextMenuEvent(QContextMenuEvent* e); void contextMenuEvent(QContextMenuEvent* e);
void mousePressEvent(QMouseEvent* e);
private slots: private slots:
void resetCategory(); void resetCategory();

Loading…
Cancel
Save