Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/ProgressBar.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
0003     SPDX-FileCopyrightText: 2017 The Qt Company Ltd.
0004 
0005     SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
0006 */
0007 
0008 
0009 import QtQuick 2.6
0010 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate
0011 import QtQuick.Templates 2.15 as T
0012 import org.kde.kirigami 2.4 as Kirigami
0013 
0014 T.ProgressBar {
0015     id: controlRoot
0016 
0017     palette: Kirigami.Theme.palette
0018 
0019     implicitWidth: 250
0020     implicitHeight: 22
0021 
0022     hoverEnabled: true
0023 
0024     contentItem: Item {}
0025 
0026     background: StylePrivate.StyleItem {
0027         // Rescale for extra precision. Adapts to the range of `from` & `to` to avoid integer overflow.
0028         property int factor: (Math.abs(controlRoot.from) < 100000 && Math.abs(controlRoot.to) < 100000)
0029             ? 10000 : 1
0030 
0031         elementType: "progressbar"
0032         control: controlRoot
0033         maximum: indeterminate ? 0 : factor * controlRoot.to
0034         minimum: indeterminate ? 0 : factor * controlRoot.from
0035         value: indeterminate ? 0 : factor * controlRoot.value
0036         horizontal: true
0037         enabled: controlRoot.enabled
0038 
0039         // TODO KF6: Remove this workaround.
0040         // See https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/179
0041         //
0042         // ScriptAction refuses to run on its own. So we add a NumberAnimation
0043         // with non-zero duration to make it tied to a monitor refresh rate.
0044         // See git history for more (e.g. why not PauseAnimation)
0045         SequentialAnimation {
0046             running: controlRoot.indeterminate && controlRoot.visible
0047             loops: Animation.Infinite
0048 
0049             NumberAnimation { duration: 1 }
0050             ScriptAction { script: controlRoot.background.updateItem() }
0051         }
0052     }
0053 }