21#include <QtDesigner/abstractformeditor.h>
22#include <QtDesigner/abstractintegration.h>
23#include <QtDesigner/private/ui4_p.h>
24#include <QtDesigner/private/formbuilderextra_p.h>
25#include <QtDesigner/private/resourcebuilder_p.h>
26#include <QtDesigner/private/textbuilder_p.h>
27#include <qdesigner_widgetitem_p.h>
30#include <widgetdatabase_p.h>
31#include <metadatabase_p.h>
33#include <layoutinfo_p.h>
34#include <spacer_widget_p.h>
35#include <pluginmanager_p.h>
36#include <widgetfactory_p.h>
37#include <abstractlanguage.h>
38#include <abstractintrospection_p.h>
40#include <qlayout_widget_p.h>
41#include <qdesigner_utils_p.h>
42#include <QtDesigner/private/ui4_p.h>
45#include <QtDesigner/propertysheet.h>
46#include <QtDesigner/abstractformeditor.h>
47#include <QtDesigner/extrainfo.h>
48#include <QtDesigner/abstractformwindowtool.h>
49#include <QtDesigner/qextensionmanager.h>
50#include <QtDesigner/container.h>
51#include <abstractdialoggui_p.h>
53#include <QtWidgets/qmenu.h>
54#include <QtWidgets/qmessagebox.h>
55#include <QtWidgets/qlayout.h>
56#include <QtWidgets/qformlayout.h>
57#include <QtWidgets/qtabwidget.h>
58#include <QtWidgets/qtoolbox.h>
59#include <QtWidgets/qstackedwidget.h>
60#include <QtWidgets/qtoolbar.h>
61#include <QtWidgets/qtabbar.h>
62#include <QtWidgets/qbuttongroup.h>
63#include <QtWidgets/qapplication.h>
64#include <QtWidgets/qmainwindow.h>
65#include <QtWidgets/qsplitter.h>
66#include <QtWidgets/qmdiarea.h>
67#include <QtWidgets/qmenubar.h>
68#include <QtWidgets/qfiledialog.h>
69#include <QtWidgets/qheaderview.h>
70#include <QtWidgets/qwizard.h>
71#include <private/qlayoutengine_p.h>
73#include <QtGui/qaction.h>
74#include <QtGui/qactiongroup.h>
76#include <QtCore/qbuffer.h>
77#include <QtCore/qdir.h>
78#include <QtCore/qmetaobject.h>
79#include <QtCore/qdebug.h>
80#include <QtCore/qversionnumber.h>
81#include <QtCore/qxmlstream.h>
86Q_DECLARE_METATYPE(QWidgetList)
90using namespace Qt::StringLiterals;
92using QFBE = QFormBuilderExtra;
95 using DomPropertyList = QList<DomProperty *>;
101#define OLD_RESOURCE_FORMAT
107 if (qtVersion >= QVersionNumber{6, 6, 2})
110 switch (qtVersion.majorVersion()) {
112 switch (qtVersion.minorVersion()) {
114 if (qtVersion.microVersion() >= 4)
118 if (qtVersion.microVersion() >= 13)
125 if (qtVersion >= QVersionNumber{5, 15, 18})
138 void setPixmapCache(DesignerPixmapCache *pixmapCache) { m_pixmapCache = pixmapCache; }
139 void setIconCache(DesignerIconCache *iconCache) { m_iconCache = iconCache; }
147 QVariant
loadResource(
const QDir &workingDirectory,
const DomProperty *icon)
const override;
151 DomProperty *
saveResource(
const QDir &workingDirectory,
const QVariant &value)
const override;
156 QDesignerFormEditorInterface *m_core;
157 DesignerPixmapCache *m_pixmapCache;
158 DesignerIconCache *m_iconCache;
161 mutable QMap<QString,
bool> m_usedQrcFiles;
162 mutable QMap<QString,
bool> m_loadedQrcFiles;
167 m_pixmapCache(pixmapCache),
168 m_iconCache(iconCache),
174static inline void setIconPixmap(QIcon::Mode m, QIcon::State s,
const QDir &workingDirectory,
175 QString path, PropertySheetIconValue &icon,
179 path = QFileInfo(workingDirectory, path).absoluteFilePath();
180 icon.setPixmap(m, s, PropertySheetPixmapValue(path));
185 switch (property->kind()) {
186 case DomProperty::Pixmap: {
188 DomResourcePixmap *dp = property->elementPixmap();
189 if (!dp->text().isEmpty()) {
191 pixmap.setPath(dp->text());
193 pixmap.setPath(QFileInfo(workingDirectory, dp->text()).absoluteFilePath());
196 if (dp->hasAttributeResource())
197 m_loadedQrcFiles.insert(QFileInfo(workingDirectory, dp->attributeResource()).absoluteFilePath(),
false);
200 return QVariant::fromValue(pixmap);
203 case DomProperty::IconSet: {
205 DomResourceIcon *di = property->elementIconSet();
206 const bool hasTheme = di->hasAttributeTheme();
208 const QString &theme = di->attributeTheme();
209 const qsizetype themeEnum = theme.startsWith(
"QIcon::"_L1)
210 ? QDesignerResourceBuilder::themeIconIndex(theme) : -1;
212 icon.setThemeEnum(themeEnum);
214 icon.setTheme(theme);
216 if (
const int flags = iconStateFlags(di)) {
217 if (flags & NormalOff)
218 setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->elementNormalOff()->text(), icon, m_lang);
219 if (flags & NormalOn)
220 setIconPixmap(QIcon::Normal, QIcon::On, workingDirectory, di->elementNormalOn()->text(), icon, m_lang);
221 if (flags & DisabledOff)
222 setIconPixmap(QIcon::Disabled, QIcon::Off, workingDirectory, di->elementDisabledOff()->text(), icon, m_lang);
223 if (flags & DisabledOn)
224 setIconPixmap(QIcon::Disabled, QIcon::On, workingDirectory, di->elementDisabledOn()->text(), icon, m_lang);
225 if (flags & ActiveOff)
226 setIconPixmap(QIcon::Active, QIcon::Off, workingDirectory, di->elementActiveOff()->text(), icon, m_lang);
227 if (flags & ActiveOn)
228 setIconPixmap(QIcon::Active, QIcon::On, workingDirectory, di->elementActiveOn()->text(), icon, m_lang);
229 if (flags & SelectedOff)
230 setIconPixmap(QIcon::Selected, QIcon::Off, workingDirectory, di->elementSelectedOff()->text(), icon, m_lang);
231 if (flags & SelectedOn)
232 setIconPixmap(QIcon::Selected, QIcon::On, workingDirectory, di->elementSelectedOn()->text(), icon, m_lang);
233 }
else if (!hasTheme) {
235 setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->text(), icon, m_lang);
236 if (di->hasAttributeResource())
237 m_loadedQrcFiles.insert(QFileInfo(workingDirectory, di->attributeResource()).absoluteFilePath(),
false);
240 return QVariant::fromValue(icon);
262 DomProperty *p =
new DomProperty;
264 const PropertySheetPixmapValue pix = qvariant_cast<PropertySheetPixmapValue>(value);
265 DomResourcePixmap *rp =
new DomResourcePixmap;
266 const QString pixPath = pix.path();
267 switch (pix.pixmapSource(m_core)) {
268 case PropertySheetPixmapValue::LanguageResourcePixmap:
269 rp->setText(pixPath);
271 case PropertySheetPixmapValue::ResourcePixmap: {
272 rp->setText(pixPath);
273 const QString qrcFile = m_core->resourceModel()->qrcPath(pixPath);
274 if (!qrcFile.isEmpty()) {
275 m_usedQrcFiles.insert(qrcFile,
false);
277 rp->setAttributeResource(workingDirectory.relativeFilePath(qrcFile));
282 case PropertySheetPixmapValue::FilePixmap:
283 rp->setText(m_saveRelative ? workingDirectory.relativeFilePath(pixPath) : pixPath);
286 p->setElementPixmap(rp);
290 const PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(value);
291 const auto &pixmaps = icon.paths();
292 const int themeEnum = icon.themeEnum();
293 const QString theme = themeEnum != -1
294 ? QDesignerResourceBuilder::fullyQualifiedThemeIconName(themeEnum) : icon.theme();
295 if (!pixmaps.isEmpty() || !theme.isEmpty()) {
296 DomResourceIcon *ri =
new DomResourceIcon;
297 if (!theme.isEmpty())
298 ri->setAttributeTheme(theme);
299 for (
auto itPix = pixmaps.cbegin(), end = pixmaps.cend(); itPix != end; ++itPix) {
300 const QIcon::Mode mode = itPix.key().first;
301 const QIcon::State state = itPix.key().second;
302 DomResourcePixmap *rp =
new DomResourcePixmap;
303 const PropertySheetPixmapValue &pix = itPix.value();
304 const PropertySheetPixmapValue::PixmapSource ps = pix.pixmapSource(m_core);
305 const QString pixPath = pix.path();
306 rp->setText(ps == PropertySheetPixmapValue::FilePixmap && m_saveRelative ? workingDirectory.relativeFilePath(pixPath) : pixPath);
307 if (state == QIcon::Off) {
310 ri->setElementNormalOff(rp);
312 ri->setText(rp->text());
314 if (ps == PropertySheetPixmapValue::ResourcePixmap) {
317 const QString qrcFile = m_core->resourceModel()->qrcPath(ri->text());
318 if (!qrcFile.isEmpty()) {
319 m_usedQrcFiles.insert(qrcFile,
false);
321 ri->setAttributeResource(workingDirectory.relativeFilePath(qrcFile));
326 case QIcon::Disabled: ri->setElementDisabledOff(rp);
break;
327 case QIcon::Active: ri->setElementActiveOff(rp);
break;
328 case QIcon::Selected: ri->setElementSelectedOff(rp);
break;
332 case QIcon::Normal: ri->setElementNormalOn(rp);
break;
333 case QIcon::Disabled: ri->setElementDisabledOn(rp);
break;
334 case QIcon::Active: ri->setElementActiveOn(rp);
break;
335 case QIcon::Selected: ri->setElementSelectedOn(rp);
break;
339 p->setElementIconSet(ri);
354template <
class DomElement>
357 const QString propertyComment = data.disambiguation();
358 if (!propertyComment.isEmpty())
359 e->setAttributeComment(propertyComment);
360 const QString propertyExtracomment = data.comment();
361 if (!propertyExtracomment.isEmpty())
362 e->setAttributeExtraComment(propertyExtracomment);
363 const QString &id = data.id();
365 e->setAttributeId(id);
366 if (!data.translatable())
367 e->setAttributeNotr(u"true"_s);
370template <
class DomElement>
373 if (e->hasAttributeComment())
374 data->setDisambiguation(e->attributeComment());
375 if (e->hasAttributeExtraComment())
376 data->setComment(e->attributeExtraComment());
377 if (e->hasAttributeId())
378 data->setId(e->attributeId());
379 if (e->hasAttributeNotr()) {
380 const QString notr = e->attributeNotr();
381 const bool translatable = !(notr ==
"true"_L1 || notr ==
"yes"_L1);
382 data->setTranslatable(translatable);
400 if (
const DomString *domString = text->elementString()) {
402 translationParametersFromDom(domString, &stringValue);
403 return QVariant::fromValue(stringValue);
405 return QVariant(QString());
410 if (value.canConvert<PropertySheetStringValue>())
411 return QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(value).value());
417 DomString *domString =
new DomString();
418 domString->setText(value);
419 DomProperty *property =
new DomProperty();
420 property->setElementString(domString);
425 const PropertySheetTranslatableData &translatableData)
427 DomString *domString =
new DomString();
428 domString->setText(value);
429 translationParametersToDom(translatableData, domString);
430 DomProperty *property =
new DomProperty();
431 property->setElementString(domString);
438 const PropertySheetStringValue str = qvariant_cast<PropertySheetStringValue>(value);
439 return stringToDomProperty(str.value(), str);
441 if (value.canConvert<QString>())
442 return stringToDomProperty(value.toString());
448 m_formWindow(formWindow),
454 QDesignerFormEditorInterface *core = m_formWindow
->core();
455 if (
const QDesignerLanguageExtension *le = qt_extension<QDesignerLanguageExtension*>(core->extensionManager(), core))
456 d->m_language = le->name();
458 setWorkingDirectory(formWindow->absoluteDir());
459 setResourceBuilder(m_resourceBuilder);
463 const QString designerWidget = u"QDesignerWidget"_s;
464 const QString layoutWidget = u"QLayoutWidget"_s;
465 const QString widget = u"QWidget"_s;
466 m_internal_to_qt.insert(layoutWidget, widget);
467 m_internal_to_qt.insert(designerWidget, widget);
468 m_internal_to_qt.insert(u"QDesignerDialog"_s, u"QDialog"_s);
469 m_internal_to_qt.insert(u"QDesignerMenuBar"_s, u"QMenuBar"_s);
470 m_internal_to_qt.insert(u"QDesignerMenu"_s, u"QMenu"_s);
471 m_internal_to_qt.insert(u"QDesignerDockWidget"_s, u"QDockWidget"_s);
474 for (
auto it = m_internal_to_qt.cbegin(), cend = m_internal_to_qt.cend(); it != cend; ++it ) {
475 if (it.value() != designerWidget && it.value() != layoutWidget)
476 m_qt_to_internal.insert(it.value(), it.key());
485 return d->readUi(dev);
490 return QApplication::translate(
"Designer",
"Qt Widgets Designer");
498 d->m_fullyQualifiedEnums = supportsQualifiedEnums(m_formWindow->core()->integration()->qtVersion());
499 QAbstractFormBuilder::save(dev, widget);
504 QAbstractFormBuilder::saveDom(ui, widget);
506 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget);
507 Q_ASSERT(sheet !=
nullptr);
509 const QVariant classVar = sheet->property(sheet->indexOf(u"objectName"_s));
511 if (classVar.canConvert<QString>())
512 classStr = classVar.toString();
515 ui->setElementClass(classStr);
517 for (
int index = 0; index < m_formWindow
->toolCount(); ++index) {
518 QDesignerFormWindowToolInterface *tool = m_formWindow->tool(index);
519 Q_ASSERT(tool !=
nullptr);
520 tool->saveToDom(ui, widget);
523 const QString author = m_formWindow->author();
524 if (!author.isEmpty()) {
525 ui->setElementAuthor(author);
528 const QString comment = m_formWindow->comment();
529 if (!comment.isEmpty()) {
530 ui->setElementComment(comment);
533 const QString exportMacro = m_formWindow->exportMacro();
534 if (!exportMacro.isEmpty()) {
535 ui->setElementExportMacro(exportMacro);
538 if (m_formWindow->useIdBasedTranslations())
539 ui->setAttributeIdbasedtr(
true);
540 if (!m_formWindow->connectSlotsByName())
541 ui->setAttributeConnectslotsbyname(
false);
543 const QVariantMap designerFormData = m_formWindow->formData();
544 if (!designerFormData.isEmpty()) {
545 DomPropertyList domPropertyList;
546 for (
auto it = designerFormData.cbegin(), cend = designerFormData.cend(); it != cend; ++it) {
547 if (DomProperty *prop = variantToDomProperty(
this, widget->metaObject(), it.key(), it.value()))
548 domPropertyList += prop;
550 if (!domPropertyList.isEmpty()) {
551 DomDesignerData* domDesignerFormData =
new DomDesignerData;
552 domDesignerFormData->setElementProperty(domPropertyList);
553 ui->setElementDesignerdata(domDesignerFormData);
557 if (!m_formWindow->includeHints().isEmpty()) {
558 const QString local = u"local"_s;
559 const QString global = u"global"_s;
560 QList<DomInclude *> ui_includes;
561 const QStringList &includeHints = m_formWindow->includeHints();
562 ui_includes.reserve(includeHints.size());
563 for (QString includeHint : includeHints) {
564 if (includeHint.isEmpty())
566 DomInclude *incl =
new DomInclude;
567 const QString location = includeHint.at(0) == u'<' ? global : local;
568 includeHint.remove(u'"');
569 includeHint.remove(u'<');
570 includeHint.remove(u'>');
571 incl->setAttributeLocation(location);
572 incl->setText(includeHint);
573 ui_includes.append(incl);
576 DomIncludes *includes =
new DomIncludes;
577 includes->setElementInclude(ui_includes);
578 ui->setElementIncludes(includes);
581 int defaultMargin = INT_MIN, defaultSpacing = INT_MIN;
584 if (defaultMargin != INT_MIN || defaultSpacing != INT_MIN) {
585 DomLayoutDefault *def =
new DomLayoutDefault;
586 if (defaultMargin != INT_MIN)
587 def->setAttributeMargin(defaultMargin);
588 if (defaultSpacing != INT_MIN)
589 def->setAttributeSpacing(defaultSpacing);
590 ui->setElementLayoutDefault(def);
593 QString marginFunction, spacingFunction;
594 m_formWindow->layoutFunction(&marginFunction, &spacingFunction);
595 if (!marginFunction.isEmpty() || !spacingFunction.isEmpty()) {
596 DomLayoutFunction *def =
new DomLayoutFunction;
598 if (!marginFunction.isEmpty())
599 def->setAttributeMargin(marginFunction);
600 if (!spacingFunction.isEmpty())
601 def->setAttributeSpacing(spacingFunction);
602 ui->setElementLayoutFunction(def);
605 QString pixFunction = m_formWindow->pixmapFunction();
606 if (!pixFunction.isEmpty()) {
607 ui->setElementPixmapFunction(pixFunction);
610 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core()))
611 extra->saveUiExtraInfo(ui);
613 if (MetaDataBase *metaDataBase = qobject_cast<MetaDataBase *>(core()->metaDataBase())) {
614 const MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(m_formWindow->mainContainer());
615 const QStringList fakeSlots = item->fakeSlots();
616 const QStringList fakeSignals =item->fakeSignals();
617 if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) {
618 DomSlots *domSlots =
new DomSlots();
619 domSlots->setElementSlot(fakeSlots);
620 domSlots->setElementSignal(fakeSignals);
621 ui->setElementSlots(domSlots);
628 QScopedPointer<DomUI> ui(readUi(dev));
629 return ui.isNull() ?
nullptr : loadUi(ui.data(), parentWidget);
634 QWidget *widget = create(ui, parentWidget);
637 widget->setProperty(
"_q_classname", widget->objectName());
638 else if (d->m_errorString.isEmpty())
639 d->m_errorString = QFormBuilderExtra::msgInvalidUiFile();
657 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core())) {
658 if (!extra->loadUiExtraInfo(ui)) {
659 const QString errorMessage = QApplication::translate(
"Designer",
"This file cannot be read because the extra info extension failed to load.");
660 core()->dialogGui()->message(parentWidget->window(), QDesignerDialogGuiInterface::FormLoadFailureMessage,
661 QMessageBox::Warning, messageBoxTitle(), errorMessage, QMessageBox::Ok);
666 qdesigner_internal::WidgetFactory *factory = qobject_cast<qdesigner_internal::WidgetFactory*>(core()->widgetFactory());
667 Q_ASSERT(factory !=
nullptr);
669 QDesignerFormWindowInterface *previousFormWindow = factory->currentFormWindow(m_formWindow);
671 m_isMainWidget =
true;
673 QWidget *mainWidget = QAbstractFormBuilder::create(ui, parentWidget);
676 m_formWindow->setUseIdBasedTranslations(ui->attributeIdbasedtr());
678 const bool connectSlotsByName = !ui->hasAttributeConnectslotsbyname() || ui->attributeConnectslotsbyname();
679 m_formWindow->setConnectSlotsByName(connectSlotsByName);
682 if (mainWidget && m_formWindow) {
683 m_formWindow->setAuthor(ui->elementAuthor());
684 m_formWindow->setComment(ui->elementComment());
685 m_formWindow->setExportMacro(ui->elementExportMacro());
688 QVariantMap designerFormData;
689 if (ui->hasElementDesignerdata()) {
690 const DomPropertyList domPropertyList = ui->elementDesignerdata()->elementProperty();
691 for (
auto *prop : domPropertyList) {
692 const QVariant vprop = domPropertyToVariant(
this, mainWidget->metaObject(), prop);
693 if (vprop.metaType().id() != QMetaType::UnknownType)
694 designerFormData.insert(prop->attributeName(), vprop);
697 m_formWindow->setFormData(designerFormData);
699 m_formWindow->setPixmapFunction(ui->elementPixmapFunction());
701 if (DomLayoutDefault *def = ui->elementLayoutDefault()) {
702 m_formWindow->setLayoutDefault(def->attributeMargin(), def->attributeSpacing());
705 if (DomLayoutFunction *fun = ui->elementLayoutFunction()) {
706 m_formWindow->setLayoutFunction(fun->attributeMargin(), fun->attributeSpacing());
709 if (DomIncludes *includes = ui->elementIncludes()) {
710 const auto global =
"global"_L1;
711 QStringList includeHints;
712 const auto &elementInclude = includes->elementInclude();
713 for (DomInclude *incl : elementInclude) {
714 QString text = incl->text();
719 if (incl->hasAttributeLocation() && incl->attributeLocation() == global ) {
727 includeHints.append(text);
730 m_formWindow->setIncludeHints(includeHints);
735 auto *mdb = core()->metaDataBase();
736 for (
auto *child : mainWidget->children()) {
737 if (QButtonGroup *bg = qobject_cast<QButtonGroup*>(child))
741 for (
int index = 0; index < m_formWindow
->toolCount(); ++index) {
742 QDesignerFormWindowToolInterface *tool = m_formWindow->tool(index);
743 Q_ASSERT(tool !=
nullptr);
744 tool->loadFromDom(ui, mainWidget);
748 factory->currentFormWindow(previousFormWindow);
750 if (
const DomSlots *domSlots = ui->elementSlots()) {
751 if (MetaDataBase *metaDataBase = qobject_cast<MetaDataBase *>(core()->metaDataBase())) {
752 QStringList fakeSlots;
753 QStringList fakeSignals;
754 if (addFakeMethods(domSlots, fakeSlots, fakeSignals)) {
755 MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(mainWidget);
756 item->setFakeSlots(fakeSlots);
757 item->setFakeSignals(fakeSignals);
763 bool hasExplicitGeometry =
false;
764 const auto &properties = ui->elementWidget()->elementProperty();
765 if (!properties.isEmpty()) {
766 for (
const DomProperty *p : properties) {
767 if (p->attributeName() ==
"geometry"_L1) {
768 hasExplicitGeometry =
true;
773 if (hasExplicitGeometry) {
776 const QSize size = mainWidget->size();
777 const QSize minSize = size.expandedTo(qSmartMinSize(mainWidget));
779 mainWidget->resize(minSize);
783 mainWidget->adjustSize();
790 const QDesignerWidgetDataBaseInterface *wdb = core()->widgetDataBase();
791 const int wdbIndex = wdb->indexOfObject(mainWidget);
792 if (wdbIndex != -1) {
793 QDesignerWidgetDataBaseItemInterface *item = wdb->item(wdbIndex);
795 if (item->isPromoted() && !item->isContainer()) {
796 item->setContainer(
true);
797 qWarning(
"** WARNING The form's main container is an unknown custom widget '%s'."
798 " Defaulting to a promoted instance of '%s', assuming container.",
799 item->name().toUtf8().constData(), item->extends().toUtf8().constData());
808 const QString className = ui_widget->attributeClass();
809 if (!m_isMainWidget && className ==
"QWidget"_L1
810 && !ui_widget->elementLayout().isEmpty()
811 && !ui_widget->hasAttributeNative()) {
816 if (container ==
nullptr) {
818 ui_widget->setAttributeClass(u"QLayoutWidget"_s);
823 const auto &actionRefs = ui_widget->elementAddAction();
824 ui_widget->setElementAddAction(QList<DomActionRef *>());
826 QWidget *w = QAbstractFormBuilder::create(ui_widget, parentWidget);
829 ui_widget->setElementAddAction(actionRefs);
835 QDesignerMenu *menu = qobject_cast<QDesignerMenu*>(w);
836 QDesignerMenuBar *menuBar = qobject_cast<QDesignerMenuBar*>(w);
841 for (DomActionRef *ui_action_ref : actionRefs) {
842 const QString name = ui_action_ref->attributeName();
843 if (name ==
"separator"_L1) {
844 QAction *sep =
new QAction(w);
845 sep->setSeparator(
true);
848 }
else if (QAction *a = d->m_actions.value(name)) {
850 }
else if (QActionGroup *g = d->m_actionGroups.value(name)) {
851 w->addActions(g->actions());
852 }
else if (QMenu *menu = w->findChild<QMenu*>(name)) {
853 w->addAction(menu->menuAction());
854 addMenuAction(menu->menuAction());
859 menu->adjustSpecialActions();
861 menuBar->adjustSpecialActions();
863 ui_widget->setAttributeClass(className);
864 applyExtensionDataFromDOM(
this, core(), ui_widget, w);
871 QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
873 if (QGridLayout *gridLayout = qobject_cast<QGridLayout*>(l)) {
874 QLayoutSupport::createEmptyCells(gridLayout);
876 if (QFormLayout *formLayout = qobject_cast<QFormLayout*>(l))
877 QLayoutSupport::createEmptyCells(formLayout);
887 if (ui_layoutItem->kind() == DomLayoutItem::Spacer) {
888 const DomSpacer *domSpacer = ui_layoutItem->elementSpacer();
889 Spacer *spacer =
static_cast<Spacer*>(core()->widgetFactory()->createWidget(u"Spacer"_s, parentWidget));
890 if (domSpacer->hasAttributeName())
891 changeObjectName(spacer, domSpacer->attributeName());
892 core()->metaDataBase()->add(spacer);
894 spacer->setInteractiveMode(
false);
895 applyProperties(spacer, ui_layoutItem->elementSpacer()->elementProperty());
896 spacer->setInteractiveMode(
true);
899 m_formWindow->manageWidget(spacer);
900 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), spacer))
901 sheet->setChanged(sheet->indexOf(u"orientation"_s),
true);
904 return new QWidgetItem(spacer);
906 if (ui_layoutItem->kind() == DomLayoutItem::Layout && parentWidget) {
907 DomLayout *ui_layout = ui_layoutItem->elementLayout();
908 QLayoutWidget *layoutWidget =
new QLayoutWidget(m_formWindow, parentWidget);
909 core()->metaDataBase()->add(layoutWidget);
912 (
void) create(ui_layout,
nullptr, layoutWidget);
913 return new QWidgetItem(layoutWidget);
915 return QAbstractFormBuilder::create(ui_layoutItem, layout, parentWidget);
920 m_formWindow->unify(o, objName,
true);
921 o->setObjectName(objName);
926
929 const QDesignerPropertySheetExtension* sheet,
int index,
933 case DomProperty::Set: {
934 const QVariant sheetValue = sheet->property(index);
935 if (sheetValue.canConvert<PropertySheetFlagValue>()) {
936 const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(sheetValue);
938 v = f.metaFlags.parseFlags(p->elementSet(), &ok);
940 designerWarning(f.metaFlags.messageParseFailed(p->elementSet()));
945 case DomProperty::Enum: {
946 const QVariant sheetValue = sheet->property(index);
947 if (sheetValue.canConvert<PropertySheetEnumValue>()) {
948 const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(sheetValue);
950 v = e.metaEnum.parseEnum(p->elementEnum(), &ok);
952 designerWarning(e.metaEnum.messageParseFailed(p->elementEnum()));
966 const QString &propertyName = p->attributeName();
968 case DomProperty::Set:
969 if (propertyName == u"features" && o->inherits(
"QDockWidget")
970 && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") {
974 case DomProperty::Enum:
975 if (propertyName == u"sizeAdjustPolicy" && o->inherits(
"QComboBox")
976 && p->elementEnum() == u"QComboBox::AdjustToMinimumContentsLength") {
988 if (properties.isEmpty())
991 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o);
998 for (DomProperty *p : properties) {
999 if (isDeprecatedQt5Property(o, p))
1001 QString propertyName = p->attributeName();
1002 if (propertyName ==
"numDigits"_L1 && o->inherits(
"QLCDNumber"))
1003 propertyName = u"digitCount"_s;
1004 const int index = sheet->indexOf(propertyName);
1006 if (!readDomEnumerationValue(p, sheet, index, v))
1007 v = toVariant(o->metaObject(), p);
1009 switch (p->kind()) {
1010 case DomProperty::String:
1011 if (index != -1 && sheet->property(index).userType() == qMetaTypeId<PropertySheetKeySequenceValue>()) {
1012 const DomString *key = p->elementString();
1013 PropertySheetKeySequenceValue keyVal(QKeySequence(key->text()));
1014 translationParametersFromDom(key, &keyVal);
1015 v = QVariant::fromValue(keyVal);
1017 const DomString *str = p->elementString();
1018 PropertySheetStringValue strVal(v.toString());
1019 translationParametersFromDom(str, &strVal);
1020 v = QVariant::fromValue(strVal);
1023 case DomProperty::StringList: {
1024 const DomStringList *list = p->elementStringList();
1025 PropertySheetStringListValue listValue(list->elementString());
1026 translationParametersFromDom(list, &listValue);
1027 v = QVariant::fromValue(listValue);
1034 d->applyPropertyInternally(o, propertyName, v);
1036 sheet->setProperty(index, v);
1037 sheet->setChanged(index,
true);
1038 }
else if (dynamicPropertiesAllowed) {
1039 QVariant defaultValue = QVariant(v.metaType());
1040 bool isDefault = (v == defaultValue);
1041 if (v.canConvert<PropertySheetIconValue>()) {
1042 defaultValue = QVariant(QMetaType(QMetaType::QIcon));
1043 isDefault = (qvariant_cast<PropertySheetIconValue>(v) == PropertySheetIconValue());
1044 }
else if (v.canConvert<PropertySheetPixmapValue>()) {
1045 defaultValue = QVariant(QMetaType(QMetaType::QPixmap));
1046 isDefault = (qvariant_cast<PropertySheetPixmapValue>(v) == PropertySheetPixmapValue());
1047 }
else if (v.canConvert<PropertySheetStringValue>()) {
1048 defaultValue = QVariant(QMetaType(QMetaType::QString));
1049 isDefault = (qvariant_cast<PropertySheetStringValue>(v) == PropertySheetStringValue());
1050 }
else if (v.canConvert<PropertySheetStringListValue>()) {
1051 defaultValue = QVariant(QMetaType(QMetaType::QStringList));
1052 isDefault = (qvariant_cast<PropertySheetStringListValue>(v) == PropertySheetStringListValue());
1053 }
else if (v.canConvert<PropertySheetKeySequenceValue>()) {
1054 defaultValue = QVariant(QMetaType(QMetaType::QKeySequence));
1055 isDefault = (qvariant_cast<PropertySheetKeySequenceValue>(v) == PropertySheetKeySequenceValue());
1057 if (defaultValue.metaType().id() != QMetaType::User) {
1058 const int idx = dynamicSheet->addDynamicProperty(p->attributeName(), defaultValue);
1060 sheet->setProperty(idx, v);
1061 sheet->setChanged(idx, !isDefault);
1066 if (propertyName ==
"objectName"_L1)
1067 changeObjectName(o, o->objectName());
1073 QString name = _name;
1075 m_isMainWidget =
false;
1077 QWidget *w = core()->widgetFactory()->createWidget(widgetName, parentWidget);
1081 if (name.isEmpty()) {
1082 QDesignerWidgetDataBaseInterface *db = core()->widgetDataBase();
1083 if (QDesignerWidgetDataBaseItemInterface *item = db->item(db->indexOfObject(w)))
1084 name = qtify(item->name());
1087 changeObjectName(w, name);
1090 if (!qobject_cast<QMenu*>(w) && (!parentWidget || !container)) {
1093 QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(
"_q_widgetOrder"));
1095 parentWidget->setProperty(
"_q_widgetOrder", QVariant::fromValue(list));
1096 QWidgetList zOrder = qvariant_cast<QWidgetList>(parentWidget->property(
"_q_zOrder"));
1098 parentWidget->setProperty(
"_q_zOrder", QVariant::fromValue(zOrder));
1101 core()->metaDataBase()->add(w);
1104 w->setWindowFlags(w->windowFlags() & ~Qt::Window);
1106 w->setWindowModality(Qt::NonModal);
1111QLayout *
QDesignerResource::createLayout(
const QString &layoutName, QObject *parent,
const QString &name)
1113 QWidget *layoutBase =
nullptr;
1114 QLayout *layout = qobject_cast<QLayout*>(parent);
1116 if (parent->isWidgetType())
1117 layoutBase =
static_cast<QWidget*>(parent);
1119 Q_ASSERT( layout !=
nullptr );
1120 layoutBase = layout->parentWidget();
1123 LayoutInfo::Type layoutType = LayoutInfo::layoutType(layoutName);
1124 if (layoutType == LayoutInfo::NoLayout) {
1125 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"The layout type '%1' is not supported, defaulting to grid.").arg(layoutName));
1126 layoutType = LayoutInfo::Grid;
1128 QLayout *lay = core()->widgetFactory()->createLayout(layoutBase, layout, layoutType);
1130 changeObjectName(lay, name);
1138 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(widget);
1142 if (qobject_cast<Spacer*>(widget) && !m_copyWidget)
1145 const QDesignerWidgetDataBaseInterface *wdb = core()->widgetDataBase();
1146 QDesignerWidgetDataBaseItemInterface *widgetInfo =
nullptr;
1147 const int widgetInfoIndex = wdb->indexOfObject(widget,
false);
1148 if (widgetInfoIndex != -1) {
1149 widgetInfo = wdb->item(widgetInfoIndex);
1151 QDesignerWidgetDataBaseItemInterface *customInfo = widgetInfo;
1152 while (customInfo && customInfo->isCustom()) {
1153 m_usedCustomWidgets.insert(customInfo,
true);
1154 const QString extends = customInfo->extends();
1155 if (extends == customInfo->name())
1157 const int extendsIndex = wdb->indexOfClassName(customInfo->extends());
1158 customInfo = extendsIndex != -1 ? wdb->item(extendsIndex) :
nullptr;
1162 DomWidget *w =
nullptr;
1164 if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(widget))
1166 else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(widget))
1168 else if (QToolBox *toolBox = qobject_cast<QToolBox*>(widget))
1170 else if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget))
1172 else if (QDesignerDockWidget *dockWidget = qobject_cast<QDesignerDockWidget*>(widget))
1176 else if (QWizardPage *wizardPage = qobject_cast<QWizardPage*>(widget))
1179 w = QAbstractFormBuilder::createDom(widget, ui_parentWidget, recursive);
1181 Q_ASSERT( w !=
nullptr );
1183 if (!qobject_cast<QLayoutWidget*>(widget) && w->attributeClass() ==
"QWidget"_L1)
1184 w->setAttributeNative(
true);
1186 const QString className = w->attributeClass();
1187 if (m_internal_to_qt.contains(className))
1188 w->setAttributeClass(m_internal_to_qt.value(className));
1190 if (isPromoted( core(), widget)) {
1191 Q_ASSERT(widgetInfo !=
nullptr);
1193 w->setAttributeClass(widgetInfo->name());
1195 const auto &prop_list = w->elementProperty();
1196 for (DomProperty *prop : prop_list) {
1197 if (prop->attributeName() ==
"geometry"_L1) {
1198 if (DomRect *rect = prop->elementRect()) {
1199 rect->setElementX(widget->x());
1200 rect->setElementY(widget->y());
1205 }
else if (widgetInfo !=
nullptr && m_usedCustomWidgets.contains(widgetInfo)) {
1206 if (widgetInfo->name() != w->attributeClass())
1207 w->setAttributeClass(widgetInfo->name());
1209 addExtensionDataToDOM(
this, core(), w, widget);
1215 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(layout);
1217 if (item ==
nullptr) {
1218 layout = layout->findChild<QLayout*>();
1220 item = core()->metaDataBase()->item(layout);
1223 if (item ==
nullptr) {
1228 if (qobject_cast<QSplitter*>(layout->parentWidget()) != 0) {
1233 m_chain.push(layout);
1235 DomLayout *l = QAbstractFormBuilder::createDom(layout, ui_parentLayout, ui_parentWidget);
1236 Q_ASSERT(l !=
nullptr);
1246 DomLayoutItem *ui_item =
nullptr;
1248 if (Spacer *s = qobject_cast<Spacer*>(item->widget())) {
1249 if (!core()->metaDataBase()->item(s))
1252 DomSpacer *spacer =
new DomSpacer();
1253 const QString objectName = s->objectName();
1254 if (!objectName.isEmpty())
1255 spacer->setAttributeName(objectName);
1257 spacer->setElementProperty(computeProperties(item->widget()));
1259 ui_item =
new DomLayoutItem();
1260 ui_item->setElementSpacer(spacer);
1261 d->m_laidout.insert(item->widget(),
true);
1262 }
else if (QLayoutWidget *layoutWidget = qobject_cast<QLayoutWidget*>(item->widget())) {
1264 Q_ASSERT(layoutWidget->layout());
1265 DomLayout *l = createDom(layoutWidget->layout(), ui_layout, ui_parentWidget);
1266 ui_item =
new DomLayoutItem();
1267 ui_item->setElementLayout(l);
1268 d->m_laidout.insert(item->widget(),
true);
1269 }
else if (!item->spacerItem()) {
1270 ui_item = QAbstractFormBuilder::createDom(item, ui_layout, ui_parentWidget);
1279 QSimpleResource::handleDomCustomWidgets(core(), dom_custom_widgets);
1284 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(m_formWindow);
1287 QStringList tabStops;
1288 const QWidgetList &tabOrder = item->tabOrder();
1289 for (QWidget *widget : tabOrder) {
1290 if (m_formWindow->mainContainer()->isAncestorOf(widget))
1291 tabStops.append(widget->objectName());
1294 if (!tabStops.isEmpty()) {
1295 DomTabStops *dom =
new DomTabStops;
1296 dom->setElementTabStop(tabStops);
1305 if (tabStops ==
nullptr || widget ==
nullptr)
1308 QWidgetList tabOrder;
1309 const QStringList &elementTabStop = tabStops->elementTabStop();
1310 for (
const QString &widgetName : elementTabStop) {
1311 if (QWidget *w = widget->findChild<QWidget*>(widgetName)) {
1316 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(m_formWindow);
1318 item->setTabOrder(tabOrder);
1322
1323
1327 return QCoreApplication::translate(
"QDesignerResource",
1328"The container extension of the widget '%1' (%2) returned a widget not managed by Designer '%3' (%4) when queried for page #%5.\n"
1329"Container pages should only be added by specifying them in XML returned by the domXml() method of the custom widget.").
1330 arg(container->objectName(), WidgetFactory::classNameOf(core, container),
1331 page->objectName(), WidgetFactory::classNameOf(core, page)).
1337 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1338 QList<DomWidget *> ui_widget_list;
1340 for (
int i=0; i<container->count(); ++i) {
1341 QWidget *page = container->widget(i);
1344 if (DomWidget *ui_page = createDom(page, ui_widget)) {
1345 ui_widget_list.append(ui_page);
1347 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1351 ui_widget->setElementWidget(ui_widget_list);
1358 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1359 QList<DomWidget *> ui_widget_list;
1361 for (
int i=0; i<container->count(); ++i) {
1362 QWidget *page = container->widget(i);
1364 if (DomWidget *ui_page = createDom(page, ui_widget)) {
1365 ui_widget_list.append(ui_page);
1367 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1372 ui_widget->setElementWidget(ui_widget_list);
1379 DomWidget *ui_widget = QAbstractFormBuilder::createDom(toolBar, ui_parentWidget,
false);
1380 if (
const QMainWindow *mainWindow = qobject_cast<QMainWindow*>(toolBar->parentWidget())) {
1381 const bool toolBarBreak = mainWindow->toolBarBreak(toolBar);
1382 const Qt::ToolBarArea area = mainWindow->toolBarArea(toolBar);
1384 auto attributes = ui_widget->elementAttribute();
1386 DomProperty *attr =
new DomProperty();
1387 attr->setAttributeName(u"toolBarArea"_s);
1388 attr->setElementEnum(QLatin1StringView(toolBarAreaMetaEnum().valueToKey(area)));
1391 attr =
new DomProperty();
1392 attr->setAttributeName(u"toolBarBreak"_s);
1393 attr->setElementBool(toolBarBreak ? u"true"_s : u"false"_s);
1395 ui_widget->setElementAttribute(attributes);
1403 DomWidget *ui_widget = QAbstractFormBuilder::createDom(dockWidget, ui_parentWidget,
true);
1404 if (QMainWindow *mainWindow = qobject_cast<QMainWindow*>(dockWidget->parentWidget())) {
1405 const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(dockWidget);
1406 DomProperty *attr =
new DomProperty();
1407 attr->setAttributeName(u"dockWidgetArea"_s);
1408 attr->setElementNumber(
int(area));
1409 ui_widget->setElementAttribute(ui_widget->elementAttribute() << attr);
1417 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1418 QList<DomWidget *> ui_widget_list;
1421 const int current = widget->currentIndex();
1422 for (
int i=0; i<container->count(); ++i) {
1423 QWidget *page = container->widget(i);
1426 DomWidget *ui_page = createDom(page, ui_widget);
1428 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1431 QList<DomProperty*> ui_attribute_list;
1434 widget->setCurrentIndex(i);
1435 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget);
1436 PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentTabIcon"_s)));
1437 DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon));
1439 p->setAttributeName(QFormBuilderStrings::iconAttribute);
1440 ui_attribute_list.append(p);
1443 p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentTabText"_s)));
1445 p->setAttributeName(QFormBuilderStrings::titleAttribute);
1446 ui_attribute_list.append(p);
1450 QVariant v = sheet->property(sheet->indexOf(u"currentTabToolTip"_s));
1452 p = textBuilder()->saveText(v);
1454 p->setAttributeName(QFormBuilderStrings::toolTipAttribute);
1455 ui_attribute_list.append(p);
1460 v = sheet->property(sheet->indexOf(u"currentTabWhatsThis"_s));
1462 p = textBuilder()->saveText(v);
1464 p->setAttributeName(QFormBuilderStrings::whatsThisAttribute);
1465 ui_attribute_list.append(p);
1469 ui_page->setElementAttribute(ui_attribute_list);
1471 ui_widget_list.append(ui_page);
1473 widget->setCurrentIndex(current);
1476 ui_widget->setElementWidget(ui_widget_list);
1483 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1484 QList<DomWidget *> ui_widget_list;
1487 const int current = widget->currentIndex();
1488 for (
int i=0; i<container->count(); ++i) {
1489 QWidget *page = container->widget(i);
1492 DomWidget *ui_page = createDom(page, ui_widget);
1494 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1499 QList<DomProperty*> ui_attribute_list;
1502 widget->setCurrentIndex(i);
1503 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget);
1504 PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentItemIcon"_s)));
1505 DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon));
1507 p->setAttributeName(QFormBuilderStrings::iconAttribute);
1508 ui_attribute_list.append(p);
1510 p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentItemText"_s)));
1512 p->setAttributeName(QFormBuilderStrings::labelAttribute);
1513 ui_attribute_list.append(p);
1517 QVariant v = sheet->property(sheet->indexOf(u"currentItemToolTip"_s));
1519 p = textBuilder()->saveText(v);
1521 p->setAttributeName(QFormBuilderStrings::toolTipAttribute);
1522 ui_attribute_list.append(p);
1526 ui_page->setElementAttribute(ui_attribute_list);
1528 ui_widget_list.append(ui_page);
1530 widget->setCurrentIndex(current);
1533 ui_widget->setElementWidget(ui_widget_list);
1540 DomWidget *ui_widget = QAbstractFormBuilder::createDom(wizardPage, ui_parentWidget,
true);
1541 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), wizardPage);
1543 const QString pageIdPropertyName = QLatin1StringView(QWizardPagePropertySheet::pageIdProperty);
1544 const int pageIdIndex = sheet->indexOf(pageIdPropertyName);
1545 if (pageIdIndex != -1 && sheet->isChanged(pageIdIndex)) {
1546 DomProperty *property = variantToDomProperty(
this, wizardPage->metaObject(), pageIdPropertyName, sheet->property(pageIdIndex));
1548 property->elementString()->setAttributeNotr(u"true"_s);
1549 DomPropertyList attributes = ui_widget->elementAttribute();
1550 attributes.push_back(property);
1551 ui_widget->setElementAttribute(attributes);
1559 if (qobject_cast<
const QToolBox *>(w))
1560 return QToolBoxWidgetPropertySheet::checkProperty(propertyName);
1561 if (qobject_cast<
const QTabWidget *>(w))
1562 return QTabWidgetPropertySheet::checkProperty(propertyName);
1563 if (qobject_cast<
const QStackedWidget *>(w))
1564 return QStackedWidgetPropertySheet::checkProperty(propertyName);
1565 if (qobject_cast<
const QMdiArea *>(w))
1572 const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(obj);
1574 const int pindex = meta->indexOfProperty(prop);
1575 if (pindex != -1 && !meta->property(pindex)->attributes().testFlag(QDesignerMetaPropertyInterface::StoredAttribute))
1578 if (prop ==
"objectName"_L1 || prop ==
"spacerName"_L1)
1581 QWidget *check_widget =
nullptr;
1582 if (obj->isWidgetType())
1583 check_widget =
static_cast<QWidget*>(obj);
1585 if (check_widget && prop ==
"geometry"_L1) {
1588 if (m_selected && m_selected == check_widget)
1591 return !LayoutInfo::isWidgetLaidout(core(), check_widget);
1597 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), obj)) {
1599 const int pindex = sheet->indexOf(prop);
1600 if (sheet->isAttribute(pindex))
1603 if (!dynamicSheet || !dynamicSheet->isDynamicProperty(pindex))
1604 return sheet->isChanged(pindex);
1605 if (!sheet->isVisible(pindex))
1615 if (item->widget() ==
nullptr) {
1619 QGridLayout *grid = qobject_cast<QGridLayout*>(layout);
1620 QBoxLayout *box = qobject_cast<QBoxLayout*>(layout);
1622 if (grid !=
nullptr) {
1623 const int rowSpan = ui_item->hasAttributeRowSpan() ? ui_item->attributeRowSpan() : 1;
1624 const int colSpan = ui_item->hasAttributeColSpan() ? ui_item->attributeColSpan() : 1;
1625 grid->addWidget(item->widget(), ui_item->attributeRow(), ui_item->attributeColumn(), rowSpan, colSpan, item->alignment());
1628 if (box !=
nullptr) {
1633 return QAbstractFormBuilder::addItem(ui_item, item, layout);
1638 core()->metaDataBase()->add(widget);
1640 if (! QAbstractFormBuilder::addItem(ui_widget, widget, parentWidget) || qobject_cast<QMainWindow*> (parentWidget)) {
1642 container->addWidget(widget);
1645 if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(parentWidget)) {
1646 const int tabIndex = tabWidget->count() - 1;
1647 const int current = tabWidget->currentIndex();
1649 tabWidget->setCurrentIndex(tabIndex);
1651 const auto &attributes = ui_widget->elementAttribute();
1652 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), parentWidget);
1653 if (
auto *picon = QFBE::propertyByName(attributes, QFormBuilderStrings::iconAttribute)) {
1654 QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
1655 sheet->setProperty(sheet->indexOf(u"currentTabIcon"_s), v);
1657 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::titleAttribute)) {
1658 QVariant v = textBuilder()->loadText(ptext);
1659 sheet->setProperty(sheet->indexOf(u"currentTabText"_s), v);
1661 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::toolTipAttribute)) {
1662 QVariant v = textBuilder()->loadText(ptext);
1663 sheet->setProperty(sheet->indexOf(u"currentTabToolTip"_s), v);
1665 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::whatsThisAttribute)) {
1666 QVariant v = textBuilder()->loadText(ptext);
1667 sheet->setProperty(sheet->indexOf(u"currentTabWhatsThis"_s), v);
1669 tabWidget->setCurrentIndex(current);
1670 }
else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) {
1671 const int itemIndex = toolBox->count() - 1;
1672 const int current = toolBox->currentIndex();
1674 toolBox->setCurrentIndex(itemIndex);
1676 const auto &attributes = ui_widget->elementAttribute();
1677 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), parentWidget);
1678 if (
auto *picon = QFBE::propertyByName(attributes, QFormBuilderStrings::iconAttribute)) {
1679 QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
1680 sheet->setProperty(sheet->indexOf(u"currentItemIcon"_s), v);
1682 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::labelAttribute)) {
1683 QVariant v = textBuilder()->loadText(ptext);
1684 sheet->setProperty(sheet->indexOf(u"currentItemText"_s), v);
1686 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::toolTipAttribute)) {
1687 QVariant v = textBuilder()->loadText(ptext);
1688 sheet->setProperty(sheet->indexOf(u"currentItemToolTip"_s), v);
1690 toolBox->setCurrentIndex(current);
1698 m_copyWidget =
true;
1700 DomUI *ui = copy(selection);
1702 d->m_laidout.clear();
1703 m_copyWidget =
false;
1708 QXmlStreamWriter writer(dev);
1709 writer.setAutoFormatting(
true);
1710 writer.setAutoFormattingIndent(1);
1711 writer.writeStartDocument();
1713 writer.writeEndDocument();
1720 if (selection.empty())
1723 m_copyWidget =
true;
1725 DomWidget *ui_widget =
new DomWidget();
1726 ui_widget->setAttributeName(clipboardObjectName);
1727 bool hasItems =
false;
1729 if (!selection.m_widgets.isEmpty()) {
1730 QList<DomWidget *> ui_widget_list;
1731 for (
auto *w : selection.m_widgets) {
1733 DomWidget *ui_child = createDom(w, ui_widget);
1734 m_selected =
nullptr;
1736 ui_widget_list.append(ui_child);
1738 if (!ui_widget_list.isEmpty()) {
1739 ui_widget->setElementWidget(ui_widget_list);
1744 if (!selection.m_actions.isEmpty()) {
1745 QList<DomAction *> domActions;
1746 for (QAction* action : std::as_const(selection.m_actions)) {
1747 if (DomAction *domAction = createDom(action))
1748 domActions += domAction;
1750 if (!domActions.isEmpty()) {
1751 ui_widget-> setElementAction(domActions);
1756 d->m_laidout.clear();
1757 m_copyWidget =
false;
1764 DomUI *ui =
new DomUI();
1765 ui->setAttributeVersion(currentUiVersion);
1766 ui->setElementWidget(ui_widget);
1767 ui->setElementResources(
saveResources(m_resourceBuilder->usedQrcFiles()
));
1769 ui->setElementCustomWidgets(cws);
1776 const int saved = m_isMainWidget;
1777 m_isMainWidget =
false;
1782 const DomWidget *topLevel = ui->elementWidget();
1784 const auto &domWidgets = topLevel->elementWidget();
1785 if (!domWidgets.isEmpty()) {
1786 const QPoint offset = m_formWindow->grid();
1787 for (DomWidget* domWidget : domWidgets) {
1788 if (QWidget *w = create(domWidget, widgetParent)) {
1789 w->move(w->pos() + offset);
1791 rc.m_widgets.append(w);
1795 const auto domActions = topLevel->elementAction();
1796 for (DomAction *domAction : domActions) {
1797 if (QAction *a = create(domAction, actionParent))
1798 rc.m_actions .append(a);
1801 m_isMainWidget = saved;
1803 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core()))
1804 extra->loadUiExtraInfo(ui);
1814 QXmlStreamReader reader(dev);
1815 bool uiInitialized =
false;
1817 while (!reader.atEnd()) {
1818 if (reader.readNext() == QXmlStreamReader::StartElement) {
1819 if (reader.name().compare(
"ui"_L1, Qt::CaseInsensitive)) {
1821 uiInitialized =
true;
1824 reader.raiseError(QCoreApplication::translate(
"QDesignerResource",
"Unexpected element <%1>").arg(reader.name().toString()));
1828 if (reader.hasError()) {
1830 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"Error while pasting clipboard contents at line %1, column %2: %3")
1831 .arg(reader.lineNumber()).arg(reader.columnNumber())
1832 .arg(reader.errorString()));
1833 uiInitialized =
false;
1834 }
else if (!uiInitialized) {
1836 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"Error while pasting clipboard contents: The root element <ui> is missing."));
1840 return FormBuilderClipboard();
1849 QAbstractFormBuilder::layoutInfo(layout, parent, margin, spacing);
1854 if (m_usedCustomWidgets.isEmpty())
1859 QDesignerFormEditorInterface *core = m_formWindow
->core();
1860 QDesignerWidgetDataBaseInterface *db = core->widgetDataBase();
1861 const bool isInternalWidgetDataBase = qobject_cast<
const WidgetDataBase *>(db);
1862 QMap<
int, DomCustomWidget *> orderedMap;
1864 for (
auto it = m_usedCustomWidgets.cbegin(), end = m_usedCustomWidgets.cend(); it != end; ++it) {
1865 QDesignerWidgetDataBaseItemInterface *item = it.key();
1866 const QString name = item->name();
1867 DomCustomWidget *custom_widget =
new DomCustomWidget;
1869 custom_widget->setElementClass(name);
1870 if (item->isContainer())
1871 custom_widget->setElementContainer(item->isContainer());
1873 if (!item->includeFile().isEmpty()) {
1874 DomHeader *header =
new DomHeader;
1875 const IncludeSpecification spec = includeSpecification(item->includeFile());
1876 header->setText(spec.first);
1878 header->setAttributeLocation(u"global"_s);
1880 custom_widget->setElementHeader(header);
1881 custom_widget->setElementExtends(item->extends());
1884 if (isInternalWidgetDataBase) {
1885 WidgetDataBaseItem *internalItem =
static_cast<WidgetDataBaseItem *>(item);
1886 const QStringList fakeSlots = internalItem->fakeSlots();
1887 const QStringList fakeSignals = internalItem->fakeSignals();
1888 if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) {
1889 DomSlots *domSlots =
new DomSlots();
1890 domSlots->setElementSlot(fakeSlots);
1891 domSlots->setElementSignal(fakeSignals);
1892 custom_widget->setElementSlots(domSlots);
1894 const QString addPageMethod = internalItem->addPageMethod();
1895 if (!addPageMethod.isEmpty())
1896 custom_widget->setElementAddPageMethod(addPageMethod);
1899 orderedMap.insert(db->indexOfClassName(name), custom_widget);
1902 DomCustomWidgets *customWidgets =
new DomCustomWidgets;
1903 customWidgets->setElementCustomWidget(orderedMap.values().toVector());
1904 return customWidgets;
1909 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), object)) {
1910 if (qobject_cast<QGridLayout *>(object)) {
1911 const int h = sheet->property(sheet->indexOf(u"horizontalSpacing"_s)).toInt();
1912 const int v = sheet->property(sheet->indexOf(u"verticalSpacing"_s)).toInt();
1922 QList<DomProperty*> properties;
1923 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), object)) {
1925 const int count = sheet->count();
1926 QList<DomProperty *> spacingProperties;
1927 const bool compressSpacings = canCompressSpacings(object);
1928 for (
int index = 0; index < count; ++index) {
1929 if (!sheet->isChanged(index) && (!dynamicSheet || !dynamicSheet->isDynamicProperty(index)))
1932 const QString propertyName = sheet->propertyName(index);
1934 if (propertyName ==
"windowModality"_L1 && !sheet->isVisible(index))
1937 const QVariant value = sheet->property(index);
1938 if (DomProperty *p = createProperty(object, propertyName, value)) {
1939 if (compressSpacings && (propertyName ==
"horizontalSpacing"_L1
1940 || propertyName ==
"verticalSpacing"_L1)) {
1941 spacingProperties.append(p);
1943 properties.append(p);
1947 if (compressSpacings) {
1948 if (spacingProperties.size() == 2) {
1949 DomProperty *spacingProperty = spacingProperties.at(0);
1950 spacingProperty->setAttributeName(u"spacing"_s);
1951 properties.append(spacingProperty);
1952 delete spacingProperties.at(1);
1954 properties += spacingProperties;
1961DomProperty *
QDesignerResource::applyProperStdSetAttribute(QObject *object,
const QString &propertyName, DomProperty *property)
1966 QExtensionManager *mgr = core()->extensionManager();
1967 if (
const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(mgr, object)) {
1969 const QDesignerPropertySheet *designerSheet = qobject_cast<QDesignerPropertySheet*>(core()->extensionManager()->extension(object, Q_TYPEID(QDesignerPropertySheetExtension)));
1970 const int index = sheet->indexOf(propertyName);
1971 if ((dynamicSheet && dynamicSheet
->isDynamicProperty(index
)) || (designerSheet && designerSheet->isDefaultDynamicProperty(index)))
1972 property->setAttributeStdset(0);
1978static inline bool hasSetter(QDesignerFormEditorInterface *core, QObject *object,
const QString &propertyName)
1980 const QDesignerMetaObjectInterface *meta = core->introspection()->metaObject(object);
1981 const int pindex = meta->indexOfProperty(propertyName);
1984 return meta->property(pindex)->hasSetter();
1987DomProperty *
QDesignerResource::createProperty(QObject *object,
const QString &propertyName,
const QVariant &value)
1989 if (!checkProperty(object, propertyName)) {
1994 const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(value);
1995 const auto mode = d->m_fullyQualifiedEnums
1996 ? DesignerMetaFlags::FullyQualified : DesignerMetaFlags::Qualified;
1997 const QString flagString = f.metaFlags.toString(f.value, mode);
1998 if (flagString.isEmpty())
2001 DomProperty *p =
new DomProperty;
2003 if (!hasSetter(core(), object, propertyName))
2004 p->setAttributeStdset(0);
2005 p->setAttributeName(propertyName);
2006 p->setElementSet(flagString);
2007 return applyProperStdSetAttribute(object, propertyName, p);
2010 const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(value);
2011 const auto mode = d->m_fullyQualifiedEnums
2012 ? DesignerMetaEnum::FullyQualified : DesignerMetaEnum::Qualified;
2014 const QString id = e.metaEnum.toString(e.value, mode, &ok);
2016 designerWarning(e.metaEnum.messageToStringFailed(e.value));
2020 DomProperty *p =
new DomProperty;
2022 if (!hasSetter(core(), object, propertyName))
2023 p->setAttributeStdset(0);
2024 p->setAttributeName(propertyName);
2025 p->setElementEnum(id);
2026 return applyProperStdSetAttribute(object, propertyName, p);
2029 const PropertySheetStringValue strVal = qvariant_cast<PropertySheetStringValue>(value);
2030 DomProperty *p = stringToDomProperty(strVal.value(), strVal);
2031 if (!hasSetter(core(), object, propertyName))
2032 p->setAttributeStdset(0);
2034 p->setAttributeName(propertyName);
2036 return applyProperStdSetAttribute(object, propertyName, p);
2039 const PropertySheetStringListValue listValue = qvariant_cast<PropertySheetStringListValue>(value);
2040 DomProperty *p =
new DomProperty;
2041 if (!hasSetter(core(), object, propertyName))
2042 p->setAttributeStdset(0);
2044 p->setAttributeName(propertyName);
2046 DomStringList *domStringList =
new DomStringList();
2047 domStringList->setElementString(listValue.value());
2048 translationParametersToDom(listValue, domStringList);
2049 p->setElementStringList(domStringList);
2050 return applyProperStdSetAttribute(object, propertyName, p);
2053 const PropertySheetKeySequenceValue keyVal = qvariant_cast<PropertySheetKeySequenceValue>(value);
2054 DomProperty *p = stringToDomProperty(keyVal.value().toString(), keyVal);
2055 if (!hasSetter(core(), object, propertyName))
2056 p->setAttributeStdset(0);
2058 p->setAttributeName(propertyName);
2060 return applyProperStdSetAttribute(object, propertyName, p);
2063 return applyProperStdSetAttribute(object, propertyName, QAbstractFormBuilder::createProperty(object, propertyName, value));
2066QStringList
QDesignerResource::mergeWithLoadedPaths(
const QStringList &paths)
const
2068 QStringList newPaths = paths;
2070 const QStringList loadedPaths = m_resourceBuilder->loadedQrcFiles();
2071 std::remove_copy_if(loadedPaths.cbegin(), loadedPaths.cend(),
2072 std::back_inserter(newPaths),
2073 [&newPaths] (
const QString &path) {
return newPaths.contains(path); });
2082 if (resources !=
nullptr) {
2083 const auto &dom_include = resources->elementInclude();
2084 for (DomResource *res : dom_include) {
2085 QString path = QDir::cleanPath(m_formWindow->absoluteDir().absoluteFilePath(res->attributeLocation()));
2086 while (!QFile::exists(path)) {
2087 QWidget *dialogParent = m_formWindow->core()->topLevel();
2088 const QString promptTitle = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"Loading qrc file");
2089 const QString prompt = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"The specified qrc file <p><b>%1</b></p><p>could not be found. Do you want to update the file location?</p>").arg(path);
2091 const QMessageBox::StandardButton answer = core()->dialogGui()->message(dialogParent, QDesignerDialogGuiInterface::ResourceLoadFailureMessage,
2092 QMessageBox::Warning, promptTitle, prompt, QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
2093 if (answer == QMessageBox::Yes) {
2094 const QFileInfo fi(path);
2095 const QString fileDialogTitle = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"New location for %1").arg(fi.fileName());
2096 const QString fileDialogPattern = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"Resource files (*.qrc)");
2097 path = core()->dialogGui()->getOpenFileName(dialogParent, fileDialogTitle, fi.absolutePath(), fileDialogPattern);
2100 m_formWindow->setProperty(
"_q_resourcepathchanged", QVariant(
true));
2105 if (!path.isEmpty()) {
2107 m_formWindow->addResourceFile(path);
2113 paths = mergeWithLoadedPaths(paths);
2116 QtResourceSet *resourceSet = m_formWindow->resourceSet();
2118 QStringList newPaths = resourceSet->activeResourceFilePaths();
2119 std::remove_copy_if(paths.cbegin(), paths.cend(),
2120 std::back_inserter(newPaths),
2121 [&newPaths] (
const QString &path) {
return newPaths.contains(path); });
2122 resourceSet->activateResourceFilePaths(newPaths);
2124 resourceSet = m_formWindow
->core()->resourceModel()->addResourceSet(paths);
2125 m_formWindow->setResourceSet(resourceSet);
2126 QObject::connect(m_formWindow->core()->resourceModel(), &QtResourceModel::resourceSetActivated,
2127 m_formWindow, &FormWindowBase::resourceSetActivated);
2134 switch (m_formWindow->resourceFileSaveMode()) {
2135 case QDesignerFormWindowInterface::SaveAllResourceFiles:
2136 paths = m_formWindow->activeResourceFilePaths();
2138 case QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles:
2139 paths = m_resourceBuilder->usedQrcFiles();
2141 case QDesignerFormWindowInterface::DontSaveResourceFiles:
2149 QtResourceSet *resourceSet = m_formWindow->resourceSet();
2150 QList<DomResource *> dom_include;
2152 const QStringList activePaths = resourceSet->activeResourceFilePaths();
2153 for (
const QString &path : activePaths) {
2154 if (qrcPaths.contains(path)) {
2155 DomResource *dom_res =
new DomResource;
2156 QString conv_path = path;
2157 if (m_resourceBuilder->isSaveRelative())
2158 conv_path = m_formWindow->absoluteDir().relativeFilePath(path);
2159 conv_path.replace(QDir::separator(), u'/');
2160 dom_res->setAttributeLocation(conv_path);
2161 dom_include.append(dom_res);
2166 DomResources *dom_resources =
new DomResources;
2167 dom_resources->setElementInclude(dom_include);
2169 return dom_resources;
2182 if (core()->metaDataBase()->item(actionGroup) !=
nullptr) {
2183 return QAbstractFormBuilder::createDom(actionGroup);
2191 if (QAction *action = QAbstractFormBuilder::create(ui_action, parent)) {
2192 core()->metaDataBase()->add(action);
2201 if (QActionGroup *actionGroup = QAbstractFormBuilder::create(ui_action_group, parent)) {
2202 core()->metaDataBase()->add(actionGroup);
2225 if (QAction *action = QAbstractFormBuilder::createAction(parent, name)) {
2226 core()->metaDataBase()->add(action);
2235 if (QActionGroup *actionGroup = QAbstractFormBuilder::createActionGroup(parent, name)) {
2236 core()->metaDataBase()->add(actionGroup);
2244
2247 const DomPropertyList attributes = ui_widget->elementAttribute();
2248 if (attributes.isEmpty())
2250 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), widget);
2251 for (
auto *prop : attributes) {
2252 const QString name = prop->attributeName();
2253 const int index = sheet->indexOf(name);
2255 const QString msg =
"Unable to apply attributive property '%1' to '%2'. It does not exist."_L1.arg(name, widget->objectName());
2256 designerWarning(msg);
2258 sheet->setProperty(index, domPropertyToVariant(
this, widget->metaObject(), prop));
2259 sheet->setChanged(index,
true);
2266 QAbstractFormBuilder::loadExtraInfo(ui_widget, widget, parentWidget);
2268 if (qobject_cast<
const QWizardPage*>(widget))
2269 applyAttributesToPropertySheet(ui_widget, widget);
virtual bool dynamicPropertiesAllowed() const =0
virtual bool isDynamicProperty(int index) const =0
virtual bool isLanguageResource(const QString &path) const =0
static void markChangedStretchProperties(QDesignerFormEditorInterface *core, QLayout *lt, const DomLayout *domLayout)
static void stretchAttributesToDom(QDesignerFormEditorInterface *core, QLayout *lt, DomLayout *domLayout)
QVariant toNativeValue(const QVariant &value) const override
bool isResourceType(const QVariant &value) const override
QVariant loadResource(const QDir &workingDirectory, const DomProperty *icon) const override
QStringList loadedQrcFiles() const
QStringList usedQrcFiles() const
QDesignerResourceBuilder(QDesignerFormEditorInterface *core, DesignerPixmapCache *pixmapCache, DesignerIconCache *iconCache)
DomProperty * saveResource(const QDir &workingDirectory, const QVariant &value) const override
bool isSaveRelative() const
void setSaveRelative(bool relative)
void setIconCache(DesignerIconCache *iconCache)
void setPixmapCache(DesignerPixmapCache *pixmapCache)
DomActionGroup * createDom(QActionGroup *actionGroup) override
QWidget * load(QIODevice *dev, QWidget *parentWidget) override
Loads an XML representation of a widget from the given device, and constructs a new widget with the s...
bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout) override
DomLayoutItem * createDom(QLayoutItem *item, DomLayout *ui_layout, DomWidget *ui_parentWidget) override
DomLayout * createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget) override
void applyProperties(QObject *o, const QList< DomProperty * > &properties) override
void createCustomWidgets(DomCustomWidgets *) override
QLayout * create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget) override
void applyTabStops(QWidget *widget, DomTabStops *tabStops) override
DomWidget * saveWidget(QToolBar *toolBar, DomWidget *ui_parentWidget)
DomCustomWidgets * saveCustomWidgets() override
DomWidget * saveWidget(QDesignerDockWidget *dockWidget, DomWidget *ui_parentWidget)
DomUI * copy(const FormBuilderClipboard &selection) override
QAction * create(DomAction *ui_action, QObject *parent) override
DomUI * readUi(QIODevice *dev)
QActionGroup * create(DomActionGroup *ui_action_group, QObject *parent) override
DomWidget * saveWidget(QWizardPage *wizardPage, DomWidget *ui_parentWidget)
void saveDom(DomUI *ui, QWidget *widget) override
void createResources(DomResources *) override
void save(QIODevice *dev, QWidget *widget) override
Saves an XML representation of the given widget to the specified device in the standard UI file forma...
QLayoutItem * create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget) override
DomResources * saveResources() override
QWidget * create(DomUI *ui, QWidget *parentWidget) override
QWidget * loadUi(DomUI *ui, QWidget *parentWidget)
void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) override
void setSaveRelative(bool relative)
QDesignerResource(FormWindow *fw)
DomWidget * createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive=true) override
DomWidget * saveWidget(QTabWidget *widget, DomWidget *ui_parentWidget)
DomWidget * saveWidget(QToolBox *widget, DomWidget *ui_parentWidget)
FormBuilderClipboard paste(DomUI *ui, QWidget *widgetParent, QObject *actionParent=nullptr) override
DomWidget * saveWidget(QWidget *widget, QDesignerContainerExtension *container, DomWidget *ui_parentWidget)
bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) override
void layoutInfo(DomLayout *layout, QObject *parent, int *margin, int *spacing) override
FormBuilderClipboard paste(QIODevice *dev, QWidget *widgetParent, QObject *actionParent=nullptr) override
QList< DomProperty * > computeProperties(QObject *obj) override
DomWidget * saveWidget(QStackedWidget *widget, DomWidget *ui_parentWidget)
QWidget * create(DomWidget *ui_widget, QWidget *parentWidget) override
DomTabStops * saveTabStops() override
bool saveRelative() const
bool copy(QIODevice *dev, const FormBuilderClipboard &selection) override
~QDesignerResource() override
QDesignerTextBuilder()=default
QVariant toNativeValue(const QVariant &value) const override
DomProperty * saveText(const QVariant &value) const override
QVariant loadText(const DomProperty *icon) const override
static bool checkProperty(const QString &propertyName)
Auxiliary methods to store/retrieve settings.
static QString messageBoxTitle()
static void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory, QString path, PropertySheetIconValue &icon, const QDesignerLanguageExtension *lang=nullptr)
static DomProperty * stringToDomProperty(const QString &value, const PropertySheetTranslatableData &translatableData)
QString msgUnmanagedPage(QDesignerFormEditorInterface *core, QWidget *container, int index, QWidget *page)
static DomProperty * stringToDomProperty(const QString &value)
void translationParametersToDom(const PropertySheetTranslatableData &data, DomElement *e)
static bool supportsQualifiedEnums(const QVersionNumber &qtVersion)
static bool hasSetter(QDesignerFormEditorInterface *core, QObject *object, const QString &propertyName)
static bool isDeprecatedQt5Property(const QObject *o, const DomProperty *p)
static bool readDomEnumerationValue(const DomProperty *p, const QDesignerPropertySheetExtension *sheet, int index, QVariant &v)
static bool checkContainerProperty(const QWidget *w, const QString &propertyName)
void translationParametersFromDom(const DomElement *e, PropertySheetTranslatableData *data)
#define OLD_RESOURCE_FORMAT
static constexpr auto clipboardObjectName
static constexpr auto currentUiVersion