Proof of concept for having the context actions statically defined in the module.
Needs work for correctly placing the items in menu and on toolbar. Old system still needs to be removed left in place to keep app useable.
This commit is contained in:
parent
7f09d5fe07
commit
601d071d0f
21 changed files with 303 additions and 70 deletions
|
|
@ -3,10 +3,12 @@
|
|||
|
||||
#include "plugin_support/IPluginContentWidgetContext.h"
|
||||
#include <QList>
|
||||
#include <typeindex>
|
||||
|
||||
class LContextAction;
|
||||
class QToolBar;
|
||||
class QAction;
|
||||
class QMenuBar;
|
||||
|
||||
/// Maintains the list of actions added to a toolbar for a specific widget
|
||||
/// it facilitates the removal of all those actions.
|
||||
|
|
@ -32,13 +34,19 @@ private:
|
|||
|
||||
class LWidgetData {
|
||||
public:
|
||||
LWidgetData(PluginModule *module);
|
||||
LWidgetData(PluginModule *module, PluginContentWidget *widget);
|
||||
PluginModule* module() { return m_module; }
|
||||
void init(PluginContentWidget *widget);
|
||||
PluginContentWidget *widget() { return m_widget; }
|
||||
void init();
|
||||
|
||||
void addToMenu(QMenuBar* menubar);
|
||||
void removeFromMenu(QMenuBar* menubar);
|
||||
private:
|
||||
PluginModule *m_module;
|
||||
PluginContentWidget *m_widget;
|
||||
WidgetToolbarManager m_toolbarManager;
|
||||
|
||||
std::vector<QAction*> m_menuActions; ///< List of actions we put in the menu
|
||||
};
|
||||
|
||||
/// Provides base implementation of IPluginContentWidgetContext
|
||||
|
|
@ -53,16 +61,19 @@ public:
|
|||
const ModuleActionParameters &action_params
|
||||
) override;
|
||||
|
||||
void addContentWidget(PluginModule *module, PluginContentWidget *widget) override;
|
||||
void addContentWidget(PluginContentWidget *widget) override;
|
||||
void removeContentWidget(PluginContentWidget *widget) override;
|
||||
|
||||
void addWidgetActionsToToolbar(PluginContentWidget *widget, QToolBar *toolbar);
|
||||
void removeWidgetActionsFromToolbar(PluginContentWidget *widget, QToolBar *toolbar);
|
||||
|
||||
void addContextActionsToMenu(PluginContentWidget *widget, QMenuBar *menubar);
|
||||
void removeContextActionsFromMenu(PluginContentWidget *widget, QMenuBar *menubar);
|
||||
private:
|
||||
|
||||
using WidgetLst = std::map<PluginContentWidget*, LWidgetData>;
|
||||
|
||||
WidgetLst m_widgetLst;
|
||||
WidgetLst m_widgetLst; /// Keeps track of which widget belongs to which module
|
||||
};
|
||||
|
||||
#endif // PLUGINCONTENTWIDGETCONTEXTBASE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue