simplify logic a lot
This commit is contained in:
parent
02ccc2d98e
commit
90c8dbc255
@ -74,109 +74,60 @@ Item {
|
|||||||
value: 0
|
value: 0
|
||||||
|
|
||||||
positionAtMinimum: 0
|
positionAtMinimum: 0
|
||||||
positionAtMaximum: backgroundPixmapItem.width
|
positionAtMaximum: background._isVertical ? background.height : background.width
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
PlasmaCore.FrameSvgItem {
|
||||||
id: contents
|
id: background
|
||||||
|
anchors.fill: parent
|
||||||
|
imagePath: _isVertical ? "widgets/bar_meter_vertical" : "widgets/bar_meter_horizontal"
|
||||||
|
prefix: "bar-inactive"
|
||||||
property bool _isVertical: orientation == Qt.Vertical
|
property bool _isVertical: orientation == Qt.Vertical
|
||||||
property int _tileWidth: width
|
|
||||||
|
|
||||||
width: _isVertical ? progressBar.height : progressBar.width
|
PlasmaCore.FrameSvgItem {
|
||||||
height: _isVertical ? progressBar.width : progressBar.height
|
id: bar
|
||||||
rotation: _isVertical ? 90 : 0
|
anchors {
|
||||||
anchors.centerIn: parent
|
left: indeterminate && !background._isVertical ? undefined : parent.left
|
||||||
|
bottom: indeterminate && background._isVertical ? undefined : parent.bottom
|
||||||
|
right: background._isVertical ? parent.right : undefined
|
||||||
|
top: background._isVertical ? undefined : parent.top
|
||||||
|
}
|
||||||
|
imagePath: background.imagePath
|
||||||
|
prefix: "bar-active"
|
||||||
|
|
||||||
Timer {
|
width: indeterminate ? units.gridUnit*2 : range.position
|
||||||
id: resizeTimer
|
height: indeterminate ? units.gridUnit*2 : range.position
|
||||||
repeat: false
|
}
|
||||||
interval: 0
|
}
|
||||||
running: false
|
|
||||||
onTriggered: {
|
|
||||||
contents._tileWidth = Math.floor(contents.width/(Math.floor(contents.width/(contents.height/1.6))))
|
|
||||||
|
|
||||||
|
PlasmaCore.Svg {
|
||||||
|
id: barSvg
|
||||||
|
imagePath: background.imagePath
|
||||||
|
}
|
||||||
|
|
||||||
if (barFrameSvg.hasElement("hint-bar-stretch")) {
|
SequentialAnimation {
|
||||||
barFrameSvg.resizeFrame(Qt.size(barPixmapItem.width, barPixmapItem.height))
|
id: indeterminateAnimation
|
||||||
} else {
|
|
||||||
barFrameSvg.resizeFrame(Qt.size(contents._tileWidth, contents.height))
|
|
||||||
}
|
|
||||||
barPixmapItem.pixmap = barFrameSvg.framePixmap()
|
|
||||||
|
|
||||||
if (backgroundFrameSvg.hasElement("hint-bar-stretch")) {
|
loops: Animation.Infinite
|
||||||
backgroundFrameSvg.resizeFrame(Qt.size(backgroundPixmapItem.width, backgroundPixmapItem.height))
|
|
||||||
} else {
|
onRunningChanged: {
|
||||||
backgroundFrameSvg.resizeFrame(Qt.size(contents._tileWidth, contents.height))
|
if (!running) {
|
||||||
}
|
barPixmapItem.x = 0
|
||||||
backgroundPixmapItem.pixmap = backgroundFrameSvg.framePixmap()
|
barPixmapItem.y = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
visible: false
|
PropertyAnimation {
|
||||||
svg: PlasmaCore.FrameSvg {
|
target: bar
|
||||||
id: barFrameSvg
|
property: background._isVertical ? "y" : "x"
|
||||||
Component.onCompleted: {
|
duration: 800
|
||||||
barFrameSvg.setImagePath("widgets/bar_meter_horizontal")
|
to: 0
|
||||||
barFrameSvg.setElementPrefix("bar-active")
|
|
||||||
resizeTimer.restart()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PlasmaCore.SvgItem {
|
PropertyAnimation {
|
||||||
visible: false
|
target: bar
|
||||||
svg: PlasmaCore.FrameSvg {
|
property: background._isVertical ? "y" : "x"
|
||||||
id: backgroundFrameSvg
|
duration: 800
|
||||||
Component.onCompleted: {
|
to: background._isVertical ? background.height - bar.height : background.width - bar.width
|
||||||
backgroundFrameSvg.setImagePath("widgets/bar_meter_horizontal")
|
|
||||||
backgroundFrameSvg.setElementPrefix("bar-inactive")
|
|
||||||
resizeTimer.restart()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QPixmapItem {
|
|
||||||
id: backgroundPixmapItem
|
|
||||||
anchors.fill: parent
|
|
||||||
fillMode: QPixmapItem.TileHorizontally
|
|
||||||
onWidthChanged: resizeTimer.restart()
|
|
||||||
onHeightChanged: resizeTimer.restart()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPixmapItem {
|
|
||||||
id: barPixmapItem
|
|
||||||
fillMode: QPixmapItem.TileHorizontally
|
|
||||||
width: indeterminate ? contents._tileWidth*2 : range.position
|
|
||||||
height: contents.height
|
|
||||||
|
|
||||||
visible: indeterminate || value > 0
|
|
||||||
onWidthChanged: resizeTimer.restart()
|
|
||||||
onHeightChanged: resizeTimer.restart()
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
id: indeterminateAnimation
|
|
||||||
|
|
||||||
loops: Animation.Infinite
|
|
||||||
|
|
||||||
onRunningChanged: {
|
|
||||||
if (!running) {
|
|
||||||
barPixmapItem.x = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyAnimation {
|
|
||||||
target: barPixmapItem
|
|
||||||
property: "x"
|
|
||||||
duration: 800
|
|
||||||
to: 0
|
|
||||||
}
|
|
||||||
PropertyAnimation {
|
|
||||||
target: barPixmapItem
|
|
||||||
property: "x"
|
|
||||||
duration: 800
|
|
||||||
to: backgroundPixmapItem.width - barPixmapItem.width
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user