Version: 9.12.0
LightApp_ModuleAction Class Reference

An action, representing the list of modules to be inserted to the toolbar. More...

#include <LightApp_ModuleAction.h>

Inheritance diagram for LightApp_ModuleAction:
Inheritance graph

Classes

class  ActionSet
 Internal class to represent list of modules buttons. More...
 
class  ActivateEvent
 Internal class to represent custom event for transfer the activation item id. More...
 
class  ComboAction
 Internal class to represent combo box with the list of modules in the toolbar. More...
 

Public Types

enum  Mode { Buttons = 0x01 , List = 0x02 , AddRemove = 0x04 , All = Buttons | List | AddRemove }
 

Public Slots

void setActiveModule (const QString &)
 Set active module. More...
 

Signals

void moduleActivated (const QString &)
 Emitted when the module is activated. More...
 
void adding ()
 
void removing (const QString &)
 
void showExtInfo ()
 

Public Member Functions

 LightApp_ModuleAction (QtxResourceMgr *, QObject *=0)
 Constructor. More...
 
virtual ~LightApp_ModuleAction ()
 Destructor. More...
 
int count () const
 Get number of registered modules. More...
 
QStringList modules () const
 Get list of modules. More...
 
QIcon moduleIcon (const QString &) const
 Get module icon. More...
 
void setModuleIcon (const QString &, const QIcon &)
 Set module icon. More...
 
QActionmoduleAction (const QString &) const
 Get module action. More...
 
void insertModule (const QString &, const QIcon &, const int=-1)
 Add module into the list. More...
 
void insertModule (const QString &, const QIcon &, bool, const int=-1)
 Add module into the list. More...
 
void removeModule (const QString &)
 Remove module from the list. More...
 
void insertExtension (const QString &)
 Add an installed extension. Now only to the Remove button's menu. More...
 
void removeExtension (const QString &)
 Remove an installed extension. More...
 
void updateExtActions ()
 Update extension actions based on dependencies. More...
 
QString activeModule () const
 Get active module. More...
 
void setMode (const Mode &)
 Set action display mode. More...
 
void setModeEnabled (const Mode &, bool)
 Enable / disable action display mode. More...
 
bool isModeEnabled (const Mode &) const
 Get action display mode. More...
 
