ImFusion SDK 4.3
PopupMenuButton Class Reference

#include <ImFusion/GUI/PopupMenuButton.h>

Extension of a QToolButton to which you can add a drop-down menu. More...

+ Inheritance diagram for PopupMenuButton:

Detailed Description

Extension of a QToolButton to which you can add a drop-down menu.

This is a mixture of a combo box and a button on a single widget. When toggling the drop down menu the user can select one of the available menu entries, which is executed directly. Furthermore, the widget saves the last selected entry and will show this as default action, which is executed when clicking on the main part of the button.

To the outside, menu entries (actions) are identified by a simple string. There is no duplicate detection of action IDs implemented in this class.

Signals

void actionTriggered (QString actionId)
 Signal emitted every time button is clicked or one of the menu entries is selected.
 

Public Member Functions

 PopupMenuButton (const QString &storageId, QWidget *parent=nullptr)
 Creates a new PopupMenuButton using the.
 
 ~PopupMenuButton () override
 Default destructor.
 
void addAction (const QString &title, const QString &actionId, bool setAsDefaultAction=false)
 Add an action to the drop down menu of this button.
 
void setActionEnabled (const QString &actionId, bool enabledState)
 Sets the enabled state of the given action.
 
const QString & currentActionId () const
 Return the ID of the currently selected default action.
 

Protected Slots

virtual void onAction (bool)
 

Protected Member Functions

void storeDefault (const QString &id)
 
QString retrieveDefault () const
 

Protected Attributes

QMenu * m_menu
 
std::map< QAction *, QString > m_actions
 
QString m_storageId
 
QString m_currentActionId
 

Constructor & Destructor Documentation

◆ PopupMenuButton()

PopupMenuButton ( const QString & storageId,
QWidget * parent = nullptr )

Creates a new PopupMenuButton using the.

Parameters
storageIdString to use as key for storing the default action in QSettings If storageId is empty, the selected default action will not be written to QSettings.
parentParent widget

Member Function Documentation

◆ addAction()

void addAction ( const QString & title,
const QString & actionId,
bool setAsDefaultAction = false )

Add an action to the drop down menu of this button.

Parameters
titleText that is shown in the menu for this item.
actionIdString ID to reference this action.
setAsDefaultActionFlag whether to use this action as default entry.

◆ setActionEnabled()

void setActionEnabled ( const QString & actionId,
bool enabledState )

Sets the enabled state of the given action.

Parameters
actionIdString ID of the action to modify
enabledStateEnabled state of the corresponding action

◆ actionTriggered

void actionTriggered ( QString actionId)
signal

Signal emitted every time button is clicked or one of the menu entries is selected.

Parameters
actionIdString ID of the selected action as provided in addAction().

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close