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>
87Q_DECLARE_METATYPE(QWidgetList)
91using namespace Qt::StringLiterals;
93using QFBE = QFormBuilderExtra;
96 using DomPropertyList = QList<DomProperty *>;
102#define OLD_RESOURCE_FORMAT
108 if (qtVersion >= QVersionNumber{6, 6, 2})
111 switch (qtVersion.majorVersion()) {
113 switch (qtVersion.minorVersion()) {
115 if (qtVersion.microVersion() >= 4)
119 if (qtVersion.microVersion() >= 13)
126 if (qtVersion >= QVersionNumber{5, 15, 18})
139 void setPixmapCache(DesignerPixmapCache *pixmapCache) { m_pixmapCache = pixmapCache; }
140 void setIconCache(DesignerIconCache *iconCache) { m_iconCache = iconCache; }
148 QVariant
loadResource(
const QDir &workingDirectory,
const DomProperty *icon)
const override;
152 DomProperty *
saveResource(
const QDir &workingDirectory,
const QVariant &value)
const override;
157 QDesignerFormEditorInterface *m_core;
158 DesignerPixmapCache *m_pixmapCache;
159 DesignerIconCache *m_iconCache;
162 mutable QMap<QString,
bool> m_usedQrcFiles;
163 mutable QMap<QString,
bool> m_loadedQrcFiles;
168 m_pixmapCache(pixmapCache),
169 m_iconCache(iconCache),
175static inline void setIconPixmap(QIcon::Mode m, QIcon::State s,
const QDir &workingDirectory,
176 QString path, PropertySheetIconValue &icon,
180 path = QFileInfo(workingDirectory, path).absoluteFilePath();
181 icon.setPixmap(m, s, PropertySheetPixmapValue(path));
186 switch (property->kind()) {
187 case DomProperty::Pixmap: {
189 DomResourcePixmap *dp = property->elementPixmap();
190 if (!dp->text().isEmpty()) {
192 pixmap.setPath(dp->text());
194 pixmap.setPath(QFileInfo(workingDirectory, dp->text()).absoluteFilePath());
197 if (dp->hasAttributeResource())
198 m_loadedQrcFiles.insert(QFileInfo(workingDirectory, dp->attributeResource()).absoluteFilePath(),
false);
201 return QVariant::fromValue(pixmap);
204 case DomProperty::IconSet: {
206 DomResourceIcon *di = property->elementIconSet();
207 const bool hasTheme = di->hasAttributeTheme();
209 const QString &theme = di->attributeTheme();
210 const qsizetype themeEnum = theme.startsWith(
"QIcon::"_L1)
211 ? QDesignerResourceBuilder::themeIconIndex(theme) : -1;
213 icon.setThemeEnum(themeEnum);
215 icon.setTheme(theme);
217 if (
const int flags = iconStateFlags(di)) {
218 if (flags & NormalOff)
219 setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->elementNormalOff()->text(), icon, m_lang);
220 if (flags & NormalOn)
221 setIconPixmap(QIcon::Normal, QIcon::On, workingDirectory, di->elementNormalOn()->text(), icon, m_lang);
222 if (flags & DisabledOff)
223 setIconPixmap(QIcon::Disabled, QIcon::Off, workingDirectory, di->elementDisabledOff()->text(), icon, m_lang);
224 if (flags & DisabledOn)
225 setIconPixmap(QIcon::Disabled, QIcon::On, workingDirectory, di->elementDisabledOn()->text(), icon, m_lang);
226 if (flags & ActiveOff)
227 setIconPixmap(QIcon::Active, QIcon::Off, workingDirectory, di->elementActiveOff()->text(), icon, m_lang);
228 if (flags & ActiveOn)
229 setIconPixmap(QIcon::Active, QIcon::On, workingDirectory, di->elementActiveOn()->text(), icon, m_lang);
230 if (flags & SelectedOff)
231 setIconPixmap(QIcon::Selected, QIcon::Off, workingDirectory, di->elementSelectedOff()->text(), icon, m_lang);
232 if (flags & SelectedOn)
233 setIconPixmap(QIcon::Selected, QIcon::On, workingDirectory, di->elementSelectedOn()->text(), icon, m_lang);
234 }
else if (!hasTheme) {
236 setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->text(), icon, m_lang);
237 if (di->hasAttributeResource())
238 m_loadedQrcFiles.insert(QFileInfo(workingDirectory, di->attributeResource()).absoluteFilePath(),
false);
241 return QVariant::fromValue(icon);
263 DomProperty *p =
new DomProperty;
266 DomResourcePixmap *rp =
new DomResourcePixmap;
267 const QString pixPath = pix.path();
268 switch (pix.pixmapSource(m_core)) {
269 case PropertySheetPixmapValue::LanguageResourcePixmap:
270 rp->setText(pixPath);
272 case PropertySheetPixmapValue::ResourcePixmap: {
273 rp->setText(pixPath);
274 const QString qrcFile = m_core->resourceModel()->qrcPath(pixPath);
275 if (!qrcFile.isEmpty()) {
276 m_usedQrcFiles.insert(qrcFile,
false);
278 rp->setAttributeResource(workingDirectory.relativeFilePath(qrcFile));
283 case PropertySheetPixmapValue::FilePixmap:
284 rp->setText(m_saveRelative ? workingDirectory.relativeFilePath(pixPath) : pixPath);
287 p->setElementPixmap(rp);
292 const auto &pixmaps = icon.paths();
293 const int themeEnum = icon.themeEnum();
294 const QString theme = themeEnum != -1
295 ? QDesignerResourceBuilder::fullyQualifiedThemeIconName(themeEnum) : icon.theme();
296 if (!pixmaps.isEmpty() || !theme.isEmpty()) {
297 DomResourceIcon *ri =
new DomResourceIcon;
298 if (!theme.isEmpty())
299 ri->setAttributeTheme(theme);
300 for (
auto itPix = pixmaps.cbegin(), end = pixmaps.cend(); itPix != end; ++itPix) {
301 const QIcon::Mode mode = itPix.key().first;
302 const QIcon::State state = itPix.key().second;
303 DomResourcePixmap *rp =
new DomResourcePixmap;
304 const PropertySheetPixmapValue &pix = itPix.value();
305 const PropertySheetPixmapValue::PixmapSource ps = pix.pixmapSource(m_core);
306 const QString pixPath = pix.path();
307 rp->setText(ps == PropertySheetPixmapValue::FilePixmap && m_saveRelative ? workingDirectory.relativeFilePath(pixPath) : pixPath);
308 if (state == QIcon::Off) {
311 ri->setElementNormalOff(rp);
313 ri->setText(rp->text());
315 if (ps == PropertySheetPixmapValue::ResourcePixmap) {
318 const QString qrcFile = m_core->resourceModel()->qrcPath(ri->text());
319 if (!qrcFile.isEmpty()) {
320 m_usedQrcFiles.insert(qrcFile,
false);
322 ri->setAttributeResource(workingDirectory.relativeFilePath(qrcFile));
327 case QIcon::Disabled: ri->setElementDisabledOff(rp);
break;
328 case QIcon::Active: ri->setElementActiveOff(rp);
break;
329 case QIcon::Selected: ri->setElementSelectedOff(rp);
break;
333 case QIcon::Normal: ri->setElementNormalOn(rp);
break;
334 case QIcon::Disabled: ri->setElementDisabledOn(rp);
break;
335 case QIcon::Active: ri->setElementActiveOn(rp);
break;
336 case QIcon::Selected: ri->setElementSelectedOn(rp);
break;
340 p->setElementIconSet(ri);
355template <
class DomElement>
358 const QString propertyComment = data.disambiguation();
359 if (!propertyComment.isEmpty())
360 e->setAttributeComment(propertyComment);
361 const QString propertyExtracomment = data.comment();
362 if (!propertyExtracomment.isEmpty())
363 e->setAttributeExtraComment(propertyExtracomment);
364 const QString &id = data.id();
366 e->setAttributeId(id);
367 if (!data.translatable())
368 e->setAttributeNotr(u"true"_s);
371template <
class DomElement>
374 if (e->hasAttributeComment())
375 data->setDisambiguation(e->attributeComment());
376 if (e->hasAttributeExtraComment())
377 data->setComment(e->attributeExtraComment());
378 if (e->hasAttributeId())
379 data->setId(e->attributeId());
380 if (e->hasAttributeNotr()) {
381 const QString notr = e->attributeNotr();
382 const bool translatable = !(notr ==
"true"_L1 || notr ==
"yes"_L1);
383 data->setTranslatable(translatable);
401 if (
const DomString *domString = text->elementString()) {
403 translationParametersFromDom(domString, &stringValue);
404 return QVariant::fromValue(stringValue);
406 return QVariant(QString());
411 if (value.canConvert<PropertySheetStringValue>())
412 return QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(value).value());
418 DomString *domString =
new DomString();
419 domString->setText(value);
420 DomProperty *property =
new DomProperty();
421 property->setElementString(domString);
426 const PropertySheetTranslatableData &translatableData)
428 DomString *domString =
new DomString();
429 domString->setText(value);
430 translationParametersToDom(translatableData, domString);
431 DomProperty *property =
new DomProperty();
432 property->setElementString(domString);
440 return stringToDomProperty(str.value(), str);
442 if (value.canConvert<QString>())
443 return stringToDomProperty(value.toString());
449 m_formWindow(formWindow),
455 QDesignerFormEditorInterface *core = m_formWindow
->core();
456 if (
const QDesignerLanguageExtension *le = qt_extension<QDesignerLanguageExtension*>(core->extensionManager(), core))
457 d->m_language = le->name();
459 setWorkingDirectory(formWindow->absoluteDir());
460 setResourceBuilder(m_resourceBuilder);
464 const QString designerWidget = u"QDesignerWidget"_s;
465 const QString layoutWidget = u"QLayoutWidget"_s;
466 const QString widget = u"QWidget"_s;
467 m_internal_to_qt.insert(layoutWidget, widget);
468 m_internal_to_qt.insert(designerWidget, widget);
469 m_internal_to_qt.insert(u"QDesignerDialog"_s, u"QDialog"_s);
470 m_internal_to_qt.insert(u"QDesignerMenuBar"_s, u"QMenuBar"_s);
471 m_internal_to_qt.insert(u"QDesignerMenu"_s, u"QMenu"_s);
472 m_internal_to_qt.insert(u"QDesignerDockWidget"_s, u"QDockWidget"_s);
475 for (
auto it = m_internal_to_qt.cbegin(), cend = m_internal_to_qt.cend(); it != cend; ++it ) {
476 if (it.value() != designerWidget && it.value() != layoutWidget)
477 m_qt_to_internal.insert(it.value(), it.key());
486 return d->readUi(dev);
491 return QApplication::translate(
"Designer",
"Qt Widgets Designer");
499 const auto qtVersion = m_formWindow
->core()->integration()->qtVersion();
500 d->m_fullyQualifiedEnums = supportsQualifiedEnums(qtVersion);
501 d->m_separateSizeConstraints = qtVersion >= QVersionNumber(7, 0, 0);
502 QAbstractFormBuilder::save(dev, widget);
507 QAbstractFormBuilder::saveDom(ui, widget);
510 Q_ASSERT(sheet !=
nullptr);
512 const QVariant classVar = sheet->property(sheet->indexOf(u"objectName"_s));
514 if (classVar.canConvert<QString>())
515 classStr = classVar.toString();
518 ui->setElementClass(classStr);
520 for (
int index = 0; index < m_formWindow
->toolCount(); ++index) {
521 QDesignerFormWindowToolInterface *tool = m_formWindow->tool(index);
522 Q_ASSERT(tool !=
nullptr);
523 tool->saveToDom(ui, widget);
526 const QString author = m_formWindow->author();
527 if (!author.isEmpty()) {
528 ui->setElementAuthor(author);
531 const QString comment = m_formWindow->comment();
532 if (!comment.isEmpty()) {
533 ui->setElementComment(comment);
536 const QString exportMacro = m_formWindow->exportMacro();
537 if (!exportMacro.isEmpty()) {
538 ui->setElementExportMacro(exportMacro);
541 if (m_formWindow->useIdBasedTranslations())
542 ui->setAttributeIdbasedtr(
true);
544 if (core()->integration()->qtVersion() >= QVersionNumber(6, 10, 0)) {
545 const QString label = m_formWindow->idBasedTranslationLabel();
546 if (!label.isEmpty())
547 ui->setAttributeLabel(label);
550 if (!m_formWindow->connectSlotsByName())
551 ui->setAttributeConnectslotsbyname(
false);
553 const QVariantMap designerFormData = m_formWindow->formData();
554 if (!designerFormData.isEmpty()) {
555 DomPropertyList domPropertyList;
556 for (
auto it = designerFormData.cbegin(), cend = designerFormData.cend(); it != cend; ++it) {
557 if (DomProperty *prop = variantToDomProperty(
this, widget->metaObject(), it.key(), it.value()))
558 domPropertyList += prop;
560 if (!domPropertyList.isEmpty()) {
561 DomDesignerData* domDesignerFormData =
new DomDesignerData;
562 domDesignerFormData->setElementProperty(domPropertyList);
563 ui->setElementDesignerdata(domDesignerFormData);
567 if (!m_formWindow->includeHints().isEmpty()) {
568 const QString local = u"local"_s;
569 const QString global = u"global"_s;
570 QList<DomInclude *> ui_includes;
571 const QStringList &includeHints = m_formWindow->includeHints();
572 ui_includes.reserve(includeHints.size());
573 for (QString includeHint : includeHints) {
574 if (includeHint.isEmpty())
576 DomInclude *incl =
new DomInclude;
577 const QString location = includeHint.at(0) == u'<' ? global : local;
578 includeHint.remove(u'"');
579 includeHint.remove(u'<');
580 includeHint.remove(u'>');
581 incl->setAttributeLocation(location);
582 incl->setText(includeHint);
583 ui_includes.append(incl);
586 DomIncludes *includes =
new DomIncludes;
587 includes->setElementInclude(ui_includes);
588 ui->setElementIncludes(includes);
591 int defaultMargin = INT_MIN, defaultSpacing = INT_MIN;
594 if (defaultMargin != INT_MIN || defaultSpacing != INT_MIN) {
595 DomLayoutDefault *def =
new DomLayoutDefault;
596 if (defaultMargin != INT_MIN)
597 def->setAttributeMargin(defaultMargin);
598 if (defaultSpacing != INT_MIN)
599 def->setAttributeSpacing(defaultSpacing);
600 ui->setElementLayoutDefault(def);
603 QString marginFunction, spacingFunction;
604 m_formWindow->layoutFunction(&marginFunction, &spacingFunction);
605 if (!marginFunction.isEmpty() || !spacingFunction.isEmpty()) {
606 DomLayoutFunction *def =
new DomLayoutFunction;
608 if (!marginFunction.isEmpty())
609 def->setAttributeMargin(marginFunction);
610 if (!spacingFunction.isEmpty())
611 def->setAttributeSpacing(spacingFunction);
612 ui->setElementLayoutFunction(def);
615 QString pixFunction = m_formWindow->pixmapFunction();
616 if (!pixFunction.isEmpty()) {
617 ui->setElementPixmapFunction(pixFunction);
620 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core()))
621 extra->saveUiExtraInfo(ui);
623 if (MetaDataBase *metaDataBase = qobject_cast<MetaDataBase *>(core()->metaDataBase())) {
624 const MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(m_formWindow->mainContainer());
625 const QStringList fakeSlots = item->fakeSlots();
626 const QStringList fakeSignals =item->fakeSignals();
627 if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) {
628 DomSlots *domSlots =
new DomSlots();
629 domSlots->setElementSlot(fakeSlots);
630 domSlots->setElementSignal(fakeSignals);
631 ui->setElementSlots(domSlots);
638 std::unique_ptr<DomUI> ui(
readUi(dev
));
639 return ui ?
loadUi(ui.get()
, parentWidget
) :
nullptr;
644 QWidget *widget = create(ui, parentWidget);
647 widget->setProperty(
"_q_classname", widget->objectName());
648 else if (d->m_errorString.isEmpty())
649 d->m_errorString = QFormBuilderExtra::msgInvalidUiFile();
667 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core())) {
668 if (!extra->loadUiExtraInfo(ui)) {
669 const QString errorMessage = QApplication::translate(
"Designer",
"This file cannot be read because the extra info extension failed to load.");
670 core()->dialogGui()->message(parentWidget->window(), QDesignerDialogGuiInterface::FormLoadFailureMessage,
671 QMessageBox::Warning, messageBoxTitle(), errorMessage, QMessageBox::Ok);
676 qdesigner_internal::WidgetFactory *factory = qobject_cast<qdesigner_internal::WidgetFactory*>(core()->widgetFactory());
677 Q_ASSERT(factory !=
nullptr);
679 QDesignerFormWindowInterface *previousFormWindow = factory->currentFormWindow(m_formWindow);
681 m_isMainWidget =
true;
683 QWidget *mainWidget = QAbstractFormBuilder::create(ui, parentWidget);
686 m_formWindow->setUseIdBasedTranslations(ui->attributeIdbasedtr());
687 m_formWindow->setIdBasedTranslationLabel(ui->attributeLabel());
689 const bool connectSlotsByName = !ui->hasAttributeConnectslotsbyname() || ui->attributeConnectslotsbyname();
690 m_formWindow->setConnectSlotsByName(connectSlotsByName);
693 if (mainWidget && m_formWindow) {
694 m_formWindow->setAuthor(ui->elementAuthor());
695 m_formWindow->setComment(ui->elementComment());
696 m_formWindow->setExportMacro(ui->elementExportMacro());
699 QVariantMap designerFormData;
700 if (ui->hasElementDesignerdata()) {
701 const DomPropertyList domPropertyList = ui->elementDesignerdata()->elementProperty();
702 for (
auto *prop : domPropertyList) {
703 const QVariant vprop = domPropertyToVariant(
this, mainWidget->metaObject(), prop);
704 if (vprop.metaType().id() != QMetaType::UnknownType)
705 designerFormData.insert(prop->attributeName(), vprop);
708 m_formWindow->setFormData(designerFormData);
710 m_formWindow->setPixmapFunction(ui->elementPixmapFunction());
712 if (DomLayoutDefault *def = ui->elementLayoutDefault()) {
716 if (DomLayoutFunction *fun = ui->elementLayoutFunction()) {
717 m_formWindow->setLayoutFunction(fun->attributeMargin(), fun->attributeSpacing());
720 if (DomIncludes *includes = ui->elementIncludes()) {
721 const auto global =
"global"_L1;
722 QStringList includeHints;
723 const auto &elementInclude = includes->elementInclude();
724 for (DomInclude *incl : elementInclude) {
725 QString text = incl->text();
730 if (incl->hasAttributeLocation() && incl->attributeLocation() == global ) {
738 includeHints.append(text);
741 m_formWindow->setIncludeHints(includeHints);
746 auto *mdb = core()->metaDataBase();
747 for (
auto *child : mainWidget->children()) {
748 if (QButtonGroup *bg = qobject_cast<QButtonGroup*>(child))
752 for (
int index = 0; index < m_formWindow
->toolCount(); ++index) {
753 QDesignerFormWindowToolInterface *tool = m_formWindow->tool(index);
754 Q_ASSERT(tool !=
nullptr);
755 tool->loadFromDom(ui, mainWidget);
759 factory->currentFormWindow(previousFormWindow);
761 if (
const DomSlots *domSlots = ui->elementSlots()) {
762 if (MetaDataBase *metaDataBase = qobject_cast<MetaDataBase *>(core()->metaDataBase())) {
763 QStringList fakeSlots;
764 QStringList fakeSignals;
765 if (addFakeMethods(domSlots, fakeSlots, fakeSignals)) {
766 MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(mainWidget);
767 item->setFakeSlots(fakeSlots);
768 item->setFakeSignals(fakeSignals);
774 bool hasExplicitGeometry =
false;
775 const auto &properties = ui->elementWidget()->elementProperty();
776 if (!properties.isEmpty()) {
777 for (
const DomProperty *p : properties) {
778 if (p->attributeName() ==
"geometry"_L1) {
779 hasExplicitGeometry =
true;
784 if (hasExplicitGeometry) {
787 const QSize size = mainWidget->size();
788 const QSize minSize = size.expandedTo(qSmartMinSize(mainWidget));
790 mainWidget->resize(minSize);
794 mainWidget->adjustSize();
801 const QDesignerWidgetDataBaseInterface *wdb = core()->widgetDataBase();
802 const int wdbIndex = wdb->indexOfObject(mainWidget);
803 if (wdbIndex != -1) {
804 QDesignerWidgetDataBaseItemInterface *item = wdb->item(wdbIndex);
806 if (item->isPromoted() && !item->isContainer()) {
807 item->setContainer(
true);
808 qWarning(
"** WARNING The form's main container is an unknown custom widget '%s'."
809 " Defaulting to a promoted instance of '%s', assuming container.",
810 item->name().toUtf8().constData(), item->extends().toUtf8().constData());
819 const QString className = ui_widget->attributeClass();
820 if (!m_isMainWidget && className ==
"QWidget"_L1
821 && !ui_widget->elementLayout().isEmpty()
822 && !ui_widget->hasAttributeNative()) {
827 if (container ==
nullptr) {
829 ui_widget->setAttributeClass(u"QLayoutWidget"_s);
834 const auto &actionRefs = ui_widget->elementAddAction();
835 ui_widget->setElementAddAction(QList<DomActionRef *>());
837 QWidget *w = QAbstractFormBuilder::create(ui_widget, parentWidget);
840 ui_widget->setElementAddAction(actionRefs);
846 QDesignerMenu *menu = qobject_cast<QDesignerMenu*>(w);
847 QDesignerMenuBar *menuBar = qobject_cast<QDesignerMenuBar*>(w);
852 for (DomActionRef *ui_action_ref : actionRefs) {
853 const QString name = ui_action_ref->attributeName();
854 if (name ==
"separator"_L1) {
855 QAction *sep =
new QAction(w);
856 sep->setSeparator(
true);
859 }
else if (QAction *a = d->m_actions.value(name)) {
861 }
else if (QActionGroup *g = d->m_actionGroups.value(name)) {
862 w->addActions(g->actions());
863 }
else if (QMenu *menu = w->findChild<QMenu*>(name)) {
864 w->addAction(menu->menuAction());
865 addMenuAction(menu->menuAction());
870 menu->adjustSpecialActions();
872 menuBar->adjustSpecialActions();
874 ui_widget->setAttributeClass(className);
875 applyExtensionDataFromDOM(
this, core(), ui_widget, w);
882 QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
884 if (QGridLayout *gridLayout = qobject_cast<QGridLayout*>(l)) {
885 QLayoutSupport::createEmptyCells(gridLayout);
887 if (QFormLayout *formLayout = qobject_cast<QFormLayout*>(l))
888 QLayoutSupport::createEmptyCells(formLayout);
898 if (ui_layoutItem->kind() == DomLayoutItem::Spacer) {
899 const DomSpacer *domSpacer = ui_layoutItem->elementSpacer();
900 Spacer *spacer =
static_cast<Spacer*>(core()->widgetFactory()->createWidget(u"Spacer"_s, parentWidget));
901 if (domSpacer->hasAttributeName())
902 changeObjectName(spacer, domSpacer->attributeName());
903 core()->metaDataBase()->add(spacer);
905 spacer->setInteractiveMode(
false);
906 applyProperties(spacer, ui_layoutItem->elementSpacer()->elementProperty());
907 spacer->setInteractiveMode(
true);
912 sheet->setChanged(sheet->indexOf(u"orientation"_s),
true);
915 return new QWidgetItem(spacer);
917 if (ui_layoutItem->kind() == DomLayoutItem::Layout && parentWidget) {
918 DomLayout *ui_layout = ui_layoutItem->elementLayout();
919 QLayoutWidget *layoutWidget =
new QLayoutWidget(m_formWindow, parentWidget);
920 core()->metaDataBase()->add(layoutWidget);
923 (
void) create(ui_layout,
nullptr, layoutWidget);
924 return new QWidgetItem(layoutWidget);
926 return QAbstractFormBuilder::create(ui_layoutItem, layout, parentWidget);
931 m_formWindow->unify(o, objName,
true);
932 o->setObjectName(objName);
937
944 case DomProperty::Set: {
945 const QVariant sheetValue = sheet->property(index);
946 if (sheetValue.canConvert<PropertySheetFlagValue>()) {
949 v = f.metaFlags.parseFlags(p->elementSet(), &ok);
951 designerWarning(f.metaFlags.messageParseFailed(p->elementSet()));
956 case DomProperty::Enum: {
957 const QVariant sheetValue = sheet->property(index);
958 if (sheetValue.canConvert<PropertySheetEnumValue>()) {
961 v = e.metaEnum.parseEnum(p->elementEnum(), &ok);
963 designerWarning(e.metaEnum.messageParseFailed(p->elementEnum()));
977 const QString &propertyName = p->attributeName();
979 case DomProperty::Set:
980 if (propertyName == u"features" && o->inherits(
"QDockWidget")
981 && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") {
985 case DomProperty::Enum:
986 if (propertyName == u"sizeAdjustPolicy" && o->inherits(
"QComboBox")
987 && p->elementEnum() == u"QComboBox::AdjustToMinimumContentsLength") {
999 if (properties.isEmpty())
1007 if (dynamicSheet !=
nullptr && !dynamicSheet->dynamicPropertiesAllowed())
1008 dynamicSheet =
nullptr;
1010 for (DomProperty *p : properties) {
1011 if (isDeprecatedQt5Property(o, p))
1013 const QString &propertyName = p->attributeName();
1014 if (propertyName ==
"numDigits"_L1 && o->inherits(
"QLCDNumber")) {
1015 applyProperty(o, p, u"digitCount"_s, sheet, dynamicSheet);
1016#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
1017 }
else if (propertyName ==
"horizontalSizeConstraint"_L1 && o->inherits(
"QLayout")) {
1018 applyProperty(o, p, u"sizeConstraint"_s, sheet, dynamicSheet);
1020 }
else if (propertyName ==
"sizeConstraint"_L1 && o->inherits(
"QLayout")) {
1021 applyProperty(o, p, u"horizontalSizeConstraint"_s, sheet, dynamicSheet);
1022 applyProperty(o, p, u"verticalSizeConstraint"_s, sheet, dynamicSheet);
1025 applyProperty(o, p, propertyName, sheet, dynamicSheet);
1030void QDesignerResource::applyProperty(QObject *o, DomProperty* p,
const QString &propertyName,
1034 const int index = sheet->indexOf(propertyName);
1036 if (!readDomEnumerationValue(p, sheet, index, v))
1037 v = toVariant(o->metaObject(), p);
1038 switch (p->kind()) {
1039 case DomProperty::String:
1041 const DomString *key = p->elementString();
1043 translationParametersFromDom(key, &keyVal);
1044 v = QVariant::fromValue(keyVal);
1046 const DomString *str = p->elementString();
1048 translationParametersFromDom(str, &strVal);
1049 v = QVariant::fromValue(strVal);
1052 case DomProperty::StringList: {
1053 const DomStringList *list = p->elementStringList();
1055 translationParametersFromDom(list, &listValue);
1056 v = QVariant::fromValue(listValue);
1062 d->applyPropertyInternally(o, propertyName, v);
1064 sheet->setProperty(index, v);
1065 sheet->setChanged(index,
true);
1066 }
else if (dynamicSheet !=
nullptr) {
1067 QVariant defaultValue = QVariant(v.metaType());
1068 bool isDefault = (v == defaultValue);
1069 if (v.canConvert<PropertySheetIconValue>()) {
1070 defaultValue = QVariant(QMetaType(QMetaType::QIcon));
1072 }
else if (v.canConvert<PropertySheetPixmapValue>()) {
1073 defaultValue = QVariant(QMetaType(QMetaType::QPixmap));
1075 }
else if (v.canConvert<PropertySheetStringValue>()) {
1076 defaultValue = QVariant(QMetaType(QMetaType::QString));
1078 }
else if (v.canConvert<PropertySheetStringListValue>()) {
1079 defaultValue = QVariant(QMetaType(QMetaType::QStringList));
1081 }
else if (v.canConvert<PropertySheetKeySequenceValue>()) {
1082 defaultValue = QVariant(QMetaType(QMetaType::QKeySequence));
1085 if (defaultValue.metaType().id() != QMetaType::User) {
1086 const int idx = dynamicSheet->addDynamicProperty(p->attributeName(), defaultValue);
1088 sheet->setProperty(idx, v);
1089 sheet->setChanged(idx, !isDefault);
1094 if (propertyName ==
"objectName"_L1)
1095 changeObjectName(o, o->objectName());
1100 QString name = _name;
1102 m_isMainWidget =
false;
1104 QWidget *w = core()->widgetFactory()->createWidget(widgetName, parentWidget);
1108 if (name.isEmpty()) {
1109 QDesignerWidgetDataBaseInterface *db = core()->widgetDataBase();
1110 if (QDesignerWidgetDataBaseItemInterface *item = db->item(db->indexOfObject(w)))
1111 name = qtify(item->name());
1114 changeObjectName(w, name);
1117 if (!qobject_cast<QMenu*>(w) && (!parentWidget || !container)) {
1120 QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(
"_q_widgetOrder"));
1122 parentWidget->setProperty(
"_q_widgetOrder", QVariant::fromValue(list));
1123 QWidgetList zOrder = qvariant_cast<QWidgetList>(parentWidget->property(
"_q_zOrder"));
1125 parentWidget->setProperty(
"_q_zOrder", QVariant::fromValue(zOrder));
1128 core()->metaDataBase()->add(w);
1131 w->setWindowFlags(w->windowFlags() & ~Qt::Window);
1133 w->setWindowModality(Qt::NonModal);
1138QLayout *
QDesignerResource::createLayout(
const QString &layoutName, QObject *parent,
const QString &name)
1140 QWidget *layoutBase =
nullptr;
1141 QLayout *layout = qobject_cast<QLayout*>(parent);
1143 if (parent->isWidgetType())
1144 layoutBase =
static_cast<QWidget*>(parent);
1146 Q_ASSERT( layout !=
nullptr );
1147 layoutBase = layout->parentWidget();
1150 LayoutInfo::Type layoutType = LayoutInfo::layoutType(layoutName);
1151 if (layoutType == LayoutInfo::NoLayout) {
1152 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"The layout type '%1' is not supported, defaulting to grid.").arg(layoutName));
1153 layoutType = LayoutInfo::Grid;
1155 QLayout *lay = core()->widgetFactory()->createLayout(layoutBase, layout, layoutType);
1157 changeObjectName(lay, name);
1165 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(widget);
1169 if (qobject_cast<Spacer*>(widget) && !m_copyWidget)
1172 const QDesignerWidgetDataBaseInterface *wdb = core()->widgetDataBase();
1173 QDesignerWidgetDataBaseItemInterface *widgetInfo =
nullptr;
1174 const int widgetInfoIndex = wdb->indexOfObject(widget,
false);
1175 if (widgetInfoIndex != -1) {
1176 widgetInfo = wdb->item(widgetInfoIndex);
1178 QDesignerWidgetDataBaseItemInterface *customInfo = widgetInfo;
1179 while (customInfo && customInfo->isCustom()) {
1180 m_usedCustomWidgets.insert(customInfo,
true);
1181 const QString extends = customInfo->extends();
1182 if (extends == customInfo->name())
1184 const int extendsIndex = wdb->indexOfClassName(customInfo->extends());
1185 customInfo = extendsIndex != -1 ? wdb->item(extendsIndex) :
nullptr;
1189 DomWidget *w =
nullptr;
1191 if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(widget))
1193 else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(widget))
1195 else if (QToolBox *toolBox = qobject_cast<QToolBox*>(widget))
1197 else if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget))
1199 else if (QDesignerDockWidget *dockWidget = qobject_cast<QDesignerDockWidget*>(widget))
1203 else if (QWizardPage *wizardPage = qobject_cast<QWizardPage*>(widget))
1206 w = QAbstractFormBuilder::createDom(widget, ui_parentWidget, recursive);
1208 Q_ASSERT( w !=
nullptr );
1210 if (!qobject_cast<QLayoutWidget*>(widget) && w->attributeClass() ==
"QWidget"_L1)
1211 w->setAttributeNative(
true);
1213 const QString className = w->attributeClass();
1214 if (m_internal_to_qt.contains(className))
1215 w->setAttributeClass(m_internal_to_qt.value(className));
1217 if (isPromoted( core(), widget)) {
1218 Q_ASSERT(widgetInfo !=
nullptr);
1220 w->setAttributeClass(widgetInfo->name());
1222 const auto &prop_list = w->elementProperty();
1223 for (DomProperty *prop : prop_list) {
1224 if (prop->attributeName() ==
"geometry"_L1) {
1225 if (DomRect *rect = prop->elementRect()) {
1226 rect->setElementX(widget->x());
1227 rect->setElementY(widget->y());
1232 }
else if (widgetInfo !=
nullptr && m_usedCustomWidgets.contains(widgetInfo)) {
1233 if (widgetInfo->name() != w->attributeClass())
1234 w->setAttributeClass(widgetInfo->name());
1236 addExtensionDataToDOM(
this, core(), w, widget);
1242 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(layout);
1244 if (item ==
nullptr) {
1245 layout = layout->findChild<QLayout*>();
1247 item = core()->metaDataBase()->item(layout);
1250 if (item ==
nullptr) {
1255 if (qobject_cast<QSplitter*>(layout->parentWidget()) != 0) {
1260 m_chain.push(layout);
1262 DomLayout *l = QAbstractFormBuilder::createDom(layout, ui_parentLayout, ui_parentWidget);
1263 Q_ASSERT(l !=
nullptr);
1273 DomLayoutItem *ui_item =
nullptr;
1275 if (Spacer *s = qobject_cast<Spacer*>(item->widget())) {
1276 if (!core()->metaDataBase()->item(s))
1279 DomSpacer *spacer =
new DomSpacer();
1280 const QString objectName = s->objectName();
1281 if (!objectName.isEmpty())
1282 spacer->setAttributeName(objectName);
1284 spacer->setElementProperty(computeProperties(item->widget()));
1286 ui_item =
new DomLayoutItem();
1287 ui_item->setElementSpacer(spacer);
1288 d->m_laidout.insert(item->widget(),
true);
1289 }
else if (QLayoutWidget *layoutWidget = qobject_cast<QLayoutWidget*>(item->widget())) {
1291 Q_ASSERT(layoutWidget->layout());
1292 DomLayout *l = createDom(layoutWidget->layout(), ui_layout, ui_parentWidget);
1293 ui_item =
new DomLayoutItem();
1294 ui_item->setElementLayout(l);
1295 d->m_laidout.insert(item->widget(),
true);
1296 }
else if (!item->spacerItem()) {
1297 ui_item = QAbstractFormBuilder::createDom(item, ui_layout, ui_parentWidget);
1306 QSimpleResource::handleDomCustomWidgets(core(), dom_custom_widgets);
1311 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(m_formWindow);
1314 QStringList tabStops;
1315 const QWidgetList &tabOrder = item->tabOrder();
1316 for (QWidget *widget : tabOrder) {
1317 if (m_formWindow->mainContainer()->isAncestorOf(widget))
1318 tabStops.append(widget->objectName());
1321 if (!tabStops.isEmpty()) {
1322 DomTabStops *dom =
new DomTabStops;
1323 dom->setElementTabStop(tabStops);
1332 if (tabStops ==
nullptr || widget ==
nullptr)
1335 QWidgetList tabOrder;
1336 const QStringList &elementTabStop = tabStops->elementTabStop();
1337 for (
const QString &widgetName : elementTabStop) {
1338 if (QWidget *w = widget->findChild<QWidget*>(widgetName)) {
1343 QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(m_formWindow);
1345 item->setTabOrder(tabOrder);
1349
1350
1354 return QCoreApplication::translate(
"QDesignerResource",
1355"The container extension of the widget '%1' (%2) returned a widget not managed by Designer '%3' (%4) when queried for page #%5.\n"
1356"Container pages should only be added by specifying them in XML returned by the domXml() method of the custom widget.").
1357 arg(container->objectName(), WidgetFactory::classNameOf(core, container),
1358 page->objectName(), WidgetFactory::classNameOf(core, page)).
1364 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1365 QList<DomWidget *> ui_widget_list;
1367 for (
int i=0; i<container->count(); ++i) {
1368 QWidget *page = container->widget(i);
1371 if (DomWidget *ui_page = createDom(page, ui_widget)) {
1372 ui_widget_list.append(ui_page);
1374 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1378 ui_widget->setElementWidget(ui_widget_list);
1385 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1386 QList<DomWidget *> ui_widget_list;
1388 for (
int i=0; i<container->count(); ++i) {
1389 QWidget *page = container->widget(i);
1391 if (DomWidget *ui_page = createDom(page, ui_widget)) {
1392 ui_widget_list.append(ui_page);
1394 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1399 ui_widget->setElementWidget(ui_widget_list);
1406 DomWidget *ui_widget = QAbstractFormBuilder::createDom(toolBar, ui_parentWidget,
false);
1407 if (
const QMainWindow *mainWindow = qobject_cast<QMainWindow*>(toolBar->parentWidget())) {
1408 const bool toolBarBreak = mainWindow->toolBarBreak(toolBar);
1409 const Qt::ToolBarArea area = mainWindow->toolBarArea(toolBar);
1411 auto attributes = ui_widget->elementAttribute();
1413 DomProperty *attr =
new DomProperty();
1414 attr->setAttributeName(u"toolBarArea"_s);
1415 attr->setElementEnum(QLatin1StringView(toolBarAreaMetaEnum().valueToKey(area)));
1418 attr =
new DomProperty();
1419 attr->setAttributeName(u"toolBarBreak"_s);
1420 attr->setElementBool(toolBarBreak ? u"true"_s : u"false"_s);
1422 ui_widget->setElementAttribute(attributes);
1430 DomWidget *ui_widget = QAbstractFormBuilder::createDom(dockWidget, ui_parentWidget,
true);
1431 if (QMainWindow *mainWindow = qobject_cast<QMainWindow*>(dockWidget->parentWidget())) {
1432 const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(dockWidget);
1433 DomProperty *attr =
new DomProperty();
1434 attr->setAttributeName(u"dockWidgetArea"_s);
1435 attr->setElementNumber(
int(area));
1436 ui_widget->setElementAttribute(ui_widget->elementAttribute() << attr);
1444 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1445 QList<DomWidget *> ui_widget_list;
1448 const int current = widget->currentIndex();
1449 for (
int i=0; i<container->count(); ++i) {
1450 QWidget *page = container->widget(i);
1453 DomWidget *ui_page = createDom(page, ui_widget);
1455 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1458 QList<DomProperty*> ui_attribute_list;
1461 widget->setCurrentIndex(i);
1463 PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentTabIcon"_s)));
1464 DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon));
1466 p->setAttributeName(QFormBuilderStrings::iconAttribute);
1467 ui_attribute_list.append(p);
1470 p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentTabText"_s)));
1472 p->setAttributeName(QFormBuilderStrings::titleAttribute);
1473 ui_attribute_list.append(p);
1477 QVariant v = sheet->property(sheet->indexOf(u"currentTabToolTip"_s));
1479 p = textBuilder()->saveText(v);
1481 p->setAttributeName(QFormBuilderStrings::toolTipAttribute);
1482 ui_attribute_list.append(p);
1487 v = sheet->property(sheet->indexOf(u"currentTabWhatsThis"_s));
1489 p = textBuilder()->saveText(v);
1491 p->setAttributeName(QFormBuilderStrings::whatsThisAttribute);
1492 ui_attribute_list.append(p);
1496 ui_page->setElementAttribute(ui_attribute_list);
1498 ui_widget_list.append(ui_page);
1500 widget->setCurrentIndex(current);
1503 ui_widget->setElementWidget(ui_widget_list);
1510 DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget,
false);
1511 QList<DomWidget *> ui_widget_list;
1514 const int current = widget->currentIndex();
1515 for (
int i=0; i<container->count(); ++i) {
1516 QWidget *page = container->widget(i);
1519 DomWidget *ui_page = createDom(page, ui_widget);
1521 designerWarning(msgUnmanagedPage(core(), widget, i, page));
1526 QList<DomProperty*> ui_attribute_list;
1529 widget->setCurrentIndex(i);
1531 PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentItemIcon"_s)));
1532 DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon));
1534 p->setAttributeName(QFormBuilderStrings::iconAttribute);
1535 ui_attribute_list.append(p);
1537 p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentItemText"_s)));
1539 p->setAttributeName(QFormBuilderStrings::labelAttribute);
1540 ui_attribute_list.append(p);
1544 QVariant v = sheet->property(sheet->indexOf(u"currentItemToolTip"_s));
1546 p = textBuilder()->saveText(v);
1548 p->setAttributeName(QFormBuilderStrings::toolTipAttribute);
1549 ui_attribute_list.append(p);
1553 ui_page->setElementAttribute(ui_attribute_list);
1555 ui_widget_list.append(ui_page);
1557 widget->setCurrentIndex(current);
1560 ui_widget->setElementWidget(ui_widget_list);
1567 DomWidget *ui_widget = QAbstractFormBuilder::createDom(wizardPage, ui_parentWidget,
true);
1570 const QString pageIdPropertyName = QLatin1StringView(QWizardPagePropertySheet::pageIdProperty);
1571 const int pageIdIndex = sheet->indexOf(pageIdPropertyName);
1572 if (pageIdIndex != -1 && sheet->isChanged(pageIdIndex)) {
1573 DomProperty *property = variantToDomProperty(
this, wizardPage->metaObject(), pageIdPropertyName, sheet->property(pageIdIndex));
1575 property->elementString()->setAttributeNotr(u"true"_s);
1576 DomPropertyList attributes = ui_widget->elementAttribute();
1577 attributes.push_back(property);
1578 ui_widget->setElementAttribute(attributes);
1586 if (qobject_cast<
const QToolBox *>(w))
1587 return QToolBoxWidgetPropertySheet::checkProperty(propertyName);
1588 if (qobject_cast<
const QTabWidget *>(w))
1589 return QTabWidgetPropertySheet::checkProperty(propertyName);
1590 if (qobject_cast<
const QStackedWidget *>(w))
1591 return QStackedWidgetPropertySheet::checkProperty(propertyName);
1592 if (qobject_cast<
const QMdiArea *>(w))
1599 const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(obj);
1601 const int pindex = meta->indexOfProperty(prop);
1602 if (pindex != -1 && !meta->property(pindex)->attributes().testFlag(QDesignerMetaPropertyInterface::StoredAttribute))
1605 if (prop ==
"objectName"_L1 || prop ==
"spacerName"_L1)
1608 if (!d->m_separateSizeConstraints && prop ==
"verticalSizeConstraint"_L1)
1611 QWidget *check_widget =
nullptr;
1612 if (obj->isWidgetType())
1613 check_widget =
static_cast<QWidget*>(obj);
1615 if (check_widget && prop ==
"geometry"_L1) {
1618 if (m_selected && m_selected == check_widget)
1621 return !LayoutInfo::isWidgetLaidout(core(), check_widget);
1629 const int pindex = sheet->indexOf(prop);
1630 if (sheet->isAttribute(pindex))
1634 return sheet->isChanged(pindex);
1635 if (!sheet->isVisible(pindex))
1645 if (item->widget() ==
nullptr) {
1649 QGridLayout *grid = qobject_cast<QGridLayout*>(layout);
1650 QBoxLayout *box = qobject_cast<QBoxLayout*>(layout);
1652 if (grid !=
nullptr) {
1653 const int rowSpan = ui_item->hasAttributeRowSpan() ? ui_item->attributeRowSpan() : 1;
1654 const int colSpan = ui_item->hasAttributeColSpan() ? ui_item->attributeColSpan() : 1;
1655 grid->addWidget(item->widget(), ui_item->attributeRow(), ui_item->attributeColumn(), rowSpan, colSpan, item->alignment());
1658 if (box !=
nullptr) {
1663 return QAbstractFormBuilder::addItem(ui_item, item, layout);
1668 core()->metaDataBase()->add(widget);
1670 if (! QAbstractFormBuilder::addItem(ui_widget, widget, parentWidget) || qobject_cast<QMainWindow*> (parentWidget)) {
1672 container->addWidget(widget);
1675 if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(parentWidget)) {
1676 const int tabIndex = tabWidget->count() - 1;
1677 const int current = tabWidget->currentIndex();
1679 tabWidget->setCurrentIndex(tabIndex);
1681 const auto &attributes = ui_widget->elementAttribute();
1683 if (
auto *picon = QFBE::propertyByName(attributes, QFormBuilderStrings::iconAttribute)) {
1684 QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
1685 sheet->setProperty(sheet->indexOf(u"currentTabIcon"_s), v);
1687 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::titleAttribute)) {
1688 QVariant v = textBuilder()->loadText(ptext);
1689 sheet->setProperty(sheet->indexOf(u"currentTabText"_s), v);
1691 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::toolTipAttribute)) {
1692 QVariant v = textBuilder()->loadText(ptext);
1693 sheet->setProperty(sheet->indexOf(u"currentTabToolTip"_s), v);
1695 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::whatsThisAttribute)) {
1696 QVariant v = textBuilder()->loadText(ptext);
1697 sheet->setProperty(sheet->indexOf(u"currentTabWhatsThis"_s), v);
1699 tabWidget->setCurrentIndex(current);
1700 }
else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) {
1701 const int itemIndex = toolBox->count() - 1;
1702 const int current = toolBox->currentIndex();
1704 toolBox->setCurrentIndex(itemIndex);
1706 const auto &attributes = ui_widget->elementAttribute();
1708 if (
auto *picon = QFBE::propertyByName(attributes, QFormBuilderStrings::iconAttribute)) {
1709 QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
1710 sheet->setProperty(sheet->indexOf(u"currentItemIcon"_s), v);
1712 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::labelAttribute)) {
1713 QVariant v = textBuilder()->loadText(ptext);
1714 sheet->setProperty(sheet->indexOf(u"currentItemText"_s), v);
1716 if (
auto *ptext = QFBE::propertyByName(attributes, QFormBuilderStrings::toolTipAttribute)) {
1717 QVariant v = textBuilder()->loadText(ptext);
1718 sheet->setProperty(sheet->indexOf(u"currentItemToolTip"_s), v);
1720 toolBox->setCurrentIndex(current);
1728 m_copyWidget =
true;
1730 DomUI *ui = copy(selection);
1732 d->m_laidout.clear();
1733 m_copyWidget =
false;
1738 QXmlStreamWriter writer(dev);
1739 writer.setAutoFormatting(
true);
1740 writer.setAutoFormattingIndent(1);
1741 writer.writeStartDocument();
1743 writer.writeEndDocument();
1750 if (selection.empty())
1753 m_copyWidget =
true;
1755 DomWidget *ui_widget =
new DomWidget();
1756 ui_widget->setAttributeName(clipboardObjectName);
1757 bool hasItems =
false;
1759 if (!selection.m_widgets.isEmpty()) {
1760 QList<DomWidget *> ui_widget_list;
1761 for (
auto *w : selection.m_widgets) {
1763 DomWidget *ui_child = createDom(w, ui_widget);
1764 m_selected =
nullptr;
1766 ui_widget_list.append(ui_child);
1768 if (!ui_widget_list.isEmpty()) {
1769 ui_widget->setElementWidget(ui_widget_list);
1774 if (!selection.m_actions.isEmpty()) {
1775 QList<DomAction *> domActions;
1776 for (QAction* action : std::as_const(selection.m_actions)) {
1777 if (DomAction *domAction = createDom(action))
1778 domActions += domAction;
1780 if (!domActions.isEmpty()) {
1781 ui_widget-> setElementAction(domActions);
1786 d->m_laidout.clear();
1787 m_copyWidget =
false;
1794 DomUI *ui =
new DomUI();
1795 ui->setAttributeVersion(currentUiVersion);
1796 ui->setElementWidget(ui_widget);
1797 ui->setElementResources(
saveResources(m_resourceBuilder->usedQrcFiles()
));
1799 ui->setElementCustomWidgets(cws);
1806 const int saved = m_isMainWidget;
1807 m_isMainWidget =
false;
1812 const DomWidget *topLevel = ui->elementWidget();
1814 const auto &domWidgets = topLevel->elementWidget();
1815 if (!domWidgets.isEmpty()) {
1816 const QPoint offset = m_formWindow->grid();
1817 for (DomWidget* domWidget : domWidgets) {
1818 if (QWidget *w = create(domWidget, widgetParent)) {
1819 w->move(w->pos() + offset);
1821 rc.m_widgets.append(w);
1825 const auto domActions = topLevel->elementAction();
1826 for (DomAction *domAction : domActions) {
1827 if (QAction *a = create(domAction, actionParent))
1828 rc.m_actions .append(a);
1831 m_isMainWidget = saved;
1833 if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(core()->extensionManager(), core()))
1834 extra->loadUiExtraInfo(ui);
1844 QXmlStreamReader reader(dev);
1845 bool uiInitialized =
false;
1847 while (!reader.atEnd()) {
1848 if (reader.readNext() == QXmlStreamReader::StartElement) {
1849 if (reader.name().compare(
"ui"_L1, Qt::CaseInsensitive)) {
1851 uiInitialized =
true;
1854 reader.raiseError(QCoreApplication::translate(
"QDesignerResource",
"Unexpected element <%1>").arg(reader.name().toString()));
1858 if (reader.hasError()) {
1860 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"Error while pasting clipboard contents at line %1, column %2: %3")
1861 .arg(reader.lineNumber()).arg(reader.columnNumber())
1862 .arg(reader.errorString()));
1863 uiInitialized =
false;
1864 }
else if (!uiInitialized) {
1866 designerWarning(QCoreApplication::translate(
"QDesignerResource",
"Error while pasting clipboard contents: The root element <ui> is missing."));
1870 return FormBuilderClipboard();
1879 QAbstractFormBuilder::layoutInfo(layout, parent, margin, spacing);
1884 if (m_usedCustomWidgets.isEmpty())
1889 QDesignerFormEditorInterface *core = m_formWindow
->core();
1890 QDesignerWidgetDataBaseInterface *db = core->widgetDataBase();
1891 const bool isInternalWidgetDataBase = qobject_cast<
const WidgetDataBase *>(db);
1892 QMap<
int, DomCustomWidget *> orderedMap;
1894 for (
auto it = m_usedCustomWidgets.cbegin(), end = m_usedCustomWidgets.cend(); it != end; ++it) {
1895 QDesignerWidgetDataBaseItemInterface *item = it.key();
1896 const QString name = item->name();
1897 DomCustomWidget *custom_widget =
new DomCustomWidget;
1899 custom_widget->setElementClass(name);
1900 if (item->isContainer())
1901 custom_widget->setElementContainer(item->isContainer());
1903 if (!item->includeFile().isEmpty()) {
1904 DomHeader *header =
new DomHeader;
1905 const IncludeSpecification spec = includeSpecification(item->includeFile());
1906 header->setText(spec.first);
1908 header->setAttributeLocation(u"global"_s);
1910 custom_widget->setElementHeader(header);
1911 custom_widget->setElementExtends(item->extends());
1914 if (isInternalWidgetDataBase) {
1915 WidgetDataBaseItem *internalItem =
static_cast<WidgetDataBaseItem *>(item);
1916 const QStringList fakeSlots = internalItem->fakeSlots();
1917 const QStringList fakeSignals = internalItem->fakeSignals();
1918 if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) {
1919 DomSlots *domSlots =
new DomSlots();
1920 domSlots->setElementSlot(fakeSlots);
1921 domSlots->setElementSignal(fakeSignals);
1922 custom_widget->setElementSlots(domSlots);
1924 const QString addPageMethod = internalItem->addPageMethod();
1925 if (!addPageMethod.isEmpty())
1926 custom_widget->setElementAddPageMethod(addPageMethod);
1929 orderedMap.insert(db->indexOfClassName(name), custom_widget);
1932 DomCustomWidgets *customWidgets =
new DomCustomWidgets;
1933 customWidgets->setElementCustomWidget(orderedMap.values().toVector());
1934 return customWidgets;
1940 if (qobject_cast<QGridLayout *>(object)) {
1941 const int h = sheet->property(sheet->indexOf(u"horizontalSpacing"_s)).toInt();
1942 const int v = sheet->property(sheet->indexOf(u"verticalSpacing"_s)).toInt();
1952 QList<DomProperty*> properties;
1955 const int count = sheet->count();
1956 QList<DomProperty *> spacingProperties;
1957 const bool compressSpacings = canCompressSpacings(object);
1958 for (
int index = 0; index < count; ++index) {
1962 const QString propertyName = sheet->propertyName(index);
1964 if (propertyName ==
"windowModality"_L1 && !sheet->isVisible(index))
1967 const QVariant value = sheet->property(index);
1968 if (DomProperty *p = createProperty(object, propertyName, value)) {
1969 if (compressSpacings && (propertyName ==
"horizontalSpacing"_L1
1970 || propertyName ==
"verticalSpacing"_L1)) {
1971 spacingProperties.append(p);
1973 properties.append(p);
1977 if (compressSpacings) {
1978 if (spacingProperties.size() == 2) {
1979 DomProperty *spacingProperty = spacingProperties.at(0);
1980 spacingProperty->setAttributeName(u"spacing"_s);
1981 properties.append(spacingProperty);
1982 delete spacingProperties.at(1);
1984 properties += spacingProperties;
1991DomProperty *
QDesignerResource::applyProperStdSetAttribute(QObject *object,
const QString &propertyName, DomProperty *property)
1996 QExtensionManager *mgr = core()->extensionManager();
1999 const QDesignerPropertySheet *designerSheet = qobject_cast<QDesignerPropertySheet*>(core()->extensionManager()->extension(object, Q_TYPEID(QDesignerPropertySheetExtension)));
2000 const int index = sheet->indexOf(propertyName);
2001 if ((dynamicSheet && dynamicSheet
->isDynamicProperty(index
)) || (designerSheet && designerSheet->isDefaultDynamicProperty(index)))
2002 property->setAttributeStdset(0);
2008static inline bool hasSetter(QDesignerFormEditorInterface *core, QObject *object,
const QString &propertyName)
2010 const QDesignerMetaObjectInterface *meta = core->introspection()->metaObject(object);
2011 const int pindex = meta->indexOfProperty(propertyName);
2014 return meta->property(pindex)->hasSetter();
2017DomProperty *
QDesignerResource::createProperty(QObject *object,
const QString &propertyName,
const QVariant &value)
2019 if (!checkProperty(object, propertyName)) {
2025 const auto mode = d->m_fullyQualifiedEnums
2026 ? DesignerMetaFlags::FullyQualified : DesignerMetaFlags::Qualified;
2027 const QString flagString = f.metaFlags.toString(f.value, mode);
2028 if (flagString.isEmpty())
2031 DomProperty *p =
new DomProperty;
2033 if (!hasSetter(core(), object, propertyName))
2034 p->setAttributeStdset(0);
2035 p->setAttributeName(propertyName);
2036 p->setElementSet(flagString);
2037 return applyProperStdSetAttribute(object, propertyName, p);
2041 const auto mode = d->m_fullyQualifiedEnums
2042 ? DesignerMetaEnum::FullyQualified : DesignerMetaEnum::Qualified;
2044 const QString id = e.metaEnum.toString(e.value, mode, &ok);
2046 designerWarning(e.metaEnum.messageToStringFailed(e.value));
2050 DomProperty *p =
new DomProperty;
2052 if (!hasSetter(core(), object, propertyName))
2053 p->setAttributeStdset(0);
2055 if (!d->m_separateSizeConstraints && propertyName ==
"horizontalSizeConstraint"_L1
2056 && object->inherits(
"QLayout")) {
2057 p->setAttributeName(
"sizeConstraint"_L1);
2059 p->setAttributeName(propertyName);
2061 p->setElementEnum(id);
2062 return applyProperStdSetAttribute(object, propertyName, p);
2066 DomProperty *p = stringToDomProperty(strVal.value(), strVal);
2067 if (!hasSetter(core(), object, propertyName))
2068 p->setAttributeStdset(0);
2070 p->setAttributeName(propertyName);
2072 return applyProperStdSetAttribute(object, propertyName, p);
2076 DomProperty *p =
new DomProperty;
2077 if (!hasSetter(core(), object, propertyName))
2078 p->setAttributeStdset(0);
2080 p->setAttributeName(propertyName);
2082 DomStringList *domStringList =
new DomStringList();
2083 domStringList->setElementString(listValue.value());
2084 translationParametersToDom(listValue, domStringList);
2085 p->setElementStringList(domStringList);
2086 return applyProperStdSetAttribute(object, propertyName, p);
2090 DomProperty *p = stringToDomProperty(keyVal.value().toString(), keyVal);
2091 if (!hasSetter(core(), object, propertyName))
2092 p->setAttributeStdset(0);
2094 p->setAttributeName(propertyName);
2096 return applyProperStdSetAttribute(object, propertyName, p);
2099 return applyProperStdSetAttribute(object, propertyName, QAbstractFormBuilder::createProperty(object, propertyName, value));
2102QStringList
QDesignerResource::mergeWithLoadedPaths(
const QStringList &paths)
const
2104 QStringList newPaths = paths;
2106 const QStringList loadedPaths = m_resourceBuilder->loadedQrcFiles();
2107 std::remove_copy_if(loadedPaths.cbegin(), loadedPaths.cend(),
2108 std::back_inserter(newPaths),
2109 [&newPaths] (
const QString &path) {
return newPaths.contains(path); });
2118 if (resources !=
nullptr) {
2119 const auto &dom_include = resources->elementInclude();
2120 for (DomResource *res : dom_include) {
2121 QString path = QDir::cleanPath(m_formWindow->absoluteDir().absoluteFilePath(res->attributeLocation()));
2122 while (!QFile::exists(path)) {
2123 QWidget *dialogParent = m_formWindow->core()->topLevel();
2124 const QString promptTitle = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"Loading qrc file");
2125 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);
2127 const QMessageBox::StandardButton answer = core()->dialogGui()->message(dialogParent, QDesignerDialogGuiInterface::ResourceLoadFailureMessage,
2128 QMessageBox::Warning, promptTitle, prompt, QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
2129 if (answer == QMessageBox::Yes) {
2130 const QFileInfo fi(path);
2131 const QString fileDialogTitle = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"New location for %1").arg(fi.fileName());
2132 const QString fileDialogPattern = QCoreApplication::translate(
"qdesigner_internal::QDesignerResource",
"Resource files (*.qrc)");
2133 path = core()->dialogGui()->getOpenFileName(dialogParent, fileDialogTitle, fi.absolutePath(), fileDialogPattern);
2136 m_formWindow->setProperty(
"_q_resourcepathchanged", QVariant(
true));
2141 if (!path.isEmpty()) {
2143 m_formWindow->addResourceFile(path);
2149 paths = mergeWithLoadedPaths(paths);
2152 QtResourceSet *resourceSet = m_formWindow->resourceSet();
2154 QStringList newPaths = resourceSet->activeResourceFilePaths();
2155 std::remove_copy_if(paths.cbegin(), paths.cend(),
2156 std::back_inserter(newPaths),
2157 [&newPaths] (
const QString &path) {
return newPaths.contains(path); });
2158 resourceSet->activateResourceFilePaths(newPaths);
2160 resourceSet = m_formWindow
->core()->resourceModel()->addResourceSet(paths);
2161 m_formWindow->setResourceSet(resourceSet);
2162 QObject::connect(m_formWindow->core()->resourceModel(), &QtResourceModel::resourceSetActivated,
2163 m_formWindow, &FormWindowBase::resourceSetActivated);
2170 switch (m_formWindow->resourceFileSaveMode()) {
2171 case QDesignerFormWindowInterface::SaveAllResourceFiles:
2172 paths = m_formWindow->activeResourceFilePaths();
2174 case QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles:
2175 paths = m_resourceBuilder->usedQrcFiles();
2177 case QDesignerFormWindowInterface::DontSaveResourceFiles:
2185 QtResourceSet *resourceSet = m_formWindow->resourceSet();
2186 QList<DomResource *> dom_include;
2188 const QStringList activePaths = resourceSet->activeResourceFilePaths();
2189 for (
const QString &path : activePaths) {
2190 if (qrcPaths.contains(path)) {
2191 DomResource *dom_res =
new DomResource;
2192 QString conv_path = path;
2193 if (m_resourceBuilder->isSaveRelative())
2194 conv_path = m_formWindow->absoluteDir().relativeFilePath(path);
2195 conv_path.replace(QDir::separator(), u'/');
2196 dom_res->setAttributeLocation(conv_path);
2197 dom_include.append(dom_res);
2202 DomResources *dom_resources =
new DomResources;
2203 dom_resources->setElementInclude(dom_include);
2205 return dom_resources;
2218 if (core()->metaDataBase()->item(actionGroup) !=
nullptr) {
2219 return QAbstractFormBuilder::createDom(actionGroup);
2227 if (QAction *action = QAbstractFormBuilder::create(ui_action, parent)) {
2228 core()->metaDataBase()->add(action);
2237 if (QActionGroup *actionGroup = QAbstractFormBuilder::create(ui_action_group, parent)) {
2238 core()->metaDataBase()->add(actionGroup);
2261 if (QAction *action = QAbstractFormBuilder::createAction(parent, name)) {
2262 core()->metaDataBase()->add(action);
2271 if (QActionGroup *actionGroup = QAbstractFormBuilder::createActionGroup(parent, name)) {
2272 core()->metaDataBase()->add(actionGroup);
2280
2283 const DomPropertyList attributes = ui_widget->elementAttribute();
2284 if (attributes.isEmpty())
2287 for (
auto *prop : attributes) {
2288 const QString name = prop->attributeName();
2289 const int index = sheet->indexOf(name);
2291 const QString msg =
"Unable to apply attributive property '%1' to '%2'. It does not exist."_L1.arg(name, widget->objectName());
2292 designerWarning(msg);
2294 sheet->setProperty(index, domPropertyToVariant(
this, widget->metaObject(), prop));
2295 sheet->setChanged(index,
true);
2302 QAbstractFormBuilder::loadExtraInfo(ui_widget, widget, parentWidget);
2304 if (qobject_cast<
const QWizardPage*>(widget))
2305 applyAttributesToPropertySheet(ui_widget, widget);
virtual bool isDynamicProperty(int index) const =0
virtual bool isLanguageResource(const QString &path) const =0
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