Commit bd392e5b authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Paned): supports a closing action on handle

parent 9fe2129e
......@@ -23,11 +23,15 @@ Item {
property alias childA: contentA.data
property alias childB: contentB.data
property int closingEdge: Qt.LeftEdge
// User limits: string or int values.
property var leftLimit: 0
property var rightLimit: 0
property bool _isClosed
property int _savedContentAWidth
// Internal limits.
property var _leftLimit
property var _rightLimit
......@@ -53,7 +57,7 @@ Item {
}
}
onWidthChanged: {
function _applyLimits () {
var rightLimit = _getLimitValue(_rightLimit)
var leftLimit = _getLimitValue(_leftLimit)
......@@ -68,6 +72,8 @@ Item {
}
}
onWidthChanged: !_isClosed && _applyLimits()
Component.onCompleted: {
_leftLimit = _parseLimit(leftLimit)
_rightLimit = _parseLimit(rightLimit)
......@@ -92,9 +98,28 @@ Item {
hoverEnabled: true
width: PanedStyle.handle.width
onDoubleClicked: {
// Save state and close.
if (!_isClosed) {
_isClosed = true
_savedContentAWidth = contentA.width
contentA.width = (closingEdge !== Qt.LeftEdge)
? container.width - width
: 0
return
}
// Restore old state.
_isClosed = false
contentA.width = _savedContentAWidth
_applyLimits()
}
onMouseXChanged: {
// Necessary because `hoverEnabled` is used.
if (!pressed) {
if (!pressed || _isClosed) {
return
}
......
......@@ -5,7 +5,7 @@ import Linphone 1.0
QtObject {
property QtObject handle: QtObject {
property int width: 8
property int width: 10
property QtObject color: QtObject {
property color hovered: Colors.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment