Author: vfr
Date: Sat Mar 19 15:55:32 2011
New Revision: 37963
URL: http://www.lyx.org/trac/changeset/37963

Log:
Fix bug #7275: Overcrowding of context menus.

Modified:
   lyx-devel/trunk/src/frontends/qt4/Menus.cpp

Modified: lyx-devel/trunk/src/frontends/qt4/Menus.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/Menus.cpp Sat Mar 19 14:16:45 2011        
(r37962)
+++ lyx-devel/trunk/src/frontends/qt4/Menus.cpp Sat Mar 19 15:55:32 2011        
(r37963)
@@ -313,6 +313,8 @@
        const_iterator end() const { return items_.end(); }
        ///
        void cat(MenuDefinition const & other);
+       ///
+       void catSub(docstring const & name);
        
        // search for func in this menu iteratively, and put menu
        // names in a stack.
@@ -656,6 +658,12 @@
 }
 
 
+void MenuDefinition::catSub(docstring const & name)
+{
+       add(MenuItem(MenuItem::Submenu,
+                               qt_("More..."), toqstr(name), QString(), 
false));
+}
+
 void MenuDefinition::cat(MenuDefinition const & other)
 {
        const_iterator et = other.end();
@@ -2067,7 +2075,15 @@
                        continue;
                }
 
-               fromLyxMenu.cat(d->getMenu(toqstr(menu_name)));
+               MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
+               //FIXME: 50 is a wild guess. We should take into account here
+               //the expansion of menu items, disabled optional items etc.
+               bool const in_sub_menu = fromLyxMenu.size() > 0 
+                       && fromLyxMenu.size() + cat_menu.size() > 50 ;
+               if (in_sub_menu)
+                       fromLyxMenu.catSub(menu_name);
+               else
+                       fromLyxMenu.cat(cat_menu);
                fromLyxMenu.add(MenuItem(MenuItem::Separator));
        }
 

Reply via email to