From 3ceb300f6ff4cb48dd03a0c9a9c324452bda4ab9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 10 Aug 2012 18:42:16 +0200 Subject: [PATCH] better calculation of tile widths --- .../plasmacomponents/qml/ProgressBar.qml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/declarativeimports/plasmacomponents/qml/ProgressBar.qml b/declarativeimports/plasmacomponents/qml/ProgressBar.qml index f9bf95367..a04f91b69 100644 --- a/declarativeimports/plasmacomponents/qml/ProgressBar.qml +++ b/declarativeimports/plasmacomponents/qml/ProgressBar.qml @@ -87,6 +87,7 @@ 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 @@ -99,17 +100,20 @@ Item { 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(Math.floor(contents.height/1.6), contents.height)) + 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(Math.floor(contents.height/1.6), contents.height)) + backgroundFrameSvg.resizeFrame(Qt.size(contents._tileWidth, contents.height)) } backgroundPixmapItem.pixmap = backgroundFrameSvg.framePixmap() } @@ -133,7 +137,7 @@ Item { QPixmapItem { id: backgroundPixmapItem anchors.fill: parent - + fillMode: QPixmapItem.TileHorizontally onWidthChanged: resizeTimer.restart() onHeightChanged: resizeTimer.restart() } @@ -141,8 +145,8 @@ Item { QPixmapItem { id: barPixmapItem - fillMode: contents._isVertical ? QPixmapItem.TileVertically : QPixmapItem.TileHorizontally - width: indeterminate ? Math.floor(height/1.6)*2 : range.position + fillMode: QPixmapItem.TileHorizontally + width: indeterminate ? contents._tileWidth*2 : range.position height: contents.height visible: indeterminate || value > 0