Bunch of renames to reduce confusion.
This commit is contained in:
parent
cbb2f897aa
commit
be2ffd7ef9
15 changed files with 184 additions and 184 deletions
61
pglab/plugin_support/LContextAction.cpp
Normal file
61
pglab/plugin_support/LContextAction.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "LContextAction.h"
|
||||
|
||||
LContextAction::LContextAction(QString text, const char * slotname)
|
||||
: m_text(std::move(text))
|
||||
, m_slotname(slotname)
|
||||
{}
|
||||
|
||||
const QIcon& LContextAction::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const MenuLocation& LContextAction::menuLocation() const
|
||||
{
|
||||
return m_menuLocation;
|
||||
}
|
||||
|
||||
void LContextAction::setIcon(QIcon icon)
|
||||
{
|
||||
m_icon = std::move(icon);
|
||||
}
|
||||
|
||||
void LContextAction::setMenuLocation(MenuLocation menu_location)
|
||||
{
|
||||
m_menuLocation = std::move(menu_location);
|
||||
}
|
||||
|
||||
void LContextAction::setToolbarLocation(ToolbarLocation toolbar_location)
|
||||
{
|
||||
m_toolbarLocation = toolbar_location;
|
||||
}
|
||||
|
||||
void LContextAction::setShortcut(QKeySequence shortcut)
|
||||
{
|
||||
m_shortCut = std::move(shortcut);
|
||||
}
|
||||
|
||||
void LContextAction::setText(QString text)
|
||||
{
|
||||
m_text = std::move(text);
|
||||
}
|
||||
|
||||
void LContextAction::setToolTip(QString tooltip)
|
||||
{
|
||||
m_toolTip = std::move(tooltip);
|
||||
}
|
||||
|
||||
const QKeySequence& LContextAction::shortcut() const
|
||||
{
|
||||
return m_shortCut;
|
||||
}
|
||||
|
||||
const QString& LContextAction::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
const QString& LContextAction::toolTip() const
|
||||
{
|
||||
return m_toolTip;
|
||||
}
|
||||
|
|
@ -12,11 +12,11 @@
|
|||
* so the action can be defined before the widget instance is created.
|
||||
* The plugin mechanism will take care of instantiating a connection to the named slot.
|
||||
*/
|
||||
class LWidgetAction {
|
||||
class LContextAction {
|
||||
public:
|
||||
///
|
||||
/// \param slotname, use SLOT macro to pass name of the slot
|
||||
LWidgetAction(QString text, const char * slotname);
|
||||
LContextAction(QString text, const char * slotname);
|
||||
|
||||
const QIcon& icon() const;
|
||||
const MenuLocation& menuLocation() const;
|
||||
|
|
@ -119,7 +119,7 @@ void LMainWindow::createActions()
|
|||
}
|
||||
|
||||
|
||||
void LMainWindow::addMenuAction(const MenuAction &ma)
|
||||
void LMainWindow::addMenuAction(const StaticAction &ma)
|
||||
{
|
||||
qDebug() << "add action " << ma.text();
|
||||
//auto ac =
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <QMainWindow>
|
||||
|
||||
class IPluginContentWidgetContext;
|
||||
class MenuAction;
|
||||
class StaticAction;
|
||||
class PluginContentWidget;
|
||||
|
||||
namespace LMainWindow_details {
|
||||
|
|
@ -46,7 +46,7 @@ private:
|
|||
PluginContentWidget *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
|
||||
|
||||
void createActions();
|
||||
void addMenuAction(const MenuAction &ma);
|
||||
void addMenuAction(const StaticAction &ma);
|
||||
|
||||
private slots:
|
||||
void actionClose_triggered();
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
#include "LWidgetAction.h"
|
||||
|
||||
LWidgetAction::LWidgetAction(QString text, const char * slotname)
|
||||
: m_text(std::move(text))
|
||||
, m_slotname(slotname)
|
||||
{}
|
||||
|
||||
const QIcon& LWidgetAction::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const MenuLocation& LWidgetAction::menuLocation() const
|
||||
{
|
||||
return m_menuLocation;
|
||||
}
|
||||
|
||||
void LWidgetAction::setIcon(QIcon icon)
|
||||
{
|
||||
m_icon = std::move(icon);
|
||||
}
|
||||
|
||||
void LWidgetAction::setMenuLocation(MenuLocation menu_location)
|
||||
{
|
||||
m_menuLocation = std::move(menu_location);
|
||||
}
|
||||
|
||||
void LWidgetAction::setToolbarLocation(ToolbarLocation toolbar_location)
|
||||
{
|
||||
m_toolbarLocation = toolbar_location;
|
||||
}
|
||||
|
||||
void LWidgetAction::setShortcut(QKeySequence shortcut)
|
||||
{
|
||||
m_shortCut = std::move(shortcut);
|
||||
}
|
||||
|
||||
void LWidgetAction::setText(QString text)
|
||||
{
|
||||
m_text = std::move(text);
|
||||
}
|
||||
|
||||
void LWidgetAction::setToolTip(QString tooltip)
|
||||
{
|
||||
m_toolTip = std::move(tooltip);
|
||||
}
|
||||
|
||||
const QKeySequence& LWidgetAction::shortcut() const
|
||||
{
|
||||
return m_shortCut;
|
||||
}
|
||||
|
||||
const QString& LWidgetAction::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
const QString& LWidgetAction::toolTip() const
|
||||
{
|
||||
return m_toolTip;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#include "MenuAction.h"
|
||||
|
||||
MenuAction::MenuAction(QString text, Func func)
|
||||
: m_text(std::move(text))
|
||||
, m_func(std::move(func))
|
||||
{}
|
||||
|
||||
const QIcon& MenuAction::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const MenuLocation& MenuAction::menuLocation() const
|
||||
{
|
||||
return m_menuLocation;
|
||||
}
|
||||
|
||||
void MenuAction::setIcon(QIcon icon)
|
||||
{
|
||||
m_icon = std::move(icon);
|
||||
}
|
||||
|
||||
void MenuAction::setMenuLocation(MenuLocation menu_location)
|
||||
{
|
||||
m_menuLocation = std::move(menu_location);
|
||||
}
|
||||
|
||||
void MenuAction::setToolbarLocation(ToolbarLocation toolbar_location)
|
||||
{
|
||||
m_toolbarLocation = toolbar_location;
|
||||
}
|
||||
|
||||
void MenuAction::setShortcut(QKeySequence shortcut)
|
||||
{
|
||||
m_shortcut = std::move(shortcut);
|
||||
}
|
||||
|
||||
void MenuAction::setText(QString text)
|
||||
{
|
||||
m_text = std::move(text);
|
||||
}
|
||||
|
||||
void MenuAction::setToolTip(QString tooltip)
|
||||
{
|
||||
m_toolTip = std::move(tooltip);
|
||||
}
|
||||
|
||||
const QKeySequence& MenuAction::shortcut() const
|
||||
{
|
||||
return m_shortcut;
|
||||
}
|
||||
|
||||
const QString& MenuAction::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
const QString& MenuAction::toolTip() const
|
||||
{
|
||||
return m_toolTip;
|
||||
}
|
||||
|
||||
void MenuAction::perform(IPluginContentWidgetContext *context) const
|
||||
{
|
||||
if (m_func)
|
||||
m_func(context);
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#include "PluginContentWidget.h"
|
||||
#include "PluginModule.h"
|
||||
#include "PluginRegister.h"
|
||||
#include "LWidgetAction.h"
|
||||
#include "LContextAction.h"
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QToolBar>
|
||||
|
|
@ -16,7 +16,7 @@ LWidgetData::LWidgetData(PluginModule *module)
|
|||
|
||||
void LWidgetData::init(PluginContentWidget *widget)
|
||||
{
|
||||
auto&& widget_actions = m_module->widgetActions();
|
||||
auto&& widget_actions = m_module->contextActions();
|
||||
m_widgetActions.reserve(widget_actions.size());
|
||||
for (auto&& wa : widget_actions) {
|
||||
m_widgetActions.push_back(createAction(wa, widget));
|
||||
|
|
@ -28,7 +28,7 @@ QList<QAction *> LWidgetData::actions()
|
|||
return m_widgetActions;
|
||||
}
|
||||
|
||||
QAction *LWidgetData::createAction(const LWidgetAction &wa, PluginContentWidget *widget)
|
||||
QAction *LWidgetData::createAction(const LContextAction &wa, PluginContentWidget *widget)
|
||||
{
|
||||
auto ac = new QAction(wa.icon(), wa.text(), widget);
|
||||
ac->setShortcut(wa.shortcut());
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "plugin_support/IPluginContentWidgetContext.h"
|
||||
#include <QList>
|
||||
|
||||
class LWidgetAction;
|
||||
class LContextAction;
|
||||
class QToolBar;
|
||||
class QAction;
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ private:
|
|||
/// 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);
|
||||
QAction *createAction(const LContextAction &wa, PluginContentWidget *widget);
|
||||
};
|
||||
|
||||
/// Provides base implementation of IPluginContentWidgetContext
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ void PluginModule::setDisplayCategory(QString category)
|
|||
m_displayCategory = std::move(category);
|
||||
}
|
||||
|
||||
void PluginModule::registerMenuAction(MenuAction action)
|
||||
void PluginModule::registerStaticAction(StaticAction action)
|
||||
{
|
||||
qDebug() << "registerMenuAction " << action.text();
|
||||
m_menuActions.emplace_back(std::move(action));
|
||||
}
|
||||
|
||||
const PluginModule::MenuActionList& PluginModule::menuActions() const
|
||||
const PluginModule::StaticActionList& PluginModule::staticActions() const
|
||||
{
|
||||
return m_menuActions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#define PLUGIN_SUPPORTPLUGINMODULE_H
|
||||
|
||||
#include "ModuleActionParameters.h"
|
||||
#include "MenuAction.h"
|
||||
#include "LWidgetAction.h"
|
||||
#include "StaticAction.h"
|
||||
#include "LContextAction.h"
|
||||
#include "PluginRegister.h"
|
||||
#include <QObject>
|
||||
#include <functional>
|
||||
|
|
@ -16,8 +16,8 @@ class IPluginContentWidgetContext;
|
|||
class PluginModule: public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using MenuActionList = std::vector<MenuAction>;
|
||||
using LWidgetActionList = std::vector<LWidgetAction>;
|
||||
using StaticActionList = std::vector<StaticAction>;
|
||||
using ContextActionList = std::vector<LContextAction>;
|
||||
using ModuleAction = std::function<void(IPluginContentWidgetContext*, const ModuleActionParameters &)>;
|
||||
using ModuleActionMap = std::map<QString, ModuleAction>;
|
||||
|
||||
|
|
@ -32,8 +32,8 @@ public:
|
|||
void setDisplayCategory(QString category);
|
||||
|
||||
/// registers an action that should always be accessible from the menu
|
||||
void registerMenuAction(MenuAction action);
|
||||
const MenuActionList& menuActions() const;
|
||||
void registerStaticAction(StaticAction action);
|
||||
const StaticActionList& staticActions() const;
|
||||
|
||||
/// "API" action that other modules can trigger by name without being linked to
|
||||
/// this module. Allows for loose coupling.
|
||||
|
|
@ -43,11 +43,11 @@ public:
|
|||
/// When the action is not found nullptr is returned.
|
||||
const ModuleAction* findModuleAction(const QString &module_action) const;
|
||||
|
||||
void registerWidgetAction(const LWidgetAction &action)
|
||||
void registerContextAction(const LContextAction &action)
|
||||
{
|
||||
m_widgetActions.push_back(action);
|
||||
}
|
||||
const LWidgetActionList& widgetActions() const { return m_widgetActions; }
|
||||
const ContextActionList& contextActions() const { return m_widgetActions; }
|
||||
private:
|
||||
/// Name shown to end users
|
||||
QString m_name;
|
||||
|
|
@ -55,9 +55,9 @@ private:
|
|||
QString m_ident;
|
||||
QString m_displayCategory;
|
||||
|
||||
MenuActionList m_menuActions;
|
||||
StaticActionList m_menuActions;
|
||||
ModuleActionMap m_moduleActions;
|
||||
LWidgetActionList m_widgetActions;
|
||||
ContextActionList m_widgetActions;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
67
pglab/plugin_support/StaticAction.cpp
Normal file
67
pglab/plugin_support/StaticAction.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include "StaticAction.h"
|
||||
|
||||
StaticAction::StaticAction(QString text, Func func)
|
||||
: m_text(std::move(text))
|
||||
, m_func(std::move(func))
|
||||
{}
|
||||
|
||||
const QIcon& StaticAction::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const MenuLocation& StaticAction::menuLocation() const
|
||||
{
|
||||
return m_menuLocation;
|
||||
}
|
||||
|
||||
void StaticAction::setIcon(QIcon icon)
|
||||
{
|
||||
m_icon = std::move(icon);
|
||||
}
|
||||
|
||||
void StaticAction::setMenuLocation(MenuLocation menu_location)
|
||||
{
|
||||
m_menuLocation = std::move(menu_location);
|
||||
}
|
||||
|
||||
void StaticAction::setToolbarLocation(ToolbarLocation toolbar_location)
|
||||
{
|
||||
m_toolbarLocation = toolbar_location;
|
||||
}
|
||||
|
||||
void StaticAction::setShortcut(QKeySequence shortcut)
|
||||
{
|
||||
m_shortcut = std::move(shortcut);
|
||||
}
|
||||
|
||||
void StaticAction::setText(QString text)
|
||||
{
|
||||
m_text = std::move(text);
|
||||
}
|
||||
|
||||
void StaticAction::setToolTip(QString tooltip)
|
||||
{
|
||||
m_toolTip = std::move(tooltip);
|
||||
}
|
||||
|
||||
const QKeySequence& StaticAction::shortcut() const
|
||||
{
|
||||
return m_shortcut;
|
||||
}
|
||||
|
||||
const QString& StaticAction::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
const QString& StaticAction::toolTip() const
|
||||
{
|
||||
return m_toolTip;
|
||||
}
|
||||
|
||||
void StaticAction::perform(IPluginContentWidgetContext *context) const
|
||||
{
|
||||
if (m_func)
|
||||
m_func(context);
|
||||
}
|
||||
|
|
@ -17,11 +17,11 @@ class IPluginContentWidgetContext;
|
|||
* It does need a context.
|
||||
*
|
||||
*/
|
||||
class MenuAction {
|
||||
class StaticAction {
|
||||
public:
|
||||
using Func = std::function<void(IPluginContentWidgetContext *context)>;
|
||||
|
||||
MenuAction(QString text, Func func);
|
||||
StaticAction(QString text, Func func);
|
||||
|
||||
const QIcon& icon() const;
|
||||
const MenuLocation& menuLocation() const;
|
||||
Loading…
Add table
Add a link
Reference in a new issue