Warning, /plasma/libplasma/tests/components/progressbar3.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2019 David Edmundson <kde@davidedmundson.co.uk>
0003  * SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 import QtQuick
0007 import QtQuick.Layouts
0008 import org.kde.plasma.components as PlasmaComponents
0009 import org.kde.kirigami as Kirigami
0010 
0011 ComponentBase {
0012     id: root
0013     title: "Plasma Components 3 ProgressBar"
0014     property int progressBarWidth: testProgressBar.width
0015 
0016     PlasmaComponents.ProgressBar {
0017         id: testProgressBar
0018         visible: false
0019     }
0020 
0021     contentItem: GridLayout {
0022         columns: 6
0023         columnSpacing: Kirigami.Units.gridUnit
0024         rowSpacing: Kirigami.Units.gridUnit
0025 
0026         ColumnLayout {
0027             PlasmaComponents.Label {
0028                 text: "0%"
0029             }
0030             PlasmaComponents.ProgressBar {
0031                 from: 0
0032                 to: 100
0033                 value: 0
0034             }
0035         }
0036 
0037         ColumnLayout {
0038             PlasmaComponents.Label {
0039                 text: "50%"
0040             }
0041             PlasmaComponents.ProgressBar {
0042                 from: 0
0043                 to: 100
0044                 value: 50
0045             }
0046         }
0047 
0048         ColumnLayout {
0049             PlasmaComponents.Label {
0050                 text: "100%"
0051             }
0052             PlasmaComponents.ProgressBar {
0053                 from: 0
0054                 to: 100
0055                 value: 100
0056             }
0057         }
0058 
0059         ColumnLayout {
0060             PlasmaComponents.Label {
0061                 id: progressBarAndSliderLabel
0062                 text: "The progress bar and slider grooves should have the same visual width."
0063                 wrapMode: Text.WordWrap
0064                 Layout.preferredWidth: progressBarWidth
0065             }
0066             GridLayout {
0067                 id: progressBarAndSliderGrid
0068                 columns: 1
0069                 rows: 2
0070                 PlasmaComponents.ProgressBar {
0071                     id: progressBar
0072                     from: 0
0073                     to: 100
0074                     value: 50
0075                 }
0076                 PlasmaComponents.Slider {
0077                     Layout.preferredWidth: progressBar.width
0078                      Layout.preferredHeight: progressBar.height
0079                     from: 0
0080                     to: 100
0081                     value: 50
0082                 }
0083             }
0084         }
0085 
0086         ColumnLayout {
0087             PlasmaComponents.Label {
0088                 text: "Min: 0; Max: 200; Value: 1\nMake sure the bar does not leak outside."
0089                 wrapMode: Text.WordWrap
0090                 Layout.preferredWidth: progressBarWidth
0091             }
0092             PlasmaComponents.ProgressBar {
0093                 from: 0
0094                 to: 200
0095                 value: 1
0096             }
0097         }
0098 
0099         ColumnLayout {
0100             PlasmaComponents.Label {
0101                 text: "Min: 0; Max: 100; Value: 110\nThe progress bar should look like it is at 100%."
0102                 wrapMode: Text.WordWrap
0103                 Layout.preferredWidth: progressBarWidth
0104             }
0105             PlasmaComponents.ProgressBar {
0106                 from: 0
0107                 to: 100
0108                 value: 110
0109             }
0110         }
0111 
0112         ColumnLayout {
0113             PlasmaComponents.Label {
0114                 text: "Min: -100; Max: 100; Value: 0\nThe progress bar should look like it is at 50%."
0115                 wrapMode: Text.WordWrap
0116                 Layout.preferredWidth: progressBarWidth
0117             }
0118             PlasmaComponents.ProgressBar {
0119                 from: -100
0120                 to: 100
0121                 value: 0
0122             }
0123         }
0124 
0125         ColumnLayout {
0126             PlasmaComponents.Label {
0127                 text: "Min: 0; Max: 100; Value: -10\nThe progress bar should look like it is at 0%."
0128                 wrapMode: Text.WordWrap
0129                 Layout.preferredWidth: progressBarWidth
0130             }
0131             PlasmaComponents.ProgressBar {
0132                 from: 0
0133                 to: 100
0134                 value: -10
0135             }
0136         }
0137 
0138         ColumnLayout {
0139             PlasmaComponents.Label {
0140                 text: "This should have a continuous movement from one end to the other and back."
0141                 wrapMode: Text.WordWrap
0142                 Layout.preferredWidth: progressBarWidth
0143             }
0144             PlasmaComponents.ProgressBar {
0145                 indeterminate: indeterminateCheckBox.checked
0146                 value: 0.5
0147             }
0148         }
0149 
0150         ColumnLayout {
0151             PlasmaComponents.Label {
0152                 text: "Checking and unchecking should not break the layout. The progress bar should look like it is at 50% if unchecked."
0153                 wrapMode: Text.WordWrap
0154                 Layout.preferredWidth: progressBarWidth
0155             }
0156             PlasmaComponents.CheckBox {
0157                 id: indeterminateCheckBox
0158                 text: "Indeterminate"
0159                 checked: true
0160             }
0161         }
0162 
0163         ColumnLayout {
0164             PlasmaComponents.Label {
0165                 text: "This should do one 'indefinite' animation cycle and then continuously animate to 100% in chunks of 10%."
0166                 wrapMode: Text.WordWrap
0167                 Layout.preferredWidth: progressBarWidth
0168             }
0169             PlasmaComponents.ProgressBar {
0170                 id: animatingProgressBar
0171                 from: 0
0172                 to: 100
0173                 // Bug 430544: A ProgressBar that was indeterminate once will
0174                 // not update its bar size according to its value anymore
0175                 // Set to false again in the Timer below
0176                 indeterminate: true
0177 
0178                 Timer {
0179                     interval: 500
0180                     triggeredOnStart: true
0181                     running: true
0182                     repeat: true
0183                     onTriggered: {
0184                         animatingProgressBar.indeterminate = false;
0185 
0186                         // ProgressBar clamps "value" by "to" (100), so we can't
0187                         // just blindly increase and then check >= 100
0188                         if (animatingProgressBar.value === 100) {
0189                             animatingProgressBar.value = 0;
0190                         } else {
0191                             animatingProgressBar.value += 10;
0192                         }
0193                     }
0194                 }
0195             }
0196         }
0197 
0198     }
0199 }