commit d76cef70a0320212adb3cfcf73aa77174802e4fc
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Sep 11 10:29:50 2019 +0200
Allow to hide formats from menus
Fixes: #11657
---
lib/configure.py | 2 +-
src/Format.h | 6 +++++-
src/LyXRC.cpp | 3 +++
src/frontends/qt/Menus.cpp | 2 ++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/configure.py b/lib/configure.py
index 618677e..d1989d1 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -676,7 +676,7 @@ def checkFormatEntries(dtl_tools):
\Format luatex tex "LaTeX (LuaTeX)" "" "" "%%"
"document,menu=export" ""
\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%"
"document,menu=export" ""
\Format xetex tex "LaTeX (XeTeX)" "" "" "%%"
"document,menu=export" ""
-\Format latexclipboard tex "LaTeX (clipboard)" "" "" "%%" ""
""
+\Format latexclipboard tex "LaTeX (clipboard)" "" "" "%%"
"menu=none" ""
\Format text txt "Plain text" a "" "%%"
"document,menu=export" "text/plain"
\Format text2 txt "Plain text (pstotext)" "" "" "%%"
"document" ""
\Format text3 txt "Plain text (ps2ascii)" "" "" "%%"
"document" ""
diff --git a/src/Format.h b/src/Format.h
index cc383c0..4fcd3c9 100644
--- a/src/Format.h
+++ b/src/Format.h
@@ -39,7 +39,9 @@ public:
/// This format should appear in the File > Export menu
export_menu = 4,
/// This may be a compressed file but doesn't need decompression
- zipped_native = 8
+ zipped_native = 8,
+ /// This format should not appear in a menu at all
+ no_menu = 16
};
///
Format(std::string const & n, std::string const & e, docstring const &
p,
@@ -96,6 +98,8 @@ public:
///
bool inExportMenu() const { return flags_ & export_menu; }
///
+ bool noMenu() const { return flags_ & no_menu; }
+ ///
bool zippedNative() const { return flags_ & zipped_native; }
///
static bool formatSorter(Format const * lhs, Format const * rhs);
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index a8d086d..83bf82d 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -884,6 +884,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool
check_format)
flgs |= Format::zipped_native;
else if (flag == "menu=export")
flgs |= Format::export_menu;
+ else if (flag == "menu=none")
+ flgs |= Format::no_menu;
else
LYXERR0("Ignoring unknown flag `"
<< flag << "' for format `"
@@ -2521,6 +2523,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc,
string const & name) c
format->documentFormat() != cit->documentFormat() ||
format->vectorFormat() != cit->vectorFormat() ||
format->inExportMenu() != cit->inExportMenu() ||
+ format->noMenu() != cit->noMenu() ||
format->mime() != cit->mime()) {
os << "\\format \"" << cit->name() << "\" \""
<< cit->extensions() << "\" \""
diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp
index de881c6..b77164b 100644
--- a/src/frontends/qt/Menus.cpp
+++ b/src/frontends/qt/Menus.cpp
@@ -1126,6 +1126,8 @@ void MenuDefinition::expandFormats(MenuItem::Kind const
kind, Buffer const * buf
switch (kind) {
case MenuItem::ImportFormats:
+ if (f->noMenu())
+ continue;
label += from_ascii("...");
break;
case MenuItem::ViewFormats: