pgLab/pglab/plugin_support/MenuAction.h
eelke f4f2474a81 Moved definition of widget instance actions to the module so other parts of the system can no about them.
The plugin system will create the Action objects and bind them to the specified slots of the
specific widget instances.
2019-01-05 19:58:23 +01:00

48 lines
1.1 KiB
C++

#ifndef MENUACTION_H
#define MENUACTION_H
#include "MenuLocation.h"
#include "ToolbarLocation.h"
#include <QIcon>
#include <QKeySequence>
#include <QString>
#include <functional>
class QAction;
class IPluginContentWidgetContext;
/** An action for in a menu or toolbar that does not pertain to a specific
* widget. It often will create a widget for instance a New or Open action.
* It does need a context.
*
*/
class MenuAction {
public:
using Func = std::function<void(IPluginContentWidgetContext *context)>;
MenuAction(QString text, Func func);
const QIcon& icon() const;
const MenuLocation& menuLocation() const;
void setIcon(QIcon icon);
void setMenuLocation(MenuLocation menu_location);
void setShortcut(QKeySequence shortcut);
void setText(QString text);
void setToolTip(QString tooltip);
const QKeySequence& shortcut() const;
const QString& text() const;
const QString& toolTip() const;
void perform(IPluginContentWidgetContext *context) const;
private:
QString m_text;
QString m_toolTip;
QIcon m_icon;
QKeySequence m_shortcut;
MenuLocation m_menuLocation;
Func m_func;
};
#endif // MENUACTION_H