Bunch of renames to reduce confusion.
This commit is contained in:
parent
cbb2f897aa
commit
be2ffd7ef9
15 changed files with 184 additions and 184 deletions
|
|
@ -117,11 +117,11 @@ void CrudPageModule::init()
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Refresh", SLOT(refresh()));
|
LContextAction wa("Refresh", SLOT(refresh()));
|
||||||
wa.setMenuLocation(MenuPath("Window/1"));
|
wa.setMenuLocation(MenuPath("Window/1"));
|
||||||
wa.setIcon(QIcon(":/icons/script_go.png"));
|
wa.setIcon(QIcon(":/icons/script_go.png"));
|
||||||
wa.setShortcut(QKeySequence(Qt::Key_F5));
|
wa.setShortcut(QKeySequence(Qt::Key_F5));
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,87 +10,87 @@ void QueryToolModule::init()
|
||||||
{
|
{
|
||||||
std::string slot_name = SLOT(QueryTool::execute());
|
std::string slot_name = SLOT(QueryTool::execute());
|
||||||
{
|
{
|
||||||
MenuAction ma("New SQL", [this] (IPluginContentWidgetContext* context)
|
StaticAction ma("New SQL", [this] (IPluginContentWidgetContext* context)
|
||||||
{ menuAction_new(context); });
|
{ menuAction_new(context); });
|
||||||
ma.setMenuLocation(MenuPath("File/New"));
|
ma.setMenuLocation(MenuPath("File/New"));
|
||||||
ma.setToolbarLocation(ToolbarLocation("main", "new"));
|
ma.setToolbarLocation(ToolbarLocation("main", "new"));
|
||||||
ma.setIcon(QIcon(":/icons/new_query_tab.png"));
|
ma.setIcon(QIcon(":/icons/new_query_tab.png"));
|
||||||
ma.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
ma.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
||||||
registerMenuAction(ma);
|
registerStaticAction(ma);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MenuAction ma("Open SQL", [this] (IPluginContentWidgetContext* context)
|
StaticAction ma("Open SQL", [this] (IPluginContentWidgetContext* context)
|
||||||
{ menuAction_open(context); });
|
{ menuAction_open(context); });
|
||||||
ma.setMenuLocation(MenuPath("File/Open"));
|
ma.setMenuLocation(MenuPath("File/Open"));
|
||||||
ma.setToolbarLocation(ToolbarLocation("main", "open"));
|
ma.setToolbarLocation(ToolbarLocation("main", "open"));
|
||||||
ma.setIcon(QIcon(":/icons/folder.png"));
|
ma.setIcon(QIcon(":/icons/folder.png"));
|
||||||
registerMenuAction(ma);
|
registerStaticAction(ma);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Save SQL", SLOT(save()));
|
LContextAction wa("Save SQL", SLOT(save()));
|
||||||
wa.setMenuLocation("File/Save");
|
wa.setMenuLocation("File/Save");
|
||||||
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
||||||
wa.setIcon(":/icons/script_save.png");
|
wa.setIcon(":/icons/script_save.png");
|
||||||
wa.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
wa.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Save SQL as", SLOT(saveAs()));
|
LContextAction wa("Save SQL as", SLOT(saveAs()));
|
||||||
wa.setMenuLocation("File/Save");
|
wa.setMenuLocation("File/Save");
|
||||||
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
||||||
wa.setIcon(":/icons/script_save.png");
|
wa.setIcon(":/icons/script_save.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Save copy of SQL as", SLOT(saveCopyAs()));
|
LContextAction wa("Save copy of SQL as", SLOT(saveCopyAs()));
|
||||||
wa.setMenuLocation("File/Save");
|
wa.setMenuLocation("File/Save");
|
||||||
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
||||||
//wa.setIcon(":/icons/script_save.png");
|
//wa.setIcon(":/icons/script_save.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("&Export data", SLOT(exportData()));
|
LContextAction wa("&Export data", SLOT(exportData()));
|
||||||
wa.setMenuLocation("File/Export");
|
wa.setMenuLocation("File/Export");
|
||||||
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
wa.setToolbarLocation(ToolbarLocation("main", "save"));
|
||||||
wa.setIcon(":/icons/table_save.png");
|
wa.setIcon(":/icons/table_save.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Copy as C string", SLOT(copyQueryAsCString()));
|
LContextAction wa("Copy as C string", SLOT(copyQueryAsCString()));
|
||||||
wa.setMenuLocation("Edit/Copy");
|
wa.setMenuLocation("Edit/Copy");
|
||||||
wa.setToolbarLocation(ToolbarLocation("edit", "copy"));
|
wa.setToolbarLocation(ToolbarLocation("edit", "copy"));
|
||||||
wa.setIcon(":/icons/token_shortland_character.png");
|
wa.setIcon(":/icons/token_shortland_character.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Copy as raw C++ string", SLOT(copyQueryAsRawCppString()));
|
LContextAction wa("Copy as raw C++ string", SLOT(copyQueryAsRawCppString()));
|
||||||
wa.setMenuLocation("Edit/Copy");
|
wa.setMenuLocation("Edit/Copy");
|
||||||
wa.setIcon(":/icons/token_shortland_character.png");
|
wa.setIcon(":/icons/token_shortland_character.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Execute", SLOT(execute()));
|
LContextAction wa("Execute", SLOT(execute()));
|
||||||
wa.setMenuLocation("Query/1");
|
wa.setMenuLocation("Query/1");
|
||||||
wa.setIcon(":/icons/script_go.png");
|
wa.setIcon(":/icons/script_go.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Explain", SLOT(explain()));
|
LContextAction wa("Explain", SLOT(explain()));
|
||||||
wa.setMenuLocation("Query/2");
|
wa.setMenuLocation("Query/2");
|
||||||
wa.setIcon(":/icons/lightbulb_off.png");
|
wa.setIcon(":/icons/lightbulb_off.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Analyze", SLOT(analyze()));
|
LContextAction wa("Analyze", SLOT(analyze()));
|
||||||
wa.setMenuLocation("Query/1");
|
wa.setMenuLocation("Query/1");
|
||||||
wa.setIcon(":/icons/lightbulb.png");
|
wa.setIcon(":/icons/lightbulb.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LWidgetAction wa("Cancel", SLOT(cancel()));
|
LContextAction wa("Cancel", SLOT(cancel()));
|
||||||
wa.setMenuLocation("Query/1");
|
wa.setMenuLocation("Query/1");
|
||||||
wa.setIcon(":/icons/script_delete.png");
|
wa.setIcon(":/icons/script_delete.png");
|
||||||
registerWidgetAction(wa);
|
registerContextAction(wa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ PropertyProxyModel.cpp \
|
||||||
plugin_support/PluginRegister.cpp \
|
plugin_support/PluginRegister.cpp \
|
||||||
plugin_support/PluginContentWidget.cpp \
|
plugin_support/PluginContentWidget.cpp \
|
||||||
plugin_support/PluginContentWidgetContextBase.cpp \
|
plugin_support/PluginContentWidgetContextBase.cpp \
|
||||||
plugin_support/MenuAction.cpp \
|
|
||||||
plugin_support/LMainWindow.cpp \
|
plugin_support/LMainWindow.cpp \
|
||||||
plugin_support/LWidgetAction.cpp \
|
|
||||||
QueryTool.cpp \
|
QueryTool.cpp \
|
||||||
QueryToolModule.cpp \
|
QueryToolModule.cpp \
|
||||||
CatalogInspector.cpp
|
CatalogInspector.cpp \
|
||||||
|
plugin_support/StaticAction.cpp \
|
||||||
|
plugin_support/LContextAction.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
QueryResultModel.h \
|
QueryResultModel.h \
|
||||||
|
|
@ -157,12 +157,12 @@ CustomDataRole.h \
|
||||||
plugin_support/ModuleActionParameters.h \
|
plugin_support/ModuleActionParameters.h \
|
||||||
plugin_support/IPluginContentWidgetContext.h \
|
plugin_support/IPluginContentWidgetContext.h \
|
||||||
plugin_support/PluginContentWidgetContextBase.h \
|
plugin_support/PluginContentWidgetContextBase.h \
|
||||||
plugin_support/MenuAction.h \
|
|
||||||
plugin_support/LMainWindow.h \
|
plugin_support/LMainWindow.h \
|
||||||
plugin_support/LWidgetAction.h \
|
|
||||||
QueryTool.h \
|
QueryTool.h \
|
||||||
QueryToolModule.h \
|
QueryToolModule.h \
|
||||||
CatalogInspector.h
|
CatalogInspector.h \
|
||||||
|
plugin_support/StaticAction.h \
|
||||||
|
plugin_support/LContextAction.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
ConnectionManagerWindow.ui \
|
ConnectionManagerWindow.ui \
|
||||||
|
|
|
||||||
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.
|
* 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.
|
* The plugin mechanism will take care of instantiating a connection to the named slot.
|
||||||
*/
|
*/
|
||||||
class LWidgetAction {
|
class LContextAction {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
/// \param slotname, use SLOT macro to pass name of the slot
|
/// \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 QIcon& icon() const;
|
||||||
const MenuLocation& menuLocation() 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();
|
qDebug() << "add action " << ma.text();
|
||||||
//auto ac =
|
//auto ac =
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
class IPluginContentWidgetContext;
|
class IPluginContentWidgetContext;
|
||||||
class MenuAction;
|
class StaticAction;
|
||||||
class PluginContentWidget;
|
class PluginContentWidget;
|
||||||
|
|
||||||
namespace LMainWindow_details {
|
namespace LMainWindow_details {
|
||||||
|
|
@ -46,7 +46,7 @@ private:
|
||||||
PluginContentWidget *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
|
PluginContentWidget *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void addMenuAction(const MenuAction &ma);
|
void addMenuAction(const StaticAction &ma);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actionClose_triggered();
|
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 "PluginContentWidget.h"
|
||||||
#include "PluginModule.h"
|
#include "PluginModule.h"
|
||||||
#include "PluginRegister.h"
|
#include "PluginRegister.h"
|
||||||
#include "LWidgetAction.h"
|
#include "LContextAction.h"
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
@ -16,7 +16,7 @@ LWidgetData::LWidgetData(PluginModule *module)
|
||||||
|
|
||||||
void LWidgetData::init(PluginContentWidget *widget)
|
void LWidgetData::init(PluginContentWidget *widget)
|
||||||
{
|
{
|
||||||
auto&& widget_actions = m_module->widgetActions();
|
auto&& widget_actions = m_module->contextActions();
|
||||||
m_widgetActions.reserve(widget_actions.size());
|
m_widgetActions.reserve(widget_actions.size());
|
||||||
for (auto&& wa : widget_actions) {
|
for (auto&& wa : widget_actions) {
|
||||||
m_widgetActions.push_back(createAction(wa, widget));
|
m_widgetActions.push_back(createAction(wa, widget));
|
||||||
|
|
@ -28,7 +28,7 @@ QList<QAction *> LWidgetData::actions()
|
||||||
return m_widgetActions;
|
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);
|
auto ac = new QAction(wa.icon(), wa.text(), widget);
|
||||||
ac->setShortcut(wa.shortcut());
|
ac->setShortcut(wa.shortcut());
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "plugin_support/IPluginContentWidgetContext.h"
|
#include "plugin_support/IPluginContentWidgetContext.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class LWidgetAction;
|
class LContextAction;
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ private:
|
||||||
/// List of actions specifically created for this widget from the widgetAction list of the module.
|
/// List of actions specifically created for this widget from the widgetAction list of the module.
|
||||||
QList<QAction *> m_widgetActions;
|
QList<QAction *> m_widgetActions;
|
||||||
|
|
||||||
QAction *createAction(const LWidgetAction &wa, PluginContentWidget *widget);
|
QAction *createAction(const LContextAction &wa, PluginContentWidget *widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Provides base implementation of IPluginContentWidgetContext
|
/// Provides base implementation of IPluginContentWidgetContext
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ void PluginModule::setDisplayCategory(QString category)
|
||||||
m_displayCategory = std::move(category);
|
m_displayCategory = std::move(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginModule::registerMenuAction(MenuAction action)
|
void PluginModule::registerStaticAction(StaticAction action)
|
||||||
{
|
{
|
||||||
qDebug() << "registerMenuAction " << action.text();
|
qDebug() << "registerMenuAction " << action.text();
|
||||||
m_menuActions.emplace_back(std::move(action));
|
m_menuActions.emplace_back(std::move(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
const PluginModule::MenuActionList& PluginModule::menuActions() const
|
const PluginModule::StaticActionList& PluginModule::staticActions() const
|
||||||
{
|
{
|
||||||
return m_menuActions;
|
return m_menuActions;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
#define PLUGIN_SUPPORTPLUGINMODULE_H
|
#define PLUGIN_SUPPORTPLUGINMODULE_H
|
||||||
|
|
||||||
#include "ModuleActionParameters.h"
|
#include "ModuleActionParameters.h"
|
||||||
#include "MenuAction.h"
|
#include "StaticAction.h"
|
||||||
#include "LWidgetAction.h"
|
#include "LContextAction.h"
|
||||||
#include "PluginRegister.h"
|
#include "PluginRegister.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
@ -16,8 +16,8 @@ class IPluginContentWidgetContext;
|
||||||
class PluginModule: public QObject {
|
class PluginModule: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using MenuActionList = std::vector<MenuAction>;
|
using StaticActionList = std::vector<StaticAction>;
|
||||||
using LWidgetActionList = std::vector<LWidgetAction>;
|
using ContextActionList = std::vector<LContextAction>;
|
||||||
using ModuleAction = std::function<void(IPluginContentWidgetContext*, const ModuleActionParameters &)>;
|
using ModuleAction = std::function<void(IPluginContentWidgetContext*, const ModuleActionParameters &)>;
|
||||||
using ModuleActionMap = std::map<QString, ModuleAction>;
|
using ModuleActionMap = std::map<QString, ModuleAction>;
|
||||||
|
|
||||||
|
|
@ -32,8 +32,8 @@ public:
|
||||||
void setDisplayCategory(QString category);
|
void setDisplayCategory(QString category);
|
||||||
|
|
||||||
/// registers an action that should always be accessible from the menu
|
/// registers an action that should always be accessible from the menu
|
||||||
void registerMenuAction(MenuAction action);
|
void registerStaticAction(StaticAction action);
|
||||||
const MenuActionList& menuActions() const;
|
const StaticActionList& staticActions() const;
|
||||||
|
|
||||||
/// "API" action that other modules can trigger by name without being linked to
|
/// "API" action that other modules can trigger by name without being linked to
|
||||||
/// this module. Allows for loose coupling.
|
/// this module. Allows for loose coupling.
|
||||||
|
|
@ -43,11 +43,11 @@ public:
|
||||||
/// When the action is not found nullptr is returned.
|
/// When the action is not found nullptr is returned.
|
||||||
const ModuleAction* findModuleAction(const QString &module_action) const;
|
const ModuleAction* findModuleAction(const QString &module_action) const;
|
||||||
|
|
||||||
void registerWidgetAction(const LWidgetAction &action)
|
void registerContextAction(const LContextAction &action)
|
||||||
{
|
{
|
||||||
m_widgetActions.push_back(action);
|
m_widgetActions.push_back(action);
|
||||||
}
|
}
|
||||||
const LWidgetActionList& widgetActions() const { return m_widgetActions; }
|
const ContextActionList& contextActions() const { return m_widgetActions; }
|
||||||
private:
|
private:
|
||||||
/// Name shown to end users
|
/// Name shown to end users
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
@ -55,9 +55,9 @@ private:
|
||||||
QString m_ident;
|
QString m_ident;
|
||||||
QString m_displayCategory;
|
QString m_displayCategory;
|
||||||
|
|
||||||
MenuActionList m_menuActions;
|
StaticActionList m_menuActions;
|
||||||
ModuleActionMap m_moduleActions;
|
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.
|
* It does need a context.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuAction {
|
class StaticAction {
|
||||||
public:
|
public:
|
||||||
using Func = std::function<void(IPluginContentWidgetContext *context)>;
|
using Func = std::function<void(IPluginContentWidgetContext *context)>;
|
||||||
|
|
||||||
MenuAction(QString text, Func func);
|
StaticAction(QString text, Func func);
|
||||||
|
|
||||||
const QIcon& icon() const;
|
const QIcon& icon() const;
|
||||||
const MenuLocation& menuLocation() const;
|
const MenuLocation& menuLocation() const;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue