mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-19 16:38:28 +00:00
New algorithm to compute needed width on dynamic texts. Fix binding loops on scrolls. Fix texts display in reply preview.
49 lines
1.4 KiB
QML
49 lines
1.4 KiB
QML
import QtQuick 2.7
|
|
import QtQuick.Controls 2.2
|
|
|
|
import Common.Styles 1.0
|
|
|
|
// =============================================================================
|
|
// A simple custom vertical scrollbar.
|
|
// =============================================================================
|
|
|
|
ScrollBar {
|
|
id: scrollBar
|
|
property int contentSizeTarget
|
|
property int sizeTarget
|
|
|
|
onContentSizeTargetChanged: delayUpdatePolicy.restart()
|
|
onSizeTargetChanged: delayUpdatePolicy.restart()
|
|
|
|
policy: ScrollBar.AlwaysOff
|
|
function updatePolicy(){
|
|
policy = contentSizeTarget > sizeTarget ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
}
|
|
function delayPolicy(){
|
|
delayUpdatePolicy.restart()
|
|
}
|
|
Component.onCompleted: updatePolicy()
|
|
Timer{// Delay to avoid binding loops
|
|
id:delayUpdatePolicy
|
|
interval:10
|
|
onTriggered: scrollBar.updatePolicy()
|
|
}
|
|
|
|
background: Rectangle {
|
|
anchors.fill: parent
|
|
color: ForceScrollBarStyle.background.color
|
|
radius: ForceScrollBarStyle.background.radius
|
|
}
|
|
contentItem: Rectangle {
|
|
color: scrollBar.pressed
|
|
? ForceScrollBarStyle.color.pressed
|
|
: (scrollBar.hovered
|
|
? ForceScrollBarStyle.color.hovered
|
|
: ForceScrollBarStyle.color.normal
|
|
)
|
|
implicitHeight: ForceScrollBarStyle.contentItem.implicitHeight
|
|
implicitWidth: ForceScrollBarStyle.contentItem.implicitWidth
|
|
radius: ForceScrollBarStyle.contentItem.radius
|
|
}
|
|
hoverEnabled: true
|
|
}
|