Class representing a panel of actions similar to Windows Vista/7 control panel items. More...
#include <actionbox.h>
Public Member Functions | |
ActionBox (const QPixmap &icon, const QString &headerText, QWidget *parent=0) | |
Constructor. More... | |
ActionBox (const QString &headerText, QWidget *parent=0) | |
Constructor. More... | |
ActionBox (QWidget *parent=0) | |
Constructor. More... | |
void | addLayout (QLayout *l) |
Adds layout l to the default layout. More... | |
void | addWidget (QWidget *w, QLayout *l=0) |
Adds widget w to the layout. More... | |
QLayout * | createHBoxLayout () |
Creates empty horizontal layout. More... | |
ActionLabel * | createItem (const QPixmap &icon, const QString &text, QLayout *l=0) |
Adds an action with icon and text to the ActionBox and returns action item. More... | |
ActionLabel * | createItem (const QString &text=QString(), QLayout *l=0) |
Adds an action with text to the ActionBox and returns action item. More... | |
ActionLabel * | createItem (QAction *action, QLayout *l=0) |
Creates action item from the action and returns it. More... | |
QList< ActionLabel * > | createItems (QList< QAction * > actions) |
Creates action items from the actions list and returns the list of action items. More... | |
QSpacerItem * | createSpacer (QLayout *l=0) |
Adds a spacer and returns spacer item. More... | |
ActionLabel * | header () const |
Returns header item of the ActionBox. More... | |
const QPixmap * | icon () const |
Returns icon of the ActionBox. More... | |
QLayout * | itemLayout () const |
Returns default layout used for actions (typically it's QVBoxLayout). More... | |
virtual QSize | minimumSizeHint () const |
void | setIcon (const QPixmap &icon) |
Sets icon of the ActionBox to icon. More... | |
Protected Member Functions | |
void | init () |
Protected Attributes | |
QVBoxLayout * | dataLayout |
ActionLabel * | headerLabel |
QLabel * | iconLabel |
Properties | |
ActionLabel | header |
QPixmap | icon |
Detailed Description
Class representing a panel of actions similar to Windows Vista/7 control panel items.
- Since
- 0.2
ActionBox normally consists of an icon, clickable header and a list of actions. Every action can have own icon as well, provide tooltips and status tips, be clickable and checkable etc. i.e. behave like a normal ActionLabel.
ActionBox objects are easily customizable via CSS technology - you can get different look just by writing corresponding style sheet.
Usage of ActionBox in the application
- Create ActionBox using constructor (or in Designer as Promoted Objects). Icon and header text can be passed to the constructor as well. For example:
- ActionBox header itself is a clickable item (based on ActionLabel), so you can retrieve it and use, for example, to connect with a slot:
- To create an action, use one of createItem() functions. For example:
createItem() also allows to create an ActionLabel from already existing QAction:
- By default, actions are arranged vertically, one per row. In order to have more than one actions in a row, first add horizontal layout item using createHBoxLayout() function, and then pass it to the createItem() to create actions.
- Sometimes you would like to have a spacer between the items. Use createSpacer() function to insert an empty space into default or specified layout.
- You can insert arbitrary layout items and widgets into ActionBox using addLayout() and addWidgets() functions. Please note that ownership of these items transferred to ActionBox, so you must not delete them manually.
Customization of ActionBox via CSS
ActionBox items can be easily customized using CSS mechanism. Just create a new style and apply it to the ActionBox with setStyleSheet().
See the following example of the complete ActionBox customization. Note that QSint–ActionBox is used as a main class name. Headers are ActionLabels with property class='header'. Actions are ActionLabels with property class='action'.
Constructor & Destructor Documentation
◆ ActionBox() [1/3]
|
explicit |
Constructor.
References headerLabel, and init().
◆ ActionBox() [2/3]
|
explicit |
Constructor.
◆ ActionBox() [3/3]
|
explicit |
Constructor.
Member Function Documentation
◆ addLayout()
void QSint::ActionBox::addLayout | ( | QLayout * | l | ) |
Adds layout l to the default layout.
◆ addWidget()
Adds widget w to the layout.
By default, widget is added to the default vertical layout. You can add widget to the specified layout passing it as l parameter.
References createSpacer(), and dataLayout.
◆ createHBoxLayout()
QLayout * QSint::ActionBox::createHBoxLayout | ( | ) |
Creates empty horizontal layout.
Use this function to arrange action items into a row.
◆ createItem() [1/3]
ActionLabel * QSint::ActionBox::createItem | ( | const QPixmap & | icon, |
const QString & | text, | ||
QLayout * | l = 0 |
||
) |
Adds an action with icon and text to the ActionBox and returns action item.
This function acts just like previous one. See the description above.
◆ createItem() [2/3]
ActionLabel * QSint::ActionBox::createItem | ( | const QString & | text = QString() , |
QLayout * | l = 0 |
||
) |
Adds an action with text to the ActionBox and returns action item.
References createSpacer(), and dataLayout.
◆ createItem() [3/3]
ActionLabel * QSint::ActionBox::createItem | ( | QAction * | action, |
QLayout * | l = 0 |
||
) |
Creates action item from the action and returns it.
By default, action is added to the default vertical layout, i.e. subsequent calls of this function will create several actions arranged vertically, one below another.
You can add action to the specified layout passing it as l parameter. This allows to do custom actions arrangements, i.e. horizontal etc.
- Since
- 0.2
Referenced by Gui::TaskView::TaskGroup::actionEvent().
◆ createItems()
QList< ActionLabel * > QSint::ActionBox::createItems | ( | QList< QAction * > | actions | ) |
Creates action items from the actions list and returns the list of action items.
- Since
- 0.2
◆ createSpacer()
QSpacerItem * QSint::ActionBox::createSpacer | ( | QLayout * | l = 0 | ) |
Adds a spacer and returns spacer item.
By default, a spacer is added to the default vertical layout. You can add a spacer to the specified layout passing it as l parameter.
Referenced by addWidget(), and createItem().
◆ header()
ActionLabel* QSint::ActionBox::header | ( | ) | const |
Returns header item of the ActionBox.
◆ icon()
const QPixmap* QSint::ActionBox::icon | ( | ) | const |
Returns icon of the ActionBox.
◆ init()
|
protected |
Referenced by ActionBox(), and DocumentObject.DocumentObject::onChanged().
◆ itemLayout()
QLayout* QSint::ActionBox::itemLayout | ( | ) | const |
Returns default layout used for actions (typically it's QVBoxLayout).
◆ minimumSizeHint()
|
virtual |
◆ setIcon()
void QSint::ActionBox::setIcon | ( | const QPixmap & | icon | ) |
Sets icon of the ActionBox to icon.
Member Data Documentation
◆ dataLayout
|
protected |
Referenced by addWidget(), and createItem().
◆ headerLabel
|
protected |
Referenced by ActionBox().
◆ iconLabel
|
protected |
Property Documentation
◆ header
|
read |
◆ icon
|
readwrite |
The documentation for this class was generated from the following files:
- src/Gui/QSint/actionpanel/actionbox.h
- src/Gui/QSint/actionpanel/actionbox.cpp