Skip to content

Commit e11d5ec

Browse files
authored
Support new pluginpreview interfaces (#130)
1 parent 6623e19 commit e11d5ec

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/mobase/wrappers/pyplugins.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,11 @@ namespace mo2::python {
190190
m, "IPluginPreview", py::multiple_inheritance())
191191
.def(py::init<>())
192192
.def("supportedExtensions", &IPluginPreview::supportedExtensions)
193+
.def("supportsArchives", &IPluginPreview::supportsArchives)
193194
.def("genFilePreview", &IPluginPreview::genFilePreview, "filename"_a,
194-
"max_size"_a);
195+
"max_size"_a)
196+
.def("genDataPreview", &IPluginPreview::genDataPreview, "file_data"_a,
197+
"filename"_a, "max_size"_a);
195198

196199
py::class_<IPluginModPage, PyPluginModPage, IPlugin,
197200
std::unique_ptr<IPluginModPage, py::nodelete>>(

src/mobase/wrappers/pyplugins.h

+12
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,24 @@ namespace mo2::python {
179179
supportedExtensions, );
180180
}
181181

182+
bool supportsArchives() const override
183+
{
184+
PYBIND11_OVERRIDE(bool, IPluginPreview, supportsArchives, );
185+
}
186+
182187
QWidget* genFilePreview(const QString& fileName,
183188
const QSize& maxSize) const override
184189
{
185190
PYBIND11_OVERRIDE_PURE(QWidget*, IPluginPreview, genFilePreview, fileName,
186191
maxSize);
187192
}
193+
194+
QWidget* genDataPreview(const QByteArray& fileData, const QString& fileName,
195+
const QSize& maxSize) const override
196+
{
197+
PYBIND11_OVERRIDE(QWidget*, IPluginPreview, genDataPreview, fileData,
198+
fileName, maxSize);
199+
}
188200
};
189201

190202
class PyPluginModPage : public PyPluginBase<IPluginModPage> {

src/pybind11-qt/include/pybind11_qt/pybind11_qt_objects.h

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <pybind11/pybind11.h>
55

6+
#include <QByteArray>
67
#include <QDateTime>
78
#include <QDir>
89
#include <QFileInfo>
@@ -41,6 +42,7 @@
4142
// the name of the PyQt6 package containing the class, and is only used for
4243
// the python signature
4344

45+
PYQT_CLASS(QtCore, QByteArray);
4446
PYQT_CLASS(QtCore, QDateTime);
4547
PYQT_CLASS(QtCore, QDir);
4648
PYQT_CLASS(QtCore, QFileInfo);

0 commit comments

Comments
 (0)