import QtQuick import Weave.Controls import Weave.Templates as T T.ProgressBar { id: root implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) hoverEnabled: root.enabled animationDuration: root.indeterminate ? Theme.component.progressbar.indeterminate.bar.transitionDuration + 1000 // TODO: token is wrong : Theme.component.progressbar.bar.transitionDuration animationEasingType: Theme.component.progressbar.bar.transitionTimingFunction Behavior on value { enabled: root.visible && valueAnimation.duration > 0 NumberAnimation { id: valueAnimation easing.type: root.animationEasingType duration: root.animationDuration } } contentItem: Item { id: content implicitWidth: 2*Theme.component.progressbar.indeterminate.bar.width implicitHeight: Theme.component.progressbar.height Item { id: clipItem clip: true height: content.height // we have to increase width by 2*triangleWidth to // ensure that the rounded ends get completely drawn at 100% width: triangleWidth + ((root.indeterminate ? isMirrored ? Math.min(1, 1 + proportionalWidth - intermediateValue) : Math.min(1, intermediateValue) : root.position) * (triangleWidth + content.width)) x: isMirrored ? (content.width+2*triangleWidth - width) : (-triangleWidth-translateOffset) property bool isMirrored: root.visualPosition !== root.position property real triangleWidth: (height/4)*3 property real transformAngle: isMirrored ? triangleWidth/height : -triangleWidth/height property real translateOffset: isMirrored ? -triangleWidth : triangleWidth property Gradient barGrad: Gradient { orientation: Gradient.Horizontal GradientStop { position: 0 color: clipItem.isMirrored ? Theme.component.progressbar.bar.backgroundColor : Theme.colorWithAlpha(Theme.component.progressbar.bar.backgroundColor, 0) } GradientStop { position: Math.max(0, clipItem.intermediateValue - clipItem.proportionalWidth) color: Theme.colorWithAlpha( Theme.component.progressbar.bar.backgroundColor, clipItem.isMirrored ? 1 : 0) } GradientStop { position: Math.min(1, clipItem.intermediateValue) color: Theme.colorWithAlpha( Theme.component.progressbar.bar.backgroundColor, clipItem.isMirrored ? 0 : 1) } GradientStop { position: 1 color: clipItem.isMirrored ? Theme.colorWithAlpha(Theme.component.progressbar.bar.backgroundColor, 0) : Theme.component.progressbar.bar.backgroundColor } } property real intermediateValue property real proportionalWidth: Math.min(0.5, Theme.component.progressbar.indeterminate.bar.width / content.width) NumberAnimation on intermediateValue { id: indeterminateAnimation loops: Animation.Infinite running: root.indeterminate from: clipItem.isMirrored ? 1.0 + clipItem.proportionalWidth : 0 to: clipItem.isMirrored ? 0 : (1.0 + clipItem.proportionalWidth) duration: root.animationDuration easing.type: root.animationEasingType } transform: Matrix4x4 { matrix: Qt.matrix4x4( 1, clipItem.transformAngle, 0, clipItem.translateOffset, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) } Rectangle { id: highlight x: root.indeterminate ? (clipItem.x < 0 ? -clipItem.x : clipItem.triangleWidth) : clipItem.isMirrored ? (-clipItem.x + clipItem.triangleWidth + clipItem.translateOffset) : (clipItem.triangleWidth + clipItem.translateOffset) width: content.width height: content.height radius: Theme.component.progressbar.bar.borderRadius color: Theme.component.progressbar.bar.backgroundColor gradient: root.indeterminate ? clipItem.barGrad : null transform: Matrix4x4 { matrix: Qt.matrix4x4( 1, -clipItem.transformAngle, 0, -clipItem.translateOffset, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) } } } } background: Rectangle { implicitWidth: Theme.component.progressbar.height implicitHeight: Theme.component.progressbar.height radius: Theme.component.progressbar.borderRadius color: Theme.component.progressbar.backgroundColor } }