aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/qpydesignerextensions.h
blob: 871fa8284914111ff67fb6667005132d071f98e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QPYDESIGNEREXTENSIONS_H
#define QPYDESIGNEREXTENSIONS_H

#include <QtDesigner/QDesignerContainerExtension>
#include <QtDesigner/QDesignerMemberSheetExtension>
#include <QtDesigner/QDesignerPropertySheetExtension>
#include <QtDesigner/QDesignerTaskMenuExtension>
#include <QtUiPlugin/QDesignerCustomWidgetCollectionInterface>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>

// Not automatically found since "find_package(Qt6 COMPONENTS Designer)" is not used

#ifdef Q_MOC_RUN
Q_DECLARE_INTERFACE(QDesignerContainerExtension, "org.qt-project.Qt.Designer.Container")
Q_DECLARE_INTERFACE(QDesignerMemberSheetExtension, "org.qt-project.Qt.Designer.MemberSheet")
Q_DECLARE_EXTENSION_INTERFACE(QDesignerPropertySheetExtension, "org.qt-project.Qt.Designer.PropertySheet")
Q_DECLARE_INTERFACE(QDesignerTaskMenuExtension, "org.qt-project.Qt.Designer.TaskMenu")
Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface, "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
#endif

struct _object; // PyObject

QT_BEGIN_NAMESPACE

// Extension implementations need to inherit QObject which cannot be done in Python.
// Provide a base class (cf QPyTextObject).

class QPyDesignerContainerExtension : public QObject, public QDesignerContainerExtension
{
    Q_OBJECT
    Q_INTERFACES(QDesignerContainerExtension)
public:
    explicit QPyDesignerContainerExtension(QObject *parent = nullptr) : QObject(parent) {}
};

class QPyDesignerMemberSheetExtension : public QObject, public QDesignerMemberSheetExtension
{
    Q_OBJECT
    Q_INTERFACES(QDesignerMemberSheetExtension)
public:
    explicit QPyDesignerMemberSheetExtension(QObject *parent = nullptr) : QObject(parent) {}
};

class QPyDesignerPropertySheetExtension : public QObject, public QDesignerPropertySheetExtension
{
    Q_OBJECT
    Q_INTERFACES(QDesignerPropertySheetExtension)
public:
    explicit QPyDesignerPropertySheetExtension(QObject *parent = nullptr) : QObject(parent) {}
};

class QPyDesignerTaskMenuExtension : public QObject, public QDesignerTaskMenuExtension
{
    Q_OBJECT
    Q_INTERFACES(QDesignerTaskMenuExtension)
public:
    explicit QPyDesignerTaskMenuExtension(QObject *parent = nullptr) : QObject(parent) {}
};

class QPyDesignerCustomWidgetCollection : public QDesignerCustomWidgetCollectionInterface
{
public:
    ~QPyDesignerCustomWidgetCollection();

    static QPyDesignerCustomWidgetCollection *instance();

    QList<QDesignerCustomWidgetInterface *> customWidgets() const override;

    static void addCustomWidget(QDesignerCustomWidgetInterface *c);

    static bool _registerCustomWidgetHelper(_object *typeArg, _object *kwds);

private:
    QPyDesignerCustomWidgetCollection();

    QList<QDesignerCustomWidgetInterface *> m_customWidgets;
};

QT_END_NAMESPACE

#endif // QPYDESIGNEREXTENSIONS_H