summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-12-24 14:34:53 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-26 13:08:49 -0800
commitb86c70ab2ce91c46355a71008334aa6743caa1e6 (patch)
tree6d734882c16b18b7d913da1dd683b5f70ba32398
parent931947b852aaa25e62715f2d8d275c0bd47fa3d5 (diff)
downloadsubsurface-b86c70ab2ce91c46355a71008334aa6743caa1e6.tar.gz
Turn filter list options into context menu
Let the menu introduced in commit 5e86442bab680b79fbd3cd490091ab9f14252e94 pop up on right-click instead of button-click. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/listfilter.ui10
-rw-r--r--desktop-widgets/simplewidgets.cpp16
-rw-r--r--desktop-widgets/simplewidgets.h1
3 files changed, 12 insertions, 15 deletions
diff --git a/desktop-widgets/listfilter.ui b/desktop-widgets/listfilter.ui
index dcdcd932e..48d813d21 100644
--- a/desktop-widgets/listfilter.ui
+++ b/desktop-widgets/listfilter.ui
@@ -51,16 +51,6 @@
</property>
</widget>
</item>
- <item>
- <widget class="QToolButton" name="selectionButton">
- <property name="text">
- <string>...</string>
- </property>
- <property name="popupMode">
- <enum>QToolButton::InstantPopup</enum>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index 167d3db1a..b63349819 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -498,6 +498,13 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
}
}
+void FilterBase::addContextMenuEntry(const QString &s, void (FilterModelBase::*fn)())
+{
+ QAction *act = new QAction(s, this);
+ connect(act, &QAction::triggered, model, fn);
+ ui.filterList->addAction(act);
+}
+
FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(parent),
model(model_)
{
@@ -511,11 +518,10 @@ FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(paren
connect(ui.filterInternalList, SIGNAL(textChanged(QString)), filter, SLOT(setFilterFixedString(QString)));
ui.filterList->setModel(filter);
- QMenu *menu = new QMenu(this);
- menu->addAction(tr("Select All"), model, &FilterModelBase::selectAll);
- menu->addAction(tr("Unselect All"), model, &FilterModelBase::clearFilter);
- menu->addAction(tr("Invert Selection"), model, &FilterModelBase::invertSelection);
- ui.selectionButton->setMenu(menu);
+ addContextMenuEntry(tr("Select All"), &FilterModelBase::selectAll);
+ addContextMenuEntry(tr("Unselect All"), &FilterModelBase::clearFilter);
+ addContextMenuEntry(tr("Invert Selection"), &FilterModelBase::invertSelection);
+ ui.filterList->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void FilterBase::showEvent(QShowEvent *event)
diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h
index 294fe26cf..fdaa4587e 100644
--- a/desktop-widgets/simplewidgets.h
+++ b/desktop-widgets/simplewidgets.h
@@ -167,6 +167,7 @@ public:
};
class FilterBase : public QWidget {
+ void addContextMenuEntry(const QString &s, void (FilterModelBase::*)());
protected:
FilterBase(FilterModelBase *model, QWidget *parent = 0);
FilterModelBase *model;