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 ABSTRACTFORMWINDOW_H
30#define ABSTRACTFORMWINDOW_H
31
32#include <QtDesigner/sdk_global.h>
33
34#include <QtWidgets/qwidget.h>
35
36QT_BEGIN_NAMESPACE
37
38class QDesignerFormEditorInterface;
39class QDesignerFormWindowCursorInterface;
40class QDesignerFormWindowToolInterface;
41class QUndoStack;
42class QDir;
43class QtResourceSet;
44
45class QDESIGNER_SDK_EXPORT QDesignerFormWindowInterface: public QWidget
46{
47 Q_OBJECT
48public:
49 enum FeatureFlag
50 {
51 EditFeature = 0x01,
52 GridFeature = 0x02,
53 TabOrderFeature = 0x04,
54 DefaultFeature = EditFeature | GridFeature
55 };
56 Q_DECLARE_FLAGS(Feature, FeatureFlag)
57
58 enum ResourceFileSaveMode
59 {
60 SaveAllResourceFiles,
61 SaveOnlyUsedResourceFiles,
62 DontSaveResourceFiles
63 };
64
65public:
66 explicit QDesignerFormWindowInterface(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
67 virtual ~QDesignerFormWindowInterface();
68
69 virtual QString fileName() const = 0;
70 virtual QDir absoluteDir() const = 0;
71
72 virtual QString contents() const = 0;
73 virtual QStringList checkContents() const = 0;
74 virtual bool setContents(QIODevice *dev, QString *errorMessage = nullptr) = 0;
75
76 virtual Feature features() const = 0;
77 virtual bool hasFeature(Feature f) const = 0;
78
79 virtual QString author() const = 0;
80 virtual void setAuthor(const QString &author) = 0;
81
82 virtual QString comment() const = 0;
83 virtual void setComment(const QString &comment) = 0;
84
85 virtual void layoutDefault(int *margin, int *spacing) = 0;
86 virtual void setLayoutDefault(int margin, int spacing) = 0;
87
88 virtual void layoutFunction(QString *margin, QString *spacing) = 0;
89 virtual void setLayoutFunction(const QString &margin, const QString &spacing) = 0;
90
91 virtual QString pixmapFunction() const = 0;
92 virtual void setPixmapFunction(const QString &pixmapFunction) = 0;
93
94 virtual QString exportMacro() const = 0;
95 virtual void setExportMacro(const QString &exportMacro) = 0;
96
97 virtual QStringList includeHints() const = 0;
98 virtual void setIncludeHints(const QStringList &includeHints) = 0;
99
100 virtual ResourceFileSaveMode resourceFileSaveMode() const = 0;
101 virtual void setResourceFileSaveMode(ResourceFileSaveMode behaviour) = 0;
102
103 virtual QtResourceSet *resourceSet() const = 0;
104 virtual void setResourceSet(QtResourceSet *resourceSet) = 0;
105
106 QStringList activeResourceFilePaths() const;
107
108 virtual QDesignerFormEditorInterface *core() const;
109 virtual QDesignerFormWindowCursorInterface *cursor() const = 0;
110
111 virtual int toolCount() const = 0;
112
113 virtual int currentTool() const = 0;
114 virtual void setCurrentTool(int index) = 0;
115
116 virtual QDesignerFormWindowToolInterface *tool(int index) const = 0;
117 virtual void registerTool(QDesignerFormWindowToolInterface *tool) = 0;
118
119 virtual QPoint grid() const = 0;
120
121 virtual QWidget *mainContainer() const = 0;
122 virtual void setMainContainer(QWidget *mainContainer) = 0;
123 virtual QWidget *formContainer() const = 0;
124
125 virtual bool isManaged(QWidget *widget) const = 0;
126
127 virtual bool isDirty() const = 0;
128
129 static QDesignerFormWindowInterface *findFormWindow(QWidget *w);
130 static QDesignerFormWindowInterface *findFormWindow(QObject *obj);
131
132 virtual QUndoStack *commandHistory() const = 0;
133 virtual void beginCommand(const QString &description) = 0;
134 virtual void endCommand() = 0;
135
136 virtual void simplifySelection(QList<QWidget*> *widgets) const = 0;
137
138 // notifications
139 virtual void emitSelectionChanged() = 0;
140
141 virtual QStringList resourceFiles() const = 0;
142 virtual void addResourceFile(const QString &path) = 0;
143 virtual void removeResourceFile(const QString &path) = 0;
144
145 virtual void ensureUniqueObjectName(QObject *object) = 0;
146
147public Q_SLOTS:
148 virtual void manageWidget(QWidget *widget) = 0;
149 virtual void unmanageWidget(QWidget *widget) = 0;
150
151 virtual void setFeatures(Feature f) = 0;
152 virtual void setDirty(bool dirty) = 0;
153 virtual void clearSelection(bool changePropertyDisplay = true) = 0;
154 virtual void selectWidget(QWidget *w, bool select = true) = 0;
155 virtual void setGrid(const QPoint &grid) = 0;
156 virtual void setFileName(const QString &fileName) = 0;
157 virtual bool setContents(const QString &contents) = 0;
158
159 virtual void editWidgets() = 0;
160 void activateResourceFilePaths(const QStringList &paths, int *errorCount = nullptr, QString *errorMessages = nullptr);
161
162Q_SIGNALS:
163 void mainContainerChanged(QWidget *mainContainer);
164 void toolChanged(int toolIndex);
165 void fileNameChanged(const QString &fileName);
166 void featureChanged(Feature f);
167 void selectionChanged();
168 void geometryChanged();
169
170 void resourceFilesChanged();
171
172 void widgetManaged(QWidget *widget);
173 void widgetUnmanaged(QWidget *widget);
174 void aboutToUnmanageWidget(QWidget *widget);
175 void activated(QWidget *widget);
176
177 void changed();
178 void widgetRemoved(QWidget *w);
179 void objectRemoved(QObject *o);
180};
181
182QT_END_NAMESPACE
183
184#endif // ABSTRACTFORMWINDOW_H
185