mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-14 20:26:50 +00:00
Remove the 'running' booleans quit and optional
Reason for this 'cleanup' is the strange "optional = false" lines at the end of the "case md_item" and "case md_subitem". Then, it is nicer to directly use the value of the switch to be the running variable and to use this to determine whether an item is optional and whether we should quit.
This commit is contained in:
parent
a033b88a37
commit
ed5585966b
@ -517,14 +517,10 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
lex.pushTable(menutags);
|
lex.pushTable(menutags);
|
||||||
lex.setContext("MenuDefinition::read: ");
|
lex.setContext("MenuDefinition::read: ");
|
||||||
|
|
||||||
bool quit = false;
|
int md_type = 0;
|
||||||
bool optional = false;
|
while (lex.isOK() && md_type != md_endmenu) {
|
||||||
|
switch (md_type = lex.lex()) {
|
||||||
while (lex.isOK() && !quit) {
|
|
||||||
switch (lex.lex()) {
|
|
||||||
case md_optitem:
|
case md_optitem:
|
||||||
optional = true;
|
|
||||||
// fallback to md_item
|
|
||||||
case md_item: {
|
case md_item: {
|
||||||
lex.next(true);
|
lex.next(true);
|
||||||
docstring const name = translateIfPossible(lex.getDocString());
|
docstring const name = translateIfPossible(lex.getDocString());
|
||||||
@ -534,8 +530,8 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
FuncRequest::Origin origin = FuncRequest::MENU;
|
FuncRequest::Origin origin = FuncRequest::MENU;
|
||||||
if (name_.startsWith("context-toc-"))
|
if (name_.startsWith("context-toc-"))
|
||||||
origin = FuncRequest::TOC;
|
origin = FuncRequest::TOC;
|
||||||
|
bool const optional = (md_type == md_optitem);
|
||||||
add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin));
|
add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin));
|
||||||
optional = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,21 +652,18 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case md_optsubmenu:
|
case md_optsubmenu:
|
||||||
optional = true;
|
|
||||||
// fallback to md_submenu
|
|
||||||
case md_submenu: {
|
case md_submenu: {
|
||||||
lex.next(true);
|
lex.next(true);
|
||||||
docstring const mlabel = translateIfPossible(lex.getDocString());
|
docstring const mlabel = translateIfPossible(lex.getDocString());
|
||||||
lex.next(true);
|
lex.next(true);
|
||||||
docstring const mname = lex.getDocString();
|
docstring const mname = lex.getDocString();
|
||||||
|
bool const optional = (md_type == md_optsubmenu);
|
||||||
add(MenuItem(MenuItem::Submenu,
|
add(MenuItem(MenuItem::Submenu,
|
||||||
toqstr(mlabel), toqstr(mname), QString(), optional));
|
toqstr(mlabel), toqstr(mname), QString(), optional));
|
||||||
optional = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case md_endmenu:
|
case md_endmenu:
|
||||||
quit = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user