Review Request: New action class proposal: KDualAction

Aurélien Gâteau agateau at
Thu Sep 2 23:17:33 BST 2010

This is an automatically generated e-mail. To reply, visit:

Review request for kdelibs.


This review-request introduces a new class named KDualAction. The goal of this class is to make it easy to create a dual-state action: an action which represents two actions, switching from one to the other whenever it is triggered. KDualAction can be used to implement actions such as the Play/Pause action of a media player or the Reload/Stop action of a web browser.

Right now some applications mis-use KToggleAction to implement such dual-state actions: They set the first action as the unchecked state and provide an alternative KGuiItem for the checked state with KToggleAction::setCheckedState(). This is wrong because when the user clicks a button representing the action in a toolbar, the button stays down.  The appropriate use cases for toggle buttons (and thus KToggleAction) are documented in a recent addition to the HIG:

Potential users for this class:

- Dragon, Juk, Amarok to implement their Play/Pause action.

- Rekonq to implement its Reload/Stop action. Konqueror could also use this but it does not feature a dual reload/stop action as far as I know.

- Dolphin could maybe use it to implement its Split/Close action (although it's a bit more involved in this case because the close action changes depending on which panel it is going to close)

- <insert-your-app-here>

I already have a patch to make Dragon use KDualAction (I used Dragon as a test application) and I plan to port other applications if the class is accepted in kdelibs (I also plan to fix some applications which mis-use KToggleAction so that they don't use setCheckedState() when it is not appropriate).


  trunk/KDE/kdelibs/kdeui/actions/kdualaction_p.h PRE-CREATION 
  trunk/KDE/kdelibs/kdeui/tests/CMakeLists.txt 1171068 
  trunk/KDE/kdelibs/kdeui/tests/kdualactiontest.cpp PRE-CREATION 
  trunk/KDE/kdelibs/kdeui/actions/kdualaction.cpp PRE-CREATION 
  trunk/KDE/kdelibs/kdeui/CMakeLists.txt 1171068 
  trunk/KDE/kdelibs/kdeui/actions/kdualaction.h PRE-CREATION 



The class comes with unit-tests. I tested the API made sense while porting Dragon to it.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the kde-core-devel mailing list