1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef ABSTRACTINTEGRATION_H
30#define ABSTRACTINTEGRATION_H
31
32#include <QtDesigner/sdk_global.h>
33
34#include <QtCore/qobject.h>
35#include <QtCore/qscopedpointer.h>
36#include <QtCore/qstringlist.h>
37#include <QtCore/qflags.h>
38
39QT_BEGIN_NAMESPACE
40
41class QDesignerFormWindowInterface;
42class QDesignerFormEditorInterface;
43class QDesignerIntegrationInterfacePrivate;
44class QDesignerResourceBrowserInterface;
45class QVariant;
46class QWidget;
47
48namespace qdesigner_internal {
49class QDesignerIntegrationPrivate;
50}
51
52class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
53{
54 Q_OBJECT
55 Q_PROPERTY(QString headerSuffix READ headerSuffix WRITE setHeaderSuffix)
56 Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase)
57
58public:
59 enum ResourceFileWatcherBehaviour
60 {
61 NoResourceFileWatcher,
62 ReloadResourceFileSilently,
63 PromptToReloadResourceFile // Default
64 };
65
66 enum FeatureFlag
67 {
68 ResourceEditorFeature = 0x1,
69 SlotNavigationFeature = 0x2,
70 DefaultWidgetActionFeature = 0x4,
71 DefaultFeature = ResourceEditorFeature | DefaultWidgetActionFeature
72 };
73 Q_DECLARE_FLAGS(Feature, FeatureFlag)
74
75 explicit QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = nullptr);
76 virtual ~QDesignerIntegrationInterface();
77
78 QDesignerFormEditorInterface *core() const;
79
80 virtual QWidget *containerWindow(QWidget *widget) const = 0;
81
82 // Create a resource browser specific to integration. Language integration takes precedence
83 virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = nullptr) = 0;
84 virtual QString headerSuffix() const = 0;
85 virtual void setHeaderSuffix(const QString &headerSuffix) = 0;
86
87 virtual bool isHeaderLowercase() const = 0;
88 virtual void setHeaderLowercase(bool headerLowerCase) = 0;
89
90 virtual Feature features() const = 0;
91 bool hasFeature(Feature f) const;
92
93 virtual ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const = 0;
94 virtual void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour) = 0;
95
96 virtual QString contextHelpId() const = 0;
97
98 void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object,
99 const QString &newName, const QString &oldName);
100 void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
101 void emitNavigateToSlot(const QString &slotSignature);
102 void emitHelpRequested(const QString &manual, const QString &document);
103
104Q_SIGNALS:
105 void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
106 void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
107 void helpRequested(const QString &manual, const QString &document);
108
109 void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
110 void navigateToSlot(const QString &slotSignature);
111
112public Q_SLOTS:
113 virtual void setFeatures(Feature f) = 0;
114 virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) = 0;
115 virtual void updateProperty(const QString &name, const QVariant &value) = 0;
116 // Additional signals of designer property editor
117 virtual void resetProperty(const QString &name) = 0;
118 virtual void addDynamicProperty(const QString &name, const QVariant &value) = 0;
119 virtual void removeDynamicProperty(const QString &name) = 0;
120
121 virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
122 virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
123 virtual void updateSelection() = 0;
124 virtual void updateCustomWidgetPlugins() = 0;
125
126private:
127 QScopedPointer<QDesignerIntegrationInterfacePrivate> d;
128};
129
130class QDESIGNER_SDK_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
131{
132 Q_OBJECT
133public:
134 explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = nullptr);
135 virtual ~QDesignerIntegration();
136
137 QString headerSuffix() const override;
138 void setHeaderSuffix(const QString &headerSuffix) override;
139
140 bool isHeaderLowercase() const override;
141 void setHeaderLowercase(bool headerLowerCase) override;
142
143 Feature features() const override;
144 virtual void setFeatures(Feature f) override;
145
146 ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const override;
147 void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour) override;
148
149 virtual QWidget *containerWindow(QWidget *widget) const override;
150
151 // Load plugins into widget database and factory.
152 static void initializePlugins(QDesignerFormEditorInterface *formEditor);
153
154 // Create a resource browser specific to integration. Language integration takes precedence
155 QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = nullptr) override;
156
157 QString contextHelpId() const override;
158
159 void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) override;
160 void updateProperty(const QString &name, const QVariant &value) override;
161 // Additional signals of designer property editor
162 void resetProperty(const QString &name) override;
163 void addDynamicProperty(const QString &name, const QVariant &value) override;
164 void removeDynamicProperty(const QString &name) override;
165
166 void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow) override;
167 void setupFormWindow(QDesignerFormWindowInterface *formWindow) override;
168 void updateSelection() override;
169 void updateCustomWidgetPlugins() override;
170
171private:
172 QScopedPointer<qdesigner_internal::QDesignerIntegrationPrivate> d;
173};
174
175QT_END_NAMESPACE
176
177#endif // ABSTRACTINTEGRATION_H
178

source code of qttools/src/designer/src/lib/sdk/abstractintegration.h