Debian Codegraph @

src/qml/AMDPMVoltOffsetForm.qml

raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2021 Juan Palacios <[email protected]>
3
4 import QtQuick 2.15
5 import QtQuick.Controls 2.15
6 import QtQuick.Layouts 1.15
7 import CoreCtrl.UIComponents 1.0
8 import "Style.js" as Style
9
10 AMD_PM_VOLT_OFFSET {
11 id: pmVoltOffset
12 objectName: "AMD_PM_VOLT_OFFSET"
13
14 width: contents.width
15 height: contents.height
16
17 onValueChanged: value => offsetSld.value = value
18
19 onRangeChanged: (min, max) => {
20 offsetSld.from = min
21 offsetSld.to = max
22 }
23
24 CPane {
25 id: contents
26
27 background: Rectangle {
28 border.color: Style.FVControl.border_color
29 border.width: 2
30 color: "#00000000"
31 }
32
33 TextMetrics {
34 id: tFMetrics
35 text: "-000"
36 }
37
38 GridLayout {
39 columns: 2
40 anchors.fill: parent
41
42 RowLayout {
43 Layout.columnSpan: 2
44
45 Label {
46 id: title
47 text: qsTr("Voltage")
48 font.pointSize: 11
49 font.bold: true
50 }
51
52 Item { Layout.fillWidth: true }
53
54 Item {
55 visible: offsetSld.value > 0
56
57 implicitWidth: warningIcn.width
58 implicitHeight: warningIcn.height
59
60 ToolTip.text: qsTr("WARNING: Operating range not available. Use with caution!")
61 ToolTip.visible: ma.containsMouse
62 MouseArea {
63 id: ma
64 anchors.fill: parent
65 hoverEnabled: true
66 }
67
68 Image {
69 id: warningIcn
70 source: "qrc:/images/WarningIcon"
71 anchors.fill: parent
72 fillMode: Image.PreserveAspectFit
73 width: Style.g_icon.small_size
74 height: Style.g_icon.small_size
75 sourceSize.width: Style.g_icon.size
76 }
77 }
78 }
79
80 CPane {
81 padding: Style.FVControl.inner_padding
82 bottomPadding: 0
83 Layout.columnSpan: 2
84
85 ColumnLayout {
86 Layout.fillWidth: true
87
88 Label {
89 text: qsTr("OFFSET")
90 Layout.alignment: Qt.AlignHCenter
91 }
92
93 Label {
94 text: "mV"
95 font.pointSize: 8
96 Layout.alignment: Qt.AlignHCenter
97 }
98
99 Slider {
100 id: offsetSld
101
102 Layout.alignment: Qt.AlignHCenter
103 orientation: Qt.Vertical
104
105 stepSize: 1
106
107 onPressedChanged: pressed => {
108 if (!pressed)
109 pmVoltOffset.changeValue(value)
110 }
111 }
112
113 CIntInput {
114 value: offsetSld.value
115 minValue: offsetSld.from
116 maxValue: offsetSld.to
117 Layout.preferredWidth: tFMetrics.width + padding * 2
118 Layout.alignment: Qt.AlignHCenter
119
120 onValueChanged: pmVoltOffset.changeValue(value)
121 }
122 }
123 }
124 }
125 }
126 }