]> git.lyx.org Git - lyx.git/commitdiff
Extend list of accessible menu info
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 8 Aug 2018 13:05:58 +0000 (15:05 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 8 Aug 2018 13:05:58 +0000 (15:05 +0200)
When searching for and item in the menu, also try to consider those that
require a BufferView (such as View/Update formats).

Also, be explicit for the default format in order to find it.

Fixes: #9851
src/frontends/Application.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/Menus.cpp
src/frontends/qt4/Menus.h
src/insets/InsetInfo.cpp

index c0ea5c31ae8d1d2f334aa8db2371d84693463618..cf82776039e98217d779f2a013475fd395c27f8e 100644 (file)
@@ -233,6 +233,8 @@ public:
        virtual bool searchMenu(FuncRequest const & func,
                docstring_list & names) const = 0;
 
+       virtual bool hasBufferView() const = 0;
+
        /// \return the icon file name for the given action.
        static docstring iconName(FuncRequest const & f, bool unknown);
        /// \return the math icon name for the given command.
index 4d20b0558a579ba3395d249d7afb722fbb6cfff1..d4b1701758ae248bae8345d66164d0d7d1250441 100644 (file)
@@ -2935,7 +2935,16 @@ Buffer const * GuiApplication::updateInset(Inset const * inset) const
 bool GuiApplication::searchMenu(FuncRequest const & func,
        docstring_list & names) const
 {
-       return d->menus_.searchMenu(func, names);
+       BufferView * bv = 0;
+       if (current_view_)
+               bv = current_view_->currentBufferView();
+       return d->menus_.searchMenu(func, names, bv);
+}
+
+
+bool GuiApplication::hasBufferView() const
+{
+       return (current_view_ && current_view_->currentBufferView());
 }
 
 
index fafdd46eea25478b49b6fd8f598e9e3c7db0f601..bc16fabdcea4be7cc8f866ae65cfbd75eba4e260 100644 (file)
@@ -76,6 +76,7 @@ public:
        void registerSocketCallback(int fd, SocketCallback func);
        void unregisterSocketCallback(int fd);
        bool searchMenu(FuncRequest const & func, docstring_list & names) const;
+       bool hasBufferView() const;
        void handleKeyFunc(FuncCode action);
        bool unhide(Buffer * buf); //override
        //@}
index 686081789ef2a02353e5ef103630890f46f86516..b9450a28575fa30952defe16497a69e25fc49ebe 100644 (file)
@@ -1131,7 +1131,7 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
                                docstring lbl = (kind == MenuItem::ViewFormats
                                        ? bformat(_("View [%1$s]|V"), label)
                                        : bformat(_("Update [%1$s]|U"), label));
-                               add(MenuItem(MenuItem::Command, toqstr(lbl), FuncRequest(action)));
+                               add(MenuItem(MenuItem::Command, toqstr(lbl), FuncRequest(action, f->name())));
                                continue;
                        }
                        break;
@@ -2540,10 +2540,10 @@ void Menus::read(Lexer & lex)
 
 
 bool Menus::searchMenu(FuncRequest const & func,
-       docstring_list & names) const
+       docstring_list & names, BufferView const * bv) const
 {
        MenuDefinition menu;
-       d->expand(d->menubar_, menu, 0);
+       d->expand(d->menubar_, menu, bv);
        return menu.searchMenu(func, names);
 }
 
index 9bc78e348073cbf067b6f05e8641e2996be62c8c..5df59ddf5dd372b58a21ca414b7687c0f2caec57 100644 (file)
@@ -14,6 +14,7 @@
 #define MENUS_H
 
 #include <QMenu>
+#include "BufferView.h"
 
 class QString;
 class QMenuBar;
@@ -70,7 +71,7 @@ public:
 
        ///
        bool searchMenu(FuncRequest const & func,
-               docstring_list & names) const;
+               docstring_list & names, BufferView const * bv = 0) const;
        ///
        void fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial = false);
 
index 8b504a65225022eba72dc2c74e48a46b6c904270..e959836dd3166409571dfb0bf15a2d23fef9c519 100644 (file)
@@ -827,8 +827,6 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                // only need to do this once.
                if (initialized_)
                        break;
-               // and we will not keep trying if we fail
-               initialized_ = true;
                docstring_list names;
                FuncRequest const func = lyxaction.lookupFunc(params_.name);
                if (func.action() == LFUN_UNKNOWN_ACTION) {
@@ -840,8 +838,11 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
                if (!theApp()) {
                        gui = _("Can't determine menu entry for action %1$s in batch mode");
                        error(from_ascii("Can't determine menu entry for action %1$s in batch mode"), params_.lang);
+                       initialized_ = true;
                        break;
                }
+               // and we will not keep trying if we fail
+               initialized_ = theApp()->hasBufferView();
                if (!theApp()->searchMenu(func, names)) {
                        gui = _("No menu entry for action %1$s");
                        error(from_ascii("No menu entry for action %1$s"), params_.lang);