[LyX/master] Reimplement properly bidi icons
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Wed Apr 15 10:46:42 UTC 2020
Le 14/04/2020 à 22:27, Jean-Marc Lasgouttes a écrit :
> commit 43eda5ad734e20e4759a225698f8977b9e38aa80
> Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
> Date: Tue Apr 14 22:41:00 2020 +0200
>
> Reimplement properly bidi icons
>
> When the cursor in RTL text, icons for "depth-increment" or
> "layout-toggle Enumerate" look wrong.
>
> Instead of relying on the clumsy "bidi" lfun of 2898c335, this new
> version relies on a new Toobar tag BidiItem that inserts an action
> which can have two icons, depending on the direction of the paragraph
> containing the caret (or of the direction of the UI when no file is
> open).
This new mechanism can probably be improved in several ways:
* icons could be mirrored programmatically if the +rtl version is not
provided (sufficient in most cases)
* the same mechanism could be expanded to support 3-state save icon that
we discussed earlier.
* this could be extended to things more complicated than plain Items if
there is a need.
My real problem now is that I have removed the useless LFUN_BIDI
function that is only needed for toolbar definition. Do I have to add a
lfun2lfun stage for that? I suspect the risk of introducing a bug is
larger than the benefit of updating something that nobody uses.
JMarc
>
> The alternative icon has the same name as the original one, with a
> "+rtl" string appended to the lfun string. The alternative icon is
> only active if the file is found. The icon themes `default', `oxygen'
> and `classic' have been updated accordingly.
>
> Fixes bug #4451.
> ---
> lib/Makefile.am | 39 +++++++++++++++-----
> lib/images/classic/depth-decrement+rtl.png | Bin 0 -> 202 bytes
> lib/images/classic/depth-increment+rtl.png | Bin 0 -> 205 bytes
> .../classic/layout-toggle_Description+rtl.png | Bin 0 -> 192 bytes
> lib/images/classic/layout-toggle_Enumerate+rtl.png | Bin 0 -> 189 bytes
> lib/images/classic/layout-toggle_Itemize+rtl.png | Bin 0 -> 183 bytes
> lib/images/classic/layout-toggle_Labeling+rtl.png | Bin 0 -> 158 bytes
> lib/images/classic/layout-toggle_List+rtl.png | Bin 0 -> 158 bytes
> lib/images/classic/layout-toggle_Section+rtl.png | Bin 0 -> 238 bytes
> lib/images/depth-decrement+rtl.svgz | Bin 0 -> 2339 bytes
> lib/images/depth-increment+rtl.svgz | Bin 0 -> 2378 bytes
> lib/images/layout-toggle_Description+rtl.svgz | Bin 0 -> 1848 bytes
> lib/images/layout-toggle_Enumerate+rtl.svgz | Bin 0 -> 2330 bytes
> lib/images/layout-toggle_Itemize+rtl.svgz | Bin 0 -> 1745 bytes
> lib/images/layout-toggle_Labeling+rtl.svgz | Bin 0 -> 1857 bytes
> lib/images/layout-toggle_List+rtl.svgz | Bin 0 -> 1857 bytes
> lib/images/layout-toggle_Section+rtl.svgz | Bin 0 -> 3565 bytes
> lib/images/oxygen/depth-decrement+rtl.svgz | Bin 0 -> 2245 bytes
> lib/images/oxygen/depth-increment+rtl.svgz | Bin 0 -> 2331 bytes
> .../oxygen/layout-toggle_Description+rtl.svgz | Bin 0 -> 1979 bytes
> lib/images/oxygen/layout-toggle_Enumerate+rtl.svgz | Bin 0 -> 4121 bytes
> lib/images/oxygen/layout-toggle_Itemize+rtl.svgz | Bin 0 -> 2122 bytes
> lib/images/oxygen/layout-toggle_Labeling+rtl.svgz | Bin 0 -> 1937 bytes
> lib/images/oxygen/layout-toggle_List+rtl.svgz | Bin 0 -> 1937 bytes
> lib/images/oxygen/layout-toggle_Section+rtl.svgz | Bin 0 -> 2712 bytes
> lib/ui/stdtoolbars.inc | 21 +++++++----
> src/frontends/qt/Action.cpp | 18 ++++++----
> src/frontends/qt/Action.h | 6 +++-
> src/frontends/qt/GuiApplication.cpp | 19 ++++++++--
> src/frontends/qt/GuiApplication.h | 8 +++-
> src/frontends/qt/GuiToolbar.cpp | 10 +++++-
> src/frontends/qt/Toolbars.cpp | 16 ++++++++
> src/frontends/qt/Toolbars.h | 2 +
> 33 files changed, 108 insertions(+), 31 deletions(-)
>
> diff --git a/lib/Makefile.am b/lib/Makefile.am
> index 0e51df7..bdd28b3 100644
> --- a/lib/Makefile.am
> +++ b/lib/Makefile.am
> @@ -568,7 +568,9 @@ dist_images_DATA1X = \
> images/tab-group-close.svgz \
> images/copy.svgz \
> images/cut.svgz \
> + images/depth-decrement+rtl.svgz \
> images/depth-decrement.svgz \
> + images/depth-increment+rtl.svgz \
> images/depth-increment.svgz \
> images/dialog-preferences.svgz \
> images/dialog-show-new-inset_citation.svgz \
> @@ -609,13 +611,18 @@ dist_images_DATA1X = \
> images/layout.svgz \
> images/layout-document.svgz \
> images/layout-paragraph.svgz \
> + images/layout-toggle_Chunk.svgz \
> + images/layout-toggle_Description+rtl.svgz \
> images/layout-toggle_Description.svgz \
> + images/layout-toggle_Enumerate+rtl.svgz \
> images/layout-toggle_Enumerate.svgz \
> + images/layout-toggle_Itemize+rtl.svgz \
> images/layout-toggle_Itemize.svgz \
> + images/layout-toggle_Labeling+rtl.svgz \
> images/layout-toggle_Labeling.svgz \
> images/layout-toggle_List.svgz \
> images/layout-toggle_LyX-Code.svgz \
> - images/layout-toggle_Chunk.svgz \
> + images/layout-toggle_Section+rtl.svgz \
> images/layout-toggle_Section.svgz \
> images/lyxfiles-system.svgz \
> images/lyxfiles-user.svgz \
> @@ -1853,7 +1860,9 @@ dist_imagesoxygen_DATA1X = \
> images/oxygen/closetab.svgz \
> images/oxygen/copy.svgz \
> images/oxygen/cut.svgz \
> + images/oxygen/depth-decrement+rtl.svgz \
> images/oxygen/depth-decrement.svgz \
> + images/oxygen/depth-increment+rtl.svgz \
> images/oxygen/depth-increment.svgz \
> images/oxygen/dialog-preferences.svgz \
> images/oxygen/dialog-show-new-inset_citation.svgz \
> @@ -1892,12 +1901,17 @@ dist_imagesoxygen_DATA1X = \
> images/oxygen/layout-paragraph.svgz \
> images/oxygen/layout.svgz \
> images/oxygen/layout-toggle_Chunk.svgz \
> + images/oxygen/layout-toggle_Description+rtl.svgz \
> images/oxygen/layout-toggle_Description.svgz \
> - images/oxygen/layout-toggle_Enumerate.svgz \
> + images/oxygen/layout-toggle_Enumerate+rtl.svgz \
> + images/oxygen/layout-toggle_Enumerate.svgz \
> + images/oxygen/layout-toggle_Itemize+rtl.svgz \
> images/oxygen/layout-toggle_Itemize.svgz \
> + images/oxygen/layout-toggle_Labeling+rtl.svgz \
> images/oxygen/layout-toggle_Labeling.svgz \
> images/oxygen/layout-toggle_List.svgz \
> images/oxygen/layout-toggle_LyX-Code.svgz \
> + images/oxygen/layout-toggle_Section+rtl.svgz \
> images/oxygen/layout-toggle_Section.svgz \
> images/oxygen/lyx-quit.svgz \
> images/oxygen/marginalnote-insert.svgz \
> @@ -2057,7 +2071,9 @@ dist_imagesclassic_DATA = \
> images/classic/tab-group-close.png \
> images/classic/copy.png \
> images/classic/cut.png \
> + images/classic/depth-decrement+rtl.png \
> images/classic/depth-decrement.png \
> + images/classic/depth-increment+rtl.png \
> images/classic/depth-increment.png \
> images/classic/dialog-preferences.png \
> images/classic/dialog-show_mathdelimiter.png \
> @@ -2092,14 +2108,19 @@ dist_imagesclassic_DATA = \
> images/classic/layout-document.png \
> images/classic/layout-paragraph.png \
> images/classic/layout.png \
> - images/classic/layout-toggle_Description.png \
> - images/classic/layout-toggle_Enumerate.png \
> - images/classic/layout-toggle_Itemize.png \
> - images/classic/layout-toggle_Labeling.png \
> - images/classic/layout-toggle_List.png \
> - images/classic/layout-toggle_LyX-Code.png \
> images/classic/layout-toggle_Chunk.png \
> - images/classic/layout-toggle_Section.png \
> + images/classic/layout-toggle_Description+rtl.png \
> + images/classic/layout-toggle_Description.png \
> + images/classic/layout-toggle_Enumerate+rtl.png \
> + images/classic/layout-toggle_Enumerate.png \
> + images/classic/layout-toggle_Itemize+rtl.png \
> + images/classic/layout-toggle_Itemize.png \
> + images/classic/layout-toggle_Labeling+rtl.png \
> + images/classic/layout-toggle_Labeling.png \
> + images/classic/layout-toggle_List.png \
> + images/classic/layout-toggle_LyX-Code.png \
> + images/classic/layout-toggle_Section+rtl.png \
> + images/classic/layout-toggle_Section.png \
> images/classic/marginalnote-insert.png \
> images/classic/master-buffer-update.png \
> images/classic/master-buffer-view.png \
> diff --git a/lib/images/classic/depth-decrement+rtl.png b/lib/images/classic/depth-decrement+rtl.png
> new file mode 100644
> index 0000000..c5c10d0
> Binary files /dev/null and b/lib/images/classic/depth-decrement+rtl.png differ
> diff --git a/lib/images/classic/depth-increment+rtl.png b/lib/images/classic/depth-increment+rtl.png
> new file mode 100644
> index 0000000..82517d8
> Binary files /dev/null and b/lib/images/classic/depth-increment+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_Description+rtl.png b/lib/images/classic/layout-toggle_Description+rtl.png
> new file mode 100644
> index 0000000..9725c96
> Binary files /dev/null and b/lib/images/classic/layout-toggle_Description+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_Enumerate+rtl.png b/lib/images/classic/layout-toggle_Enumerate+rtl.png
> new file mode 100644
> index 0000000..9b22744
> Binary files /dev/null and b/lib/images/classic/layout-toggle_Enumerate+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_Itemize+rtl.png b/lib/images/classic/layout-toggle_Itemize+rtl.png
> new file mode 100644
> index 0000000..2e86102
> Binary files /dev/null and b/lib/images/classic/layout-toggle_Itemize+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_Labeling+rtl.png b/lib/images/classic/layout-toggle_Labeling+rtl.png
> new file mode 100644
> index 0000000..5f0c84e
> Binary files /dev/null and b/lib/images/classic/layout-toggle_Labeling+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_List+rtl.png b/lib/images/classic/layout-toggle_List+rtl.png
> new file mode 100644
> index 0000000..5f0c84e
> Binary files /dev/null and b/lib/images/classic/layout-toggle_List+rtl.png differ
> diff --git a/lib/images/classic/layout-toggle_Section+rtl.png b/lib/images/classic/layout-toggle_Section+rtl.png
> new file mode 100644
> index 0000000..e17c0dd
> Binary files /dev/null and b/lib/images/classic/layout-toggle_Section+rtl.png differ
> diff --git a/lib/images/depth-decrement+rtl.svgz b/lib/images/depth-decrement+rtl.svgz
> new file mode 100644
> index 0000000..cd87995
> Binary files /dev/null and b/lib/images/depth-decrement+rtl.svgz differ
> diff --git a/lib/images/depth-increment+rtl.svgz b/lib/images/depth-increment+rtl.svgz
> new file mode 100644
> index 0000000..7a77e62
> Binary files /dev/null and b/lib/images/depth-increment+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_Description+rtl.svgz b/lib/images/layout-toggle_Description+rtl.svgz
> new file mode 100644
> index 0000000..8a421ea
> Binary files /dev/null and b/lib/images/layout-toggle_Description+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_Enumerate+rtl.svgz b/lib/images/layout-toggle_Enumerate+rtl.svgz
> new file mode 100644
> index 0000000..203ac9f
> Binary files /dev/null and b/lib/images/layout-toggle_Enumerate+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_Itemize+rtl.svgz b/lib/images/layout-toggle_Itemize+rtl.svgz
> new file mode 100644
> index 0000000..dc8b357
> Binary files /dev/null and b/lib/images/layout-toggle_Itemize+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_Labeling+rtl.svgz b/lib/images/layout-toggle_Labeling+rtl.svgz
> new file mode 100644
> index 0000000..b24502f
> Binary files /dev/null and b/lib/images/layout-toggle_Labeling+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_List+rtl.svgz b/lib/images/layout-toggle_List+rtl.svgz
> new file mode 100644
> index 0000000..b24502f
> Binary files /dev/null and b/lib/images/layout-toggle_List+rtl.svgz differ
> diff --git a/lib/images/layout-toggle_Section+rtl.svgz b/lib/images/layout-toggle_Section+rtl.svgz
> new file mode 100644
> index 0000000..8d9e340
> Binary files /dev/null and b/lib/images/layout-toggle_Section+rtl.svgz differ
> diff --git a/lib/images/oxygen/depth-decrement+rtl.svgz b/lib/images/oxygen/depth-decrement+rtl.svgz
> new file mode 100644
> index 0000000..ceb1a7d
> Binary files /dev/null and b/lib/images/oxygen/depth-decrement+rtl.svgz differ
> diff --git a/lib/images/oxygen/depth-increment+rtl.svgz b/lib/images/oxygen/depth-increment+rtl.svgz
> new file mode 100644
> index 0000000..b2890f4
> Binary files /dev/null and b/lib/images/oxygen/depth-increment+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_Description+rtl.svgz b/lib/images/oxygen/layout-toggle_Description+rtl.svgz
> new file mode 100644
> index 0000000..4c906b1
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_Description+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_Enumerate+rtl.svgz b/lib/images/oxygen/layout-toggle_Enumerate+rtl.svgz
> new file mode 100644
> index 0000000..19907b4
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_Enumerate+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_Itemize+rtl.svgz b/lib/images/oxygen/layout-toggle_Itemize+rtl.svgz
> new file mode 100644
> index 0000000..1f71c41
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_Itemize+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_Labeling+rtl.svgz b/lib/images/oxygen/layout-toggle_Labeling+rtl.svgz
> new file mode 100644
> index 0000000..ca26ee0
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_Labeling+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_List+rtl.svgz b/lib/images/oxygen/layout-toggle_List+rtl.svgz
> new file mode 100644
> index 0000000..ca26ee0
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_List+rtl.svgz differ
> diff --git a/lib/images/oxygen/layout-toggle_Section+rtl.svgz b/lib/images/oxygen/layout-toggle_Section+rtl.svgz
> new file mode 100644
> index 0000000..ba5dfa5
> Binary files /dev/null and b/lib/images/oxygen/layout-toggle_Section+rtl.svgz differ
> diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc
> index 4af3606..7b6c129 100644
> --- a/lib/ui/stdtoolbars.inc
> +++ b/lib/ui/stdtoolbars.inc
> @@ -36,13 +36,18 @@
> # Item "Small font" "font-size small"
> # Item Emphasized set-emph
> #
> +# BidiItem is like Item, but an alternative icon (with name ending
> +# with "+rtl") will be used <hen the paragraph has a right-to-left
> +# layout.
> +#
> # Layouts adds the layouts combo-box to the toolbar
> #
> # Separator adds some spacing to the toolbar
> #
> -# Minibuffer adds the command buffer (Qt only, only one may exist)
> +# Minibuffer adds the command buffer (only one may exist)
> #
> -# TableInsert "The tooltip" adds a special widget for quick insertion of tables
> +# TableInsert "The tooltip" adds a special widget for quick
> +# insertion of tables
> #
> # PopupMenu "name" "The tooltip"
> #
> @@ -113,12 +118,12 @@ ToolbarSet
>
> Toolbar "extra" "Extra"
> Item "Default" "layout"
> - Item "Numbered list" "layout-toggle Enumerate"
> - Item "Itemized list" "layout-toggle Itemize"
> - Item "Labeled List" "layout-toggle Labeling"
> - Item "Description" "layout-toggle Description"
> - Item "Increase depth" "depth-increment"
> - Item "Decrease depth" "depth-decrement"
> + BidiItem "Numbered list" "layout-toggle Enumerate"
> + BidiItem "Itemized list" "layout-toggle Itemize"
> + BidiItem "Labeled List" "layout-toggle Labeling"
> + BidiItem "Description" "layout-toggle Description"
> + BidiItem "Increase depth" "depth-increment"
> + BidiItem "Decrease depth" "depth-decrement"
> Separator
> Item "Insert figure float" "float-insert figure"
> Item "Insert table float" "float-insert table"
> diff --git a/src/frontends/qt/Action.cpp b/src/frontends/qt/Action.cpp
> index bd102e6..cc16190 100644
> --- a/src/frontends/qt/Action.cpp
> +++ b/src/frontends/qt/Action.cpp
> @@ -11,6 +11,7 @@
> #include <config.h>
>
> #include "Action.h"
> +#include "GuiApplication.h"
>
> // DispatchResult.h is needed by the windows compiler because lyx::dispatch
> // returns a DispatchResult const reference. Gcc does not complain. Weird...
> @@ -33,27 +34,25 @@ namespace frontend {
>
> Action::Action(FuncRequest func, QIcon const & icon, QString const & text,
> QString const & tooltip, QObject * parent)
> - : QAction(parent), func_(make_shared<FuncRequest>(move(func)))
> + : QAction(parent), func_(make_shared<FuncRequest>(move(func))), icon_(icon)
> {
> - init(icon, text, tooltip);
> + init(text, tooltip);
> }
>
>
> Action::Action(shared_ptr<FuncRequest const> func,
> QIcon const & icon, QString const & text,
> QString const & tooltip, QObject * parent)
> - : QAction(parent), func_(func)
> + : QAction(parent), func_(func), icon_(icon)
> {
> - init(icon, text, tooltip);
> + init(text, tooltip);
> }
>
>
> -void Action::init(QIcon const & icon, QString const & text,
> - QString const & tooltip)
> +void Action::init(QString const & text, QString const & tooltip)
> {
> // only Qt/Mac handles that
> setMenuRole(NoRole);
> - setIcon(icon);
> setText(text);
> setToolTip(tooltip);
> setStatusTip(tooltip);
> @@ -76,6 +75,11 @@ void Action::update()
> setCheckable(false);
> }
>
> + if (rtlIcon_.isNull() || !guiApp->rtlContext())
> + setIcon(icon_);
> + else
> + setIcon(rtlIcon_);
> +
> setEnabled(status.enabled());
> }
>
> diff --git a/src/frontends/qt/Action.h b/src/frontends/qt/Action.h
> index 8bc4a71..411eb72 100644
> --- a/src/frontends/qt/Action.h
> +++ b/src/frontends/qt/Action.h
> @@ -43,6 +43,8 @@ public:
> QIcon const & icon, QString const & text,
> QString const & tooltip, QObject * parent);
>
> + void setRtlIcon(QIcon const & icon) { rtlIcon_ = icon; }
> +
> void update();
>
> Q_SIGNALS:
> @@ -53,8 +55,10 @@ private Q_SLOTS:
> void action();
>
> private:
> - void init(QIcon const & icon, QString const & text, QString const & tooltip);
> + void init(QString const & text, QString const & tooltip);
> std::shared_ptr<FuncRequest const> func_;
> + QIcon icon_;
> + QIcon rtlIcon_;
> };
>
>
> diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
> index 64ab6cf..ddc06bd 100644
> --- a/src/frontends/qt/GuiApplication.cpp
> +++ b/src/frontends/qt/GuiApplication.cpp
> @@ -486,7 +486,7 @@ QString themeIconName(QString const & action)
> }
>
>
> -QString iconName(FuncRequest const & f, bool unknown)
> +QString iconName(FuncRequest const & f, bool unknown, QString const & suffix)
> {
> initializeResources();
> QString name1;
> @@ -527,6 +527,9 @@ QString iconName(FuncRequest const & f, bool unknown)
> }
> }
>
> + // maybe a suffix?
> + name1 += suffix;
> +
> QStringList imagedirs;
> imagedirs << "images/" << "images/ipa/";
> search_mode mode = theGuiApp()->imageSearchMode();
> @@ -611,7 +614,7 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex
> }
>
>
> -QIcon getIcon(FuncRequest const & f, bool unknown)
> +QIcon getIcon(FuncRequest const & f, bool unknown, QString const & suffix)
> {
> #if (QT_VERSION >= 0x040600)
> if (lyxrc.use_system_theme_icons) {
> @@ -628,7 +631,7 @@ QIcon getIcon(FuncRequest const & f, bool unknown)
> }
> #endif
>
> - QString icon = iconName(f, unknown);
> + QString icon = iconName(f, unknown, suffix);
> if (icon.isEmpty())
> return QIcon();
>
> @@ -2400,6 +2403,16 @@ void GuiApplication::resetGui()
> }
>
>
> +bool GuiApplication::rtlContext() const
> +{
> + if (current_view_ && current_view_->currentBufferView()) {
> + BufferView const * bv = current_view_->currentBufferView();
> + return bv->cursor().innerParagraph().isRTL(bv->buffer().params());
> + } else
> + return layoutDirection() == Qt::RightToLeft;
> +}
> +
> +
> void GuiApplication::createView(int view_id)
> {
> createView(QString(), true, view_id);
> diff --git a/src/frontends/qt/GuiApplication.h b/src/frontends/qt/GuiApplication.h
> index f5b11c9..ba603d6 100644
> --- a/src/frontends/qt/GuiApplication.h
> +++ b/src/frontends/qt/GuiApplication.h
> @@ -88,6 +88,8 @@ public:
> void hideDialogs(std::string const & name, Inset * inset) const;
> ///
> void resetGui();
> + /// Return true if current position is RTL of if no document is open and interface if RTL
> + bool rtlContext() const;
>
> ///
> Clipboard & clipboard();
> @@ -256,7 +258,8 @@ private:
> extern GuiApplication * guiApp;
>
> /// \return the icon file name for the given action.
> -QString iconName(FuncRequest const & f, bool unknown);
> +QString iconName(FuncRequest const & f, bool unknown,
> + QString const & suffix = QString());
>
> /// \return the pixmap for the given path, name and extension.
> /// in case of errors a warning is produced and an empty pixmap is returned.
> @@ -267,7 +270,8 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex
> bool getPixmap(QPixmap & pixmap, QString const & path);
>
> /// \return an icon for the given action.
> -QIcon getIcon(FuncRequest const & f, bool unknown);
> +QIcon getIcon(FuncRequest const & f, bool unknown,
> + QString const & suffix = QString());
>
> ///
> GuiApplication * theGuiApp();
> diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp
> index 9da3306..11cb1e3 100644
> --- a/src/frontends/qt/GuiToolbar.cpp
> +++ b/src/frontends/qt/GuiToolbar.cpp
> @@ -129,7 +129,10 @@ Action * GuiToolbar::addItem(ToolbarItem const & item)
> text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
>
> Action * act = new Action(item.func_, getIcon(*item.func_, false), text,
> - text, this);
> + text, this);
> + if (item.type_ == ToolbarItem::BIDICOMMAND)
> + act->setRtlIcon(getIcon(*item.func_, false, "+rtl"));
> +
> actions_.append(act);
> return act;
> }
> @@ -518,6 +521,11 @@ void GuiToolbar::add(ToolbarItem const & item)
> LYXERR0("Unknown dynamic menu type: " << item.name_);
> break;
> }
> + case ToolbarItem::BIDICOMMAND: {
> + if (!getStatus(*item.func_).unknown())
> + addAction(addItem(item));
> + break;
> + }
> case ToolbarItem::COMMAND: {
> if (!getStatus(*item.func_).unknown())
> addAction(addItem(item));
> diff --git a/src/frontends/qt/Toolbars.cpp b/src/frontends/qt/Toolbars.cpp
> index bf4617c..5455f86 100644
> --- a/src/frontends/qt/Toolbars.cpp
> +++ b/src/frontends/qt/Toolbars.cpp
> @@ -63,6 +63,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
> {
> enum {
> TO_COMMAND = 1,
> + TO_BIDICOMMAND,
> TO_ENDTOOLBAR,
> TO_SEPARATOR,
> TO_LAYOUTS,
> @@ -79,6 +80,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
> };
>
> struct LexerKeyword toolTags[] = {
> + { "bidiitem", TO_BIDICOMMAND},
> { "dynamicmenu", TO_DYNAMICMENU},
> { "end", TO_ENDTOOLBAR },
> { "exportformats", TO_EXPORTFORMATS },
> @@ -138,6 +140,20 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
> }
> break;
>
> + case TO_BIDICOMMAND:
> + if (lex.next(true)) {
> + docstring const tooltip = translateIfPossible(lex.getDocString());
> + lex.next(true);
> + string const func_arg = lex.getString();
> + LYXERR(Debug::PARSER, "ToolbarInfo::read TO_BIDICOMMAND func: `"
> + << func_arg << '\'');
> +
> + FuncRequest func =
> + lyxaction.lookupFunc(func_arg);
> + add(ToolbarItem(ToolbarItem::BIDICOMMAND, func, tooltip));
> + }
> + break;
> +
> case TO_MINIBUFFER:
> add(ToolbarItem(ToolbarItem::MINIBUFFER,
> FuncRequest(FuncCode(ToolbarItem::MINIBUFFER))));
> diff --git a/src/frontends/qt/Toolbars.h b/src/frontends/qt/Toolbars.h
> index a4acb41..4a0a64f 100644
> --- a/src/frontends/qt/Toolbars.h
> +++ b/src/frontends/qt/Toolbars.h
> @@ -29,6 +29,8 @@ namespace frontend {
> class ToolbarItem {
> public:
> enum Type {
> + /// command/action with rtl version
> + BIDICOMMAND,
> /// command/action
> COMMAND,
> /// the command buffer
>
More information about the lyx-devel
mailing list