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//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists for the convenience
34// of Qt Designer. This header
35// file may change from version to version without notice, or even be removed.
36//
37// We mean it.
38//
39
40#ifndef FORMWINDOWBASE_H
41#define FORMWINDOWBASE_H
42
43#include "shared_global_p.h"
44
45#include <QtDesigner/abstractformwindow.h>
46
47#include <QtCore/qvariant.h>
48#include <QtCore/qlist.h>
49
50QT_BEGIN_NAMESPACE
51
52class QDesignerDnDItemInterface;
53class QMenu;
54class QtResourceSet;
55class QDesignerPropertySheet;
56
57namespace qdesigner_internal {
58
59class QEditorFormBuilder;
60class DeviceProfile;
61class Grid;
62
63class DesignerPixmapCache;
64class DesignerIconCache;
65class FormWindowBasePrivate;
66
67class QDESIGNER_SHARED_EXPORT FormWindowBase: public QDesignerFormWindowInterface
68{
69 Q_OBJECT
70public:
71 enum HighlightMode { Restore, Highlight };
72
73 explicit FormWindowBase(QDesignerFormEditorInterface *core, QWidget *parent = nullptr,
74 Qt::WindowFlags flags = {});
75 ~FormWindowBase() override;
76
77 QVariantMap formData();
78 void setFormData(const QVariantMap &vm);
79
80 QStringList checkContents() const override;
81
82 // Deprecated
83 QPoint grid() const override;
84
85 // Deprecated
86 void setGrid(const QPoint &grid) override;
87
88 bool hasFeature(Feature f) const override;
89 Feature features() const override;
90 void setFeatures(Feature f) override;
91
92 const Grid &designerGrid() const;
93 void setDesignerGrid(const Grid& grid);
94
95 bool hasFormGrid() const;
96 void setHasFormGrid(bool b);
97
98 bool gridVisible() const;
99
100 ResourceFileSaveMode resourceFileSaveMode() const override;
101 void setResourceFileSaveMode(ResourceFileSaveMode behavior) override;
102
103 static const Grid &defaultDesignerGrid();
104 static void setDefaultDesignerGrid(const Grid& grid);
105
106 // Overwrite to initialize and return a full popup menu for a managed widget
107 virtual QMenu *initializePopupMenu(QWidget *managedWidget);
108 // Helper to create a basic popup menu from task menu extensions (internal/public)
109 static QMenu *createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QObject *o, bool trailingSeparator = true);
110
111 virtual bool dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, QWidget *target,
112 const QPoint &global_mouse_pos) = 0;
113
114 // Helper to find the widget at the mouse position with some flags.
115 enum WidgetUnderMouseMode { FindSingleSelectionDropTarget, FindMultiSelectionDropTarget };
116 QWidget *widgetUnderMouse(const QPoint &formPos, WidgetUnderMouseMode m);
117
118 virtual QWidget *widgetAt(const QPoint &pos) = 0;
119 virtual QWidget *findContainer(QWidget *w, bool excludeLayout) const = 0;
120
121 void deleteWidgetList(const QWidgetList &widget_list);
122
123 virtual void highlightWidget(QWidget *w, const QPoint &pos, HighlightMode mode = Highlight) = 0;
124
125 enum PasteMode { PasteAll, PasteActionsOnly };
126#if QT_CONFIG(clipboard)
127 virtual void paste(PasteMode pasteMode) = 0;
128#endif
129
130 // Factory method to create a form builder
131 virtual QEditorFormBuilder *createFormBuilder() = 0;
132
133 virtual bool blockSelectionChanged(bool blocked) = 0;
134
135 DesignerPixmapCache *pixmapCache() const;
136 DesignerIconCache *iconCache() const;
137 QtResourceSet *resourceSet() const override;
138 void setResourceSet(QtResourceSet *resourceSet) override;
139 void addReloadableProperty(QDesignerPropertySheet *sheet, int index);
140 void removeReloadableProperty(QDesignerPropertySheet *sheet, int index);
141 void addReloadablePropertySheet(QDesignerPropertySheet *sheet, QObject *object);
142 void reloadProperties();
143
144 void emitWidgetRemoved(QWidget *w);
145 void emitObjectRemoved(QObject *o);
146
147 DeviceProfile deviceProfile() const;
148 QString styleName() const;
149 QString deviceProfileName() const;
150
151 enum LineTerminatorMode {
152 LFLineTerminator,
153 CRLFLineTerminator,
154 NativeLineTerminator =
155#if defined (Q_OS_WIN)
156 CRLFLineTerminator
157#else
158 LFLineTerminator
159#endif
160 };
161
162 void setLineTerminatorMode(LineTerminatorMode mode);
163 LineTerminatorMode lineTerminatorMode() const;
164
165 bool useIdBasedTranslations() const;
166 void setUseIdBasedTranslations(bool v);
167
168 bool connectSlotsByName() const;
169 void setConnectSlotsByName(bool v);
170
171public slots:
172 void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged);
173
174private slots:
175 void triggerDefaultAction(QWidget *w);
176 void sheetDestroyed(QObject *object);
177
178private:
179 void syncGridFeature();
180 void connectSheet(QDesignerPropertySheet *sheet);
181 void disconnectSheet(QDesignerPropertySheet *sheet);
182
183 FormWindowBasePrivate *m_d;
184};
185
186} // namespace qdesigner_internal
187
188QT_END_NAMESPACE
189
190#endif // FORMWINDOWBASE_H
191

source code of qttools/src/designer/src/lib/shared/formwindowbase_p.h