diff --git a/tests/ui/modules/Common/Collapse.qml b/tests/ui/modules/Common/Collapse.qml index 3ee5d9f97..db984c2c8 100644 --- a/tests/ui/modules/Common/Collapse.qml +++ b/tests/ui/modules/Common/Collapse.qml @@ -2,6 +2,7 @@ import QtQuick 2.7 import Common 1.0 import Common.Styles 1.0 +import Utils 1.0 // ============================================================================= // A simple component to build collapsed item. @@ -12,10 +13,11 @@ Item { // --------------------------------------------------------------------------- - property alias target: targetChanges.target + property var target property int targetHeight property bool _collapsed: false + property var _savedHeight // --------------------------------------------------------------------------- @@ -24,7 +26,29 @@ Item { // --------------------------------------------------------------------------- function setCollapsed (status) { + if (_collapsed === status) { + return + } + _collapsed = status + + // Warning: Unable to use `PropertyChanges` because the change order is unknown. + // It exists a bug on Ubuntu if the `height` property is changed before `minimumHeight`. + if (_collapsed) { + _savedHeight = Utils.extractProperties(target, [ + 'height', + 'maximumHeight', + 'minimumHeight' + ]) + + target.minimumHeight = collapse.targetHeight + target.maximumHeight = Constants.sizeMax + target.height = collapse.targetHeight + } else { + target.minimumHeight = _savedHeight.minimumHeight + target.maximumHeight = _savedHeight.maximumHeight + target.height = _savedHeight.height + } } // --------------------------------------------------------------------------- @@ -32,6 +56,8 @@ Item { implicitHeight: button.iconSize implicitWidth: button.iconSize + property int savedHeight + ActionButton { id: button @@ -40,7 +66,7 @@ Item { iconSize: CollapseStyle.iconSize useStates: false - onClicked: _collapsed = !_collapsed + onClicked: setCollapsed(!_collapsed) } // --------------------------------------------------------------------------- @@ -52,15 +78,6 @@ Item { rotation: 180 target: button } - - PropertyChanges { - id: targetChanges - - height: collapse.targetHeight - maximumHeight: Constants.sizeMax - maximumWidth: Constants.sizeMax - minimumHeight: collapse.targetHeight - } } transitions: Transition { diff --git a/tests/ui/modules/Common/Popup/DesktopPopup.qml b/tests/ui/modules/Common/Popup/DesktopPopup.qml index 142bda69d..391363283 100644 --- a/tests/ui/modules/Common/Popup/DesktopPopup.qml +++ b/tests/ui/modules/Common/Popup/DesktopPopup.qml @@ -33,7 +33,7 @@ Item { // --------------------------------------------------------------------------- - // DO NOT TOUCH THIS PROPERTIES. + // DO NOT TOUCH THESE PROPERTIES. // No visible. visible: false diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index 68cd5925f..c43b3773d 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -259,6 +259,21 @@ function assert (condition, message) { // ----------------------------------------------------------------------------- +function extractProperties (obj, pattern) { + if (!pattern) { + return {} + } + + var obj2 = {} + pattern.forEach(function (property) { + obj2[property] = obj[property] + }) + + return obj2 +} + +// ----------------------------------------------------------------------------- + // Returns an array from a `object` or `array` argument. function ensureArray (obj) { if (isArray(obj)) {