From e11d5ec00d45d971f65d13b1d48b08397a2b4ff9 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Thu, 11 Jul 2024 04:27:19 -0500 Subject: [PATCH] Support new pluginpreview interfaces (#130) --- src/mobase/wrappers/pyplugins.cpp | 5 ++++- src/mobase/wrappers/pyplugins.h | 12 ++++++++++++ .../include/pybind11_qt/pybind11_qt_objects.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/mobase/wrappers/pyplugins.cpp b/src/mobase/wrappers/pyplugins.cpp index 21fd436..49fca7e 100644 --- a/src/mobase/wrappers/pyplugins.cpp +++ b/src/mobase/wrappers/pyplugins.cpp @@ -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_>( diff --git a/src/mobase/wrappers/pyplugins.h b/src/mobase/wrappers/pyplugins.h index ff2b479..bb49e92 100644 --- a/src/mobase/wrappers/pyplugins.h +++ b/src/mobase/wrappers/pyplugins.h @@ -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 { diff --git a/src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h b/src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h index ad5aa1e..e16b5ea 100644 --- a/src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h +++ b/src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -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);