From a29671593e09dae181cb7ae0df59c96dc404d638 Mon Sep 17 00:00:00 2001 From: eelke Date: Tue, 1 Jan 2019 08:26:20 +0100 Subject: [PATCH] Simplified module registration --- pglab/CrudTab.cpp | 7 +------ pglab/QueryTab.cpp | 8 +------- pglab/plugin_support/MenuAction.cpp | 6 ++++++ pglab/plugin_support/MenuAction.h | 11 +++++++++++ pglab/plugin_support/PluginModule.h | 5 +++++ 5 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 pglab/plugin_support/MenuAction.cpp create mode 100644 pglab/plugin_support/MenuAction.h diff --git a/pglab/CrudTab.cpp b/pglab/CrudTab.cpp index 7865faf..0b03ef1 100644 --- a/pglab/CrudTab.cpp +++ b/pglab/CrudTab.cpp @@ -143,9 +143,4 @@ void CrudPageModule::moduleAction_open( } -namespace { - - std::weak_ptr register_variable = createPluginModule - ("CRUD tool", "pglab.crudpage"); - -} +REGISTER_PLUGIN_MODULE(CrudPageModule, "CRUD tool", "pglab.crudpage") diff --git a/pglab/QueryTab.cpp b/pglab/QueryTab.cpp index fd33353..a2db049 100644 --- a/pglab/QueryTab.cpp +++ b/pglab/QueryTab.cpp @@ -684,10 +684,4 @@ void QueryToolModule::new_triggered() { } - -namespace { - - std::weak_ptr register_variable = createPluginModule - ("Query tool", "pglab.querytool"); - -} +REGISTER_PLUGIN_MODULE(QueryToolModule, "Query tool", "pglab.querytool") diff --git a/pglab/plugin_support/MenuAction.cpp b/pglab/plugin_support/MenuAction.cpp new file mode 100644 index 0000000..87199e2 --- /dev/null +++ b/pglab/plugin_support/MenuAction.cpp @@ -0,0 +1,6 @@ +#include "MenuAction.h" + +MenuAction::MenuAction() +{ + +} diff --git a/pglab/plugin_support/MenuAction.h b/pglab/plugin_support/MenuAction.h new file mode 100644 index 0000000..95409c5 --- /dev/null +++ b/pglab/plugin_support/MenuAction.h @@ -0,0 +1,11 @@ +#ifndef MENUACTION_H +#define MENUACTION_H + + +class MenuAction +{ +public: + MenuAction(); +}; + +#endif // MENUACTION_H \ No newline at end of file diff --git a/pglab/plugin_support/PluginModule.h b/pglab/plugin_support/PluginModule.h index 68b147c..c5aa8a0 100644 --- a/pglab/plugin_support/PluginModule.h +++ b/pglab/plugin_support/PluginModule.h @@ -53,5 +53,10 @@ std::shared_ptr createPluginModule(QString name, QString ident) return std::move(module); } +#define REGISTER_PLUGIN_MODULE(module, name, ident) \ + namespace {\ + std::weak_ptr register_variable = createPluginModule\ + (#name, #ident);} + #endif // PLUGIN_SUPPORTPLUGINMODULE_H