Jean-Marc Lasgouttes 43eda5ad73 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).

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.
2020-04-14 22:47:56 +02:00

69 lines
1.3 KiB
C++

// -*- C++ -*-
/**
* \file Action.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef ACTION_H
#define ACTION_H
#include <QAction>
#include <memory>
class QIcon;
namespace lyx {
class FuncRequest;
namespace frontend {
/**
* Action - Qt interface with LyX' FuncRequest.
*
* Action can be used in LyX menubar and/or toolbars.
*/
class Action : public QAction
{
Q_OBJECT
public:
// Makes a copy of func
Action(FuncRequest func, QIcon const & icon, QString const & text,
QString const & tooltip, QObject * parent);
// Takes shared ownership of func.
// Use for perf-sensitive code such as populating menus.
Action(std::shared_ptr<FuncRequest const> func,
QIcon const & icon, QString const & text,
QString const & tooltip, QObject * parent);
void setRtlIcon(QIcon const & icon) { rtlIcon_ = icon; }
void update();
Q_SIGNALS:
/// the current action is triggered
void triggered(QAction *);
private Q_SLOTS:
void action();
private:
void init(QString const & text, QString const & tooltip);
std::shared_ptr<FuncRequest const> func_;
QIcon icon_;
QIcon rtlIcon_;
};
} // namespace frontend
} // namespace lyx
#endif // ACTION_H