diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index 1d0104a1de..82d588786d 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -8751,14 +8751,12 @@ Verbatim \end_layout \begin_layout Verbatim - This is Verbatim. \end_layout \begin_layout Verbatim \noindent \align block - The following 2 lines are empty: \end_layout @@ -8771,7 +8769,6 @@ The following 2 lines are empty: \end_layout \begin_layout Verbatim - Almost everything is allowed in Verbatim:"%&$§#~'` \backslash }][{| @@ -8795,7 +8792,6 @@ Verbatim \end_layout \begin_layout Verbatim* - This is Verbatim*. \end_layout @@ -41119,13 +41115,41 @@ Command Buffer \family default - can be turned on and off. + can be turned +\emph on +on +\emph default + and +\emph on +off +\emph default +. The \emph on on \emph default state is denoted in the menu with a checkmark. - The + +\change_deleted -712698321 1608195495 + +\change_inserted -712698321 1608195492 + +\end_layout + +\begin_layout Standard +The +\change_inserted -712698321 1608195407 + +\family sans +Phonetic +\begin_inset space ~ +\end_inset + +Symbols +\family default +, +\change_unchanged + \family sans Table \family default @@ -41156,12 +41180,34 @@ Panels toolbars can additionally be set to the state \emph on automatic +\change_deleted -712698321 1608195728 + \emph default -, denoted in the menu with the suffix +, +\change_inserted -712698321 1608196033 +. + The state of these toolbars is set and indicated in a submenu which lets + you select +\family sans +On +\family default +, +\family sans +Off +\family default +, and +\family sans +Automatic +\family default +. +\change_deleted -712698321 1608195563 +denoted in the menu with the suffix \family sans (auto) \family default . +\change_unchanged + \end_layout \begin_layout Standard @@ -41169,7 +41215,15 @@ In the \emph on on \emph default - state the toolbar is permanently shown; in the + state the toolbar is permanently shown +\change_inserted -712698321 1608195803 +, in the +\emph on +off +\emph default + state it is never shown +\change_unchanged +; in the \emph on automatic \emph default @@ -41177,7 +41231,11 @@ automatic or when a certain feature is enabled. That means that the review toolbar will only be shown if change tracking is activated, the math and table toolbars are only shown if the cursor - is inside a formula or table respectively. + is inside a formula or table respectively +\change_inserted -712698321 1608195857 +, the phonetic symbols toolbar only in the phonetic symbols environment +\change_unchanged +. \end_layout \begin_layout Standard diff --git a/lib/doc/de/UserGuide.lyx b/lib/doc/de/UserGuide.lyx index 105eb51c2e..dfe5702533 100644 --- a/lib/doc/de/UserGuide.lyx +++ b/lib/doc/de/UserGuide.lyx @@ -8649,10 +8649,12 @@ Unformatiert \end_layout \begin_layout Verbatim + Dies ist Unformatiert. \end_layout \begin_layout Verbatim + Die folgenden 2 Zeilen sind leer: \end_layout @@ -8665,6 +8667,7 @@ Die folgenden 2 Zeilen sind leer: \end_layout \begin_layout Verbatim + Fast alles ist in Unformatiert erlaubt:"%&$§#~'` \backslash }][{| @@ -8688,6 +8691,7 @@ Unformatiert \end_layout \begin_layout Verbatim* + Dies ist Unformatiert*. \end_layout @@ -38548,12 +38552,16 @@ enen Werkzeugleisten eingestellt werden. Befehlseingabefenster \family default können an- und ausgeschaltet werden. - Der Zustand + Der Status \emph on an \emph default ist im Menü mit einem Häkchen gekennzeichnet. - Die Werkzeugleisten + +\end_layout + +\begin_layout Standard +Die Werkzeugleisten \family sans Überarbeiten \family default @@ -38571,29 +38579,36 @@ Kontrollflächen \family default , \family sans -Mathe-Makros +Mathe-Makros, \family default - und + \family sans Mathe \family default - können zusätzlich auf den Zustand + und +\family sans +Phonetische Symbole +\family default + können zusätzlich auf den Status \emph on automatisch \emph default - gesetzt werden, der im Menü mit dem Suffix -\family sans -(automatisch) -\family default - gekennzeichnet ist. + gesetzt werden. + Der Status dieser Werkzeugleisten wird in einem Untermenü mit den Einträgen + Ein, Aus und Automatisch gesetzt und angezeigt. \end_layout \begin_layout Standard -Im Zustand +Im Status \emph on an \emph default - wird die Werkzeugleiste permanent angezeigt, im Zustand + wird die Werkzeugleiste permanent angezeigt, im Status +\emph on +aus +\emph default + nie. + Im Zustand \emph on automatisch \emph default @@ -38603,13 +38618,18 @@ automatisch \family sans Überarbeiten \family default - nur angezeigt wird, wenn Änderungsverfolgung aktiviert ist, die Mathe und - Tabellen Werkzeugleisten werden nur angezeigt, wenn der Cursor in einer + nur angezeigt wird, wenn Änderungsverfolgung aktiviert ist, die Mathe- + und Tabellen-Werkzeugleisten werden nur angezeigt, wenn der Cursor in einer Formel bzw. \begin_inset space \space{} \end_inset -Tabelle ist. +Tabelle ist, die Werkzeugleiste mit phonetischen Symbolen nur in der Einfügung + +\emph on +Phonetische Symbole +\emph default +. \end_layout \begin_layout Standard diff --git a/src/FuncCode.h b/src/FuncCode.h index 391faf71ce..6b970fb579 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -491,6 +491,8 @@ enum FuncCode LFUN_IF_RELATIVES, // spitz 20200102 LFUN_WINDOW_RAISE, // forenr, 20202104 LFUN_CITATION_OPEN, // sanda, 20200815 + LFUN_TOOLBAR_SET, // spitz 20201217 + // 385 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 25bf0493c6..462e397d3a 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3975,6 +3975,19 @@ void LyXAction::init() */ { LFUN_TOOLBAR_MOVABLE, "toolbar-movable", NoBuffer, Buffer }, +/*! + * \var lyx::FuncCode lyx::LFUN_TOOLBAR_SET + * \li Action: Sets visibility of a given toolbar to on, off, or auto. + * \li Notion: Skipping "auto" when allowauto is false. + * \li Syntax: toolbar-set [on|off|auto] + * \li Params: : standard|extra|table|math|mathmacrotemplate|\n + minibuffer|review|view/update|math_panels|vcs| + view-others|update-others + * \li Origin: spitz, 17 Dec 2020 + * \endvar + */ + { LFUN_TOOLBAR_SET, "toolbar-set", NoBuffer, Buffer }, + /*! * \var lyx::FuncCode lyx::LFUN_TOOLBAR_TOGGLE * \li Action: Toggles visibility of a given toolbar between on/off/auto. diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp index 4e906e5e71..5600f4a74f 100644 --- a/src/frontends/qt/GuiToolbar.cpp +++ b/src/frontends/qt/GuiToolbar.cpp @@ -611,36 +611,51 @@ bool GuiToolbar::isVisibiltyOn() const } -void GuiToolbar::toggle() +void GuiToolbar::setState(string const state) { - docstring state; - if (visibility_ & Toolbars::ALLOWAUTO) { - if (!(visibility_ & Toolbars::AUTO)) { + docstring newstate; + if (state == "auto") { + if (visibility_ & Toolbars::ALLOWAUTO) { visibility_ |= Toolbars::AUTO; hide(); - state = _("auto"); - } else { - visibility_ &= ~Toolbars::AUTO; - if (isVisible()) { - hide(); - state = _("off"); - } else { - show(); - state = _("on"); - } - } + newstate = _("auto"); + } else + owner_.message(bformat(_("Toolbar \"%1$s\" does not support state \"auto\""), + qstring_to_ucs4(windowTitle()))); } else { - if (isVisible()) { + if (visibility_ & Toolbars::AUTO) + visibility_ &= ~Toolbars::AUTO; + if (state == "off") { hide(); - state = _("off"); - } else { + newstate = _("off"); + } else if (state == "on") { show(); - state = _("on"); + newstate = _("on"); } } owner_.message(bformat(_("Toolbar \"%1$s\" state set to %2$s"), - qstring_to_ucs4(windowTitle()), state)); + qstring_to_ucs4(windowTitle()), newstate)); +} + + +void GuiToolbar::toggle() +{ + if (visibility_ & Toolbars::ALLOWAUTO) { + if (!(visibility_ & Toolbars::AUTO) && !isVisibiltyOn()) { + setState("auto"); + } else { + if (isVisibiltyOn()) + setState("off"); + else + setState("on"); + } + } else { + if (isVisible()) + setState("off"); + else + setState("on"); + } } void GuiToolbar::movable(bool silent) diff --git a/src/frontends/qt/GuiToolbar.h b/src/frontends/qt/GuiToolbar.h index aebc9e2844..262b09ef07 100644 --- a/src/frontends/qt/GuiToolbar.h +++ b/src/frontends/qt/GuiToolbar.h @@ -147,6 +147,8 @@ public: /// Refresh the contents of the bar. void update(int context = 0); + /// + void setState(std::string const state); /// void toggle(); diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 6f50a15d57..1643493c08 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -2117,6 +2117,41 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) flag.setOnOff(devel_mode_); break; + case LFUN_TOOLBAR_SET: { + string const name = cmd.getArg(0); + string const state = cmd.getArg(1); + if (name.empty() || state.empty()) { + enable = false; + docstring const msg = + _("Function toolbar-set requires two arguments!"); + flag.message(msg); + break; + } + if (state != "on" && state != "off" && state != "auto") { + enable = false; + docstring const msg = + bformat(_("Invalid argument \"%1$s\" to function toolbar-set!"), + from_utf8(state)); + flag.message(msg); + break; + } + if (GuiToolbar * t = toolbar(name)) { + bool const autovis = t->visibility() & Toolbars::AUTO; + if (state == "on") + flag.setOnOff(t->isVisible() && !autovis); + else if (state == "off") + flag.setOnOff(!t->isVisible() && !autovis); + else if (state == "auto") + flag.setOnOff(autovis); + } else { + enable = false; + docstring const msg = + bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)); + flag.message(msg); + } + break; + } + case LFUN_TOOLBAR_TOGGLE: { string const name = cmd.getArg(0); if (GuiToolbar * t = toolbar(name)) @@ -4275,6 +4310,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) dr.setMessage(_("Developer mode is now disabled.")); break; + case LFUN_TOOLBAR_SET: { + string const name = cmd.getArg(0); + string const state = cmd.getArg(1); + if (GuiToolbar * t = toolbar(name)) + t->setState(state); + break; + } + case LFUN_TOOLBAR_TOGGLE: { string const name = cmd.getArg(0); if (GuiToolbar * t = toolbar(name)) diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp index c30b73807c..266fb68d30 100644 --- a/src/frontends/qt/Menus.cpp +++ b/src/frontends/qt/Menus.cpp @@ -1415,8 +1415,19 @@ void MenuDefinition::expandToolbars() Toolbars::Infos::const_iterator cit = guiApp->toolbars().begin(); Toolbars::Infos::const_iterator end = guiApp->toolbars().end(); for (; cit != end; ++cit) { - MenuItem const item(MenuItem::Command, toqstr(cit->gui_name), - FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name)); + MenuItem item(MenuItem::Command, toqstr(cit->gui_name), + FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name)); + if (cit->allow_auto) { + MenuDefinition tristate; + tristate.add(MenuItem(MenuItem::Command, qt_("[[Toolbar]]On|O"), + FuncRequest(LFUN_TOOLBAR_SET, cit->name + " on"))); + tristate.add(MenuItem(MenuItem::Command, qt_("[[Toolbar]]Off|f"), + FuncRequest(LFUN_TOOLBAR_SET, cit->name + " off"))); + tristate.add(MenuItem(MenuItem::Command, qt_("[[Toolbar]]Automatic|A"), + FuncRequest(LFUN_TOOLBAR_SET, cit->name + " auto"))); + item = MenuItem(MenuItem::Submenu,toqstr(cit->gui_name)); + item.setSubmenu(tristate); + } if (guiApp->toolbars().isMainToolbar(cit->name)) add(item); else diff --git a/src/frontends/qt/Toolbars.cpp b/src/frontends/qt/Toolbars.cpp index 7d29344732..cf184ae9e2 100644 --- a/src/frontends/qt/Toolbars.cpp +++ b/src/frontends/qt/Toolbars.cpp @@ -405,8 +405,7 @@ void Toolbars::readToolbarSettings(Lexer & lex) if (visibility & ALLOWAUTO) { if (ToolbarInfo const * ti = info(name)) - const_cast(ti)->gui_name += - " (" + _("auto") + ")"; + const_cast(ti)->allow_auto = true; } } } diff --git a/src/frontends/qt/Toolbars.h b/src/frontends/qt/Toolbars.h index 2d9213986c..be621c9db8 100644 --- a/src/frontends/qt/Toolbars.h +++ b/src/frontends/qt/Toolbars.h @@ -80,12 +80,14 @@ public: typedef Items::const_iterator item_iterator; explicit ToolbarInfo(std::string const & name = std::string()) - : name(name) {} + : name(name), allow_auto(false) {} /// toolbar name std::string name; /// toolbar GUI name docstring gui_name; + /// allows auto visibility + bool allow_auto; /// toolbar contents Items items;