Skip to content

Commit

Permalink
Support new pluginpreview interfaces (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn authored Jul 11, 2024
1 parent 6623e19 commit e11d5ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mobase/wrappers/pyplugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ namespace mo2::python {
m, "IPluginPreview", py::multiple_inheritance())
.def(py::init<>())
.def("supportedExtensions", &IPluginPreview::supportedExtensions)
.def("supportsArchives", &IPluginPreview::supportsArchives)
.def("genFilePreview", &IPluginPreview::genFilePreview, "filename"_a,
"max_size"_a);
"max_size"_a)
.def("genDataPreview", &IPluginPreview::genDataPreview, "file_data"_a,
"filename"_a, "max_size"_a);

py::class_<IPluginModPage, PyPluginModPage, IPlugin,
std::unique_ptr<IPluginModPage, py::nodelete>>(
Expand Down
12 changes: 12 additions & 0 deletions src/mobase/wrappers/pyplugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,24 @@ namespace mo2::python {
supportedExtensions, );
}

bool supportsArchives() const override
{
PYBIND11_OVERRIDE(bool, IPluginPreview, supportsArchives, );
}

QWidget* genFilePreview(const QString& fileName,
const QSize& maxSize) const override
{
PYBIND11_OVERRIDE_PURE(QWidget*, IPluginPreview, genFilePreview, fileName,
maxSize);
}

QWidget* genDataPreview(const QByteArray& fileData, const QString& fileName,
const QSize& maxSize) const override
{
PYBIND11_OVERRIDE(QWidget*, IPluginPreview, genDataPreview, fileData,
fileName, maxSize);
}
};

class PyPluginModPage : public PyPluginBase<IPluginModPage> {
Expand Down
2 changes: 2 additions & 0 deletions src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <pybind11/pybind11.h>

#include <QByteArray>
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
Expand Down Expand Up @@ -41,6 +42,7 @@
// the name of the PyQt6 package containing the class, and is only used for
// the python signature

PYQT_CLASS(QtCore, QByteArray);
PYQT_CLASS(QtCore, QDateTime);
PYQT_CLASS(QtCore, QDir);
PYQT_CLASS(QtCore, QFileInfo);
Expand Down

0 comments on commit e11d5ec

Please sign in to comment.