Snap to buttons width → restores auto-sizing

This commit is contained in:
miruka 2019-05-13 12:37:35 -04:00
parent 645aa73183
commit f2c84d5260

View File

@ -91,9 +91,31 @@ HColumnLayout {
collapsed: width < Layout.minimumWidth + 8 collapsed: width < Layout.minimumWidth + 8
property bool wasSnapped: false
property int referenceWidth: roomHeader.buttonsWidth property int referenceWidth: roomHeader.buttonsWidth
onReferenceWidthChanged: onReferenceWidthChanged: {
if (chatSplitView.canAutoSize) { width = referenceWidth } if (chatSplitView.canAutoSize || wasSnapped) {
if (wasSnapped) { chatSplitView.canAutoSize = true }
width = referenceWidth
}
}
property int currentWidth: width
onCurrentWidthChanged: {
if (referenceWidth != width &&
referenceWidth - 15 < width &&
width < referenceWidth + 15)
{
currentWidth = referenceWidth
width = referenceWidth
wasSnapped = true
currentWidth = Qt.binding(
function() { return roomSidePane.width }
)
} else {
wasSnapped = false
}
}
width: referenceWidth // Initial width width: referenceWidth // Initial width
Layout.minimumWidth: HStyle.avatar.size Layout.minimumWidth: HStyle.avatar.size