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
formeditor.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
4#include "formeditor.h"
28
29// sdk
30#include <QtDesigner/qextensionmanager.h>
31#include <QtDesigner/abstractintegration.h>
32// shared
33#include <pluginmanager_p.h>
34#include <qdesigner_taskmenu_p.h>
35#include <qdesigner_membersheet_p.h>
36#include <qdesigner_promotion_p.h>
37#include <dialoggui_p.h>
38#include <qdesigner_introspection_p.h>
39#include <qdesigner_qsettings_p.h>
40
42
43using namespace Qt::StringLiterals;
44
45namespace qdesigner_internal {
46
47FormEditor::FormEditor(QObject *parent) : FormEditor(QStringList{}, parent)
48{
49}
50
51FormEditor::FormEditor(const QStringList &pluginPaths,
52 QObject *parent)
54{
55 setIntrospection(new QDesignerIntrospection);
56 setDialogGui(new DialogGui);
57 auto *pluginManager = new QDesignerPluginManager(pluginPaths, this);
58 setPluginManager(pluginManager);
59
60 WidgetDataBase *widgetDatabase = new WidgetDataBase(this, this);
61 setWidgetDataBase(widgetDatabase);
62
63 MetaDataBase *metaDataBase = new MetaDataBase(this, this);
64 setMetaDataBase(metaDataBase);
65
66 WidgetFactory *widgetFactory = new WidgetFactory(this, this);
67 setWidgetFactory(widgetFactory);
68
69 FormWindowManager *formWindowManager = new FormWindowManager(this, this);
70 setFormManager(formWindowManager);
71 connect(formWindowManager, &QDesignerFormWindowManagerInterface::formWindowAdded,
72 widgetFactory, &WidgetFactory::formWindowAdded);
73 connect(formWindowManager, &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
74 widgetFactory, &WidgetFactory::activeFormWindowChanged);
75
76 QExtensionManager *mgr = new QExtensionManager(this);
77 const QString containerExtensionId = Q_TYPEID(QDesignerContainerExtension);
78
79 QDesignerStackedWidgetContainerFactory::registerExtension(mgr, containerExtensionId);
80 QDesignerTabWidgetContainerFactory::registerExtension(mgr, containerExtensionId);
81 QDesignerToolBoxContainerFactory::registerExtension(mgr, containerExtensionId);
82 QMainWindowContainerFactory::registerExtension(mgr, containerExtensionId);
83 QDockWidgetContainerFactory::registerExtension(mgr, containerExtensionId);
84 QScrollAreaContainerFactory::registerExtension(mgr, containerExtensionId);
85 QMdiAreaContainerFactory::registerExtension(mgr, containerExtensionId);
86 QWizardContainerFactory::registerExtension(mgr, containerExtensionId);
87
88 mgr->registerExtensions(new QDesignerLayoutDecorationFactory(mgr),
89 Q_TYPEID(QDesignerLayoutDecorationExtension));
90
91 const QString actionProviderExtensionId = Q_TYPEID(QDesignerActionProviderExtension);
92 QToolBarActionProviderFactory::registerExtension(mgr, actionProviderExtensionId);
93 QMenuBarActionProviderFactory::registerExtension(mgr, actionProviderExtensionId);
94 QMenuActionProviderFactory::registerExtension(mgr, actionProviderExtensionId);
95
96 QDesignerDefaultPropertySheetFactory::registerExtension(mgr);
97 QDockWidgetPropertySheetFactory::registerExtension(mgr);
98 QLayoutWidgetPropertySheetFactory::registerExtension(mgr);
99 SpacerPropertySheetFactory::registerExtension(mgr);
100 LinePropertySheetFactory::registerExtension(mgr);
101 LayoutPropertySheetFactory::registerExtension(mgr);
102 QStackedWidgetPropertySheetFactory::registerExtension(mgr);
103 QToolBoxWidgetPropertySheetFactory::registerExtension(mgr);
104 QTabWidgetPropertySheetFactory::registerExtension(mgr);
105 QMdiAreaPropertySheetFactory::registerExtension(mgr);
106 QWizardPagePropertySheetFactory::registerExtension(mgr);
107 QWizardPropertySheetFactory::registerExtension(mgr);
108
109 QTreeViewPropertySheetFactory::registerExtension(mgr);
110 QTableViewPropertySheetFactory::registerExtension(mgr);
111
112 QDesignerTaskMenuFactory::registerExtension(mgr, u"QDesignerInternalTaskMenuExtension"_s);
113
114 mgr->registerExtensions(new QDesignerMemberSheetFactory(mgr),
115 Q_TYPEID(QDesignerMemberSheetExtension));
116
117 setExtensionManager(mgr);
118
119 setPromotion(new QDesignerPromotion(this));
120
121 QtResourceModel *resourceModel = new QtResourceModel(this);
122 setResourceModel(resourceModel);
123 connect(resourceModel, &QtResourceModel::qrcFileModifiedExternally,
124 this, &FormEditor::slotQrcFileChangedExternally);
125
126 QList<QDesignerOptionsPageInterface*> optionsPages;
127 optionsPages << new TemplateOptionsPage(this) << new FormEditorOptionsPage(this) << new EmbeddedOptionsPage(this);
128 setOptionsPages(optionsPages);
129
130 setSettingsManager(new QDesignerQSettings());
131}
132
133FormEditor::~FormEditor() = default;
134
135void FormEditor::slotQrcFileChangedExternally(const QString &path)
136{
137 if (!integration())
138 return;
139
140 QDesignerIntegration::ResourceFileWatcherBehaviour behaviour = integration()->resourceFileWatcherBehaviour();
141 if (behaviour == QDesignerIntegration::NoResourceFileWatcher)
142 return;
143 if (behaviour == QDesignerIntegration::PromptToReloadResourceFile) {
144 QMessageBox::StandardButton button = dialogGui()->message(topLevel(), QDesignerDialogGuiInterface::FileChangedMessage, QMessageBox::Warning,
145 tr("Resource File Changed"),
146 tr("The file \"%1\" has changed outside Designer. Do you want to reload it?").arg(path),
147 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
148
149 if (button != QMessageBox::Yes)
150 return;
151 }
152
153 resourceModel()->reload(path);
154}
155
156}
157
158QT_END_NAMESPACE
FormEditor(const QStringList &pluginPaths, QObject *parent=nullptr)
Combined button and popup list for selecting options.