commit ed44bbddee012f1cb38752142aba8e068dce47d2
Author: Juergen Spitzmueller <[email protected]>
Date: Thu Apr 18 10:27:19 2019 +0200
Add MenuString to InsetLayout
Fixes: #8818
---
lib/doc/Customization.lyx | 78 ++++++++++++++++++++++++++++++++++++++++-
lib/doc/de/Customization.lyx | 64 +++++++++++++++++++++++++++++++++-
lib/scripts/layout2layout.py | 7 +++-
src/TextClass.cpp | 2 +-
src/frontends/qt4/Menus.cpp | 11 ++++--
src/insets/InsetLayout.cpp | 5 +++
src/insets/InsetLayout.h | 4 ++
7 files changed, 160 insertions(+), 11 deletions(-)
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index c953b42..568c31b 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -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
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index f32aabb..372acb5 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -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"
@@ -18472,6 +18472,66 @@ LyxType
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
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 331a51f..b899695 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -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
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 566ac7a..e381060 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -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
diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp
index 6690588..91ab3f2 100644
--- a/src/frontends/qt4/Menus.cpp
+++ b/src/frontends/qt4/Menus.cpp
@@ -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.
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index b62affd..6094135 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -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);
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 0eb2708..dc46946 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -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_;