[PATCH] misbehaving of KToggleActions in exclusiveGroup

David Faure faure at kde.org
Mon Oct 17 11:52:10 BST 2005


On Tuesday 27 September 2005 14:25, David Faure wrote:
> On Tuesday 27 September 2005 14:16, Tobias Koenig wrote:
> > Hi,
> > 
> > when you use several KToggleActions in exclusiveGroup mode and plug
> > them as KActionList into a menubar the following bug appears:
> > 
> > 1) Select a non-selected item -> it's checked and all other items of the
> >    group become unchecked.
> > 
> > 2) Select a selected item -> _all_ items (also the selected) becomes
> >    unchecked...
> > 
> > The second shouldn't happen, so the attached patch avoids the toggle
> > when the action is already checked and in a exclusive group.
> 
> We have a workaround in e.g. kword for this problem, so I agree that there is a problem.
> I also checked, and the workaround (cf KWView::viewTextMode()) won't break things
> if the fix is applied.
> 
> However the reason I didn't fix kdelibs for this back then, was that I thought
> there might be a case where applications might want "0 or 1 actions among this group are selected"
> instead of what you want (and kword wants), which is "always exactly 1 action among this group is selected".
> But since then I don't remember seeing such an application. So if nobody objects
> with a concrete case where an app would want the "0 or 1" behavior, I don't object either;
> it's certainly confusing for the common "always 1" case.

Hehe, and of course now that this is in, we found a case where we have the need for "0 or 1":
that's the case of the subscript/superscript icons in kword. This change broke those icons,
since it was then impossible to select "neither subscript nor superscript".

Laurent fixed that by removing setExclusiveGroup for those actions and manually
unchecking one action when the other one is activated, but still, the point remains
that this is a behavior-incompatible change which might break other KDE-3.x apps
that used setExclusiveGroup like koffice did - for exclusive actions, but not meaning
"always one has to be selected".

I wonder if we shouldn't have two kind of exclusive groups. 
The "0 or 1" and the "always 1" groups, for lack of better names.

"always 1" is often used for "modes" : we have to be in one of those N modes, it's not
possible to be in no mode at all. "0 or 1" is when the default mode (like normal text,
neither subscript not superscript) is implicit.

Hmm. setExclusiveGroup( "...", KAction::AlwaysSelectOne ) ?
Of course it will only make sense if all actions in a group use the same flag...

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).





More information about the kde-core-devel mailing list