- Public Member Functions inherited from QtxAction
 QtxAction (QObject *=0, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QString &, int, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QIcon &, const QString &, int, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QIcon &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
virtual ~QtxAction ()
 Destructor. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Customize action events. More...
 
QString shortcutActionName () const
 Return shortcut action name for the action. More...
 
void setShortcutActionName (const QString &)
 Set shortcut action name to the action. More...
 

Protected Member Functions

virtual void addedTo (QWidget *)
 Called when the action is added to the widget. More...
 
virtual void removedFrom (QWidget *)
 Remove action from widget. More...
 
virtual bool event (QEvent *)
 Perform delayed activation with specified id. More...
 
- Protected Member Functions inherited from QtxAction
virtual void customEvent (QEvent *)
 Process notification events. More...
 

Private Slots

void onChanged ()
 Called when action state is changed. More...
 
void onTriggered (int)
 Called when module button is triggered. More...
 
void onComboActivated (int)
 Called when combo box item is activated. More...
 

Private Member Functions

void update ()
 Update an action. More...
 
void update (QtxComboBox *)
 Update combo box. More...
 
QActionactive () const
 Get an action corresponding to the active module. More...
 
void activate (int, bool=true)
 Activate a module item. More...
 

Private Attributes

ComboActionmyCombo
 
QtxActionmyAdd
 
QtxActionmyRemove
 
QtxActionmyInfo
 
ActionSetmySet
 
QActionmySeparator
 
int myMode
 
QSignalMapper * myMapper
 

Detailed Description

An action, representing the list of modules to be inserted to the toolbar.

In the toolbar this action is represented as the combo box with the list of available modules, and a set of buttons for each module. Additionally, combo box contains an item representing "neutral point" of the application (i.e. no active module).

In menu, the action is represented as a plain list of items, one per module.

Only one module can be active at the moment. It can be set programmatically with setActiveModule() function. Use this method with empty string to turn to the "neutral point". To get active module, use activeModule() function.

When user activates/deactivates a module, the moduleActivated() signal is emitted.

The action also provides an additional separate item "Add modules"; when this button is pressed, a adding() signal is emitted. This signal can be connected to a dedicated slot aimed to dynamically add a new module into the application. In addition, a button "Remove module" shows a dropdown menu with the list of user modules; when any item is selected, the removing() signal is emitted. This signal may be connected to a slot aimed to dynamically remove selected user module from application.

It is possible to customize which elements to show via the setMode() of setModeEnabled() functions. By default, all elements are shown. The following choices are possible:

Member Enumeration Documentation

◆ Mode

Enumerator
Buttons 
List 
AddRemove 
All 

Constructor & Destructor Documentation

◆ LightApp_ModuleAction()

LightApp_ModuleAction::LightApp_ModuleAction ( QtxResourceMgr resMgr,
QObject parent = 0 
)

◆ ~LightApp_ModuleAction()

LightApp_ModuleAction::~LightApp_ModuleAction ( )
virtual

Destructor.

Member Function Documentation

◆ activate()

void LightApp_ModuleAction::activate ( int  id,
bool  fromAction = true 
)
private

Activate a module item.

Parameters
idmodule identifier
fromActiontrue if function is called from the module button

References QtxActionSet::actions(), activeModule(), moduleActivated(), LightApp_ModuleAction::ActionSet::moduleId(), myCombo, mySet, QtxComboBox::setCurrentId(), and LightApp_ModuleAction::ComboAction::widgets().

◆ active()

QAction * LightApp_ModuleAction::active ( ) const
private

Get an action corresponding to the active module.

Returns
active module action or 0 if there is no active module

References QtxActionSet::actions(), and mySet.

◆ activeModule()

QString LightApp_ModuleAction::activeModule ( ) const

Get active module.

If there is no active module ("neutral point"), then the null string is returned.

Returns
active module name
See also
setActiveModule()

References active().

◆ addedTo()

void LightApp_ModuleAction::addedTo ( QWidget w)
protectedvirtual

Called when the action is added to the widget.

Parameters
wwidget (not used)

Reimplemented from QtxAction.

References myAdd, myCombo, myInfo, myRemove, mySeparator, mySet, and update().

◆ adding

void LightApp_ModuleAction::adding ( )
signal

◆ count()

int LightApp_ModuleAction::count ( ) const

Get number of registered modules.

Returns
modules count

References modules().

◆ event()

bool LightApp_ModuleAction::event ( QEvent e)
protectedvirtual

Perform delayed activation with specified id.

Parameters
ecustom event
Returns
true if the event was processed successfully and false otherwise.

References activate().

◆ insertExtension()

void LightApp_ModuleAction::insertExtension ( const QString &  name)

Add an installed extension. Now only to the Remove button's menu.

Parameters
namean extension's name
See also
removeExtension()

References myMapper, and myRemove.

◆ insertModule() [1/2]

void LightApp_ModuleAction::insertModule ( const QString &  name,
const QIcon &  ico,
bool  isCustom,
const int  idx = -1 
)

Add module into the list.

Parameters
namemodule name
icomodule icon
isCustomfalse to insert regular module, true to insert user module
idxposition in the module list (if -1, the module is added to the end of list)
See also
removeModule()

References QtxActionSet::insertAction(), mySet, QtxAction::QtxAction(), and update().

◆ insertModule() [2/2]

void LightApp_ModuleAction::insertModule ( const QString &  name,
const QIcon &  ico,
const int  idx = -1 
)

Add module into the list.

Parameters
namemodule name
icomodule icon
idxposition in the module list (if -1, the module is added to the end of list)
See also
removeModule()

◆ isModeEnabled()

bool LightApp_ModuleAction::isModeEnabled ( const Mode mode) const

Get action display mode.

Parameters
modeaction display mode
See also
setMode()

References myMode.

◆ moduleAction()

QAction * LightApp_ModuleAction::moduleAction ( const QString &  name) const

Get module action.

Parameters
namemodule name

References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.

◆ moduleActivated

void LightApp_ModuleAction::moduleActivated ( const QString &  name)
signal

Emitted when the module is activated.

Parameters
namemodule name (empty string for neutral point)

◆ moduleIcon()

QIcon LightApp_ModuleAction::moduleIcon ( const QString &  name) const

Get module icon.

Parameters
namemodule name
Returns
module icon
See also
setModuleIcon()

References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.

◆ modules()

QStringList LightApp_ModuleAction::modules ( ) const

Get list of modules.

Returns
modules names list

References QtxActionSet::actions(), and mySet.

◆ onChanged

void LightApp_ModuleAction::onChanged ( )
privateslot

Called when action state is changed.

This slot is used to prevent making the parent action visible.

◆ onComboActivated

void LightApp_ModuleAction::onComboActivated ( int  id)
privateslot

Called when combo box item is activated.

Parameters
idmodule identifier

◆ onTriggered

void LightApp_ModuleAction::onTriggered ( int  id)
privateslot

Called when module button is triggered.

Parameters
idmodule identifier

References activate().

◆ removedFrom()

void LightApp_ModuleAction::removedFrom ( QWidget w)
protectedvirtual

Remove action from widget.

Parameters
wwidget (menu or toolbar)
Returns
true if the action is removed successfully and false otherwise.
See also
addTo()

Reimplemented from QtxAction.

References myAdd, myCombo, myInfo, myRemove, mySeparator, and mySet.

◆ removeExtension()

void LightApp_ModuleAction::removeExtension ( const QString &  name)

Remove an installed extension.

Parameters
namean extension's name
See also
insertExtension()

References myRemove, update(), and updateExtActions().

◆ removeModule()

void LightApp_ModuleAction::removeModule ( const QString &  name)

Remove module from the list.

Parameters
namemodule name
See also
insertModule()

References LightApp_ModuleAction::ActionSet::moduleId(), mySet, QtxActionSet::removeAction(), and update().

◆ removing

void LightApp_ModuleAction::removing ( const QString &  )
signal

◆ setActiveModule

void LightApp_ModuleAction::setActiveModule ( const QString &  name)
slot

Set active module.

To turn to the "neutral point" (no active module), pass empty string.

Parameters
namenew active module name
See also
activeModule()

References activate(), activeModule(), LightApp_ModuleAction::ActionSet::moduleId(), and mySet.

◆ setMode()

void LightApp_ModuleAction::setMode ( const Mode mode)

Set action display mode.

Parameters
modeaction display options (combination of flags)
See also
mode()

References myMode, and update().

◆ setModeEnabled()

void LightApp_ModuleAction::setModeEnabled ( const Mode mode,
bool  enabled 
)

Enable / disable action display mode.

Parameters
modeaction display options (combination of flags)
enabledtrue to enable mode, false to disable mode
See also
mode()

References myMode, and update().

◆ setModuleIcon()

void LightApp_ModuleAction::setModuleIcon ( const QString &  name,
const QIcon &  ico 
)

Set module icon.

Parameters
namemodule name
iconew module icon
See also
moduleIcon()

References LightApp_ModuleAction::ActionSet::moduleAction(), mySet, and update().

◆ showExtInfo

void LightApp_ModuleAction::showExtInfo ( )
signal

◆ update() [1/2]

void LightApp_ModuleAction::update ( )
private

◆ update() [2/2]

void LightApp_ModuleAction::update ( QtxComboBox cb)
private

◆ updateExtActions()

void LightApp_ModuleAction::updateExtActions ( )

Update extension actions based on dependencies.

Parameters

References myRemove.

Member Data Documentation

◆ myAdd

QtxAction* LightApp_ModuleAction::myAdd
private

◆ myCombo

ComboAction* LightApp_ModuleAction::myCombo
private

◆ myInfo

QtxAction* LightApp_ModuleAction::myInfo
private

◆ myMapper

QSignalMapper* LightApp_ModuleAction::myMapper
private

◆ myMode

int LightApp_ModuleAction::myMode
private

◆ myRemove

QtxAction* LightApp_ModuleAction::myRemove
private

◆ mySeparator

QAction* LightApp_ModuleAction::mySeparator
private

◆ mySet

ActionSet* LightApp_ModuleAction::mySet
private

The documentation for this class was generated from the following files: