Warning, /frameworks/qqc2-desktop-style/tests/testBars.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2023 ivan (@ratijas) tkachenko <me@ratijas.tk>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Templates as T
0010 import QtQuick.Layouts
0011
0012 import org.kde.kirigami as Kirigami
0013
0014 Kirigami.ApplicationWindow {
0015 title: "Progress Bars & Sliders"
0016 width: demo.implicitWidth
0017 height: demo.implicitHeight
0018
0019 component LoopAnimation : SequentialAnimation {
0020 id: animation
0021
0022 property real to: 1
0023
0024 running: true
0025
0026 // this is bound to global time, so that you could open multiple
0027 // windows side by side, and they all play in sync
0028 ScriptAction {
0029 script: phase.value = value() * animation.to
0030 function value() {
0031 var phase = Date.now() % 7000;
0032 if (phase < 500) {
0033 return 0;
0034 } else if (phase < 3500) {
0035 return (phase - 500) / 3000;
0036 } else if (phase < 4000) {
0037 return 1;
0038 } else {
0039 return 1 - ((phase - 4000) / 3000);
0040 }
0041 }
0042 }
0043 PropertyAction {
0044 id: phase
0045 }
0046 PauseAnimation { duration: 1 }
0047 onFinished: restart()
0048 }
0049
0050 component Demo : GridLayout {
0051 id: layout
0052 columns: 4
0053 columnSpacing: Kirigami.Units.smallSpacing
0054 rowSpacing: Kirigami.Units.smallSpacing
0055
0056 Slider {
0057 orientation: Qt.Vertical
0058 to: 10
0059 value: 3
0060 stepSize: 1
0061 LoopAnimation on value {
0062 to: 10
0063 }
0064 Layout.fillHeight: true
0065 Layout.rowSpan: 11
0066 }
0067
0068 Slider {
0069 orientation: Qt.Vertical
0070 to: 10
0071 value: 3
0072 stepSize: 1
0073 Layout.fillHeight: true
0074 Layout.rowSpan: 11
0075 }
0076
0077 Label {
0078 text: "Mirrorring:"
0079 Layout.alignment: Qt.AlignRight
0080 }
0081
0082 RowLayout {
0083 spacing: Kirigami.Units.smallSpacing
0084 Label {
0085 text: layout.LayoutMirroring.enabled ? "Enabled" : "Disabled"
0086 Layout.rightMargin: Kirigami.Units.gridUnit * 2
0087 }
0088
0089 Label {
0090 text: "Inherit:"
0091 Layout.alignment: Qt.AlignRight
0092 }
0093
0094 Label {
0095 text: layout.LayoutMirroring.childrenInherit ? "Yes" : "No"
0096 }
0097 }
0098
0099 Label {
0100 text: "Value:"
0101 Layout.alignment: Qt.AlignRight
0102 }
0103
0104 Label {
0105 text: value.toFixed(2)
0106 property real value
0107 LoopAnimation on value {}
0108 Layout.fillWidth: true
0109 }
0110
0111 Item {
0112 Layout.preferredHeight: Kirigami.Units.gridUnit
0113 Layout.columnSpan: 2
0114 }
0115
0116 Label {
0117 text: "Progress Bar:"
0118 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0119 }
0120
0121 ProgressBar {
0122 LoopAnimation on value {}
0123 Layout.fillWidth: true
0124 }
0125
0126 Item {
0127 Layout.preferredHeight: Kirigami.Units.gridUnit
0128 Layout.columnSpan: 2
0129 }
0130
0131 Label {
0132 text: "Indeterminate:"
0133 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0134 }
0135
0136 ProgressBar {
0137 indeterminate: true
0138 Layout.fillWidth: true
0139 }
0140
0141 Item {
0142 Layout.preferredHeight: Kirigami.Units.gridUnit
0143 Layout.columnSpan: 2
0144 }
0145
0146 Label {
0147 text: "Slider:"
0148 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0149 }
0150
0151 Slider {
0152 stepSize: 0.1
0153 LoopAnimation on value {}
0154 Layout.fillWidth: true
0155 }
0156
0157 Item {
0158 Layout.preferredHeight: Kirigami.Units.gridUnit
0159 Layout.columnSpan: 2
0160 }
0161
0162 Label {
0163 text: "Manual:"
0164 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0165 }
0166
0167 // Test for BUG-455339
0168 Slider {
0169 to: 300000
0170 stepSize: 30000
0171 value: 90000
0172 Layout.fillWidth: true
0173 }
0174
0175 Label {
0176 text: "Non-live:"
0177 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0178 }
0179
0180 RowLayout {
0181 spacing: Kirigami.Units.largeSpacing
0182 Layout.fillWidth: true
0183
0184 // Test for BUG-473400
0185 Slider {
0186 id: nonLiveSlider
0187 live: false
0188 to: 300000
0189 stepSize: 30000
0190 value: 90000
0191 Layout.fillWidth: true
0192 }
0193
0194 Label {
0195 text: String(Math.round(nonLiveSlider.value))
0196 horizontalAlignment: Text.AlignRight
0197 Layout.preferredWidth: nonLiveSliderTextMetrics.advanceWidth
0198 LayoutMirroring.enabled: false
0199 }
0200
0201 TextMetrics {
0202 id: nonLiveSliderTextMetrics
0203 font: nonLiveSlider.font
0204 text: String(nonLiveSlider.to)
0205 }
0206 }
0207 }
0208
0209 Kirigami.Page {
0210 id: demo
0211
0212 anchors.fill: parent
0213 contentItem: ColumnLayout {
0214 spacing: Kirigami.Units.largeSpacing
0215 RowLayout {
0216 Layout.fillWidth: false
0217 Layout.fillHeight: false
0218 Layout.alignment: Qt.AlignHCenter
0219 spacing: Kirigami.Units.smallSpacing
0220
0221 Label {
0222 text: "Application Layout Direction:"
0223 Layout.alignment: Qt.AlignRight
0224 }
0225 Label {
0226 text: Qt.application.layoutDirection === Qt.RightToLeft ? "Right to Left" : "Left to Right"
0227 }
0228 }
0229 Kirigami.Separator { Layout.fillWidth: true }
0230 RowLayout {
0231 Layout.fillHeight: false
0232 spacing: Kirigami.Units.largeSpacing
0233
0234 Demo {
0235 id: sampleDemo
0236 LayoutMirroring.enabled: true
0237 LayoutMirroring.childrenInherit: true
0238 }
0239 Kirigami.Separator { Layout.fillHeight: true }
0240 Demo {
0241 LayoutMirroring.enabled: false
0242 LayoutMirroring.childrenInherit: true
0243 }
0244 Layout.bottomMargin: Kirigami.Units.gridUnit
0245 }
0246 Kirigami.Separator { Layout.fillWidth: true }
0247 Demo {
0248 Layout.fillWidth: false
0249 Layout.fillHeight: false
0250 Layout.alignment: Qt.AlignHCenter
0251 Layout.preferredWidth: sampleDemo.width
0252 }
0253 Item {
0254 Layout.fillHeight: true
0255 }
0256 Kirigami.SelectableLabel {
0257 Layout.fillWidth: true
0258 horizontalAlignment: Text.AlignHCenter
0259 textFormat: Text.MarkdownText
0260 text: "Hint: run this test both with `export LANGUAGE=ar:en_US LANG=ar_EG.UTF-8 LC_ALL=` and `export LANGUAGE=en:en_US LANG=en_US.UTF-8 LC_ALL=` environments."
0261 }
0262 }
0263 }
0264 }