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.
This commit is contained in:
eelke 2019-01-05 19:58:23 +01:00
parent d0c4dabe8b
commit f4f2474a81
21 changed files with 418 additions and 204 deletions

View file

@ -2,6 +2,26 @@
#define PLUGINCONTENTWIDGETCONTEXTBASE_H
#include "plugin_support/IPluginContentWidgetContext.h"
#include <QList>
class LWidgetAction;
class QToolBar;
class QAction;
class LWidgetData {
public:
LWidgetData(PluginModule *module);
PluginModule* module() { return m_module; }
void init(PluginContentWidget *widget);
QList<QAction *> actions();
private:
PluginModule *m_module;
/// List of actions specifically created for this widget from the widgetAction list of the module.
QList<QAction *> m_widgetActions;
QAction *createAction(const LWidgetAction &wa, PluginContentWidget *widget);
};
/// Provides base implementation of IPluginContentWidgetContext
class PluginContentWidgetContextBase : public IPluginContentWidgetContext
@ -14,6 +34,17 @@ public:
QString module_action,
const ModuleActionParameters &action_params
) override;
void addContentWidget(PluginModule *module, PluginContentWidget *widget) override;
void removeContentWidget(PluginContentWidget *widget) override;
void addWidgetActionsToToolbar(PluginContentWidget *widget, QToolBar *toolbar);
void removeWidgetActionsFromToolbar(PluginContentWidget *widget, QToolBar *toolbar);
private:
using WidgetLst = std::map<PluginContentWidget*, LWidgetData>;
WidgetLst m_widgetLst;
};
#endif // PLUGINCONTENTWIDGETCONTEXTBASE_H