#ifndef ACTION_H
#define ACTION_H
-#include "frontends/LyXView.h"
-#include "funcrequest.h"
-
-#include "support/docstring.h"
-
#include <QAction>
+#include <memory>
-//class FuncRequest;
-
-//class string;
+class QIcon;
namespace lyx {
+
+class FuncRequest;
+
namespace frontend {
/**
*
* Action can be used in LyX menubar and/or toolbars.
*/
-class Action: public QAction {
+class Action : public QAction
+{
Q_OBJECT
-public:
- Action(LyXView & lyxView, lyx::docstring const & text,
- FuncRequest const & func, lyx::docstring const & tooltip = lyx::docstring());
+public:
+ // Makes a copy of func
+ Action(FuncRequest func, QIcon const & icon, QString const & text,
+ QString const & tooltip, QObject * parent);
- Action(LyXView & lyxView, std::string const & icon, lyx::docstring const & text,
- FuncRequest const & func, lyx::docstring const & tooltip = lyx::docstring());
+ // 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 update();
-// void setAction(FuncRequest const & func);
+Q_SIGNALS:
+ /// the current action is triggered
+ void triggered(QAction *);
private Q_SLOTS:
void action();
private:
- FuncRequest const & func_ ;
- //FuncRequest func_ ;
- LyXView & lyxView_;
+ void init(QIcon const & icon, QString const & text, QString const & tooltip);
+ std::shared_ptr<FuncRequest const> func_;
};