/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.4 import Lomiri.Components 1.2 Item { id: progressBarStyle property color foregroundColor: LomiriColors.orange property color foregroundTextColor: '#FFFFFF' property color backgroundColor: Theme.palette.normal.base property color backgroundTextColor: Theme.palette.normal.baseText property var progressBar: styledItem implicitWidth: units.gu(38) implicitHeight: units.gu(4) LomiriShapeOverlay { id: background anchors.fill: parent backgroundColor: progressBarStyle.backgroundColor overlayColor: foregroundColor overlayRect: Qt.application.layoutDirection == Qt.LeftToRight ? Qt.rect(0.0, 0.0, progressBarStyle.progress, 1.0) : Qt.rect(1.0 - progressBarStyle.progress, 0.0, 1.0, 1.0) } property real progress: progressBar.indeterminate ? 0.0 : progressBar.value / (progressBar.maximumValue - progressBar.minimumValue) Label { id: valueLabel anchors.centerIn: background fontSize: "medium" color: backgroundTextColor text: progressBar.indeterminate ? i18n.dtr("lomiri-ui-toolkit", "In Progress") : "%1%".arg(Number(progressBarStyle.progress * 100.0).toFixed(0)) visible: !progressBar.hasOwnProperty("showProgressPercentage") || progressBar.showProgressPercentage SequentialAnimation on opacity { loops: Animation.Infinite running: progressBar.indeterminate LomiriNumberAnimation { to: 0.2; duration: LomiriAnimation.BriskDuration } LomiriNumberAnimation { to: 1.0; duration: LomiriAnimation.BriskDuration } } } PartialColorize { anchors.fill: valueLabel sourceItem: progressBar.indeterminate ? null : valueLabel leftColor: foregroundTextColor rightColor: backgroundTextColor progress: (progressBarStyle.progress * background.width - valueLabel.x) / valueLabel.width mirror: Qt.application.layoutDirection == Qt.RightToLeft visible: !progressBar.hasOwnProperty("showProgressPercentage") || progressBar.showProgressPercentage } }