• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Slots | Signals | Public Member Functions | List of all members
KDualAction Class Reference

#include <kdualaction.h>

Inheritance diagram for KDualAction:
Inheritance graph
[legend]

Public Slots

void setActive (bool state)
 

Signals

void activeChanged (bool)
 
void activeChangedByUser (bool)
 
- Signals inherited from KAction
void authorized (KAuth::Action *action)
 
void globalShortcutChanged (const QKeySequence &)
 
void triggered (Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
 

Public Member Functions

 KDualAction (QObject *parent)
 
 KDualAction (const QString &inactiveText, const QString &activeText, QObject *parent)
 
 ~KDualAction ()
 
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 KAction
 KAction (QObject *parent)
 
 KAction (const QString &text, QObject *parent)
 
 KAction (const KIcon &icon, const QString &text, QObject *parent)
 
virtual ~KAction ()
 
KAuth::Action * authAction () const
 
bool event (QEvent *)
 
void forgetGlobalShortcut ()
 
const KShortcut & globalShortcut (ShortcutTypes type=ActiveShortcut) const
 
bool globalShortcutAllowed () const
 
bool isGlobalShortcutEnabled () const
 
bool isShortcutConfigurable () const
 
KRockerGesture rockerGesture (ShortcutTypes type=ActiveShortcut) const
 
void setAuthAction (KAuth::Action *action)
 
void setAuthAction (const QString &actionName)
 
void setGlobalShortcut (const KShortcut &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut), GlobalShortcutLoading loading=Autoloading)
 
void setGlobalShortcutAllowed (bool allowed, GlobalShortcutLoading loading=Autoloading)
 
void setHelpText (const QString &text)
 
void setRockerGesture (const KRockerGesture &gest, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
 
void setShapeGesture (const KShapeGesture &gest, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
 
void setShortcut (const KShortcut &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
 
void setShortcut (const QKeySequence &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
 
void setShortcutConfigurable (bool configurable)
 
void setShortcuts (const QList< QKeySequence > &shortcuts, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
 
KShapeGesture shapeGesture (ShortcutTypes type=ActiveShortcut) const
 
KShortcut shortcut (ShortcutTypes types=ActiveShortcut) const
 

Additional Inherited Members

- Public Types inherited from KAction
enum  GlobalShortcutLoading { Autoloading = 0x0, NoAutoloading = 0x4 }
 
enum  ShortcutType { ActiveShortcut = 0x1, DefaultShortcut = 0x2 }
 
- Properties inherited from KAction
KShortcut globalShortcut
 
bool globalShortcutAllowed
 
bool globalShortcutEnabled
 
KShortcut shortcut
 
bool shortcutConfigurable
 

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 58 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 71 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 61 of file kdualaction.cpp.

KDualAction::~KDualAction ( )

Definition at line 78 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 84 of file kdualaction.cpp.

QIcon KDualAction::activeIcon ( ) const

Gets the icon for the active state.

Definition at line 89 of file kdualaction.cpp.

QString KDualAction::activeText ( ) const

Gets the text for the active state.

Definition at line 94 of file kdualaction.cpp.

QString KDualAction::activeToolTip ( ) const

Gets the tooltip for the active state.

Definition at line 99 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 114 of file kdualaction.cpp.

KGuiItem KDualAction::inactiveGuiItem ( ) const

Gets the KGuiItem for the inactive state.

Definition at line 86 of file kdualaction.cpp.

QIcon KDualAction::inactiveIcon ( ) const

Gets the icon for the inactive state.

Definition at line 91 of file kdualaction.cpp.

QString KDualAction::inactiveText ( ) const

Gets the text for the inactive state.

Definition at line 96 of file kdualaction.cpp.

QString KDualAction::inactiveToolTip ( ) const

Gets the tooltip for the inactive state.

Definition at line 101 of file kdualaction.cpp.

bool KDualAction::isActive ( ) const

Returns the action state.

The action is inactive by default.

Definition at line 129 of file kdualaction.cpp.

void KDualAction::setActive ( bool  state)
slot

Sets the action state.

activeChanged() will be emitted but not activeChangedByUser().

Definition at line 119 of file kdualaction.cpp.

void KDualAction::setActiveGuiItem ( const KGuiItem &  item)

Sets the KGuiItem for the active state.

Definition at line 83 of file kdualaction.cpp.

void KDualAction::setActiveIcon ( const QIcon &  icon)

Sets the icon for the active state.

Definition at line 88 of file kdualaction.cpp.

void KDualAction::setActiveText ( const QString &  text)

Sets the text for the active state.

Definition at line 93 of file kdualaction.cpp.

void KDualAction::setActiveToolTip ( const QString &  toolTip)

Sets the tooltip for the active state.

Definition at line 98 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 109 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 103 of file kdualaction.cpp.

void KDualAction::setInactiveGuiItem ( const KGuiItem &  item)

Sets the KGuiItem for the inactive state.

Definition at line 85 of file kdualaction.cpp.

void KDualAction::setInactiveIcon ( const QIcon &  icon)

Sets the icon for the inactive state.

Definition at line 90 of file kdualaction.cpp.

void KDualAction::setInactiveText ( const QString &  text)

Sets the text for the inactive state.

Definition at line 95 of file kdualaction.cpp.

void KDualAction::setInactiveToolTip ( const QString &  toolTip)

Sets the tooltip for the inactive state.

Definition at line 100 of file kdualaction.cpp.


The documentation for this class was generated from the following files:
  • kdualaction.h
  • kdualaction.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal