mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-30 18:39:23 +00:00
fix(ui/modules/Common/Collapse): fix the change order of the minimumHeight, maximumHeight and height
This commit is contained in:
parent
bdd17a36b4
commit
d37559bb73
3 changed files with 44 additions and 12 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Item {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// DO NOT TOUCH THIS PROPERTIES.
|
||||
// DO NOT TOUCH THESE PROPERTIES.
|
||||
|
||||
// No visible.
|
||||
visible: false
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue