From 8877fee4fabfab5f9cfa3f3421fd7704eed7070c Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 20 Apr 2018 16:39:58 +0100 Subject: [PATCH] Implement IpluginModPage bindings. --- src/runner/proxypluginwrappers.cpp | 49 ++++++++++++++++++++++++++++++ src/runner/proxypluginwrappers.h | 17 +++++++++++ src/runner/pythonrunner.cpp | 5 +++ 3 files changed, 71 insertions(+) diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index 76106af..207199e 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -2,6 +2,7 @@ #include #include "error.h" #include "gilock.h" +#include #include namespace boost @@ -429,6 +430,54 @@ void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent) } /// end IPluginInstallerCustom Wrapper ///////////////////////////// +/// IPluginModPage Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginModPageWrapper) + +QString IPluginModPageWrapper::displayName() const +{ + try { + return this->get_override("displayName")(); + } PYCATCH; +} + +QIcon IPluginModPageWrapper::icon() const +{ + try { + return this->get_override("icon")(); + } PYCATCH; +} + +QUrl IPluginModPageWrapper::pageURL() const +{ + try { + return this->get_override("pageURL")(); + } PYCATCH; +} + +bool IPluginModPageWrapper::useIntegratedBrowser() const +{ + try { + return this->get_override("useIntegratedBrowser")(); + } PYCATCH; +} + +bool IPluginModPageWrapper::handlesDownload(const QUrl & pageURL, const QUrl & downloadURL, MOBase::ModRepositoryFileInfo & fileInfo) const +{ + try { + return this->get_override("handlesDownload")(pageURL, downloadURL, fileInfo); + } PYCATCH; +} + +void IPluginModPageWrapper::setParentWidget(QWidget * widget) +{ + try { + this->get_override("setParentWidget")(widget); + } PYCATCH; +} +/// end IPluginModPage Wrapper +///////////////////////////// /// IPluginTool Wrapper diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 0c01c3a..e0ce858 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #ifndef Q_MOC_RUN @@ -133,6 +134,22 @@ public: }; +class IPluginModPageWrapper : public MOBase::IPluginModPage, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginModPage) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +public: + virtual QString displayName() const override; + virtual QIcon icon() const override; + virtual QUrl pageURL() const override; + virtual bool useIntegratedBrowser() const override; + virtual bool handlesDownload(const QUrl &pageURL, const QUrl &downloadURL, MOBase::ModRepositoryFileInfo &fileInfo) const override; + virtual void setParentWidget(QWidget *widget) override; +}; + + class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper { Q_OBJECT diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 3566de1..2461674 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -1101,6 +1101,10 @@ BOOST_PYTHON_MODULE(mobase) .def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginInstallerCustom::setParentWidget)) ; + bpy::class_("IPluginModPage") + .def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginModPage::setParentWidget)) + ; + bpy::class_, boost::noncopyable>("IPluginTool") .def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginTool::setParentWidget)) ; @@ -1243,6 +1247,7 @@ QObject *PythonRunner::instantiate(const QString &pluginName) // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject TRY_PLUGIN_TYPE(IPluginFileMapperWrapper, pluginObj); TRY_PLUGIN_TYPE(IPluginInstallerCustom, pluginObj); + TRY_PLUGIN_TYPE(IPluginModPage, pluginObj); TRY_PLUGIN_TYPE(IPluginTool, pluginObj); } catch (const bpy::error_already_set&) { qWarning("failed to run python script \"%s\"", qPrintable(pluginName));