Add MenuString to InsetLayout

Fixes: #8818
This commit is contained in:
Juergen Spitzmueller 2019-04-18 10:27:19 +02:00
parent 17abf68bac
commit ed44bbddee
7 changed files with 160 additions and 11 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 571
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true
@ -44,7 +44,7 @@ logicalmkup
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\inputencoding auto-legacy
\fontencoding auto
\font_roman "lmodern" "default"
\font_sans "lmss" "default"
@ -20256,6 +20256,80 @@ LyxType
\end_inset
.
\change_inserted -712698321 1555575738
\end_layout
\begin_layout Description
\change_inserted -712698321 1555575844
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1555575740
MenuString
\end_layout
\end_inset
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1555575740
[string]
\end_layout
\end_inset
A dedicated string for the menu.
You can define an accelerator by appending the respective character to
the string, divided by
\begin_inset Quotes eld
\end_inset
|
\begin_inset Quotes erd
\end_inset
(e.
\begin_inset space \thinspace{}
\end_inset
g.
\begin_inset space \space{}
\end_inset
\begin_inset Quotes eld
\end_inset
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1555575781
My Inset|M
\end_layout
\end_inset
\begin_inset Quotes erd
\end_inset
).
This specification is optional.
If it is not given the inset name as specified in the type declaration
will be used instead for the menu.
\change_unchanged
\end_layout
\begin_layout Description

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 571
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true
@ -52,7 +52,7 @@ logicalmkup
\maintain_unincluded_children false
\language ngerman
\language_package default
\inputencoding auto
\inputencoding auto-legacy
\fontencoding auto
\font_roman "lmodern" "FreeSerif"
\font_sans "lmss" "FreeSans"
@ -18471,6 +18471,66 @@ LyxType
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
MenuString
\end_layout
\end_inset
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
[string]
\end_layout
\end_inset
Eine spezifische Zeichenkette für das Menü.
Sie können ein Tastenkürzel definieren, indem Sie das entsprechende Zeichen
an die Zeichenkette mit
\begin_inset Quotes gld
\end_inset
|
\begin_inset Quotes grd
\end_inset
abgetrennt anhängen (z.
\begin_inset space \thinspace{}
\end_inset
B.
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
Meine Einfügung|M
\end_layout
\end_inset
).
Diese Spezifikation ist optional.
Wenn Sie fehlt, wird der Name der Einfügung (aus der
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
Typ
\end_layout
\end_inset
-Spezifikation) für das Menü verwendet.
\end_layout
\begin_layout Description
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
MultiPar
\end_layout

View File

@ -11,7 +11,7 @@
# This script will update a .layout file to current format
# The latest layout format is also defined in src/TextClass.cpp
currentFormat = 72
currentFormat = 73
# Incremented to format 4, 6 April 2007, lasgouttes
@ -242,6 +242,9 @@ currentFormat = 72
# Incremented to format 72, 26 March 2019 by spitz
# New TextClass tag TableStyle
# Incremented to format 73, 18 April 2019 by spitz
# New InsetLayout tag MenuString
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
@ -491,7 +494,7 @@ def convert(lines, end_format):
i += 1
continue
if format >= 65 and format <= 71:
if format >= 65 and format <= 72:
# nothing to do.
i += 1
continue

View File

@ -62,7 +62,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
int const LAYOUT_FORMAT = 72; // spitz: TableStyle
int const LAYOUT_FORMAT = 73; // spitz: MenuString
// Layout format for the current lyx file format. Controls which format is

View File

@ -1230,13 +1230,16 @@ void MenuDefinition::expandFlexInsert(
if (cit->second.lyxtype() == type) {
if (!cit->second.obsoleted_by().empty())
continue;
docstring label = cit->first;
docstring name = cit->first;
// we remove the "Flex:" prefix, if it is present
if (prefixIs(label, from_ascii("Flex:")))
label = label.substr(5);
if (prefixIs(name, from_ascii("Flex:")))
name = name.substr(5);
docstring const label = (cit->second.menustring().empty()) ?
name
: cit->second.menustring();
addWithStatusCheck(MenuItem(MenuItem::Command,
toqstr(translateIfPossible(label)),
FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(name))));
}
}
// FIXME This is a little clunky.

View File

@ -120,6 +120,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
IL_LYXTYPE,
IL_OBSOLETEDBY,
IL_KEEPEMPTY,
IL_MENUSTRING,
IL_MULTIPAR,
IL_NEEDCPROTECT,
IL_NEEDMBOXPROTECT,
@ -178,6 +179,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{ "latextype", IL_LATEXTYPE },
{ "leftdelim", IL_LEFTDELIM },
{ "lyxtype", IL_LYXTYPE },
{ "menustring", IL_MENUSTRING },
{ "multipar", IL_MULTIPAR },
{ "needcprotect", IL_NEEDCPROTECT },
{ "needmboxprotect", IL_NEEDMBOXPROTECT },
@ -251,6 +253,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
case IL_LABELSTRING:
lex >> labelstring_;
break;
case IL_MENUSTRING:
lex >> menustring_;
break;
case IL_DECORATION:
lex >> tmp;
decoration_ = translateDecoration(tmp);

View File

@ -66,6 +66,8 @@ public:
///
docstring labelstring() const { return labelstring_; }
///
docstring menustring() const { return menustring_; }
///
bool contentaslabel() const { return contentaslabel_; }
///
InsetDecoration decoration() const { return decoration_; }
@ -212,6 +214,8 @@ private:
///
docstring labelstring_;
///
docstring menustring_;
///
bool contentaslabel_;
///
InsetDecoration decoration_;