• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmacomponents
  • qml
ProgressBar.qml
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 import QtQuick 1.0
21 import org.kde.plasma.core 0.1 as PlasmaCore
22 import org.kde.qtextracomponents 0.1
23 
33 Item {
34  id: progressBar
35 
36  // Common API
38  property alias minimumValue: range.minimumValue
40  property alias maximumValue: range.maximumValue
42  property alias value: range.value
55  property alias indeterminate: indeterminateAnimation.running
56 
57  // Plasma API
61  property int orientation: Qt.Horizontal
62 
63  width: 100
64  height: 20
65  opacity: enabled ? 1.0 : 0.5
66 
67  RangeModel {
68  id: range
69 
70  // default values
71  minimumValue: 0.0
72  maximumValue: 1.0
73  value: 0
74 
75  positionAtMinimum: 0
76  positionAtMaximum: backgroundPixmapItem.width
77  }
78 
79  Item {
80  id: contents
81 
82  property bool _isVertical: orientation == Qt.Vertical
83  property int _tileWidth: width
84 
85  width: _isVertical ? progressBar.height : progressBar.width
86  height: _isVertical ? progressBar.width : progressBar.height
87  rotation: _isVertical ? 90 : 0
88  anchors.centerIn: parent
89 
90  Timer {
91  id: resizeTimer
92  repeat: false
93  interval: 0
94  running: false
95  onTriggered: {
96  contents._tileWidth = Math.floor(contents.width/(Math.floor(contents.width/(contents.height/1.6))))
97 
98 
99  if (barFrameSvg.hasElement("hint-bar-stretch")) {
100  barFrameSvg.resizeFrame(Qt.size(barPixmapItem.width, barPixmapItem.height))
101  } else {
102  barFrameSvg.resizeFrame(Qt.size(contents._tileWidth, contents.height))
103  }
104  barPixmapItem.pixmap = barFrameSvg.framePixmap()
105 
106  if (backgroundFrameSvg.hasElement("hint-bar-stretch")) {
107  backgroundFrameSvg.resizeFrame(Qt.size(backgroundPixmapItem.width, backgroundPixmapItem.height))
108  } else {
109  backgroundFrameSvg.resizeFrame(Qt.size(contents._tileWidth, contents.height))
110  }
111  backgroundPixmapItem.pixmap = backgroundFrameSvg.framePixmap()
112  }
113  }
114  PlasmaCore.FrameSvg {
115  id: barFrameSvg
116  Component.onCompleted: {
117  barFrameSvg.setImagePath("widgets/bar_meter_horizontal")
118  barFrameSvg.setElementPrefix("bar-active")
119  resizeTimer.restart()
120  }
121  }
122  PlasmaCore.FrameSvg {
123  id: backgroundFrameSvg
124  Component.onCompleted: {
125  backgroundFrameSvg.setImagePath("widgets/bar_meter_horizontal")
126  backgroundFrameSvg.setElementPrefix("bar-inactive")
127  resizeTimer.restart()
128  }
129  }
130  QPixmapItem {
131  id: backgroundPixmapItem
132  anchors.fill: parent
133  fillMode: QPixmapItem.TileHorizontally
134  onWidthChanged: resizeTimer.restart()
135  onHeightChanged: resizeTimer.restart()
136  }
137 
138 
139  QPixmapItem {
140  id: barPixmapItem
141  fillMode: QPixmapItem.TileHorizontally
142  width: indeterminate ? contents._tileWidth*2 : range.position
143  height: contents.height
144 
145  visible: indeterminate || value > 0
146  onWidthChanged: resizeTimer.restart()
147  onHeightChanged: resizeTimer.restart()
148 
149  SequentialAnimation {
150  id: indeterminateAnimation
151 
152  loops: Animation.Infinite
153 
154  onRunningChanged: {
155  if (!running) {
156  barPixmapItem.x = 0
157  }
158  }
159 
160  PropertyAnimation {
161  target: barPixmapItem
162  property: "x"
163  duration: 800
164  to: 0
165  }
166  PropertyAnimation {
167  target: barPixmapItem
168  property: "x"
169  duration: 800
170  to: backgroundPixmapItem.width - barPixmapItem.width
171  }
172  }
173  }
174  }
175 }
Item
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaComponents

Skip menu "PlasmaComponents"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal