]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/Action.h
Amend 4cd568d31266
[lyx.git] / src / frontends / qt / Action.h
1 // -*- C++ -*-
2 /**
3  * \file Action.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef ACTION_H
13 #define ACTION_H
14
15 #include <QAction>
16 #include <memory>
17
18 class QIcon;
19
20 namespace lyx {
21
22 class FuncRequest;
23
24 namespace frontend {
25
26 /**
27  * Action - Qt interface with LyX' FuncRequest.
28  *
29  * Action can be used in LyX menubar and/or toolbars.
30  */
31 class Action : public QAction
32 {
33         Q_OBJECT
34
35 public:
36         // Makes a copy of func
37         Action(FuncRequest func, QIcon const & icon, QString const & text,
38                QString const & tooltip, QObject * parent);
39
40         // Takes shared ownership of func.
41         // Use for perf-sensitive code such as populating menus.
42         Action(std::shared_ptr<FuncRequest const> func,
43                QIcon const & icon, QString const & text,
44                QString const & tooltip, QObject * parent);
45
46         void setRtlIcon(QIcon const & icon) { rtlIcon_ = icon; }
47
48         void update();
49
50 Q_SIGNALS:
51         /// the current action is triggered
52         void triggered(QAction *);
53
54 private Q_SLOTS:
55         void action();
56
57 private:
58         void init(QString const & text, QString const & tooltip);
59         std::shared_ptr<FuncRequest const> func_;
60         QIcon icon_;
61         QIcon rtlIcon_;
62 };
63
64
65 } // namespace frontend
66 } // namespace lyx
67
68 #endif // ACTION_H