KDualAction
#include <KDualAction>
Signals | |
void | activeChanged (bool) |
void | activeChangedByUser (bool) |
Public Slots | |
void | setActive (bool state) |
Additional Inherited Members | |
Public Types inherited from QAction | |
enum | ActionEvent |
enum | MenuRole |
enum | Priority |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties inherited from QAction | |
autoRepeat | |
checkable | |
checked | |
enabled | |
font | |
icon | |
iconText | |
iconVisibleInMenu | |
menuRole | |
priority | |
shortcut | |
shortcutContext | |
shortcutVisibleInContextMenu | |
statusTip | |
text | |
toolTip | |
visible | |
whatsThis | |
Properties inherited from QObject | |
objectName | |
Static Public Member Functions inherited from QObject | |
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) |
Public Attributes inherited from QAction | |
AboutQtRole | |
AboutRole | |
ApplicationSpecificRole | |
HighPriority | |
Hover | |
LowPriority | |
NormalPriority | |
NoRole | |
PreferencesRole | |
QuitRole | |
TextHeuristicRole | |
Trigger | |
Protected Member Functions inherited from QAction | |
virtual bool | event (QEvent *e) override |
Protected Member Functions inherited from QObject | |
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) |
Detailed Description
An action which can alternate between two texts/icons when triggered.
KDualAction should be used when you want to create an action which alternate between two states when triggered but which should not be rendered as a checkable widget because it is more appropriate to change the text and icon of the action instead.
You should use KDualAction to implement this kind of actions instead of KToggleAction because KToggleAction is rendered as a checkable widget: this means one of your state will have a checkbox in a menu and will be represented as a sunken button in a toolbar.
Porting from KToggleAction to KDualAction:
- If you used the KToggleAction constructor which accepts the action text, adjust the constructor: KDualAction constructor accepts both inactive and active text.
- Replace connections to the checked(bool) signal with a connection to the activeChanged(bool) (or activeChangedByUser(bool))
- Replace calls to setChecked()/isChecked() with setActive()/isActive()
- Replace calls to setCheckedState(guiItem) with setActiveGuiItem(guiItem)
- Since
- 4.6
Definition at line 50 of file kdualaction.h.
Constructor & Destructor Documentation
◆ KDualAction() [1/2]
|
explicit |
Constructs a KDualAction with the specified parent.
Texts must be set with setTextForState() or setGuiItemForState().
Definition at line 57 of file kdualaction.cpp.
◆ KDualAction() [2/2]
KDualAction::KDualAction | ( | const QString & | inactiveText, |
const QString & | activeText, | ||
QObject * | parent ) |
Constructs a KDualAction with the specified parent and texts.
Definition at line 47 of file kdualaction.cpp.
Member Function Documentation
◆ activeChanged
|
signal |
Emitted when the state changes.
This signal is emitted when the user trigger the action and when setActive() is called.
◆ activeChangedByUser
|
signal |
Only emitted when the state changes because the user triggered the action.
◆ activeGuiItem()
KGuiItem KDualAction::activeGuiItem | ( | ) | const |
Gets the KGuiItem for the active state.
Definition at line 70 of file kdualaction.cpp.
◆ activeIcon()
QIcon KDualAction::activeIcon | ( | ) | const |
Gets the icon for the active state.
Definition at line 87 of file kdualaction.cpp.
◆ activeText()
QString KDualAction::activeText | ( | ) | const |
Gets the text for the active state.
Definition at line 104 of file kdualaction.cpp.
◆ activeToolTip()
QString KDualAction::activeToolTip | ( | ) | const |
Gets the tooltip for the active state.
Definition at line 121 of file kdualaction.cpp.
◆ autoToggle()
bool KDualAction::autoToggle | ( | ) | const |
Returns whether the current action will automatically be changed when the user triggers this action.
The default value is true.
Definition at line 145 of file kdualaction.cpp.
◆ inactiveGuiItem()
KGuiItem KDualAction::inactiveGuiItem | ( | ) | const |
Gets the KGuiItem for the inactive state.
Definition at line 78 of file kdualaction.cpp.
◆ inactiveIcon()
QIcon KDualAction::inactiveIcon | ( | ) | const |
Gets the icon for the inactive state.
Definition at line 95 of file kdualaction.cpp.
◆ inactiveText()
QString KDualAction::inactiveText | ( | ) | const |
Gets the text for the inactive state.
Definition at line 112 of file kdualaction.cpp.
◆ inactiveToolTip()
QString KDualAction::inactiveToolTip | ( | ) | const |
Gets the tooltip for the inactive state.
Definition at line 129 of file kdualaction.cpp.
◆ isActive()
bool KDualAction::isActive | ( | ) | const |
Returns the action state.
The action is inactive by default.
Definition at line 160 of file kdualaction.cpp.
◆ setActive
|
slot |
Sets the action state.
activeChanged() will be emitted but not activeChangedByUser().
Definition at line 150 of file kdualaction.cpp.
◆ setActiveGuiItem()
void KDualAction::setActiveGuiItem | ( | const KGuiItem & | item | ) |
Sets the KGuiItem for the active state.
Definition at line 66 of file kdualaction.cpp.
◆ setActiveIcon()
void KDualAction::setActiveIcon | ( | const QIcon & | icon | ) |
Sets the icon for the active state.
Definition at line 83 of file kdualaction.cpp.
◆ setActiveText()
void KDualAction::setActiveText | ( | const QString & | text | ) |
Sets the text for the active state.
Definition at line 100 of file kdualaction.cpp.
◆ setActiveToolTip()
void KDualAction::setActiveToolTip | ( | const QString & | toolTip | ) |
Sets the tooltip for the active state.
Definition at line 117 of file kdualaction.cpp.
◆ setAutoToggle()
void KDualAction::setAutoToggle | ( | bool | value | ) |
Defines whether the current action should automatically be changed when the user triggers this action.
Definition at line 140 of file kdualaction.cpp.
◆ setIconForStates()
void KDualAction::setIconForStates | ( | const QIcon & | icon | ) |
Convenience method to set the icon for both active and inactive states.
Definition at line 134 of file kdualaction.cpp.
◆ setInactiveGuiItem()
void KDualAction::setInactiveGuiItem | ( | const KGuiItem & | item | ) |
Sets the KGuiItem for the inactive state.
Definition at line 74 of file kdualaction.cpp.
◆ setInactiveIcon()
void KDualAction::setInactiveIcon | ( | const QIcon & | icon | ) |
Sets the icon for the inactive state.
Definition at line 91 of file kdualaction.cpp.
◆ setInactiveText()
void KDualAction::setInactiveText | ( | const QString & | text | ) |
Sets the text for the inactive state.
Definition at line 108 of file kdualaction.cpp.
◆ setInactiveToolTip()
void KDualAction::setInactiveToolTip | ( | const QString & | toolTip | ) |
Sets the tooltip for the inactive state.
Definition at line 125 of file kdualaction.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.