mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Implement IpluginModPage bindings.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <utility.h>
|
||||
#include "error.h"
|
||||
#include "gilock.h"
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <iplugingame.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <iplugininstallercustom.h>
|
||||
#include <ipluginmodpage.h>
|
||||
#include <iplugintool.h>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
@@ -133,6 +134,22 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class IPluginModPageWrapper : public MOBase::IPluginModPage, public boost::python::wrapper<MOBase::IPluginModPage>
|
||||
{
|
||||
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<MOBase::IPluginTool>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -1101,6 +1101,10 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
.def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginInstallerCustom::setParentWidget))
|
||||
;
|
||||
|
||||
bpy::class_<IPluginModPageWrapper, boost::noncopyable>("IPluginModPage")
|
||||
.def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginModPage::setParentWidget))
|
||||
;
|
||||
|
||||
bpy::class_<IPluginToolWrapper, bpy::bases<IPlugin>, 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));
|
||||
|
||||
Reference in New Issue
Block a user