Changeset b86c70a in subsurface


Ignore:
Timestamp:
Dec 26, 2017, 1:08:49 PM (4 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
b6bf57a
Parents:
931947b8
git-author:
Berthold Stoeger <bstoeger@…> (12/24/17 05:34:53)
git-committer:
Dirk Hohndel <dirk@…> (12/26/17 13:08:49)
Message:

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@…>

Location:
desktop-widgets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/listfilter.ui

    r7451517e rb86c70a  
    5252      </widget>
    5353     </item>
    54      <item>
    55       <widget class="QToolButton" name="selectionButton">
    56        <property name="text">
    57         <string>...</string>
    58        </property>
    59        <property name="popupMode">
    60         <enum>QToolButton::InstantPopup</enum>
    61        </property>
    62       </widget>
    63      </item>
    6454    </layout>
    6555   </item>
  • desktop-widgets/simplewidgets.cpp

    reec69de rb86c70a  
    499499}
    500500
     501void FilterBase::addContextMenuEntry(const QString &s, void (FilterModelBase::*fn)())
     502{
     503        QAction *act = new QAction(s, this);
     504        connect(act, &QAction::triggered, model, fn);
     505        ui.filterList->addAction(act);
     506}
     507
    501508FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(parent),
    502509        model(model_)
     
    512519        ui.filterList->setModel(filter);
    513520
    514         QMenu *menu = new QMenu(this);
    515         menu->addAction(tr("Select All"), model, &FilterModelBase::selectAll);
    516         menu->addAction(tr("Unselect All"), model, &FilterModelBase::clearFilter);
    517         menu->addAction(tr("Invert Selection"), model, &FilterModelBase::invertSelection);
    518         ui.selectionButton->setMenu(menu);
     521        addContextMenuEntry(tr("Select All"), &FilterModelBase::selectAll);
     522        addContextMenuEntry(tr("Unselect All"), &FilterModelBase::clearFilter);
     523        addContextMenuEntry(tr("Invert Selection"), &FilterModelBase::invertSelection);
     524        ui.filterList->setContextMenuPolicy(Qt::ActionsContextMenu);
    519525}
    520526
  • desktop-widgets/simplewidgets.h

    r931947b8 rb86c70a  
    168168
    169169class FilterBase : public QWidget {
     170        void addContextMenuEntry(const QString &s, void (FilterModelBase::*)());
    170171protected:
    171172        FilterBase(FilterModelBase *model, QWidget *parent = 0);
Note: See TracChangeset for help on using the changeset viewer.