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