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