KSelectAction
#include <KSelectAction>

Public Types | |
enum | ToolBarMode { MenuMode, ComboBoxMode } |
![]() | |
enum | ActionEvent |
enum | MenuRole |
enum | Priority |
Properties | |
int | comboWidth |
QAction | currentAction |
int | currentItem |
QString | currentText |
bool | editable |
QStringList | items |
ToolBarMode | toolBarMode |
QToolButton::ToolButtonPopupMode | toolButtonPopupMode |
![]() | |
autoRepeat | |
checkable | |
checked | |
enabled | |
font | |
icon | |
iconText | |
iconVisibleInMenu | |
menuRole | |
priority | |
shortcut | |
shortcutContext | |
shortcutVisibleInContextMenu | |
statusTip | |
text | |
toolTip | |
visible | |
whatsThis | |
![]() | |
objectName | |
Signals | |
void | indexTriggered (int index) |
void | textTriggered (const QString &text) |
void | triggered (const QString &text) |
void | triggered (int index) |
void | triggered (QAction *action) |
Protected Slots | |
virtual void | actionTriggered (QAction *action) |
void | slotToggled (bool) |
Protected Member Functions | |
KWIDGETSADDONS_NO_EXPORT | KSelectAction (KSelectActionPrivate &dd, QObject *parent) |
QWidget * | createWidget (QWidget *parent) override |
void | deleteWidget (QWidget *widget) override |
bool | event (QEvent *event) override |
bool | eventFilter (QObject *watched, QEvent *event) override |
![]() | |
QList< QWidget * > | createdWidgets () const const |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
const std::unique_ptr< class KSelectActionPrivate > | d_ptr |
Additional Inherited Members | |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
AboutQtRole | |
AboutRole | |
ApplicationSpecificRole | |
HighPriority | |
Hover | |
LowPriority | |
NormalPriority | |
NoRole | |
PreferencesRole | |
QuitRole | |
TextHeuristicRole | |
Trigger | |
![]() | |
typedef | QObjectList |
Detailed Description
Action for selecting one of several items.
Action for selecting one of several items.
This action shows up a submenu with a list of items. One of them can be checked. If the user clicks on an item this item will automatically be checked, the formerly checked item becomes unchecked. There can be only one item checked at a time.
Definition at line 44 of file kselectaction.h.
Member Enumeration Documentation
◆ ToolBarMode
Enumerator | |
---|---|
MenuMode | Creates a button which pops up a menu when interacted with, as defined by toolButtonPopupMode(). |
ComboBoxMode | Creates a combo box which contains the actions. This is the default. |
Definition at line 96 of file kselectaction.h.
Constructor & Destructor Documentation
◆ KSelectAction() [1/4]
|
explicit |
Constructs a selection action with the specified parent.
- Parameters
-
parent The action's parent object.
Definition at line 52 of file kselectaction.cpp.
◆ KSelectAction() [2/4]
Constructs a selection action with text; a shortcut may be specified by the ampersand character (e.g. "&Option" creates a shortcut with key O )
This is the most common KSelectAction used when you do not have a corresponding icon (note that it won't appear in the current version of the "Edit ToolBar" dialog, because an action needs an icon to be plugged in a toolbar...).
- Parameters
-
text The text that will be displayed. parent The action's parent object.
Definition at line 57 of file kselectaction.cpp.
◆ KSelectAction() [3/4]
Constructs a selection action with text and an icon; a shortcut may be specified by the ampersand character (e.g. "&Option" creates a shortcut with key O )
This is the other common KSelectAction used. Use it when you do have a corresponding icon.
- Parameters
-
icon The icon to display. text The text that will be displayed. parent The action's parent object.
Definition at line 63 of file kselectaction.cpp.
◆ ~KSelectAction()
|
override |
Destructor.
Definition at line 78 of file kselectaction.cpp.
◆ KSelectAction() [4/4]
|
protected |
Creates a new KSelectAction object.
- Parameters
-
dd the private d member parent The action's parent object.
Definition at line 70 of file kselectaction.cpp.
Member Function Documentation
◆ action() [1/2]
QAction * KSelectAction::action | ( | const QString & | text, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Searches for an action with the specified text, using a search whose case sensitivity is defined by cs.
Definition at line 168 of file kselectaction.cpp.
◆ action() [2/2]
QAction * KSelectAction::action | ( | int | index | ) | const |
Returns the action at index, if one exists.
Definition at line 159 of file kselectaction.cpp.
◆ actions()
Returns the list of selectable actions.
Definition at line 102 of file kselectaction.cpp.
◆ actionTriggered
|
protectedvirtualslot |
This function is called whenever an action from the selections is triggered.
The default implementation calls trigger() if isCheckable() is true
, then emits the signals triggered(QAction *), triggered(int) and triggered(const QString &) as well as since 5.78 the signals indexTriggered(int) and textTriggered(const QString &).
Definition at line 315 of file kselectaction.cpp.
◆ addAction() [1/3]
Overloaded member function, provided for convenience, which creates an action from text
and icon
and inserts it into the list of selectable actions.
The newly created action is checkable and not user configurable.
Definition at line 257 of file kselectaction.cpp.
◆ addAction() [2/3]
Overloaded member function, provided for convenience, which creates an action from text
and inserts it into the list of selectable actions.
The newly created action is checkable and not user configurable.
Definition at line 240 of file kselectaction.cpp.
◆ addAction() [3/3]
void KSelectAction::addAction | ( | QAction * | action | ) |
Add action to the list of selectable actions.
Definition at line 235 of file kselectaction.cpp.
◆ changeItem()
void KSelectAction::changeItem | ( | int | index, |
const QString & | text | ||
) |
Changes the text of item.
- Parameters
-
index to text .
Definition at line 353 of file kselectaction.cpp.
◆ clear()
void KSelectAction::clear | ( | ) |
Remove and delete all the items in this action.
- See also
- removeAllActions()
Definition at line 391 of file kselectaction.cpp.
◆ comboWidth()
int KSelectAction::comboWidth | ( | ) | const |
When this action is plugged into a toolbar, it creates a combobox.
This returns the maximum width set by setComboWidth
◆ createWidget()
Reimplemented from QWidgetAction.
Reimplemented from QWidgetAction.
Definition at line 521 of file kselectaction.cpp.
◆ currentAction()
QAction* KSelectAction::currentAction | ( | ) | const |
Returns the current QAction.
- See also
- setCurrentAction
◆ currentItem()
int KSelectAction::currentItem | ( | ) | const |
Returns the index of the current item.
- See also
- currentText(), currentAction()
◆ currentText()
QString KSelectAction::currentText | ( | ) | const |
Returns the text of the currently selected item.
- See also
- currentItem(), currentAction()
◆ deleteWidget()
|
overrideprotectedvirtual |
Reimplemented from QWidgetAction.
Reimplemented from QWidgetAction.
Definition at line 599 of file kselectaction.cpp.
◆ indexTriggered
|
signal |
This signal is emitted when an item is selected.
- Parameters
-
index indicates the item selected
In your KSelectAction subclass to be backward-compatible to KF < 5.78, emit instead just the deprecated signal triggered(int). That will also automatically emit indexTriggered(int) because this signal is connected to the deprecated one in the KSelectAction constructor. Only if you compile against a variant of KWidgetsAddons built without all API deprecated up to version 5.78, then emit this signal directly. Your code would be like this:
- Since
- 5.78
◆ insertAction()
Inserts the action action to this widget's list of actions, before the action before.
It appends the action if before is a null pointer or before is not a valid action for this widget.
- Since
- 5.0
Definition at line 293 of file kselectaction.cpp.
◆ isEditable()
bool KSelectAction::isEditable | ( | ) | const |
When this action is plugged into a toolbar, it creates a combobox.
- Returns
- true if the combo editable.
Definition at line 431 of file kselectaction.cpp.
◆ items()
QStringList KSelectAction::items | ( | ) | const |
Convenience function which returns the items that can be selected with this action.
It is the same as iterating selectableActionGroup()->actions() and looking at each action's text().
◆ menuAccelsEnabled()
bool KSelectAction::menuAccelsEnabled | ( | ) | const |
Returns whether ampersands passed to methods using QStrings are interpreted as keyboard accelerator indicators or as literal ampersands.
Definition at line 515 of file kselectaction.cpp.
◆ removeAction()
Remove the specified action from this action selector.
You take ownership here, so save or delete it in order to not leak the action.
Reimplemented in KRecentFilesAction.
Definition at line 264 of file kselectaction.cpp.
◆ removeAllActions()
void KSelectAction::removeAllActions | ( | ) |
Remove all the items in this action.
Unlike clear(), this will not delete the actions.
- See also
- clear()
Definition at line 411 of file kselectaction.cpp.
◆ selectableActionGroup()
QActionGroup * KSelectAction::selectableActionGroup | ( | ) | const |
The action group used to create exclusivity between the actions associated with this action.
Definition at line 96 of file kselectaction.cpp.
◆ setComboWidth()
void KSelectAction::setComboWidth | ( | int | width | ) |
When this action is plugged into a toolbar, it creates a combobox.
This gives a maximum size to the combobox. The minimum size is automatically given by the contents (the items).
Definition at line 201 of file kselectaction.cpp.
◆ setCurrentAction() [1/2]
bool KSelectAction::setCurrentAction | ( | const QString & | text, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) |
Overloaded member function, provided for convenience, to set the currently checked action to be the action which has text
as its text().
If there is no action at that index, the currently checked action (if any) will be deselected.
- Returns
- true if a corresponding action was found, otherwise false
Definition at line 195 of file kselectaction.cpp.
◆ setCurrentAction() [2/2]
bool KSelectAction::setCurrentAction | ( | QAction * | action | ) |
Sets the currently checked item.
- Parameters
-
action the QAction to become the currently checked item.
- Returns
- true if a corresponding action was found and successfully checked.
Definition at line 126 of file kselectaction.cpp.
◆ setCurrentItem()
bool KSelectAction::setCurrentItem | ( | int | index | ) |
Convenience function to set the currently checked action to be the action at index index
.
If there is no action at that index, the currently checked action (if any) will be deselected.
- Returns
- true if a corresponding action was found and thus set to the current action, otherwise false
Definition at line 153 of file kselectaction.cpp.
◆ setEditable()
void KSelectAction::setEditable | ( | bool | edit | ) |
When this action is plugged into a toolbar, it creates a combobox.
This makes the combo editable or read-only.
Definition at line 419 of file kselectaction.cpp.
◆ setItems()
void KSelectAction::setItems | ( | const QStringList & | lst | ) |
Convenience function to create the list of selectable items.
Any previously existing items will be cleared.
Definition at line 364 of file kselectaction.cpp.
◆ setMaxComboViewCount()
void KSelectAction::setMaxComboViewCount | ( | int | n | ) |
Sets the maximum items that are visible at once if the action is a combobox, that is the number of items in the combobox's viewport.
Definition at line 217 of file kselectaction.cpp.
◆ setMenuAccelsEnabled()
void KSelectAction::setMenuAccelsEnabled | ( | bool | b | ) |
Sets whether any occurrence of the ampersand character ( & ) in items should be interpreted as keyboard accelerator for items displayed in a menu or not.
Only applies to (overloaded) methods dealing with QStrings, not those dealing with QActions.
Defaults to true.
- Parameters
-
b true if ampersands indicate a keyboard accelerator, otherwise false.
Definition at line 509 of file kselectaction.cpp.
◆ setToolBarMode()
void KSelectAction::setToolBarMode | ( | ToolBarMode | mode | ) |
Set the type of widget to be inserted in a toolbar to mode.
Definition at line 451 of file kselectaction.cpp.
◆ setToolButtonPopupMode()
void KSelectAction::setToolButtonPopupMode | ( | QToolButton::ToolButtonPopupMode | mode | ) |
Set how this list of actions should behave when in popup mode and plugged into a toolbar.
Definition at line 463 of file kselectaction.cpp.
◆ slotToggled
|
protectedslot |
For structured menu building.
Deselects all items if the action was unchecked by the top menu
Definition at line 437 of file kselectaction.cpp.
◆ textTriggered
|
signal |
This signal is emitted when an item is selected.
- Parameters
-
text indicates the item selected
In your KSelectAction subclass to be backward-compatible to KF < 5.78, emit instead just the deprecated signal triggered(const QString &). That will also automatically emit textTriggered(const QString &) because this signal is connected to the deprecated one in the KSelectAction constructor. Only if you compile against a variant of KWidgetsAddons built without all API deprecated up to version 5.78, then emit this signal directly. Your code would be like this:
- Since
- 5.78
◆ toolBarMode()
ToolBarMode KSelectAction::toolBarMode | ( | ) | const |
Returns which type of widget (combo box or button with drop-down menu) will be inserted in a toolbar.
◆ toolButtonPopupMode()
QToolButton::ToolButtonPopupMode KSelectAction::toolButtonPopupMode | ( | ) | const |
Returns the style for the list of actions, when this action is plugged into a KToolBar.
The default value is QToolButton::InstantPopup
- See also
- QToolButton::setPopupMode()
◆ triggered [1/3]
|
signal |
This signal is emitted when an item is selected.
- Parameters
-
text indicates the item selected
- Deprecated:
- Since 5.78, use textTriggered(const QString &)
◆ triggered [2/3]
|
signal |
This signal is emitted when an item is selected.
- Parameters
-
index indicates the item selected
- Deprecated:
- Since 5.78, use indexTriggered(int)
◆ triggered [3/3]
|
signal |
This signal is emitted when an item is selected.
- Parameters
-
action indicates the item selected
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 04:04:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.