diff options
Diffstat (limited to 'src/designer/src/components/propertyeditor')
3 files changed, 38 insertions, 0 deletions
diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index 27d265696..ecbc5be4a 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -1151,6 +1151,7 @@ void DesignerPropertyManager::slotPropertyDestroyed(QtProperty *property) m_fontManager.slotPropertyDestroyed(property); m_brushManager.slotPropertyDestroyed(property); } + m_alignDefault.remove(property); } QStringList DesignerPropertyManager::attributes(int propertyType) const @@ -1255,6 +1256,12 @@ QVariant DesignerPropertyManager::attributeValue(const QtProperty *property, con return itIcon.value(); } + if (attribute == alignDefaultAttribute()) { + Qt::Alignment v = m_alignDefault.value(property, + Qt::Alignment(Qt::AlignLeading | Qt::AlignHCenter)); + return QVariant(uint(v)); + } + return QtVariantPropertyManager::attributeValue(property, attribute); } @@ -1430,6 +1437,8 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, emit attributeChanged(property, attribute, v); emit propertyChanged(property); + } else if (attribute == alignDefaultAttribute()) { + m_alignDefault[property] = Qt::Alignment(value.toUInt()); } QtVariantPropertyManager::setAttribute(property, attribute, value); } @@ -1477,6 +1486,16 @@ int DesignerPropertyManager::designerKeySequenceTypeId() return qMetaTypeId<PropertySheetKeySequenceValue>(); } +QString DesignerPropertyManager::alignDefaultAttribute() +{ + return QStringLiteral("alignDefault"); +} + +uint DesignerPropertyManager::alignDefault(const QtVariantProperty *prop) +{ + return prop->attributeValue(DesignerPropertyManager::alignDefaultAttribute()).toUInt(); +} + bool DesignerPropertyManager::isPropertyTypeSupported(int propertyType) const { switch (propertyType) { @@ -2184,6 +2203,16 @@ void DesignerPropertyManager::uninitializeProperty(QtProperty *property) QtVariantPropertyManager::uninitializeProperty(property); } +bool DesignerPropertyManager::resetTextAlignmentProperty(QtProperty *property) +{ + const auto it = m_alignDefault.constFind(property); + if (it == m_alignDefault.cend()) + return false; + QtVariantProperty *alignProperty = variantProperty(property); + alignProperty->setValue(DesignerPropertyManager::alignDefault(alignProperty)); + alignProperty->setModified(false); + return true; +} bool DesignerPropertyManager::resetFontSubProperty(QtProperty *property) { diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.h b/src/designer/src/components/propertyeditor/designerpropertymanager.h index abc6e385c..c3f55942a 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.h +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.h @@ -135,6 +135,7 @@ public: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; + bool resetTextAlignmentProperty(QtProperty *property); bool resetFontSubProperty(QtProperty *property); bool resetIconSubProperty(QtProperty *subProperty); @@ -156,6 +157,10 @@ public: static bool useIdBasedTranslations() { return m_IdBasedTranslations; } + static QString alignDefaultAttribute(); + + static uint alignDefault(const QtVariantProperty *prop); + public Q_SLOTS: void setAttribute(QtProperty *property, const QString &attribute, const QVariant &value) override; void setValue(QtProperty *property, const QVariant &value) override; @@ -200,6 +205,7 @@ private: PropertyToPropertyMap m_propertyToAlignV; PropertyToPropertyMap m_alignHToProperty; PropertyToPropertyMap m_alignVToProperty; + QHash<const QtProperty *, Qt::Alignment> m_alignDefault; QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> > m_propertyToIconSubProperties; QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> > m_iconSubPropertyToState; diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index 392f1c3f5..48a4120a9 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -1187,6 +1187,9 @@ void PropertyEditor::slotResetProperty(QtProperty *property) if (m_propertyManager->resetIconSubProperty(property)) return; + if (m_propertyManager->resetTextAlignmentProperty(property)) + return; + if (!m_propertyToGroup.contains(property)) return; |