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// Qt-Security score:significant reason:default
4
8#include <qdesigner_utils_p.h>
9
10#include <QtDesigner/private/properties_p.h>
11#include <QtDesigner/private/ui4_p.h>
12
13#include <QtDesigner/abstractformeditor.h>
14#include <QtDesigner/abstractlanguage.h>
15#include <QtDesigner/qextensionmanager.h>
16#include <QtDesigner/extrainfo.h>
17
18#include <QtUiPlugin/customwidget.h>
19
20#include <QtWidgets/qwidget.h>
21
22#include <QtGui/qaction.h>
23#include <QtGui/qicon.h>
24
25#include <QtCore/qdebug.h>
26#include <QtCore/qcoreapplication.h>
27
29
30using namespace Qt::StringLiterals;
31
32namespace qdesigner_internal {
33
35
42
44
49
54
64
74
79
84
89
90// Custom widgets handling helpers
91
92// Add unique fake slots and signals to lists
94{
95 if (!domSlots)
96 return false;
97
98 bool rc = false;
100 for (const QString &fakeSlot : elementSlots)
101 if (fakeSlots.indexOf(fakeSlot) == -1) {
103 rc = true;
104 }
105
107 for (const QString &fakeSignal : elementSignals)
108 if (fakeSignals.indexOf(fakeSignal) == -1) {
110 rc = true;
111 }
112 return rc;
113}
114
116{
118 if (!domSlots)
119 return;
120
121 // Merge in new slots, signals
127 }
128}
129
130// Perform one iteration of adding the custom widgets to the database,
131// looking up the base class and inheriting its data.
132// Remove the succeeded custom widgets from the list.
133// Classes whose base class could not be found are left in the list.
134
137{
139 for (qsizetype i = 0; i < custom_widget_list.size(); ) {
140 bool classInserted = false;
148 if (header->hasAttributeLocation() && header->attributeLocation() == "global"_L1)
150 }
152 // Append a new item
153 if (base_class.isEmpty()) {
155 item->setPromoted(false);
156 item->setGroup(QCoreApplication::translate("Designer", "Custom Widgets"));
159 item->setCustom(true);
161 db->append(item);
163 classInserted = true;
164 } else {
165 // Create a new entry cloned from base class. Note that this will ignore existing
166 // classes, eg, plugin custom widgets.
168 appendDerived(db, customClassName, QCoreApplication::translate("Designer", "Promoted Widgets"),
171 true,true);
172 // Ok, base class found.
173 if (item) {
174 // Hack to accommodate for old UI-files in which "container" is not set properly:
175 // Apply "container" from DOM only if true (else, eg classes from QFrame might not accept
176 // dropping child widgets on them as container=false). This also allows for
177 // QWidget-derived stacked pages.
178 if (domIsContainer)
180
183 classInserted = true;
184 }
185 }
186 // Skip failed item.
187 if (!classInserted)
188 i++;
189 }
190
191}
192
195{
196 if (dom_custom_widgets == nullptr)
197 return;
199 // Attempt to insert each item derived from its base class.
200 // This should at most require two iterations in the event that the classes are out of order
201 // (derived first, max depth: promoted custom plugin = 2)
202 for (int iteration = 0; iteration < 2; iteration++) {
205 return;
206 }
207 // Oops, there are classes left whose base class could not be found.
208 // Default them to QWidget with warnings.
209 const QString fallBackBaseClass = u"QWidget"_s;
213 qDebug() << "** WARNING The base class " << base_class << " of the custom widget class " << customClassName
214 << " could not be found. Defaulting to " << fallBackBaseClass << '.';
216 }
217 // One more pass.
219}
220
221// ------------ FormBuilderClipboard
222
227
229{
230 return m_widgets.isEmpty() && m_actions.isEmpty();
231}
232}
233
234QT_END_NAMESPACE
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.