Module can register action Window adds this action to its menu Clicking the menu item for the action has the expected result But menu structure still needs work (everything is now put into one dropdown menu)
49 lines
1.1 KiB
C++
49 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
|