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
qsimpleresource.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#include <qdesigner_utils_p.h>
8
9#include <QtDesigner/private/properties_p.h>
10#include <QtDesigner/private/ui4_p.h>
11
12#include <QtDesigner/abstractformeditor.h>
13#include <QtDesigner/abstractlanguage.h>
14#include <QtDesigner/qextensionmanager.h>
15#include <QtDesigner/extrainfo.h>
16
17#include <QtUiPlugin/customwidget.h>
18
19#include <QtWidgets/qwidget.h>
20
21#include <QtGui/qaction.h>
22#include <QtGui/qicon.h>
23
24#include <QtCore/qdebug.h>
25#include <QtCore/qcoreapplication.h>
26
28
29using namespace Qt::StringLiterals;
30
31namespace qdesigner_internal {
32
34
41
43
48
53
63
73
78
83
88
89// Custom widgets handling helpers
90
91// Add unique fake slots and signals to lists
93{
94 if (!domSlots)
95 return false;
96
97 bool rc = false;
99 for (const QString &fakeSlot : elementSlots)
100 if (fakeSlots.indexOf(fakeSlot) == -1) {
102 rc = true;
103 }
104
106 for (const QString &fakeSignal : elementSignals)
107 if (fakeSignals.indexOf(fakeSignal) == -1) {
109 rc = true;
110 }
111 return rc;
112}
113
115{
117 if (!domSlots)
118 return;
119
120 // Merge in new slots, signals
126 }
127}
128
129// Perform one iteration of adding the custom widgets to the database,
130// looking up the base class and inheriting its data.
131// Remove the succeeded custom widgets from the list.
132// Classes whose base class could not be found are left in the list.
133
136{
138 for (qsizetype i = 0; i < custom_widget_list.size(); ) {
139 bool classInserted = false;
147 if (header->hasAttributeLocation() && header->attributeLocation() == "global"_L1)
149 }
151 // Append a new item
152 if (base_class.isEmpty()) {
154 item->setPromoted(false);
155 item->setGroup(QCoreApplication::translate("Designer", "Custom Widgets"));
158 item->setCustom(true);
160 db->append(item);
162 classInserted = true;
163 } else {
164 // Create a new entry cloned from base class. Note that this will ignore existing
165 // classes, eg, plugin custom widgets.
167 appendDerived(db, customClassName, QCoreApplication::translate("Designer", "Promoted Widgets"),
170 true,true);
171 // Ok, base class found.
172 if (item) {
173 // Hack to accommodate for old UI-files in which "container" is not set properly:
174 // Apply "container" from DOM only if true (else, eg classes from QFrame might not accept
175 // dropping child widgets on them as container=false). This also allows for
176 // QWidget-derived stacked pages.
177 if (domIsContainer)
179
182 classInserted = true;
183 }
184 }
185 // Skip failed item.
186 if (!classInserted)
187 i++;
188 }
189
190}
191
194{
195 if (dom_custom_widgets == nullptr)
196 return;
198 // Attempt to insert each item derived from its base class.
199 // This should at most require two iterations in the event that the classes are out of order
200 // (derived first, max depth: promoted custom plugin = 2)
201 for (int iteration = 0; iteration < 2; iteration++) {
204 return;
205 }
206 // Oops, there are classes left whose base class could not be found.
207 // Default them to QWidget with warnings.
208 const QString fallBackBaseClass = u"QWidget"_s;
212 qDebug() << "** WARNING The base class " << base_class << " of the custom widget class " << customClassName
213 << " could not be found. Defaulting to " << fallBackBaseClass << '.';
215 }
216 // One more pass.
218}
219
220// ------------ FormBuilderClipboard
221
226
228{
229 return m_widgets.isEmpty() && m_actions.isEmpty();
230}
231}
232
233QT_END_NAMESPACE
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.