KDualAction

Search for usage in LXR

#include <KDualAction>

Inheritance diagram for KDualAction:

Signals

void activeChanged (bool)
 
void activeChangedByUser (bool)
 

Public Slots

void setActive (bool state)
 

Public Member Functions

 KDualAction (const QString &inactiveText, const QString &activeText, QObject *parent)
 
 KDualAction (QObject *parent)
 
KGuiItem activeGuiItem () const
 
QIcon activeIcon () const
 
QString activeText () const
 
QString activeToolTip () const
 
bool autoToggle () const
 
KGuiItem inactiveGuiItem () const
 
QIcon inactiveIcon () const
 
QString inactiveText () const
 
QString inactiveToolTip () const
 
bool isActive () const
 
void setActiveGuiItem (const KGuiItem &)
 
void setActiveIcon (const QIcon &)
 
void setActiveText (const QString &)
 
void setActiveToolTip (const QString &)
 
void setAutoToggle (bool)
 
void setIconForStates (const QIcon &icon)
 
void setInactiveGuiItem (const KGuiItem &)
 
void setInactiveIcon (const QIcon &)
 
void setInactiveText (const QString &)
 
void setInactiveToolTip (const QString &)
 
- Public Member Functions inherited from QAction
 QAction (const QIcon &icon, const QString &text, QObject *parent)
 
 QAction (const QString &text, QObject *parent)
 
 QAction (QObject *parent)
 
QActionGroupactionGroup () const const
 
void activate (ActionEvent event)
 
QList< QGraphicsWidget * > associatedGraphicsWidgets () const const
 
QList< QObject * > associatedObjects () const const
 
QList< QWidget * > associatedWidgets () const const
 
bool autoRepeat () const const
 
void changed ()
 
void checkableChanged (bool checkable)
 
QVariant data () const const
 
void enabledChanged (bool enabled)
 
QFont font () const const
 
void hover ()
 
void hovered ()
 
QIcon icon () const const
 
QString iconText () const const
 
bool isCheckable () const const
 
bool isChecked () const const
 
bool isEnabled () const const
 
bool isIconVisibleInMenu () const const
 
bool isSeparator () const const
 
bool isShortcutVisibleInContextMenu () const const
 
bool isVisible () const const
 
QMenumenu () const const
 
MenuRole menuRole () const const
 
QWidgetparentWidget () const const
 
Priority priority () const const
 
void resetEnabled ()
 
void setActionGroup (QActionGroup *group)
 
void setAutoRepeat (bool)
 
void setCheckable (bool)
 
void setChecked (bool)
 
void setData (const QVariant &data)
 
void setDisabled (bool b)
 
void setEnabled (bool)
 
void setFont (const QFont &font)
 
void setIcon (const QIcon &icon)
 
void setIconText (const QString &text)
 
void setIconVisibleInMenu (bool visible)
 
void setMenu (QMenu *menu)
 
void setMenuRole (MenuRole menuRole)
 
void setPriority (Priority priority)
 
void setSeparator (bool b)
 
void setShortcut (const QKeySequence &shortcut)
 
void setShortcutContext (Qt::ShortcutContext context)
 
void setShortcuts (const QList< QKeySequence > &shortcuts)
 
void setShortcuts (QKeySequence::StandardKey key)
 
void setShortcutVisibleInContextMenu (bool show)
 
void setStatusTip (const QString &statusTip)
 
void setText (const QString &text)
 
void setToolTip (const QString &tip)
 
void setVisible (bool)
 
void setWhatsThis (const QString &what)
 
QKeySequence shortcut () const const
 
Qt::ShortcutContext shortcutContext () const const
 
QList< QKeySequenceshortcuts () const const
 
bool showStatusText (QObject *object)
 
QString statusTip () const const
 
QString text () const const
 
void toggle ()
 
void toggled (bool checked)
 
QString toolTip () const const
 
void trigger ()
 
void triggered (bool checked)
 
void visibleChanged ()
 
QString whatsThis () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Public Types inherited from QAction
enum  ActionEvent
 
enum  MenuRole
 
enum  Priority
 
- 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
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- 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
 
QObjectsender () 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:

  1. If you used the KToggleAction constructor which accepts the action text, adjust the constructor: KDualAction constructor accepts both inactive and active text.
  2. Replace connections to the checked(bool) signal with a connection to the activeChanged(bool) (or activeChangedByUser(bool))
  3. Replace calls to setChecked()/isChecked() with setActive()/isActive()
  4. Replace calls to setCheckedState(guiItem) with setActiveGuiItem(guiItem)
Author
Aurélien Gâteau agate.nosp@m.au@k.nosp@m.de.or.nosp@m.g
Since
4.6

Definition at line 50 of file kdualaction.h.

Constructor & Destructor Documentation

◆ KDualAction() [1/2]

KDualAction::KDualAction ( QObject * parent)
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

void KDualAction::activeChanged ( bool )
signal

Emitted when the state changes.

This signal is emitted when the user trigger the action and when setActive() is called.

◆ activeChangedByUser

void KDualAction::activeChangedByUser ( bool )
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

void KDualAction::setActive ( bool state)
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:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.