1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef ABSTRACTINTEGRATION_H |
5 | #define ABSTRACTINTEGRATION_H |
6 | |
7 | #include <QtDesigner/sdk_global.h> |
8 | |
9 | #include <QtCore/qobject.h> |
10 | #include <QtCore/qscopedpointer.h> |
11 | #include <QtCore/qstringlist.h> |
12 | #include <QtCore/qflags.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QDesignerFormWindowInterface; |
17 | class QDesignerFormEditorInterface; |
18 | class QDesignerIntegrationInterfacePrivate; |
19 | class QDesignerResourceBrowserInterface; |
20 | class QVariant; |
21 | class QWidget; |
22 | |
23 | namespace qdesigner_internal { |
24 | class QDesignerIntegrationPrivate; |
25 | } |
26 | |
27 | class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject |
28 | { |
29 | Q_OBJECT |
30 | Q_PROPERTY(QString headerSuffix READ headerSuffix WRITE setHeaderSuffix) |
31 | Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase) |
32 | |
33 | public: |
34 | enum ResourceFileWatcherBehaviour |
35 | { |
36 | NoResourceFileWatcher, |
37 | ReloadResourceFileSilently, |
38 | PromptToReloadResourceFile // Default |
39 | }; |
40 | Q_ENUM(ResourceFileWatcherBehaviour) |
41 | |
42 | enum FeatureFlag |
43 | { |
44 | ResourceEditorFeature = 0x1, |
45 | SlotNavigationFeature = 0x2, |
46 | DefaultWidgetActionFeature = 0x4, |
47 | DefaultFeature = ResourceEditorFeature | DefaultWidgetActionFeature |
48 | }; |
49 | Q_DECLARE_FLAGS(Feature, FeatureFlag) |
50 | |
51 | explicit QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = nullptr); |
52 | virtual ~QDesignerIntegrationInterface(); |
53 | |
54 | QDesignerFormEditorInterface *core() const; |
55 | |
56 | virtual QWidget *containerWindow(QWidget *widget) const = 0; |
57 | |
58 | // Create a resource browser specific to integration. Language integration takes precedence |
59 | virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = nullptr) = 0; |
60 | virtual QString () const = 0; |
61 | virtual void (const QString &) = 0; |
62 | |
63 | virtual bool () const = 0; |
64 | virtual void (bool ) = 0; |
65 | |
66 | virtual Feature features() const = 0; |
67 | bool hasFeature(Feature f) const; |
68 | |
69 | virtual ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const = 0; |
70 | virtual void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour) = 0; |
71 | |
72 | virtual QString contextHelpId() const = 0; |
73 | |
74 | void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, |
75 | const QString &newName, const QString &oldName); |
76 | void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList ¶meterNames); |
77 | void emitNavigateToSlot(const QString &slotSignature); |
78 | void emitHelpRequested(const QString &manual, const QString &document); |
79 | |
80 | Q_SIGNALS: |
81 | void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value); |
82 | void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName); |
83 | void helpRequested(const QString &manual, const QString &document); |
84 | |
85 | void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList ¶meterNames); |
86 | void navigateToSlot(const QString &slotSignature); |
87 | |
88 | public Q_SLOTS: |
89 | virtual void setFeatures(Feature f) = 0; |
90 | virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) = 0; |
91 | virtual void updateProperty(const QString &name, const QVariant &value) = 0; |
92 | // Additional signals of designer property editor |
93 | virtual void resetProperty(const QString &name) = 0; |
94 | virtual void addDynamicProperty(const QString &name, const QVariant &value) = 0; |
95 | virtual void removeDynamicProperty(const QString &name) = 0; |
96 | |
97 | virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow) = 0; |
98 | virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow) = 0; |
99 | virtual void updateSelection() = 0; |
100 | virtual void updateCustomWidgetPlugins() = 0; |
101 | |
102 | private: |
103 | QScopedPointer<QDesignerIntegrationInterfacePrivate> d; |
104 | }; |
105 | |
106 | class QDESIGNER_SDK_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface |
107 | { |
108 | Q_OBJECT |
109 | public: |
110 | explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = nullptr); |
111 | virtual ~QDesignerIntegration(); |
112 | |
113 | QString () const override; |
114 | void (const QString &) override; |
115 | |
116 | bool () const override; |
117 | void (bool ) override; |
118 | |
119 | Feature features() const override; |
120 | virtual void setFeatures(Feature f) override; |
121 | |
122 | ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const override; |
123 | void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour) override; |
124 | |
125 | virtual QWidget *containerWindow(QWidget *widget) const override; |
126 | |
127 | // Load plugins into widget database and factory. |
128 | static void initializePlugins(QDesignerFormEditorInterface *formEditor); |
129 | |
130 | // Create a resource browser specific to integration. Language integration takes precedence |
131 | QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = nullptr) override; |
132 | |
133 | QString contextHelpId() const override; |
134 | |
135 | void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) override; |
136 | void updateProperty(const QString &name, const QVariant &value) override; |
137 | // Additional signals of designer property editor |
138 | void resetProperty(const QString &name) override; |
139 | void addDynamicProperty(const QString &name, const QVariant &value) override; |
140 | void removeDynamicProperty(const QString &name) override; |
141 | |
142 | void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow) override; |
143 | void setupFormWindow(QDesignerFormWindowInterface *formWindow) override; |
144 | void updateSelection() override; |
145 | void updateCustomWidgetPlugins() override; |
146 | |
147 | private: |
148 | QScopedPointer<qdesigner_internal::QDesignerIntegrationPrivate> d; |
149 | }; |
150 | |
151 | QT_END_NAMESPACE |
152 | |
153 | #endif // ABSTRACTINTEGRATION_H |
154 | |