]> git.lyx.org Git - features.git/commitdiff
Fix bug #7275: Overcrowding of context menus.
authorVincent van Ravesteijn <vfr@lyx.org>
Sat, 19 Mar 2011 14:55:32 +0000 (14:55 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sat, 19 Mar 2011 14:55:32 +0000 (14:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37963 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Menus.cpp

index c25ad978ab83dca0362e0a6fa723cf78ddd5c880..86607796b77eb8f9b619adfd9ac7060279616ad0 100644 (file)
@@ -313,6 +313,8 @@ public:
        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 @@ bool MenuDefinition::hasFunc(FuncRequest const & func) const
 }
 
 
+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 @@ void Menus::updateMenu(Menu * qmenu)
                        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));
        }