[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: XML GUI Separator after ActionList
From:       Albert Astals Cid <aacid () kde ! org>
Date:       2008-04-12 12:05:03
Message-ID: 200804121405.04502.aacid () kde ! org
[Download RAW message or body]

Moving the discussion to k-c-d as it's about a bug on core libs. Please only 
answer to k-c-d

A Dissabte 12 Abril 2008, Joris Guisson va escriure:
> Hi,

Hi

>
> I'm putting some menus into XML for greater extendability, and have run
> into a problem. If you put a Separator after an ActionList, it will not be
> shown. For example the following code snippet :
>
>     <Menu name="GroupsSubMenu" icon="application-x-bittorrent"><text>Add to
> Group</text>
>         <ActionList name="view_groups_list" />
>         <Separator />
>         <Action name="view_add_to_new_group" />
>     </Menu>
>
> Results in the view_add_to_new_group action always following the
> view_groups_list ActionList, the separator is never shown. If you first put
> the action, then the separator and finally the action list, it is shown.
>
> So is this a bug or a feature ? I can understand hiding the separator when
> the list is empty, but it should be shown when it is not empty.

It's a bug, on build time when KXMLGUIBuilder sees the separator, the menu is 
empty because your action list is still empty, so thinks the separator is at 
the beginning and should not be added. 

This could be fixed inside xmlgui, but won't be easy.

On the other side, QMenu is already smart enough not to paint 
leading/trailing/repeated separators (see QMenuPrivate::filterActions) so i 
suggest just removing these checks from KXMLGUIBuilder::createCustomElement

Opinions?

Albert

>
> Joris,
>
> Btw, I'm using KDE 4.0.2



["kxmlguibuilder.cpp.patch" (text/x-diff)]

Index: kxmlguibuilder.cpp
===================================================================
--- kxmlguibuilder.cpp	(revision 794087)
+++ kxmlguibuilder.cpp	(working copy)
@@ -290,12 +290,8 @@
   {
     if ( QMenu *menu = qobject_cast<QMenu*>( parent ) )
     {
-      // Don't insert multiple separators in a row
-      if ( before && before->isSeparator() )
-        return 0;
-      // Don't insert a separator at the top of the menu
-      if ( menu->actions().count() == 0 )
-        return 0;
+      // QMenu already cares for leading/trailing/repeated separators
+      // no need to check anything
 
       return menu->insertSeparator( before );
     }


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic