simplify logic a lot
This commit is contained in:
parent
02ccc2d98e
commit
90c8dbc255
@ -74,84 +74,36 @@ 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
|
||||||
|
|
||||||
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
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: QPixmapItem.TileHorizontally
|
imagePath: _isVertical ? "widgets/bar_meter_vertical" : "widgets/bar_meter_horizontal"
|
||||||
onWidthChanged: resizeTimer.restart()
|
prefix: "bar-inactive"
|
||||||
onHeightChanged: resizeTimer.restart()
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaCore.Svg {
|
||||||
QPixmapItem {
|
id: barSvg
|
||||||
id: barPixmapItem
|
imagePath: background.imagePath
|
||||||
fillMode: QPixmapItem.TileHorizontally
|
}
|
||||||
width: indeterminate ? contents._tileWidth*2 : range.position
|
|
||||||
height: contents.height
|
|
||||||
|
|
||||||
visible: indeterminate || value > 0
|
|
||||||
onWidthChanged: resizeTimer.restart()
|
|
||||||
onHeightChanged: resizeTimer.restart()
|
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
id: indeterminateAnimation
|
id: indeterminateAnimation
|
||||||
@ -161,22 +113,21 @@ Item {
|
|||||||
onRunningChanged: {
|
onRunningChanged: {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
barPixmapItem.x = 0
|
barPixmapItem.x = 0
|
||||||
|
barPixmapItem.y = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: barPixmapItem
|
target: bar
|
||||||
property: "x"
|
property: background._isVertical ? "y" : "x"
|
||||||
duration: 800
|
duration: 800
|
||||||
to: 0
|
to: 0
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
target: barPixmapItem
|
target: bar
|
||||||
property: "x"
|
property: background._isVertical ? "y" : "x"
|
||||||
duration: 800
|
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