summaryrefslogtreecommitdiffhomepage
path: root/api
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-04-03 12:26:38 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-04-05 03:23:13 +0200
commiteb32a2ac02c6d1adcfeb0a1a5522f8aaea442489 (patch)
treeb15b4ab34600e9c5d5da17eac33ea687167bbfc7 /api
parent22a853b388597e9549125df69508c1c38706dd1d (diff)
i18n: provide for non-QObject classes
See compat/tr.hpp for comment.
Diffstat (limited to 'api')
-rw-r--r--api/plugin-api.cpp7
-rw-r--r--api/plugin-api.hpp24
-rw-r--r--api/plugin-support.hpp4
3 files changed, 22 insertions, 13 deletions
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp
index 6c9a21bc..004938f1 100644
--- a/api/plugin-api.cpp
+++ b/api/plugin-api.cpp
@@ -5,7 +5,7 @@ using namespace plugin_api::detail;
// these exist so that vtable is emitted in a single compilation unit, not all of them.
-Metadata::~Metadata() {}
+Metadata_::~Metadata_() {}
IFilter::~IFilter() {}
IProtocol::~IProtocol() {}
ITracker::~ITracker() {}
@@ -37,7 +37,7 @@ module_status ITracker::error(const QString& error)
return module_status(error);
}
-Metadata::Metadata() {}
+Metadata_::Metadata_() {}
IFilter::IFilter() {}
IFilterDialog::IFilterDialog() {}
IProtocol::IProtocol() {}
@@ -69,5 +69,6 @@ module_status module_status_mixin::status_ok() { return module_status(); }
module_status module_status_mixin::error(const QString& error)
{
- return module_status(error.isEmpty() ? _("Unknown error") : error);
+ return module_status(error.isEmpty() ? "Unknown error" : error);
}
+
diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp
index 4a797f73..75555e93 100644
--- a/api/plugin-api.hpp
+++ b/api/plugin-api.hpp
@@ -16,6 +16,7 @@
#include <QDialog>
#include "compat/simple-mat.hpp"
+#include "compat/tr.hpp"
#include "export.hpp"
using Pose = Mat<double, 6, 1>;
@@ -49,14 +50,14 @@ private slots:
#define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \
extern "C" OTR_PLUGIN_EXPORT ctor_ret_class* GetConstructor(); \
- extern "C" OTR_PLUGIN_EXPORT Metadata* GetMetadata(); \
+ extern "C" OTR_PLUGIN_EXPORT Metadata_* GetMetadata(); \
extern "C" OTR_PLUGIN_EXPORT dialog_ret_class* GetDialog(); \
\
extern "C" OTR_PLUGIN_EXPORT ctor_ret_class* GetConstructor() \
{ \
return new ctor_class; \
} \
- extern "C" OTR_PLUGIN_EXPORT Metadata* GetMetadata() \
+ extern "C" OTR_PLUGIN_EXPORT Metadata_* GetMetadata() \
{ \
return new metadata_class; \
} \
@@ -67,19 +68,26 @@ private slots:
// implement this in all plugins
// also you must link against "opentrack-api" in CMakeLists.txt to avoid vtable link errors
-struct OTR_API_EXPORT Metadata
+class OTR_API_EXPORT Metadata_
{
- Metadata(const Metadata&) = delete;
- Metadata(Metadata&&) = delete;
- Metadata& operator=(const Metadata&) = delete;
- Metadata();
+public:
+ Metadata_();
// plugin name to be displayed in the interface
virtual QString name() = 0;
// plugin icon, you can return an empty QIcon()
virtual QIcon icon() = 0;
// optional destructor
- virtual ~Metadata();
+ virtual ~Metadata_();
+};
+
+class OTR_API_EXPORT Metadata : public TR, public Metadata_
+{
+ Q_OBJECT
+
+public:
+ Metadata() {}
+ ~Metadata() {}
};
struct OTR_API_EXPORT module_status final
diff --git a/api/plugin-support.hpp b/api/plugin-support.hpp
index 8fc01b98..b3f3396b 100644
--- a/api/plugin-support.hpp
+++ b/api/plugin-support.hpp
@@ -32,7 +32,7 @@
#define OPENTRACK_SOLIB_PREFIX "lib"
extern "C" typedef void* (*OPENTRACK_CTOR_FUNPTR)(void);
-extern "C" typedef Metadata* (*OPENTRACK_METADATA_FUNPTR)(void);
+extern "C" typedef Metadata_* (*OPENTRACK_METADATA_FUNPTR)(void);
struct dylib final
{
@@ -72,7 +72,7 @@ struct dylib final
if (check((Meta = (OPENTRACK_METADATA_FUNPTR) handle.resolve("GetMetadata"), !Meta)))
return;
- auto m = std::unique_ptr<Metadata>(Meta());
+ auto m = std::unique_ptr<Metadata_>(Meta());
icon = m->icon();
name = m->name();