mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Fix Qt bindings.
This commit is contained in:
@@ -42,14 +42,6 @@ namespace pybind11::detail::qt {
|
||||
*/
|
||||
pybind11::object get_attr_rec(std::string_view package, std::string_view path);
|
||||
|
||||
/**
|
||||
* @brief Conditional add_pointer if T is non-copyable.
|
||||
*
|
||||
*/
|
||||
template <class QClass>
|
||||
using ptr_if_non_copy_t = std::conditional_t<std::is_copy_constructible_v<QClass>,
|
||||
QClass, std::add_pointer_t<QClass>>;
|
||||
|
||||
} // namespace pybind11::detail::qt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,8 +27,14 @@
|
||||
}; \
|
||||
} \
|
||||
template <> \
|
||||
struct type_caster<qt::ptr_if_non_copy_t<QClass>> \
|
||||
: qt::qt_type_caster<qt::ptr_if_non_copy_t<QClass>> { \
|
||||
struct type_caster<QClass*> \
|
||||
: std::conditional_t<std::is_copy_constructible_v<QClass>, \
|
||||
type_caster_generic, qt::qt_type_caster<QClass*>> { \
|
||||
}; \
|
||||
template <> \
|
||||
struct type_caster<QClass> \
|
||||
: std::conditional_t<std::is_copy_constructible_v<QClass>, \
|
||||
qt::qt_type_caster<QClass>, type_caster<QClass*>> { \
|
||||
}
|
||||
|
||||
namespace pybind11::detail {
|
||||
@@ -44,16 +50,13 @@ namespace pybind11::detail {
|
||||
PYQT_CLASS(QtCore, QSize);
|
||||
PYQT_CLASS(QtCore, QUrl);
|
||||
|
||||
PYQT_CLASS(QtGui, QColor);
|
||||
PYQT_CLASS(QtGui, QIcon);
|
||||
PYQT_CLASS(QtGui, QPixmap);
|
||||
|
||||
PYQT_CLASS(QtWidgets, QMainWindow);
|
||||
PYQT_CLASS(QtWidgets, QWidget);
|
||||
|
||||
template <>
|
||||
struct type_caster<QWidget> : qt::qt_type_caster<QWidget*> {
|
||||
};
|
||||
|
||||
} // namespace pybind11::detail
|
||||
|
||||
#undef METADATA
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace mo2::python {
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
using namespace pybind11::literals;
|
||||
|
||||
void add_versioninfo_classes(py::module_ m)
|
||||
{
|
||||
py::enum_<MOBase::VersionInfo::ReleaseType>(m, "ReleaseType")
|
||||
@@ -128,56 +130,52 @@ namespace mo2::python {
|
||||
.value("TRACKED_TRUE", TrackedState::TRACKED_TRUE)
|
||||
.value("TRACKED_UNKNOWN", TrackedState::TRACKED_UNKNOWN);
|
||||
|
||||
// py::class_<IModInterface, boost::noncopyable>("IModInterface",
|
||||
// py::no_init)
|
||||
// .def("name", &IModInterface::name)
|
||||
// .def("absolutePath", &IModInterface::absolutePath)
|
||||
py::class_<IModInterface>(m, "IModInterface")
|
||||
.def("name", &IModInterface::name)
|
||||
.def("absolutePath", &IModInterface::absolutePath)
|
||||
|
||||
// .def("comments", &IModInterface::comments)
|
||||
// .def("notes", &IModInterface::notes)
|
||||
// .def("gameName", &IModInterface::gameName)
|
||||
// .def("repository", &IModInterface::repository)
|
||||
// .def("nexusId", &IModInterface::nexusId)
|
||||
// .def("version", &IModInterface::version)
|
||||
// .def("newestVersion", &IModInterface::newestVersion)
|
||||
// .def("ignoredVersion", &IModInterface::ignoredVersion)
|
||||
// .def("installationFile", &IModInterface::installationFile)
|
||||
// .def("converted", &IModInterface::converted)
|
||||
// .def("validated", &IModInterface::validated)
|
||||
// .def("color", &IModInterface::color)
|
||||
// .def("url", &IModInterface::url)
|
||||
// .def("primaryCategory", &IModInterface::primaryCategory)
|
||||
// .def("categories", &IModInterface::categories)
|
||||
// .def("trackedState", &IModInterface::trackedState)
|
||||
// .def("endorsedState", &IModInterface::endorsedState)
|
||||
// .def("fileTree", &IModInterface::fileTree)
|
||||
// .def("isOverwrite", &IModInterface::isOverwrite)
|
||||
// .def("isBackup", &IModInterface::isBackup)
|
||||
// .def("isSeparator", &IModInterface::isSeparator)
|
||||
// .def("isForeign", &IModInterface::isForeign)
|
||||
.def("comments", &IModInterface::comments)
|
||||
.def("notes", &IModInterface::notes)
|
||||
.def("gameName", &IModInterface::gameName)
|
||||
.def("repository", &IModInterface::repository)
|
||||
.def("nexusId", &IModInterface::nexusId)
|
||||
.def("version", &IModInterface::version)
|
||||
.def("newestVersion", &IModInterface::newestVersion)
|
||||
.def("ignoredVersion", &IModInterface::ignoredVersion)
|
||||
.def("installationFile", &IModInterface::installationFile)
|
||||
.def("converted", &IModInterface::converted)
|
||||
.def("validated", &IModInterface::validated)
|
||||
.def("color", &IModInterface::color)
|
||||
.def("url", &IModInterface::url)
|
||||
.def("primaryCategory", &IModInterface::primaryCategory)
|
||||
.def("categories", &IModInterface::categories)
|
||||
.def("trackedState", &IModInterface::trackedState)
|
||||
.def("endorsedState", &IModInterface::endorsedState)
|
||||
.def("fileTree", &IModInterface::fileTree)
|
||||
.def("isOverwrite", &IModInterface::isOverwrite)
|
||||
.def("isBackup", &IModInterface::isBackup)
|
||||
.def("isSeparator", &IModInterface::isSeparator)
|
||||
.def("isForeign", &IModInterface::isForeign)
|
||||
|
||||
// .def("setVersion", &IModInterface::setVersion,
|
||||
// py::arg("version")) .def("setNewestVersion",
|
||||
// &IModInterface::setNewestVersion, py::arg("version"))
|
||||
// .def("setIsEndorsed", &IModInterface::setIsEndorsed,
|
||||
// py::arg("endorsed")) .def("setNexusID",
|
||||
// &IModInterface::setNexusID, py::arg("nexus_id"))
|
||||
// .def("addNexusCategory", &IModInterface::addNexusCategory,
|
||||
// py::arg("category_id")) .def("addCategory",
|
||||
// &IModInterface::addCategory, py::arg("name"))
|
||||
// .def("removeCategory", &IModInterface::removeCategory,
|
||||
// py::arg("name")) .def("setGameName", &IModInterface::setGameName,
|
||||
// py::arg("name")) .def("setUrl", &IModInterface::setUrl,
|
||||
// py::arg("url")) .def("pluginSetting",
|
||||
// &IModInterface::pluginSetting, (py::arg("plugin_name"), "key",
|
||||
// py::arg("default") = QVariant())) .def("pluginSettings",
|
||||
// &IModInterface::pluginSettings, py::arg("plugin_name"))
|
||||
// .def("setPluginSetting", &IModInterface::setPluginSetting,
|
||||
// (py::arg("plugin_name"), "key", py::arg("value")))
|
||||
// .def("clearPluginSettings", &IModInterface::clearPluginSettings,
|
||||
// py::arg("plugin_name"))
|
||||
|
||||
// ;
|
||||
.def("setVersion", &IModInterface::setVersion, py::arg("version"))
|
||||
.def("setNewestVersion", &IModInterface::setNewestVersion,
|
||||
py::arg("version"))
|
||||
.def("setIsEndorsed", &IModInterface::setIsEndorsed, py::arg("endorsed"))
|
||||
.def("setNexusID", &IModInterface::setNexusID, py::arg("nexus_id"))
|
||||
.def("addNexusCategory", &IModInterface::addNexusCategory,
|
||||
py::arg("category_id"))
|
||||
.def("addCategory", &IModInterface::addCategory, py::arg("name"))
|
||||
.def("removeCategory", &IModInterface::removeCategory, py::arg("name"))
|
||||
.def("setGameName", &IModInterface::setGameName, py::arg("name"))
|
||||
.def("setUrl", &IModInterface::setUrl, py::arg("url"))
|
||||
.def("pluginSetting", &IModInterface::pluginSetting, py::arg("plugin_name"),
|
||||
py::arg("key"), py::arg("default") = QVariant())
|
||||
.def("pluginSettings", &IModInterface::pluginSettings,
|
||||
py::arg("plugin_name"))
|
||||
.def("setPluginSetting", &IModInterface::setPluginSetting,
|
||||
py::arg("plugin_name"), py::arg("key"), py::arg("value"))
|
||||
.def("clearPluginSettings", &IModInterface::clearPluginSettings,
|
||||
py::arg("plugin_name"));
|
||||
}
|
||||
|
||||
void add_modrepository_classes(py::module_ m)
|
||||
|
||||
Reference in New Issue
Block a user