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