Basic concept of MenuAction is working
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)
This commit is contained in:
parent
f130c426a1
commit
dc8a052544
12 changed files with 220 additions and 28 deletions
|
|
@ -1,11 +1,49 @@
|
|||
#ifndef MENUACTION_H
|
||||
#ifndef MENUACTION_H
|
||||
#define MENUACTION_H
|
||||
|
||||
#include "MenuLocation.h"
|
||||
#include "ToolbarLocation.h"
|
||||
|
||||
class MenuAction
|
||||
{
|
||||
#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:
|
||||
MenuAction();
|
||||
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
|
||||
|
||||
#endif // MENUACTION_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue