An action, representing the list of modules to be inserted to the toolbar. More...
#include <LightApp_ModuleAction.h>
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... | |
QAction * | moduleAction (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... | |
QAction * | active () const |
Get an action corresponding to the active module. More... | |
void | activate (int, bool=true) |
Activate a module item. More... | |
Private Attributes | |
ComboAction * | myCombo |
QtxAction * | myAdd |
QtxAction * | myRemove |
QtxAction * | myInfo |
ActionSet * | mySet |
QAction * | mySeparator |
int | myMode |
QSignalMapper * | myMapper |
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:
LightApp_ModuleAction::LightApp_ModuleAction | ( | QtxResourceMgr * | resMgr, |
QObject * | parent = 0 |
||
) |
Constructor.
resMgr | resource manager |
parent | parent object |
References adding(), All, QtxResourceMgr::loadPixmap(), myAdd, myCombo, myInfo, myMapper, myMode, myRemove, mySeparator, mySet, onChanged(), onComboActivated(), onTriggered(), QtxAction::QtxAction(), removing(), and showExtInfo().
|
virtual |
Destructor.
|
private |
Activate a module item.
id | module identifier |
fromAction | true 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().
|
private |
Get an action corresponding to the active module.
References QtxActionSet::actions(), and mySet.
QString LightApp_ModuleAction::activeModule | ( | ) | const |
Get active module.
If there is no active module ("neutral point"), then the null string is returned.
References active().
|
protectedvirtual |
|
signal |
int LightApp_ModuleAction::count | ( | ) | const |
|
protectedvirtual |
Perform delayed activation with specified id.
e | custom event |
true
if the event was processed successfully and false
otherwise. References activate().
void LightApp_ModuleAction::insertExtension | ( | const QString & | name | ) |
Add an installed extension. Now only to the Remove button's menu.
name | an extension's name |
void LightApp_ModuleAction::insertModule | ( | const QString & | name, |
const QIcon & | ico, | ||
bool | isCustom, | ||
const int | idx = -1 |
||
) |
Add module into the list.
name | module name |
ico | module icon |
isCustom | false to insert regular module, true to insert user module |
idx | position in the module list (if -1, the module is added to the end of list) |
References QtxActionSet::insertAction(), mySet, QtxAction::QtxAction(), and update().
void LightApp_ModuleAction::insertModule | ( | const QString & | name, |
const QIcon & | ico, | ||
const int | idx = -1 |
||
) |
Add module into the list.
name | module name |
ico | module icon |
idx | position in the module list (if -1, the module is added to the end of list) |
bool LightApp_ModuleAction::isModeEnabled | ( | const Mode & | mode | ) | const |
QAction * LightApp_ModuleAction::moduleAction | ( | const QString & | name | ) | const |
Get module action.
name | module name |
References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.
|
signal |
Emitted when the module is activated.
name | module name (empty string for neutral point) |
QIcon LightApp_ModuleAction::moduleIcon | ( | const QString & | name | ) | const |
Get module icon.
name | module name |
References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.
QStringList LightApp_ModuleAction::modules | ( | ) | const |
|
privateslot |
Called when action state is changed.
This slot is used to prevent making the parent action visible.
|
privateslot |
Called when combo box item is activated.
id | module identifier |
|
privateslot |
|
protectedvirtual |
void LightApp_ModuleAction::removeExtension | ( | const QString & | name | ) |
Remove an installed extension.
name | an extension's name |
References myRemove, update(), and updateExtActions().
void LightApp_ModuleAction::removeModule | ( | const QString & | name | ) |
Remove module from the list.
name | module name |
References LightApp_ModuleAction::ActionSet::moduleId(), mySet, QtxActionSet::removeAction(), and update().
|
signal |
|
slot |
Set active module.
To turn to the "neutral point" (no active module), pass empty string.
name | new active module name |
References activate(), activeModule(), LightApp_ModuleAction::ActionSet::moduleId(), and mySet.
void LightApp_ModuleAction::setMode | ( | const Mode & | mode | ) |
void LightApp_ModuleAction::setModeEnabled | ( | const Mode & | mode, |
bool | enabled | ||
) |
void LightApp_ModuleAction::setModuleIcon | ( | const QString & | name, |
const QIcon & | ico | ||
) |
Set module icon.
name | module name |
ico | new module icon |
References LightApp_ModuleAction::ActionSet::moduleAction(), mySet, and update().
|
signal |
|
private |
|
private |
Update combo box.
cb | combo box |
References QtxActionSet::actions(), active(), LightApp_ModuleAction::ActionSet::moduleId(), mySet, QtxComboBox::setCurrentId(), and QtxComboBox::setId().
void LightApp_ModuleAction::updateExtActions | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |