]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Action.h
Add missing initialization
[lyx.git] / src / frontends / qt4 / Action.h
index 570732653c95527bf0966a424314729326a8d505..8bc4a71f2442d0e0fce6082a1f5f9ea5dcc59dbd 100644 (file)
 #ifndef ACTION_H
 #define ACTION_H
 
-#include "frontends/LyXView.h"
-#include "funcrequest.h"
-
 #include <QAction>
+#include <memory>
 
-//class FuncRequest;
-
-//class string;
+class QIcon;
 
 namespace lyx {
+
+class FuncRequest;
+
 namespace frontend {
 
 /**
@@ -29,27 +28,33 @@ 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, std::string const & text,
-               FuncRequest const & func, std::string const & tooltip="");
+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, std::string const & text,
-               FuncRequest const & func, std::string const & tooltip="");
+       // 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_;
 };