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 (QObject *parent)
 
 KDualAction (const QString &inactiveText, const QString &activeText, 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 (QObject *parent)
 
 QAction (const QString &text, QObject *parent)
 
 QAction (const QIcon &icon, const QString &text, QObject *parent)
 
QActionGroupactionGroup () const const
 
void activate (QAction::ActionEvent event)
 
QList< QGraphicsWidget * > associatedGraphicsWidgets () const const
 
QList< QWidget * > associatedWidgets () const const
 
bool autoRepeat () const const
 
void changed ()
 
QVariant data () const const
 
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
 
QAction::MenuRole menuRole () const const
 
QWidgetparentWidget () const const
 
QAction::Priority priority () const const
 
void setActionGroup (QActionGroup *group)
 
void setAutoRepeat (bool)
 
void setCheckable (bool)
 
void setChecked (bool)
 
void setData (const QVariant &userData)
 
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 (QAction::MenuRole menuRole)
 
void setPriority (QAction::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 (QWidget *widget)
 
QString statusTip () const const
 
QString text () const const
 
void toggle ()
 
void toggled (bool checked)
 
QString toolTip () const const
 
void trigger ()
 
void triggered (bool checked)
 
QString whatsThis () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
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 ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
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 QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
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_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, 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 *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
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, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (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[email protected][email protected][email protected]de.or[email protected]g
Since
4.6

Definition at line 50 of file kdualaction.h.

Constructor & Destructor Documentation

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::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

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.

void KDualAction::activeChangedByUser ( bool  )
signal

Only emitted when the state changes because the user triggered the action.

KGuiItem KDualAction::activeGuiItem ( ) const

Gets the KGuiItem for the active state.

Definition at line 70 of file kdualaction.cpp.

QIcon KDualAction::activeIcon ( ) const

Gets the icon for the active state.

Definition at line 87 of file kdualaction.cpp.

QString KDualAction::activeText ( ) const

Gets the text for the active state.

Definition at line 104 of file kdualaction.cpp.

QString KDualAction::activeToolTip ( ) const

Gets the tooltip for the active state.

Definition at line 121 of file kdualaction.cpp.

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.

KGuiItem KDualAction::inactiveGuiItem ( ) const

Gets the KGuiItem for the inactive state.

Definition at line 78 of file kdualaction.cpp.

QIcon KDualAction::inactiveIcon ( ) const

Gets the icon for the inactive state.

Definition at line 95 of file kdualaction.cpp.

QString KDualAction::inactiveText ( ) const

Gets the text for the inactive state.

Definition at line 112 of file kdualaction.cpp.

QString KDualAction::inactiveToolTip ( ) const

Gets the tooltip for the inactive state.

Definition at line 129 of file kdualaction.cpp.

bool KDualAction::isActive ( ) const

Returns the action state.

The action is inactive by default.

Definition at line 160 of file kdualaction.cpp.

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.

void KDualAction::setActiveGuiItem ( const KGuiItem item)

Sets the KGuiItem for the active state.

Definition at line 66 of file kdualaction.cpp.

void KDualAction::setActiveIcon ( const QIcon icon)

Sets the icon for the active state.

Definition at line 83 of file kdualaction.cpp.

void KDualAction::setActiveText ( const QString text)

Sets the text for the active state.

Definition at line 100 of file kdualaction.cpp.

void KDualAction::setActiveToolTip ( const QString toolTip)

Sets the tooltip for the active state.

Definition at line 117 of file kdualaction.cpp.

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.

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.

void KDualAction::setInactiveGuiItem ( const KGuiItem item)

Sets the KGuiItem for the inactive state.

Definition at line 74 of file kdualaction.cpp.

void KDualAction::setInactiveIcon ( const QIcon icon)

Sets the icon for the inactive state.

Definition at line 91 of file kdualaction.cpp.

void KDualAction::setInactiveText ( const QString text)

Sets the text for the inactive state.

Definition at line 108 of file kdualaction.cpp.

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-2021 The KDE developers.
Generated on Fri Jun 18 2021 22:44:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.