qpydesignerextensions.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright (C) 2021 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. #ifndef QPYDESIGNEREXTENSIONS_H
  4. #define QPYDESIGNEREXTENSIONS_H
  5. #include <QtDesigner/QDesignerContainerExtension>
  6. #include <QtDesigner/QDesignerMemberSheetExtension>
  7. #include <QtDesigner/QDesignerPropertySheetExtension>
  8. #include <QtDesigner/QDesignerTaskMenuExtension>
  9. #include <QtUiPlugin/QDesignerCustomWidgetCollectionInterface>
  10. #include <QtUiPlugin/QDesignerCustomWidgetInterface>
  11. // Not automatically found since "find_package(Qt6 COMPONENTS Designer)" is not used
  12. #ifdef Q_MOC_RUN
  13. Q_DECLARE_INTERFACE(QDesignerContainerExtension, "org.qt-project.Qt.Designer.Container")
  14. Q_DECLARE_INTERFACE(QDesignerMemberSheetExtension, "org.qt-project.Qt.Designer.MemberSheet")
  15. Q_DECLARE_EXTENSION_INTERFACE(QDesignerPropertySheetExtension, "org.qt-project.Qt.Designer.PropertySheet")
  16. Q_DECLARE_INTERFACE(QDesignerTaskMenuExtension, "org.qt-project.Qt.Designer.TaskMenu")
  17. Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface, "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
  18. #endif
  19. struct _object; // PyObject
  20. QT_BEGIN_NAMESPACE
  21. // Extension implementations need to inherit QObject which cannot be done in Python.
  22. // Provide a base class (cf QPyTextObject).
  23. class QPyDesignerContainerExtension : public QObject, public QDesignerContainerExtension
  24. {
  25. Q_OBJECT
  26. Q_INTERFACES(QDesignerContainerExtension)
  27. public:
  28. explicit QPyDesignerContainerExtension(QObject *parent = nullptr) : QObject(parent) {}
  29. };
  30. class QPyDesignerMemberSheetExtension : public QObject, public QDesignerMemberSheetExtension
  31. {
  32. Q_OBJECT
  33. Q_INTERFACES(QDesignerMemberSheetExtension)
  34. public:
  35. explicit QPyDesignerMemberSheetExtension(QObject *parent = nullptr) : QObject(parent) {}
  36. };
  37. class QPyDesignerPropertySheetExtension : public QObject, public QDesignerPropertySheetExtension
  38. {
  39. Q_OBJECT
  40. Q_INTERFACES(QDesignerPropertySheetExtension)
  41. public:
  42. explicit QPyDesignerPropertySheetExtension(QObject *parent = nullptr) : QObject(parent) {}
  43. };
  44. class QPyDesignerTaskMenuExtension : public QObject, public QDesignerTaskMenuExtension
  45. {
  46. Q_OBJECT
  47. Q_INTERFACES(QDesignerTaskMenuExtension)
  48. public:
  49. explicit QPyDesignerTaskMenuExtension(QObject *parent = nullptr) : QObject(parent) {}
  50. };
  51. class QPyDesignerCustomWidgetCollection : public QDesignerCustomWidgetCollectionInterface
  52. {
  53. public:
  54. ~QPyDesignerCustomWidgetCollection();
  55. static QPyDesignerCustomWidgetCollection *instance();
  56. QList<QDesignerCustomWidgetInterface *> customWidgets() const override;
  57. static void addCustomWidget(QDesignerCustomWidgetInterface *c);
  58. static bool _registerCustomWidgetHelper(_object *typeArg, _object *kwds);
  59. private:
  60. QPyDesignerCustomWidgetCollection();
  61. QList<QDesignerCustomWidgetInterface *> m_customWidgets;
  62. };
  63. QT_END_NAMESPACE
  64. #endif // QPYDESIGNEREXTENSIONS_H