diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-07 13:07:33 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-07 16:58:13 +0000 |
commit | 5806781fa95ea6714735a904299f86662d590a68 (patch) | |
tree | f175f94e770d337d353a10aa4dc03bac9b8f42cc | |
parent | 914c7c3fe0dc674c4c23ec83eb2f5be1413c6c9f (diff) | |
download | qttools-5806781fa95ea6714735a904299f86662d590a68.tar.gz |
Qt Designer: Port the subproperty handling to 64bit masks
The QPalette resolve mask type has been changed to 64bit.
Adapt the code accordingly.
Task-number: QTBUG-110963
Change-Id: I9d1a2f20c7b671a0ef1a9182ccb2f8c964b231ab
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit a4551c99697430b173c96462beddc57fa2bd9a14)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
3 files changed, 46 insertions, 36 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index 2544bb8b8..51a0084b8 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -1458,10 +1458,12 @@ public: QDesignerPropertySheetExtension *s, int i) : PropertyHelper(o, sp, s, i) {} - Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) override; + Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, + quint64 subPropertyMask) override; }; -PropertyHelper::Value ArrowKeyPropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) +PropertyHelper::Value ArrowKeyPropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, + bool changed, quint64 subPropertyMask) { // Apply operation to obtain the new geometry value. QWidget *w = qobject_cast<QWidget*>(object()); diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 761024586..91bc9f6ed 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -145,16 +145,16 @@ enum KeySequenceSubPropertyMask { SubPropertyKeySequenceValue = 1, SubPropertyKe SubPropertyKeySequenceTranslatable = 4, SubPropertyKeySequenceDisambiguation = 8, SubPropertyKeySequenceId = 16 }; -enum CommonSubPropertyMask { SubPropertyAll = 0xFFFFFFFF }; +enum CommonSubPropertyMask : quint64 { SubPropertyAll = quint64(-1) }; // Set the mask flag in mask if the properties do not match. #define COMPARE_SUBPROPERTY(object1, object2, getter, mask, maskFlag) \ if (object1.getter() != object2.getter()) (mask) |= (maskFlag); // find changed subproperties of a rectangle -unsigned compareSubProperties(const QRect & r1, const QRect & r2) +quint64 compareSubProperties(const QRect & r1, const QRect & r2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(r1, r2, x, rc, SubPropertyX) COMPARE_SUBPROPERTY(r1, r2, y, rc, SubPropertyY) COMPARE_SUBPROPERTY(r1, r2, width, rc, SubPropertyWidth) @@ -163,17 +163,17 @@ unsigned compareSubProperties(const QRect & r1, const QRect & r2) } // find changed subproperties of a QSize -unsigned compareSubProperties(const QSize & r1, const QSize & r2) +quint64 compareSubProperties(const QSize & r1, const QSize & r2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(r1, r2, width, rc, SubPropertyWidth) COMPARE_SUBPROPERTY(r1, r2, height, rc, SubPropertyHeight) return rc; } // find changed subproperties of a QSizePolicy -unsigned compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) +quint64 compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(sp1, sp2, horizontalPolicy, rc, SubPropertyHSizePolicy) COMPARE_SUBPROPERTY(sp1, sp2, horizontalStretch, rc, SubPropertyHStretch) COMPARE_SUBPROPERTY(sp1, sp2, verticalPolicy, rc, SubPropertyVSizePolicy) @@ -181,9 +181,9 @@ unsigned compareSubProperties(const QSizePolicy & sp1, const QSizePolicy & sp2) return rc; } // find changed subproperties of qdesigner_internal::PropertySheetStringValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringValue & str1, const qdesigner_internal::PropertySheetStringValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetStringValue & str1, const qdesigner_internal::PropertySheetStringValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyStringValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringTranslatable) @@ -192,9 +192,9 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringValue return rc; } // find changed subproperties of qdesigner_internal::PropertySheetStringListValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringListValue & str1, const qdesigner_internal::PropertySheetStringListValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetStringListValue & str1, const qdesigner_internal::PropertySheetStringListValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyStringListValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyStringListComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyStringListTranslatable) @@ -203,9 +203,9 @@ unsigned compareSubProperties(const qdesigner_internal::PropertySheetStringListV return rc; } // find changed subproperties of qdesigner_internal::PropertySheetKeySequenceValue -unsigned compareSubProperties(const qdesigner_internal::PropertySheetKeySequenceValue & str1, const qdesigner_internal::PropertySheetKeySequenceValue & str2) +quint64 compareSubProperties(const qdesigner_internal::PropertySheetKeySequenceValue & str1, const qdesigner_internal::PropertySheetKeySequenceValue & str2) { - unsigned rc = 0; + quint64 rc = 0; COMPARE_SUBPROPERTY(str1, str2, value, rc, SubPropertyKeySequenceValue) COMPARE_SUBPROPERTY(str1, str2, comment, rc, SubPropertyKeySequenceComment) COMPARE_SUBPROPERTY(str1, str2, translatable, rc, SubPropertyKeySequenceTranslatable) @@ -220,8 +220,8 @@ template <class Property> void compareFontSubProperty(const QFont & f1, const QFont & f2, Property (QFont::*getter) () const, - unsigned maskBit, - unsigned &mask) + quint64 maskBit, + quint64 &mask) { const bool f1Changed = f1.resolveMask() & maskBit; const bool f2Changed = f2.resolveMask() & maskBit; @@ -235,9 +235,9 @@ void compareFontSubProperty(const QFont & f1, } } // find changed subproperties of a QFont -unsigned compareSubProperties(const QFont & f1, const QFont & f2) +quint64 compareSubProperties(const QFont & f1, const QFont & f2) { - unsigned rc = 0; + quint64 rc = 0; compareFontSubProperty(f1, f2, &QFont::family, QFontFamiliesResolved, rc); compareFontSubProperty(f1, f2, &QFont::pointSize, QFont::SizeResolved, rc); compareFontSubProperty(f1, f2, &QFont::bold, QFont::WeightResolved, rc); @@ -262,9 +262,9 @@ bool roleColorChanged(const QPalette & p1, const QPalette & p2, QPalette::ColorR return false; } // find changed subproperties of a QPalette taking the [undocumented] resolve flags into account -unsigned compareSubProperties(const QPalette & p1, const QPalette & p2) +quint64 compareSubProperties(const QPalette & p1, const QPalette & p2) { - unsigned rc = 0; + quint64 rc = 0; unsigned maskBit = 1u; // generate a mask for each role const unsigned p1Changed = p1.resolveMask(); @@ -286,9 +286,9 @@ unsigned compareSubProperties(const QPalette & p1, const QPalette & p2) // find changed subproperties of a QAlignment which is a flag combination of vertical and horizontal -unsigned compareSubProperties(Qt::Alignment a1, Qt::Alignment a2) +quint64 compareSubProperties(Qt::Alignment a1, Qt::Alignment a2) { - unsigned rc = 0; + quint64 rc = 0; if ((a1 & Qt::AlignHorizontal_Mask) != (a2 & Qt::AlignHorizontal_Mask)) rc |= SubPropertyHorizontalAlignment; if ((a1 & Qt::AlignVertical_Mask) != (a2 & Qt::AlignVertical_Mask)) @@ -301,7 +301,7 @@ Qt::Alignment variantToAlignment(const QVariant & q) return Qt::Alignment(qdesigner_internal::Utils::valueOf(q)); } // find changed subproperties of a variant -unsigned compareSubProperties(const QVariant & q1, const QVariant & q2, qdesigner_internal::SpecialProperty specialProperty) +quint64 compareSubProperties(const QVariant & q1, const QVariant & q2, qdesigner_internal::SpecialProperty specialProperty) { // Do not clobber new value in the comparison function in // case someone sets a QString on a PropertySheetStringValue. @@ -459,7 +459,8 @@ QFont applyFontSubProperty(const QFont &oldValue, const QFont &newValue, unsigne } // apply changed subproperties to a QPalette -QPalette applyPaletteSubProperty(const QPalette &oldValue, const QPalette &newValue, unsigned mask) +QPalette applyPaletteSubProperty(const QPalette &oldValue, const QPalette &newValue, + quint64 mask) { QPalette rc = oldValue; // apply a mask for each role @@ -501,7 +502,9 @@ Qt::Alignment applyAlignmentSubProperty(Qt::Alignment oldValue, Qt::Alignment ne namespace qdesigner_internal { // apply changed subproperties to a variant -PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant &newValue, qdesigner_internal::SpecialProperty specialProperty, unsigned mask, bool changed) +PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant &newValue, + qdesigner_internal::SpecialProperty specialProperty, + quint64 mask, bool changed) { if (mask == SubPropertyAll) return PropertyHelper::Value(newValue, changed); @@ -809,7 +812,8 @@ void PropertyHelper::ensureUniqueObjectName(QDesignerFormWindowInterface *fw, QO } } -PropertyHelper::Value PropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) +PropertyHelper::Value PropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, + bool changed, quint64 subPropertyMask) { // Set new whole value if (subPropertyMask == SubPropertyAll) @@ -1030,17 +1034,20 @@ void PropertyListCommand::setOldValue(const QVariant &oldValue, int index) // ----- SetValueFunction: Set a new value when applied to a PropertyHelper. class SetValueFunction { public: - SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, unsigned subPropertyMask); + SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, + quint64 subPropertyMask); PropertyHelper::Value operator()(PropertyHelper&); private: QDesignerFormWindowInterface *m_formWindow; const PropertyHelper::Value m_newValue; - const unsigned m_subPropertyMask; + const quint64 m_subPropertyMask; }; -SetValueFunction::SetValueFunction(QDesignerFormWindowInterface *formWindow, const PropertyHelper::Value &newValue, unsigned subPropertyMask) : +SetValueFunction::SetValueFunction(QDesignerFormWindowInterface *formWindow, + const PropertyHelper::Value &newValue, + quint64 subPropertyMask) : m_formWindow(formWindow), m_newValue(newValue), m_subPropertyMask(subPropertyMask) @@ -1102,7 +1109,7 @@ template <class PropertyListIterator, class Function> // set a new value, return update mask -unsigned PropertyListCommand::setValue(const QVariant &value, bool changed, unsigned subPropertyMask) +unsigned PropertyListCommand::setValue(const QVariant &value, bool changed, quint64 subPropertyMask) { if(debugPropertyCommands) qDebug() << "PropertyListCommand::setValue(" << value @@ -1215,7 +1222,7 @@ bool SetPropertyCommand::init(const QObjectList &list, const QString &apropertyN return true; } -unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *referenceObject) +quint64 SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *referenceObject) { // figure out the mask of changed sub properties when comparing newValue to the current value of the reference object. if (!referenceObject) diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h index a1399dd7b..de5ea31b1 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h +++ b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h @@ -62,7 +62,8 @@ public: SpecialProperty specialProperty() const { return m_specialProperty; } // set a new value. Can be overwritten to perform a transformation (see // handling of Arrow key move in FormWindow class). - virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, + bool changed, quint64 subPropertyMask); // restore old value Value restoreOldValue(QDesignerFormWindowInterface *fw); @@ -133,7 +134,7 @@ protected: bool initList(const QObjectList &list, const QString &apropertyName, QObject *referenceObject = nullptr); // set a new value, return update mask - unsigned setValue(const QVariant &value, bool changed, unsigned subPropertyMask); + unsigned setValue(const QVariant &value, bool changed, quint64 subPropertyMask); // restore old value, return update mask unsigned restoreOldValue(); @@ -204,10 +205,10 @@ protected: virtual QVariant mergeValue(const QVariant &newValue); private: - unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject); + quint64 subPropertyMask(const QVariant &newValue, QObject *referenceObject); void setDescription(); QVariant m_newValue; - unsigned m_subPropertyMask; + quint64 m_subPropertyMask; }; class QDESIGNER_SHARED_EXPORT ResetPropertyCommand: public PropertyListCommand |