Warning, /frameworks/qqc2-desktop-style/tests/testBars.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2022 ivan (@ratijas) tkachenko <me@ratijas.tk>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15
0009 import QtQuick.Templates 2.15 as T
0010 import QtQuick.Layouts 1.15
0011
0012 import org.kde.kirigami 2.20 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 running: true
0021
0022 // this is bound to global time, so that you could open multiple
0023 // windows side by side, and they all play in sync
0024 ScriptAction {
0025 script: phase.value = value()
0026 function value() {
0027 var phase = Date.now() % 7000;
0028 if (phase < 500) {
0029 return 0;
0030 } else if (phase < 3500) {
0031 return (phase - 500) / 3000;
0032 } else if (phase < 4000) {
0033 return 1;
0034 } else {
0035 return 1 - ((phase - 4000) / 3000);
0036 }
0037 }
0038 }
0039 PropertyAction {
0040 id: phase
0041 }
0042 PauseAnimation { duration: 1 }
0043 onFinished: restart()
0044 }
0045
0046 component Demo : GridLayout {
0047 id: layout
0048 columns: 2
0049 columnSpacing: Kirigami.Units.smallSpacing
0050 rowSpacing: Kirigami.Units.smallSpacing
0051
0052 Label {
0053 text: "Mirrorring:"
0054 Layout.alignment: Qt.AlignRight
0055 }
0056
0057 RowLayout {
0058 spacing: Kirigami.Units.smallSpacing
0059 Label {
0060 text: layout.LayoutMirroring.enabled ? "Enabled" : "Disabled"
0061 Layout.rightMargin: Kirigami.Units.gridUnit * 2
0062 }
0063
0064 Label {
0065 text: "Inherit:"
0066 Layout.alignment: Qt.AlignRight
0067 }
0068
0069 Label {
0070 text: layout.LayoutMirroring.childrenInherit ? "Yes" : "No"
0071 }
0072 }
0073
0074 Label {
0075 text: "Value:"
0076 Layout.alignment: Qt.AlignRight
0077 }
0078
0079 Label {
0080 text: value.toFixed(2)
0081 property real value
0082 LoopAnimation on value {}
0083 Layout.fillWidth: true
0084 }
0085
0086 Item {
0087 Layout.preferredHeight: Kirigami.Units.gridUnit
0088 Layout.columnSpan: 2
0089 }
0090
0091 Label {
0092 text: "Progress Bar:"
0093 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0094 }
0095
0096 ProgressBar {
0097 LoopAnimation on value {}
0098 Layout.fillWidth: true
0099 }
0100
0101 Item {
0102 Layout.preferredHeight: Kirigami.Units.gridUnit
0103 Layout.columnSpan: 2
0104 }
0105
0106 Label {
0107 text: "Indeterminate:"
0108 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0109 }
0110
0111 ProgressBar {
0112 indeterminate: true
0113 Layout.fillWidth: true
0114 }
0115
0116 Item {
0117 Layout.preferredHeight: Kirigami.Units.gridUnit
0118 Layout.columnSpan: 2
0119 }
0120
0121 Label {
0122 text: "Slider:"
0123 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0124 }
0125
0126 Slider {
0127 stepSize: 0.1
0128 LoopAnimation on value {}
0129 Layout.fillWidth: true
0130 }
0131
0132 Item {
0133 Layout.preferredHeight: Kirigami.Units.gridUnit
0134 Layout.columnSpan: 2
0135 }
0136
0137 Label {
0138 text: "Manual:"
0139 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0140 }
0141
0142 // Test for BUG-455339
0143 Slider {
0144 to: 300000
0145 stepSize: 30000
0146 value: 90000
0147 Layout.fillWidth: true
0148 }
0149 }
0150
0151 Kirigami.Page {
0152 id: demo
0153
0154 anchors.fill: parent
0155 contentItem: ColumnLayout {
0156 spacing: Kirigami.Units.largeSpacing
0157 RowLayout {
0158 Layout.fillWidth: false
0159 Layout.fillHeight: false
0160 Layout.alignment: Qt.AlignHCenter
0161 spacing: Kirigami.Units.smallSpacing
0162
0163 Label {
0164 text: "Application Layout Direction:"
0165 Layout.alignment: Qt.AlignRight
0166 }
0167 Label {
0168 text: Qt.application.layoutDirection === Qt.RightToLeft ? "Right to Left" : "Left to Right"
0169 }
0170 }
0171 Kirigami.Separator { Layout.fillWidth: true }
0172 RowLayout {
0173 Layout.fillHeight: false
0174 spacing: Kirigami.Units.largeSpacing
0175
0176 Demo {
0177 id: sampleDemo
0178 LayoutMirroring.enabled: true
0179 LayoutMirroring.childrenInherit: true
0180 }
0181 Kirigami.Separator { Layout.fillHeight: true }
0182 Demo {
0183 LayoutMirroring.enabled: false
0184 LayoutMirroring.childrenInherit: true
0185 }
0186 Layout.bottomMargin: Kirigami.Units.gridUnit
0187 }
0188 Kirigami.Separator { Layout.fillWidth: true }
0189 Demo {
0190 Layout.fillWidth: false
0191 Layout.fillHeight: false
0192 Layout.alignment: Qt.AlignHCenter
0193 Layout.preferredWidth: sampleDemo.width
0194 }
0195 Item {
0196 Layout.fillHeight: true
0197 }
0198 Kirigami.SelectableLabel {
0199 Layout.fillWidth: true
0200 horizontalAlignment: Text.AlignHCenter
0201 textFormat: Text.MarkdownText
0202 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."
0203 }
0204 }
0205 }
0206 }