#define ACTION_H
#include <QAction>
+#include <memory>
class QIcon;
Q_OBJECT
public:
- Action(QIcon const & icon, QString const & text,
- FuncRequest const & func, QString const & tooltip, QObject * parent);
+ // 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 update();
void action();
private:
- FuncRequest const & func_ ;
+ void init(QIcon const & icon, QString const & text, QString const & tooltip);
+ std::shared_ptr<FuncRequest const> func_;
};