X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FAction.h;h=8bc4a71f2442d0e0fce6082a1f5f9ea5dcc59dbd;hb=1f10969bb5c5f36017bf5ba8671381b09945cf57;hp=570732653c95527bf0966a424314729326a8d505;hpb=82a90fceb77907fcbf97629cad88978b0a62ecf6;p=lyx.git diff --git a/src/frontends/qt4/Action.h b/src/frontends/qt4/Action.h index 570732653c..8bc4a71f24 100644 --- a/src/frontends/qt4/Action.h +++ b/src/frontends/qt4/Action.h @@ -12,16 +12,15 @@ #ifndef ACTION_H #define ACTION_H -#include "frontends/LyXView.h" -#include "funcrequest.h" - #include +#include -//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 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 func_; };