mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Extend list of accessible menu info
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
This commit is contained in:
parent
d1fbbb78a8
commit
91a5263d68
@ -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.
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
//@}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user