diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-18 09:53:21 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-18 08:34:37 +0000 |
commit | 85624e87256005a2560a658722da5c982c8374ad (patch) | |
tree | 3cbf263ea6959e8292ad036df60fa234fc052c12 | |
parent | f63d6afdc3d172c68bd88fd35e1a1cddf4379a6c (diff) |
Qt Designer: Support id-based translations
- Introduce a per-string id attribute and a global
attribute indicating whether the form uses ids.
- Introduce a new "id" subproperty in the property editor
which is used depending on the form setting.
- Add a settings to the form settings dialog.
[ChangeLog][Qt Designer] Qt Designer now supports id-based translations.
Task-number: QTBUG-34610
Change-Id: I9b0aa36fba0543960212a257e6aa2d9c23ab84c5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
14 files changed, 196 insertions, 29 deletions
diff --git a/src/designer/data/ui4.xsd b/src/designer/data/ui4.xsd index 8c4576ea6..8448a62b4 100644 --- a/src/designer/data/ui4.xsd +++ b/src/designer/data/ui4.xsd @@ -26,6 +26,7 @@ <xs:attribute name="version" type="xs:string" /> <xs:attribute name="language" type="xs:string" /> <xs:attribute name="displayname" type="xs:string" /> + <xs:attribute name="idbasedtr" type="xs:boolean" /> <!-- Legacy attribute generated by uic3 --> <xs:attribute name="stdsetdef" type="xs:integer" /> <!-- Legacy attribute generated by the VS integration --> @@ -380,6 +381,7 @@ <xs:attribute name="notr" type="xs:string" /> <xs:attribute name="comment" type="xs:string" /> <xs:attribute name="extracomment" type="xs:string" /> + <xs:attribute name="id" type="xs:string" /> <xs:sequence> <xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> @@ -409,6 +411,7 @@ <xs:attribute name="notr" type="xs:string" /> <xs:attribute name="comment" type="xs:string" /> <xs:attribute name="extracomment" type="xs:string" /> + <xs:attribute name="id" type="xs:string" /> </xs:complexType> <xs:complexType name="PointF"> diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index 96f86d169..94c79ae3c 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -66,6 +66,7 @@ struct FormWindowData { bool hasFormGrid{false}; Grid grid; + bool idBasedTranslations{false}; }; inline bool operator==(const FormWindowData &fd1, const FormWindowData &fd2) { return fd1.equals(fd2); } @@ -77,7 +78,9 @@ QDebug operator<<(QDebug str, const FormWindowData &d) << ',' << d.defaultSpacing << " LayoutFunctions=" << d.layoutFunctionsEnabled << ',' << d.marginFunction << ',' << d.spacingFunction << " PixFunction=" << d.pixFunction << " Author=" << d.author << " Hints=" << d.includeHints - << " Grid=" << d.hasFormGrid << d.grid.deltaX() << d.grid.deltaY() << '\n'; + << " Grid=" << d.hasFormGrid << d.grid.deltaX() << d.grid.deltaY() + << " ID-based translations" << d.idBasedTranslations + << '\n'; return str; } @@ -93,7 +96,8 @@ bool FormWindowData::equals(const FormWindowData &rhs) const author == rhs.author && includeHints == rhs.includeHints && hasFormGrid == rhs.hasFormGrid && - grid == rhs.grid; + grid == rhs.grid && + idBasedTranslations == rhs.idBasedTranslations; } void FormWindowData::fromFormWindow(FormWindowBase* fw) @@ -123,6 +127,7 @@ void FormWindowData::fromFormWindow(FormWindowBase* fw) hasFormGrid = fw->hasFormGrid(); grid = hasFormGrid ? fw->designerGrid() : FormWindowBase::defaultDesignerGrid(); + idBasedTranslations = fw->useIdBasedTranslations(); } void FormWindowData::applyToFormWindow(FormWindowBase* fw) const @@ -148,6 +153,7 @@ void FormWindowData::applyToFormWindow(FormWindowBase* fw) const fw->setHasFormGrid(hasFormGrid); if (hasFormGrid || hadFormGrid != hasFormGrid) fw->setDesignerGrid(hasFormGrid ? grid : FormWindowBase::defaultDesignerGrid()); + fw->setUseIdBasedTranslations(idBasedTranslations); } // -------------------------- FormWindowSettings @@ -213,6 +219,7 @@ FormWindowData FormWindowSettings::data() const rc.hasFormGrid = m_ui->gridPanel->isChecked(); rc.grid = m_ui->gridPanel->grid(); + rc.idBasedTranslations = m_ui->idBasedTranslationsCheckBox->isChecked(); return rc; } @@ -239,6 +246,7 @@ void FormWindowSettings::setData(const FormWindowData &data) m_ui->gridPanel->setChecked(data.hasFormGrid); m_ui->gridPanel->setGrid(data.grid); + m_ui->idBasedTranslationsCheckBox->setChecked(data.idBasedTranslations); } void FormWindowSettings::accept() diff --git a/src/designer/src/components/formeditor/formwindowsettings.ui b/src/designer/src/components/formeditor/formwindowsettings.ui index 0aa0c7279..6bb092078 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.ui +++ b/src/designer/src/components/formeditor/formwindowsettings.ui @@ -170,20 +170,7 @@ </item> </layout> </item> - <item row="5" column="1"> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>111</width> - <height>115</height> - </size> - </property> - </spacer> - </item> - <item row="7" column="0" colspan="2"> + <item row="8" column="0" colspan="2"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -193,14 +180,14 @@ </property> </widget> </item> - <item row="6" column="0" colspan="2"> + <item row="7" column="0" colspan="2"> <widget class="Line" name="line"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="4" column="0" rowspan="2"> + <item row="4" column="0" rowspan="3"> <widget class="QGroupBox" name="includeHintsGroupBox"> <property name="title"> <string>&Include Hints</string> @@ -259,6 +246,35 @@ </layout> </widget> </item> + <item row="5" column="1"> + <widget class="QGroupBox" name="translationsGroupBox"> + <property name="title"> + <string>Translations</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="idBasedTranslationsCheckBox"> + <property name="text"> + <string>ID-based</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="6" column="1"> + <spacer> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>111</width> + <height>115</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <customwidgets> diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 4da1e7b4c..bd6a3aa52 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -338,6 +338,9 @@ inline void translationParametersToDom(const PropertySheetTranslatableData &data const QString propertyExtracomment = data.comment(); if (!propertyExtracomment.isEmpty()) e->setAttributeExtraComment(propertyExtracomment); + const QString &id = data.id(); + if (!id.isEmpty()) + e->setAttributeId(id); if (!data.translatable()) e->setAttributeNotr(QStringLiteral("true")); } @@ -349,6 +352,8 @@ inline void translationParametersFromDom(const DomElement *e, PropertySheetTrans data->setDisambiguation(e->attributeComment()); if (e->hasAttributeExtraComment()) data->setComment(e->attributeExtraComment()); + if (e->hasAttributeId()) + data->setId(e->attributeId()); if (e->hasAttributeNotr()) { const QString notr = e->attributeNotr(); const bool translatable = !(notr == QStringLiteral("true") || notr == QStringLiteral("yes")); @@ -502,6 +507,8 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) ui->setElementExportMacro(exportMacro); } + ui->setAttributeIdbasedtr(m_formWindow->useIdBasedTranslations()); + const QVariantMap designerFormData = m_formWindow->formData(); if (!designerFormData.empty()) { DomPropertyList domPropertyList; @@ -626,6 +633,9 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) QDesignerWidgetItemInstaller wii; // Make sure we use QDesignerWidgetItem. QWidget *mainWidget = QAbstractFormBuilder::create(ui, parentWidget); + if (m_formWindow) + m_formWindow->setUseIdBasedTranslations(ui->attributeIdbasedtr()); + if (mainWidget && m_formWindow) { m_formWindow->setAuthor(ui->elementAuthor()); m_formWindow->setComment(ui->elementComment()); diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index e4efb8959..8edd361da 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -109,17 +109,27 @@ void TranslatablePropertyManager<PropertySheetValue>::initialize(QtVariantProper m_translatableToValue.insert(translatable, property); property->addSubProperty(translatable); - QtVariantProperty *disambiguation = m->addProperty(QVariant::String, DesignerPropertyManager::tr("disambiguation")); - disambiguation->setValue(value.disambiguation()); - m_valueToDisambiguation.insert(property, disambiguation); - m_disambiguationToValue.insert(disambiguation, property); - property->addSubProperty(disambiguation); + if (!DesignerPropertyManager::useIdBasedTranslations()) { + QtVariantProperty *disambiguation = m->addProperty(QVariant::String, DesignerPropertyManager::tr("disambiguation")); + disambiguation->setValue(value.disambiguation()); + m_valueToDisambiguation.insert(property, disambiguation); + m_disambiguationToValue.insert(disambiguation, property); + property->addSubProperty(disambiguation); + } QtVariantProperty *comment = m->addProperty(QVariant::String, DesignerPropertyManager::tr("comment")); comment->setValue(value.comment()); m_valueToComment.insert(property, comment); m_commentToValue.insert(comment, property); property->addSubProperty(comment); + + if (DesignerPropertyManager::useIdBasedTranslations()) { + QtVariantProperty *id = m->addProperty(QVariant::String, DesignerPropertyManager::tr("id")); + id->setValue(value.id()); + m_valueToId.insert(property, id); + m_idToValue.insert(id, property); + property->addSubProperty(id); + } } template <class PropertySheetValue> @@ -139,10 +149,16 @@ bool TranslatablePropertyManager<PropertySheetValue>::uninitialize(QtProperty *p delete disambiguation; m_disambiguationToValue.remove(disambiguation); } + if (QtProperty *id = m_valueToId.value(property)) { + delete id; + m_idToValue.remove(id); + } + m_values.remove(property); m_valueToComment.remove(property); m_valueToTranslatable.remove(property); m_valueToDisambiguation.remove(property); + m_valueToId.remove(property); return true; } @@ -167,6 +183,12 @@ bool TranslatablePropertyManager<PropertySheetValue>::destroy(QtProperty *subPro m_disambiguationToValue.erase(disambiguationToValueIt); return true; } + const auto idToValueIt = m_idToValue.find(subProperty); + if (idToValueIt != m_idToValue.end()) { + m_valueToId.remove(idToValueIt.value()); + m_idToValue.erase(idToValueIt); + return true; + } return false; } @@ -205,6 +227,16 @@ int TranslatablePropertyManager<PropertySheetValue>::valueChanged(QtVariantPrope } return DesignerPropertyManager::Unchanged; } + if (QtProperty *property = m_idToValue.value(propertyIn)) { + const PropertySheetValue oldValue = m_values.value(property); + PropertySheetValue newValue = oldValue; + newValue.setId(value.toString()); + if (newValue != oldValue) { + m->variantProperty(property)->setValue(QVariant::fromValue(newValue)); + return DesignerPropertyManager::Changed; + } + return DesignerPropertyManager::Unchanged; + } return DesignerPropertyManager::NoMatch; } @@ -228,6 +260,8 @@ int TranslatablePropertyManager<PropertySheetValue>::setValue(QtVariantPropertyM translatable->setValue(value.translatable()); if (QtVariantProperty *disambiguation = m->variantProperty(m_valueToDisambiguation.value(property))) disambiguation->setValue(value.disambiguation()); + if (QtVariantProperty *id = m->variantProperty(m_valueToId.value(property))) + id->setValue(value.id()); it.value() = value; return DesignerPropertyManager::Changed; } @@ -876,6 +910,8 @@ DesignerPropertyManager::~DesignerPropertyManager() clear(); } +bool DesignerPropertyManager::m_IdBasedTranslations = false; + int DesignerPropertyManager::bitCount(int mask) const { int count = 0; diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.h b/src/designer/src/components/propertyeditor/designerpropertymanager.h index caacee0fc..0aa220d56 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.h +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.h @@ -108,10 +108,12 @@ private: QHash<QtProperty *, QtProperty *> m_valueToComment; QHash<QtProperty *, QtProperty *> m_valueToTranslatable; QHash<QtProperty *, QtProperty *> m_valueToDisambiguation; + QHash<QtProperty *, QtProperty *> m_valueToId; QHash<QtProperty *, QtProperty *> m_commentToValue; QHash<QtProperty *, QtProperty *> m_translatableToValue; QHash<QtProperty *, QtProperty *> m_disambiguationToValue; + QHash<QtProperty *, QtProperty *> m_idToValue; }; class DesignerPropertyManager : public QtVariantPropertyManager @@ -149,6 +151,11 @@ public: void setObject(QObject *object) { m_object = object; } + static void setUseIdBasedTranslations(bool v) + { m_IdBasedTranslations = v; } + static bool useIdBasedTranslations() + { return m_IdBasedTranslations; } + public Q_SLOTS: void setAttribute(QtProperty *property, const QString &attribute, const QVariant &value) override; void setValue(QtProperty *property, const QVariant &value) override; @@ -238,6 +245,7 @@ private: QObject *m_object; QtProperty *m_sourceOfChange; + static bool m_IdBasedTranslations; }; class DesignerEditorFactory : public QtVariantEditorFactory diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index 16ea1f7b6..2fc1ff415 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -912,6 +912,9 @@ void PropertyEditor::setObject(QObject *object) m_propertyManager->setObject(object); QDesignerFormWindowInterface *formWindow = QDesignerFormWindowInterface::findFormWindow(m_object); FormWindowBase *fwb = qobject_cast<FormWindowBase *>(formWindow); + const bool idIdBasedTranslation = fwb && fwb->useIdBasedTranslations(); + const bool idIdBasedTranslationUnchanged = (idIdBasedTranslation == DesignerPropertyManager::useIdBasedTranslations()); + DesignerPropertyManager::setUseIdBasedTranslations(idIdBasedTranslation); m_treeFactory->setFormWindowBase(fwb); m_groupFactory->setFormWindowBase(fwb); @@ -933,6 +936,7 @@ void PropertyEditor::setObject(QObject *object) m_propertySheet = qobject_cast<QDesignerPropertySheetExtension*>(m->extension(object, Q_TYPEID(QDesignerPropertySheetExtension))); if (m_propertySheet) { + const int stringTypeId = qMetaTypeId<PropertySheetStringValue>(); const int propertyCount = m_propertySheet->count(); for (int i = 0; i < propertyCount; ++i) { if (!m_propertySheet->isVisible(i)) @@ -945,8 +949,14 @@ void PropertyEditor::setObject(QObject *object) const QMap<QString, QtVariantProperty *>::const_iterator rit = toRemove.constFind(propertyName); if (rit != toRemove.constEnd()) { QtVariantProperty *property = rit.value(); - if (m_propertyToGroup.value(property) == groupName && toBrowserType(m_propertySheet->property(i), propertyName) == property->propertyType()) + const int propertyType = property->propertyType(); + // Also remove string properties in case a change in translation mode + // occurred since different sub-properties are used (disambiguation/id). + if (m_propertyToGroup.value(property) == groupName + && (idIdBasedTranslationUnchanged || propertyType != stringTypeId) + && toBrowserType(m_propertySheet->property(i), propertyName) == propertyType) { toRemove.remove(propertyName); + } } } } diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index ad1dc792e..985d82b99 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -83,6 +83,7 @@ public: const DeviceProfile m_deviceProfile; FormWindowBase::LineTerminatorMode m_lineTerminatorMode; FormWindowBase::ResourceFileSaveMode m_saveResourcesBehaviour; + bool m_useIdBasedTranslations; }; FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) : @@ -94,7 +95,8 @@ FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) m_resourceSet(0), m_deviceProfile(QDesignerSharedSettings(core).currentDeviceProfile()), m_lineTerminatorMode(FormWindowBase::NativeLineTerminator), - m_saveResourcesBehaviour(FormWindowBase::SaveAllResourceFiles) + m_saveResourcesBehaviour(FormWindowBase::SaveAllResourceFiles), + m_useIdBasedTranslations(false) { } @@ -526,6 +528,16 @@ void FormWindowBase::triggerDefaultAction(QWidget *widget) QTimer::singleShot(0, action, &QAction::trigger); } +bool FormWindowBase::useIdBasedTranslations() const +{ + return m_d->m_useIdBasedTranslations; +} + +void FormWindowBase::setUseIdBasedTranslations(bool v) +{ + m_d->m_useIdBasedTranslations = v; +} + QStringList FormWindowBase::checkContents() const { if (!mainContainer()) diff --git a/src/designer/src/lib/shared/formwindowbase_p.h b/src/designer/src/lib/shared/formwindowbase_p.h index 55fe299af..a206664f5 100644 --- a/src/designer/src/lib/shared/formwindowbase_p.h +++ b/src/designer/src/lib/shared/formwindowbase_p.h @@ -161,6 +161,9 @@ public: void setLineTerminatorMode(LineTerminatorMode mode); LineTerminatorMode lineTerminatorMode() const; + bool useIdBasedTranslations() const; + void setUseIdBasedTranslations(bool v); + public slots: void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged); diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 6c7417f81..43da500ad 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -156,9 +156,15 @@ void checkSizes(QDesignerFormWindowInterface *fw, const QSize &size, QSize *form enum RectSubPropertyMask { SubPropertyX=1, SubPropertyY = 2, SubPropertyWidth = 4, SubPropertyHeight = 8 }; enum SizePolicySubPropertyMask { SubPropertyHSizePolicy = 1, SubPropertyHStretch = 2, SubPropertyVSizePolicy = 4, SubPropertyVStretch = 8 }; enum AlignmentSubPropertyMask { SubPropertyHorizontalAlignment = 1, SubPropertyVerticalAlignment = 2 }; -enum StringSubPropertyMask { SubPropertyStringValue = 1, SubPropertyStringComment = 2, SubPropertyStringTranslatable = 4, SubPropertyStringDisambiguation = 8 }; -enum StringListSubPropertyMask { SubPropertyStringListValue = 1, SubPropertyStringListComment = 2, SubPropertyStringListTranslatable = 4, SubPropertyStringListDisambiguation = 8 }; -enum KeySequenceSubPropertyMask { SubPropertyKeySequenceValue = 1, SubPropertyKeySequenceComment = 2, SubPropertyKeySequenceTranslatable = 4, SubPropertyKeySequenceDisambiguation = 8 }; +enum StringSubPropertyMask { SubPropertyStringValue = 1, SubPropertyStringComment = 2, + SubPropertyStringTranslatable = 4, SubPropertyStringDisambiguation = 8, + SubPropertyStringId = 16 }; +enum StringListSubPropertyMask { SubPropertyStringListValue = 1, SubPropertyStringListComment = 2, + SubPropertyStringListTranslatable = 4, SubPropertyStringListDisambiguation = 8, + SubPropertyStringListId = 16 }; +enum KeySequenceSubPropertyMask { SubPropertyKeySequenceValue = 1, SubPropertyKeySequenceComment = 2, + SubPropertyKeySequenceTranslatable = 4, SubPropertyKeySequenceDisambiguation = 8, + SubPropertyKeySequenceId = 16 }; enum CommonSubPropertyMask { SubPropertyAll = 0xFFFFFFFF }; @@ -202,6 +208,7 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringValue COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringTranslatable) COMPARE_SUBPROPERTY(str1, str2, disambiguation, rc, SubPropertyStringDisambiguation) + COMPARE_SUBPROPERTY(str1, str2, id, rc, SubPropertyStringId) return rc; } // find changed subproperties of qdesigner_internal::PropertySheetStringListValue @@ -212,6 +219,7 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringListV COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringListComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringListTranslatable) COMPARE_SUBPROPERTY(str1, str2, disambiguation, rc, SubPropertyStringListDisambiguation) + COMPARE_SUBPROPERTY(str1, str2, id, rc, SubPropertyStringListId) return rc; } // find changed subproperties of qdesigner_internal::PropertySheetKeySequenceValue @@ -222,6 +230,7 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetKeySequence COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyKeySequenceComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyKeySequenceTranslatable) COMPARE_SUBPROPERTY(str1, str2, disambiguation, rc, SubPropertyKeySequenceDisambiguation) + COMPARE_SUBPROPERTY(str1, str2, id, rc, SubPropertyKeySequenceId) return rc; } @@ -395,6 +404,7 @@ qdesigner_internal::PropertySheetStringValue applyStringSubProperty(const qdesig SET_SUBPROPERTY(rc, newValue, comment, setComment, mask, SubPropertyStringComment) SET_SUBPROPERTY(rc, newValue, translatable, setTranslatable, mask, SubPropertyStringTranslatable) SET_SUBPROPERTY(rc, newValue, disambiguation, setDisambiguation, mask, SubPropertyStringDisambiguation) + SET_SUBPROPERTY(rc, newValue, id, setId, mask, SubPropertyStringId) return rc; } @@ -407,6 +417,7 @@ qdesigner_internal::PropertySheetStringListValue applyStringListSubProperty(cons SET_SUBPROPERTY(rc, newValue, comment, setComment, mask, SubPropertyStringListComment) SET_SUBPROPERTY(rc, newValue, translatable, setTranslatable, mask, SubPropertyStringListTranslatable) SET_SUBPROPERTY(rc, newValue, disambiguation, setDisambiguation, mask, SubPropertyStringListDisambiguation) + SET_SUBPROPERTY(rc, newValue, id, setId, mask, SubPropertyStringListId) return rc; } @@ -419,6 +430,7 @@ qdesigner_internal::PropertySheetKeySequenceValue applyKeySequenceSubProperty(co SET_SUBPROPERTY(rc, newValue, comment, setComment, mask, SubPropertyKeySequenceComment) SET_SUBPROPERTY(rc, newValue, translatable, setTranslatable, mask, SubPropertyKeySequenceTranslatable) SET_SUBPROPERTY(rc, newValue, disambiguation, setDisambiguation, mask, SubPropertyKeySequenceDisambiguation) + SET_SUBPROPERTY(rc, newValue, id, setId, mask, SubPropertyKeySequenceId) return rc; } diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index fc0e203a0..27144f4e7 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -456,7 +456,8 @@ namespace qdesigner_internal { return m_translatable == rhs.m_translatable && m_disambiguation == rhs.m_disambiguation - && m_comment == rhs.m_comment; + && m_comment == rhs.m_comment + && m_id == rhs.m_id; } PropertySheetStringValue::PropertySheetStringValue(const QString &value, diff --git a/src/designer/src/lib/shared/qdesigner_utils_p.h b/src/designer/src/lib/shared/qdesigner_utils_p.h index af2fd5246..41e84fe6e 100644 --- a/src/designer/src/lib/shared/qdesigner_utils_p.h +++ b/src/designer/src/lib/shared/qdesigner_utils_p.h @@ -330,11 +330,14 @@ public: void setDisambiguation(const QString &d) { m_disambiguation = d; } QString comment() const { return m_comment; } void setComment(const QString &comment) { m_comment = comment; } + QString id() const { return m_id; } + void setId(const QString &id) { m_id = id; } private: bool m_translatable; QString m_disambiguation; QString m_comment; + QString m_id; }; // -------------- StringValue: Returned by the property sheet for strings diff --git a/src/designer/src/lib/uilib/ui4.cpp b/src/designer/src/lib/uilib/ui4.cpp index d0ce3e5d6..abadaf95f 100644 --- a/src/designer/src/lib/uilib/ui4.cpp +++ b/src/designer/src/lib/uilib/ui4.cpp @@ -83,6 +83,10 @@ void DomUI::read(QXmlStreamReader &reader) setAttributeDisplayname(attribute.value().toString()); continue; } + if (name == QLatin1String("idbasedtr")) { + setAttributeIdbasedtr(attribute.value() == QLatin1String("true")); + continue; + } if (name == QLatin1String("stdsetdef")) { setAttributeStdsetdef(attribute.value().toInt()); continue; @@ -213,6 +217,9 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeDisplayname()) writer.writeAttribute(QStringLiteral("displayname"), attributeDisplayname()); + if (hasAttributeIdbasedtr()) + writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeStdsetdef()) writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef())); @@ -4038,6 +4045,10 @@ void DomStringList::read(QXmlStreamReader &reader) setAttributeExtraComment(attribute.value().toString()); continue; } + if (name == QLatin1String("id")) { + setAttributeId(attribute.value().toString()); + continue; + } reader.raiseError(QLatin1String("Unexpected attribute ") + name); } @@ -4073,6 +4084,9 @@ void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeExtraComment()) writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment()); + if (hasAttributeId()) + writer.writeAttribute(QStringLiteral("id"), attributeId()); + for (const QString &v : m_string) writer.writeTextElement(QStringLiteral("string"), v); @@ -4472,6 +4486,10 @@ void DomString::read(QXmlStreamReader &reader) setAttributeExtraComment(attribute.value().toString()); continue; } + if (name == QLatin1String("id")) { + setAttributeId(attribute.value().toString()); + continue; + } reader.raiseError(QLatin1String("Unexpected attribute ") + name); } @@ -4507,6 +4525,9 @@ void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeExtraComment()) writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment()); + if (hasAttributeId()) + writer.writeAttribute(QStringLiteral("id"), attributeId()); + if (!m_text.isEmpty()) writer.writeCharacters(m_text); diff --git a/src/designer/src/lib/uilib/ui4_p.h b/src/designer/src/lib/uilib/ui4_p.h index e1fd2fb8e..4b1da2e53 100644 --- a/src/designer/src/lib/uilib/ui4_p.h +++ b/src/designer/src/lib/uilib/ui4_p.h @@ -175,6 +175,11 @@ public: inline void setAttributeDisplayname(const QString &a) { m_attr_displayname = a; m_has_attr_displayname = true; } inline void clearAttributeDisplayname() { m_has_attr_displayname = false; } + inline bool hasAttributeIdbasedtr() const { return m_has_attr_idbasedtr; } + inline bool attributeIdbasedtr() const { return m_attr_idbasedtr; } + inline void setAttributeIdbasedtr(bool a) { m_attr_idbasedtr = a; m_has_attr_idbasedtr = true; } + inline void clearAttributeIdbasedtr() { m_has_attr_idbasedtr = false; } + inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } inline int attributeStdsetdef() const { return m_attr_stdsetdef; } inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; } @@ -288,6 +293,9 @@ private: QString m_attr_displayname; bool m_has_attr_displayname = false; + bool m_attr_idbasedtr = false; + bool m_has_attr_idbasedtr = false; + int m_attr_stdsetdef = 0; bool m_has_attr_stdsetdef = false; @@ -2067,6 +2075,11 @@ public: inline void setAttributeExtraComment(const QString &a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } inline void clearAttributeExtraComment() { m_has_attr_extraComment = false; } + inline bool hasAttributeId() const { return m_has_attr_id; } + inline QString attributeId() const { return m_attr_id; } + inline void setAttributeId(const QString &a) { m_attr_id = a; m_has_attr_id = true; } + inline void clearAttributeId() { m_has_attr_id = false; } + // child element accessors inline QStringList elementString() const { return m_string; } void setElementString(const QStringList &a); @@ -2082,6 +2095,9 @@ private: QString m_attr_extraComment; bool m_has_attr_extraComment = false; + QString m_attr_id; + bool m_has_attr_id = false; + // child element data uint m_children = 0; QStringList m_string; @@ -2258,6 +2274,11 @@ public: inline void setAttributeExtraComment(const QString &a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } inline void clearAttributeExtraComment() { m_has_attr_extraComment = false; } + inline bool hasAttributeId() const { return m_has_attr_id; } + inline QString attributeId() const { return m_attr_id; } + inline void setAttributeId(const QString &a) { m_attr_id = a; m_has_attr_id = true; } + inline void clearAttributeId() { m_has_attr_id = false; } + private: QString m_text; @@ -2270,6 +2291,9 @@ private: QString m_attr_extraComment; bool m_has_attr_extraComment = false; + + QString m_attr_id; + bool m_has_attr_id = false; }; class QDESIGNER_UILIB_EXPORT DomPointF { |