Warning, /plasma/libksysguard/tests/formatter/test_formatter.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010
0011 import org.kde.ksysguard.formatter as Formatter
0012
0013 Pane {
0014 width: 400
0015 height: 400
0016
0017 ColumnLayout {
0018 anchors.fill: parent
0019
0020 TextField {
0021 id: input
0022 Layout.fillWidth: true
0023 }
0024
0025 ComboBox {
0026 id: unitCombo
0027
0028 Layout.fillWidth: true
0029
0030 textRole: "key"
0031
0032 model: [
0033 { key: "Bytes", value: Formatter.Units.UnitByte },
0034 { key: "Kilobytes", value: Formatter.Units.UnitKiloByte },
0035 { key: "Megabytes", value: Formatter.Units.UnitMegaByte },
0036 { key: "Bytes per Second", value: Formatter.Units.UnitByteRate },
0037 { key: "Hertz", value: Formatter.Units.UnitHertz },
0038 { key: "Second", value: Formatter.Units.UnitSecond },
0039 { key: "Celcius", value: Formatter.Units.UnitCelsius },
0040 { key: "Volt", value: Formatter.Units.UnitVolt },
0041 { key: "Watt", value: Formatter.Units.UnitWatt }
0042 ]
0043 }
0044
0045 ComboBox {
0046 id: prefixCombo
0047
0048 Layout.fillWidth: true
0049
0050 textRole: "key"
0051
0052 model: [
0053 { key: "None", value: Formatter.Units.MetricPrefixUnity },
0054 { key: "Auto-adjust", value: Formatter.Units.MetricPrefixAutoAdjust },
0055 { key: "Kilo", value: Formatter.Units.MetricPrefixKilo },
0056 { key: "Mega", value: Formatter.Units.MetricPrefixMega },
0057 { key: "Giga", value: Formatter.Units.MetricPrefixGiga },
0058 { key: "Tera", value: Formatter.Units.MetricPrefixTera },
0059 { key: "Peta", value: Formatter.Units.MetricPrefixPeta }
0060 ]
0061 }
0062
0063 Label {
0064 text: Formatter.Formatter.formatValueShowNull(input.text,
0065 unitCombo.model[unitCombo.currentIndex].value,
0066 prefixCombo.model[prefixCombo.currentIndex].value
0067 )
0068 }
0069 }
0070 }