mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Merge pull request #7 from AnyOldName3/cleanup
Cleanup dead code & update .gitignore
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
CMakeLists.txt.user
|
||||
edit
|
||||
build
|
||||
vsbuild
|
||||
std*.log
|
||||
vs_std*.log
|
||||
msbuild.log
|
||||
*.bak
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
#include "proxypluginwrappers.h"
|
||||
#include <boost/python.hpp>
|
||||
#include <utility.h>
|
||||
//#include "error.h"
|
||||
#include "gilock.h"
|
||||
|
||||
namespace bpy = boost::python;
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
#define PYCATCH catch (const bpy::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
|
||||
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IPluginTool Wrapper
|
||||
|
||||
|
||||
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return this->get_override("init")(bpy::ptr(moInfo));
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("name")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("author")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("description")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
MOBase::VersionInfo IPluginToolWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("version")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginToolWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isActive")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("settings")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("displayName")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("tooltip")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QIcon IPluginToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("icon")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
void IPluginToolWrapper::setParentWidget(QWidget *parent)
|
||||
{
|
||||
try {
|
||||
this->get_override("setParentWidget")(parent);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
void IPluginToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
GILock lock;
|
||||
|
||||
this->get_override("display")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
/// end IPluginTool Wrapper
|
||||
/////////////////////////////////////
|
||||
/// IPluginInstallerCustom Wrapper
|
||||
|
||||
|
||||
bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return this->get_override("init")(bpy::ptr(moInfo));
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("name")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("author")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("description")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("version")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isActive")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> IPluginInstallerCustomWrapper::settings() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("settings")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
unsigned int IPluginInstallerCustomWrapper::priority() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("priority")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isManualInstaller() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isManualInstaller")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &tree) const
|
||||
{
|
||||
try {
|
||||
//return this->get_override("isArchiveSupported")(tree);
|
||||
return false;
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isArchiveSupported")(archiveName);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
std::set<QString> IPluginInstallerCustomWrapper::supportedExtensions() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("supportedExtensions")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install(GuessedValue<QString> &modName, const QString &archiveName,
|
||||
const QString &version, int modID)
|
||||
{
|
||||
try {
|
||||
return this->get_override("install")(modName, archiveName, version, modID);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent)
|
||||
{
|
||||
try {
|
||||
this->get_override("setParentWidget")(parent);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#ifndef PROXYPLUGINWRAPPERS_H
|
||||
#define PROXYPLUGINWRAPPERS_H
|
||||
|
||||
|
||||
#include <iplugintool.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <iplugininstallercustom.h>
|
||||
#include <iplugindiagnose.h>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
class IPluginWrapper : public boost::python::wrapper<MOBase::IPlugin>
|
||||
{
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
};
|
||||
|
||||
|
||||
class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper<MOBase::IPluginTool>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
public slots:
|
||||
virtual void display() const;
|
||||
};
|
||||
|
||||
|
||||
class IPluginInstallerCustomWrapper: public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
virtual unsigned int priority() const;
|
||||
virtual bool isManualInstaller() const;
|
||||
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
||||
virtual bool isArchiveSupported(const QString &archiveName) const;
|
||||
virtual std::set<QString> supportedExtensions() const;
|
||||
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, const QString &archiveName,
|
||||
const QString &version, int modID);
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PROXYPLUGINWRAPPERS_H
|
||||
@@ -1,112 +0,0 @@
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
|
||||
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction)
|
||||
: m_InitFunction(initFunction)
|
||||
, m_NameFunction(nameFunction)
|
||||
, m_AuthorFunction(authorFunction)
|
||||
, m_DescriptionFunction(descriptionFunction)
|
||||
, m_VersionFunction(versionFunction)
|
||||
, m_IsActiveFunction(isActiveFunction)
|
||||
, m_SettingsFunction(settingsFunction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PythonPluginWrapper::reportPythonError() const
|
||||
{
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
} else {
|
||||
qCritical("An unexpected C++ exception was thrown in python code");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_NameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_AuthorFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DescriptionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
MOBase::VersionInfo PythonPluginWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return MOBase::VersionInfo();
|
||||
}
|
||||
}
|
||||
|
||||
bool PythonPluginWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_IsActiveFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
||||
{
|
||||
QList<MOBase::PluginSetting> result;
|
||||
try {
|
||||
boost::python::object l = m_SettingsFunction();
|
||||
if (!l.is_none()) {
|
||||
// boost::python::list l = extract<boost::python::list>(temp);
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
result.append(extract<MOBase::PluginSetting>(l[i]));
|
||||
}
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef PYTHONPLUGINWRAPPER_H
|
||||
#define PYTHONPLUGINWRAPPER_H
|
||||
|
||||
#include <iplugin.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
||||
{
|
||||
|
||||
public:
|
||||
PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction);
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
protected:
|
||||
void reportPythonError() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_InitFunction;
|
||||
boost::python::object m_NameFunction;
|
||||
boost::python::object m_AuthorFunction;
|
||||
boost::python::object m_DescriptionFunction;
|
||||
boost::python::object m_VersionFunction;
|
||||
boost::python::object m_IsActiveFunction;
|
||||
boost::python::object m_SettingsFunction;
|
||||
|
||||
};
|
||||
|
||||
#endif // PYTHONPLUGINWRAPPER_H
|
||||
@@ -1,80 +0,0 @@
|
||||
#include "pythontoolwrapper.h"
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
PythonToolWrapper::PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget)
|
||||
: PythonPluginWrapper(initFunction, nameFunction, authorFunction, descriptionFunction,
|
||||
versionFunction, isActiveFunction, settingsFunction)
|
||||
, m_DisplayNameFunction(displayNameFunction)
|
||||
, m_ToolTipFunction(tooltipFunction)
|
||||
, m_IconFunction(iconFunction)
|
||||
, m_DisplayFunction(displayFunction)
|
||||
, m_SetParentWidget(setParentWidget)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString PythonToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DisplayNameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_ToolTipFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QIcon PythonToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
std::vector<const char*> rows;
|
||||
boost::python::object l = m_IconFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
rows.push_back(extract<const char*>(l[i]));
|
||||
}
|
||||
return QIcon(QPixmap(&rows[0]));
|
||||
} else {
|
||||
return QIcon();
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void PythonToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
m_SetParentWidget(parentWidget());
|
||||
|
||||
m_DisplayFunction();
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef PYTHONTOOLWRAPPER_H
|
||||
#define PYTHONTOOLWRAPPER_H
|
||||
|
||||
|
||||
#include <iplugintool.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
class PythonToolWrapper : public QObject, public MOBase::IPluginTool, public PythonPluginWrapper
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
public:
|
||||
PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget);
|
||||
|
||||
using PythonPluginWrapper::init;
|
||||
using PythonPluginWrapper::name;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void display() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_DisplayNameFunction;
|
||||
boost::python::object m_ToolTipFunction;
|
||||
boost::python::object m_IconFunction;
|
||||
boost::python::object m_DisplayFunction;
|
||||
|
||||
boost::python::object m_SetParentWidget;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PYTHONTOOLWRAPPER_H
|
||||
@@ -1,111 +0,0 @@
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
|
||||
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction)
|
||||
: m_InitFunction(initFunction)
|
||||
, m_NameFunction(nameFunction)
|
||||
, m_AuthorFunction(authorFunction)
|
||||
, m_DescriptionFunction(descriptionFunction)
|
||||
, m_VersionFunction(versionFunction)
|
||||
, m_IsActiveFunction(isActiveFunction)
|
||||
, m_SettingsFunction(settingsFunction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PythonPluginWrapper::reportPythonError() const
|
||||
{
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
} else {
|
||||
qCritical("An unexpected C++ exception was thrown in python code");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_NameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_AuthorFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DescriptionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
MOBase::VersionInfo PythonPluginWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return MOBase::VersionInfo();
|
||||
}
|
||||
}
|
||||
|
||||
bool PythonPluginWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_IsActiveFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
||||
{
|
||||
QList<MOBase::PluginSetting> result;
|
||||
try {
|
||||
boost::python::object l = m_SettingsFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
result.append(extract<MOBase::PluginSetting>(l[i]));
|
||||
}
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef PYTHONPLUGINWRAPPER_H
|
||||
#define PYTHONPLUGINWRAPPER_H
|
||||
|
||||
#include <iplugin.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
||||
{
|
||||
|
||||
public:
|
||||
PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction);
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
protected:
|
||||
|
||||
void reportPythonError() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_InitFunction;
|
||||
boost::python::object m_NameFunction;
|
||||
boost::python::object m_AuthorFunction;
|
||||
boost::python::object m_DescriptionFunction;
|
||||
boost::python::object m_VersionFunction;
|
||||
boost::python::object m_IsActiveFunction;
|
||||
boost::python::object m_SettingsFunction;
|
||||
|
||||
};
|
||||
|
||||
#endif // PYTHONPLUGINWRAPPER_H
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <iplugingame.h>
|
||||
#include <iplugin.h>
|
||||
#include "uibasewrappers.h"
|
||||
#include "pythonpluginwrapper.h"
|
||||
#include "proxypluginwrappers.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#include "pythontoolwrapper.h"
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
PythonToolWrapper::PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget)
|
||||
: PythonPluginWrapper(initFunction, nameFunction, authorFunction, descriptionFunction,
|
||||
versionFunction, isActiveFunction, settingsFunction)
|
||||
, m_DisplayNameFunction(displayNameFunction)
|
||||
, m_ToolTipFunction(tooltipFunction)
|
||||
, m_IconFunction(iconFunction)
|
||||
, m_DisplayFunction(displayFunction)
|
||||
, m_SetParentWidget(setParentWidget)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString PythonToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DisplayNameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_ToolTipFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QIcon PythonToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
std::vector<const char*> rows;
|
||||
boost::python::object l = m_IconFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
rows.push_back(extract<const char*>(l[i]));
|
||||
}
|
||||
return QIcon(QPixmap(&rows[0]));
|
||||
} else {
|
||||
return QIcon();
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void PythonToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
m_SetParentWidget(parentWidget());
|
||||
|
||||
m_DisplayFunction();
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#ifndef PYTHONTOOLWRAPPER_H
|
||||
#define PYTHONTOOLWRAPPER_H
|
||||
|
||||
#include <iplugintool.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
class PythonToolWrapper : public MOBase::IPluginTool, public PythonPluginWrapper
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
public:
|
||||
PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget);
|
||||
|
||||
using PythonPluginWrapper::init;
|
||||
using PythonPluginWrapper::name;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void display() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_DisplayNameFunction;
|
||||
boost::python::object m_ToolTipFunction;
|
||||
boost::python::object m_IconFunction;
|
||||
boost::python::object m_DisplayFunction;
|
||||
|
||||
boost::python::object m_SetParentWidget;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PYTHONTOOLWRAPPER_H
|
||||
Reference in New Issue
Block a user