2019-01-01 11:15:16 +01:00
|
|
|
|
#ifndef MENUACTION_H
|
2019-01-01 08:26:20 +01:00
|
|
|
|
#define MENUACTION_H
|
|
|
|
|
|
|
2019-01-01 11:15:16 +01:00
|
|
|
|
#include "MenuLocation.h"
|
|
|
|
|
|
#include "ToolbarLocation.h"
|
2019-01-01 08:26:20 +01:00
|
|
|
|
|
2019-01-01 11:15:16 +01:00
|
|
|
|
#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 {
|
2019-01-01 08:26:20 +01:00
|
|
|
|
public:
|
2019-01-01 11:15:16 +01:00
|
|
|
|
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);
|
2019-01-31 19:25:54 +01:00
|
|
|
|
void setToolbarLocation(ToolbarLocation toolbar_location);
|
2019-01-05 19:58:23 +01:00
|
|
|
|
void setShortcut(QKeySequence shortcut);
|
2019-01-01 11:15:16 +01:00
|
|
|
|
void setText(QString text);
|
|
|
|
|
|
void setToolTip(QString tooltip);
|
2019-01-05 19:58:23 +01:00
|
|
|
|
const QKeySequence& shortcut() const;
|
2019-01-01 11:15:16 +01:00
|
|
|
|
const QString& text() const;
|
|
|
|
|
|
const QString& toolTip() const;
|
|
|
|
|
|
|
|
|
|
|
|
void perform(IPluginContentWidgetContext *context) const;
|
|
|
|
|
|
private:
|
|
|
|
|
|
QString m_text;
|
|
|
|
|
|
QString m_toolTip;
|
|
|
|
|
|
QIcon m_icon;
|
2019-01-05 19:58:23 +01:00
|
|
|
|
QKeySequence m_shortcut;
|
2019-01-01 11:15:16 +01:00
|
|
|
|
MenuLocation m_menuLocation;
|
2019-01-31 19:25:54 +01:00
|
|
|
|
ToolbarLocation m_toolbarLocation;
|
2019-01-01 11:15:16 +01:00
|
|
|
|
|
|
|
|
|
|
Func m_func;
|
2019-01-01 08:26:20 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2019-01-01 11:15:16 +01:00
|
|
|
|
#endif // MENUACTION_H
|