mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Turn filter list options into context menu
Let the menu introduced in commit 5e86442bab
pop up on right-click instead of button-click.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
931947b852
commit
b86c70ab2c
3 changed files with 12 additions and 15 deletions
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue