Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
abstractformeditor.cpp
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
8
9#include <QtDesigner/abstractoptionspage.h>
10#include <QtDesigner/abstractsettings.h>
11#include <QtDesigner/abstractpropertyeditor.h>
12#include <QtDesigner/abstractformwindowmanager.h>
13#include <QtDesigner/qextensionmanager.h>
14#include <QtDesigner/abstractmetadatabase.h>
15#include <QtDesigner/abstractwidgetdatabase.h>
16#include <QtDesigner/abstractwidgetfactory.h>
17#include <QtDesigner/abstractobjectinspector.h>
18#include <QtDesigner/abstractintegration.h>
19#include <QtDesigner/abstractactioneditor.h>
20#include <QtDesigner/abstractwidgetbox.h>
21
22#include <actioneditor_p.h>
23#include <pluginmanager_p.h>
24#include <qtresourcemodel_p.h>
25#include <qtgradientmanager_p.h>
26#include <widgetfactory_p.h>
27#include <shared_settings_p.h>
28#include <formwindowbase_p.h>
29#include <grid_p.h>
30#include <iconloader_p.h>
31#include <QtDesigner/abstractpromotioninterface.h>
32
33#include <QtGui/qicon.h>
34
35// Must be done outside of the Qt namespace
36static void initResources()
37{
38 Q_INIT_RESOURCE(shared);
39 Q_INIT_RESOURCE(ClamshellPhone);
40 Q_INIT_RESOURCE(PortableMedia);
41 Q_INIT_RESOURCE(S60_nHD_Touchscreen);
42 Q_INIT_RESOURCE(S60_QVGA_Candybar);
43 Q_INIT_RESOURCE(SmartPhone2);
44 Q_INIT_RESOURCE(SmartPhone);
45 Q_INIT_RESOURCE(SmartPhoneWithButtons);
46 Q_INIT_RESOURCE(TouchscreenPhone);
47}
48
49QT_BEGIN_NAMESPACE
50
51using namespace Qt::StringLiterals;
52
79
81
83{
84 delete m_settingsManager;
85 delete m_formWindowManager;
86 delete m_promotion;
87 delete m_introspection;
88 delete m_dialogGui;
89 delete m_resourceModel;
90 qDeleteAll(m_optionsPages);
91}
92
93/*!
94 \class QDesignerFormEditorInterface
95
96 \brief The QDesignerFormEditorInterface class allows you to access
97 Qt Widgets Designer's various components.
98
99 \inmodule QtDesigner
100
101 \QD's current QDesignerFormEditorInterface object holds
102 information about all \QD's components: The action editor, the
103 object inspector, the property editor, the widget box, and the
104 extension and form window managers. QDesignerFormEditorInterface
105 contains a collection of functions that provides interfaces to all
106 these components. They are typically used to query (and
107 manipulate) the respective component. For example:
108
109 \snippet lib/tools_designer_src_lib_sdk_abstractobjectinspector.cpp 0
110
111 QDesignerFormEditorInterface is not intended to be instantiated
112 directly. A pointer to \QD's current QDesignerFormEditorInterface
113 object (\c formEditor in the example above) is provided by the
114 QDesignerCustomWidgetInterface::initialize() function's
115 parameter. When implementing a custom widget plugin, you must
116 subclass the QDesignerCustomWidgetInterface to expose your plugin
117 to \QD.
118
119 QDesignerFormEditorInterface also provides functions that can set
120 the action editor, property editor, object inspector and widget
121 box. These are only useful if you want to provide your own custom
122 components.
123
124 If designer is embedded in another program, one could to provide its
125 own settings manager. The manager is used by the components of \QD
126 to store/retrieve persistent configuration settings. The default
127 manager uses QSettings as the backend.
128
129 Finally, QDesignerFormEditorInterface provides the topLevel()
130 function that returns \QD's top-level widget.
131
132 \sa QDesignerCustomWidgetInterface
133*/
134
135/*!
136 Constructs a QDesignerFormEditorInterface object with the given \a
137 parent.
138*/
139
140QDesignerFormEditorInterface::QDesignerFormEditorInterface(QObject *parent)
141 : QObject(parent),
142 d(new QDesignerFormEditorInterfacePrivate())
143{
144 initResources();
145}
146
147/*!
148 Destroys the QDesignerFormEditorInterface object.
149*/
150QDesignerFormEditorInterface::~QDesignerFormEditorInterface() = default;
151
152/*!
153 Returns an interface to \QD's widget box.
154
155 \sa setWidgetBox()
156*/
157QDesignerWidgetBoxInterface *QDesignerFormEditorInterface::widgetBox() const
158{
159 return d->m_widgetBox;
160}
161
162/*!
163 Sets \QD's widget box to be the specified \a widgetBox.
164
165 \sa widgetBox()
166*/
167void QDesignerFormEditorInterface::setWidgetBox(QDesignerWidgetBoxInterface *widgetBox)
168{
169 d->m_widgetBox = widgetBox;
170}
171
172/*!
173 Returns an interface to \QD's property editor.
174
175 \sa setPropertyEditor()
176*/
177QDesignerPropertyEditorInterface *QDesignerFormEditorInterface::propertyEditor() const
178{
179 return d->m_propertyEditor;
180}
181
182/*!
183 Sets \QD's property editor to be the specified \a propertyEditor.
184
185 \sa propertyEditor()
186*/
187void QDesignerFormEditorInterface::setPropertyEditor(QDesignerPropertyEditorInterface *propertyEditor)
188{
189 d->m_propertyEditor = propertyEditor;
190}
191
192/*!
193 Returns an interface to \QD's action editor.
194
195 \sa setActionEditor()
196*/
197QDesignerActionEditorInterface *QDesignerFormEditorInterface::actionEditor() const
198{
199 return d->m_actionEditor;
200}
201
202/*!
203 Sets \QD's action editor to be the specified \a actionEditor.
204
205 \sa actionEditor()
206*/
207void QDesignerFormEditorInterface::setActionEditor(QDesignerActionEditorInterface *actionEditor)
208{
209 d->m_actionEditor = actionEditor;
210}
211
212/*!
213 Returns \QD's top-level widget.
214*/
215QWidget *QDesignerFormEditorInterface::topLevel() const
216{
217 return d->m_topLevel;
218}
219
220/*!
221 \internal
222*/
223void QDesignerFormEditorInterface::setTopLevel(QWidget *topLevel)
224{
225 d->m_topLevel = topLevel;
226}
227
228/*!
229 Returns an interface to \QD's form window manager.
230*/
231QDesignerFormWindowManagerInterface *QDesignerFormEditorInterface::formWindowManager() const
232{
233 return d->m_formWindowManager;
234}
235
236/*!
237 \internal
238*/
239void QDesignerFormEditorInterface::setFormManager(QDesignerFormWindowManagerInterface *formWindowManager)
240{
241 d->m_formWindowManager = formWindowManager;
242}
243
244/*!
245 Returns an interface to \QD's extension manager.
246*/
247QExtensionManager *QDesignerFormEditorInterface::extensionManager() const
248{
249 return d->m_extensionManager;
250}
251
252/*!
253 \internal
254*/
255void QDesignerFormEditorInterface::setExtensionManager(QExtensionManager *extensionManager)
256{
257 d->m_extensionManager = extensionManager;
258}
259
260/*!
261 \internal
262
263 Returns an interface to the meta database used by the form editor.
264*/
265QDesignerMetaDataBaseInterface *QDesignerFormEditorInterface::metaDataBase() const
266{
267 return d->m_metaDataBase;
268}
269
270/*!
271 \internal
272*/
273void QDesignerFormEditorInterface::setMetaDataBase(QDesignerMetaDataBaseInterface *metaDataBase)
274{
275 d->m_metaDataBase = metaDataBase;
276}
277
278/*!
279 \internal
280
281 Returns an interface to the widget database used by the form editor.
282*/
283QDesignerWidgetDataBaseInterface *QDesignerFormEditorInterface::widgetDataBase() const
284{
285 return d->m_widgetDataBase;
286}
287
288/*!
289 \internal
290*/
291void QDesignerFormEditorInterface::setWidgetDataBase(QDesignerWidgetDataBaseInterface *widgetDataBase)
292{
293 d->m_widgetDataBase = widgetDataBase;
294}
295
296/*!
297 \internal
298
299 Returns an interface to the designer promotion handler.
300*/
301
302QDesignerPromotionInterface *QDesignerFormEditorInterface::promotion() const
303{
304 return d->m_promotion;
305}
306
307/*!
308 \internal
309
310 Sets the designer promotion handler.
311*/
312
313void QDesignerFormEditorInterface::setPromotion(QDesignerPromotionInterface *promotion)
314{
315 delete d->m_promotion;
316 d->m_promotion = promotion;
317}
318
319/*!
320 \internal
321
322 Returns an interface to the widget factory used by the form editor
323 to create widgets for the form.
324*/
325QDesignerWidgetFactoryInterface *QDesignerFormEditorInterface::widgetFactory() const
326{
327 return d->m_widgetFactory;
328}
329
330/*!
331 \internal
332*/
333void QDesignerFormEditorInterface::setWidgetFactory(QDesignerWidgetFactoryInterface *widgetFactory)
334{
335 d->m_widgetFactory = widgetFactory;
336}
337
338/*!
339 Returns an interface to \QD's object inspector.
340*/
341QDesignerObjectInspectorInterface *QDesignerFormEditorInterface::objectInspector() const
342{
343 return d->m_objectInspector;
344}
345
346/*!
347 Sets \QD's object inspector to be the specified \a
348 objectInspector.
349
350 \sa objectInspector()
351*/
352void QDesignerFormEditorInterface::setObjectInspector(QDesignerObjectInspectorInterface *objectInspector)
353{
354 d->m_objectInspector = objectInspector;
355}
356
357/*!
358 \internal
359
360 Returns an interface to the integration.
361*/
362QDesignerIntegrationInterface *QDesignerFormEditorInterface::integration() const
363{
364 return d->m_integration;
365}
366
367/*!
368 \internal
369*/
370void QDesignerFormEditorInterface::setIntegration(QDesignerIntegrationInterface *integration)
371{
372 d->m_integration = integration;
373}
374
375/*!
376 \internal
377 \since 4.5
378 Returns the list of options pages that allow the user to configure \QD components.
379*/
380QList<QDesignerOptionsPageInterface*> QDesignerFormEditorInterface::optionsPages() const
381{
382 return d->m_optionsPages;
383}
384
385/*!
386 \internal
387 \since 4.5
388 Sets the list of options pages that allow the user to configure \QD components.
389*/
390void QDesignerFormEditorInterface::setOptionsPages(const QList<QDesignerOptionsPageInterface*> &optionsPages)
391{
392 d->m_optionsPages = optionsPages;
393}
394
395
396/*!
397 \internal
398
399 Returns the plugin manager used by the form editor.
400*/
401QDesignerPluginManager *QDesignerFormEditorInterface::pluginManager() const
402{
403 return d->m_pluginManager;
404}
405
406/*!
407 \internal
408
409 Sets the plugin manager used by the form editor to the specified
410 \a pluginManager.
411*/
412void QDesignerFormEditorInterface::setPluginManager(QDesignerPluginManager *pluginManager)
413{
414 d->m_pluginManager = pluginManager;
415}
416
417/*!
418 \internal
419 \since 4.4
420 Returns the resource model used by the form editor.
421*/
422QtResourceModel *QDesignerFormEditorInterface::resourceModel() const
423{
424 return d->m_resourceModel;
425}
426
427/*!
428 \internal
429
430 Sets the resource model used by the form editor to the specified
431 \a resourceModel.
432*/
433void QDesignerFormEditorInterface::setResourceModel(QtResourceModel *resourceModel)
434{
435 d->m_resourceModel = resourceModel;
436}
437
438/*!
439 \internal
440 \since 4.4
441 Returns the gradient manager used by the style sheet editor.
442*/
443QtGradientManager *QDesignerFormEditorInterface::gradientManager() const
444{
445 return d->m_gradientManager;
446}
447
448/*!
449 \internal
450
451 Sets the gradient manager used by the style sheet editor to the specified
452 \a gradientManager.
453*/
454void QDesignerFormEditorInterface::setGradientManager(QtGradientManager *gradientManager)
455{
456 d->m_gradientManager = gradientManager;
457}
458
459/*!
460 \internal
461 \since 4.5
462 Returns the settings manager used by the components to store persistent settings.
463*/
464QDesignerSettingsInterface *QDesignerFormEditorInterface::settingsManager() const
465{
466 return d->m_settingsManager;
467}
468
469/*!
470 \internal
471 \since 4.5
472 Sets the settings manager used to store/retrieve the persistent settings of the components.
473*/
474void QDesignerFormEditorInterface::setSettingsManager(QDesignerSettingsInterface *settingsManager)
475{
476 if (d->m_settingsManager)
477 delete d->m_settingsManager;
478 d->m_settingsManager = settingsManager;
479
480 // This is a (hopefully) safe place to perform settings-dependent
481 // initializations.
482 const qdesigner_internal::QDesignerSharedSettings settings(this);
483 qdesigner_internal::FormWindowBase::setDefaultDesignerGrid(settings.defaultGrid());
484 qdesigner_internal::ActionEditor::setObjectNamingMode(settings.objectNamingMode());
485}
486
487/*!
488 \internal
489 \since 4.4
490 Returns the introspection used by the form editor.
491*/
492QDesignerIntrospectionInterface *QDesignerFormEditorInterface::introspection() const
493{
494 return d->m_introspection;
495}
496
497/*!
498 \internal
499 \since 4.4
500
501 Sets the introspection used by the form editor to the specified \a introspection.
502*/
503void QDesignerFormEditorInterface::setIntrospection(QDesignerIntrospectionInterface *introspection)
504{
505 delete d->m_introspection;
506 d->m_introspection = introspection;
507}
508
509/*!
510 \internal
511
512 Returns the path to the resources used by the form editor.
513*/
514QString QDesignerFormEditorInterface::resourceLocation() const
515{
516#ifdef Q_OS_MACOS
517 return u":/qt-project.org/formeditor/images/mac"_s;
518#else
519 return u":/qt-project.org/formeditor/images/win"_s;
520#endif
521}
522
523/*!
524 \internal
525
526 Returns the dialog GUI used by the form editor.
527*/
528
529QDesignerDialogGuiInterface *QDesignerFormEditorInterface::dialogGui() const
530{
531 return d->m_dialogGui;
532}
533
534/*!
535 \internal
536
537 Sets the dialog GUI used by the form editor to the specified \a dialogGui.
538*/
539
540void QDesignerFormEditorInterface::setDialogGui(QDesignerDialogGuiInterface *dialogGui)
541{
542 delete d->m_dialogGui;
543 d->m_dialogGui = dialogGui;
544}
545
546/*!
547 \internal
548
549 \since 5.0
550
551 Returns the plugin instances of QDesignerPluginManager.
552*/
553
554QObjectList QDesignerFormEditorInterface::pluginInstances() const
555{
556 return d->m_pluginManager->instances();
557}
558
559/*!
560 \internal
561
562 \since 5.0
563
564 Return icons for actions of \QD.
565*/
566
567QIcon QDesignerFormEditorInterface::createIcon(const QString &name)
568{
569 return qdesigner_internal::createIconSet(name);
570}
571
572QT_END_NAMESPACE
static void initResources()
QList< QDesignerOptionsPageInterface * > m_optionsPages
QPointer< QtGradientManager > m_gradientManager
QPointer< QtResourceModel > m_resourceModel
QDesignerDialogGuiInterface * m_dialogGui
QPointer< QDesignerFormWindowManagerInterface > m_formWindowManager
QPointer< QDesignerObjectInspectorInterface > m_objectInspector
QPointer< QDesignerWidgetFactoryInterface > m_widgetFactory
QDesignerIntrospectionInterface * m_introspection
QPointer< QDesignerWidgetBoxInterface > m_widgetBox
QPointer< QDesignerMetaDataBaseInterface > m_metaDataBase
QDesignerSettingsInterface * m_settingsManager
QPointer< QDesignerIntegrationInterface > m_integration
QPointer< QDesignerActionEditorInterface > m_actionEditor
QPointer< QDesignerPropertyEditorInterface > m_propertyEditor
QDesignerPromotionInterface * m_promotion
QPointer< QDesignerWidgetDataBaseInterface > m_widgetDataBase
QPointer< QExtensionManager > m_extensionManager