mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(Paned): supports a closing action on handle
This commit is contained in:
parent
9fe2129ec3
commit
bd392e5b48
2 changed files with 29 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue