Skip to content

Commit a0701bd

Browse files
committed
Add scale dialgs
1 parent aaaf23f commit a0701bd

12 files changed

Lines changed: 175 additions & 37 deletions

File tree

assets/assets.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,6 @@
8686
<file>icons/scroll-down.svg</file>
8787
<file>icons/scroll-top.svg</file>
8888
<file>icons/scroll-up.svg</file>
89+
<file>qml/Widgets/SimpleDial.qml</file>
8990
</qresource>
9091
</RCC>

assets/qml/Widgets/MapDelegate.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ Window {
203203
anchors.fill: parent
204204
copyrightsVisible: false
205205
anchors.margins: parent.border.width
206-
onActiveMapTypeChanged: console.log(map.activeMapType)
207206

208207
tilt: 27
209208
zoomLevel: 16

assets/qml/Widgets/SimpleDial.qml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
import QtQuick 2.12
24+
import QtQuick.Controls 2.0
25+
26+
Dial {
27+
id: control
28+
29+
property string text: control.value.toFixed(1)
30+
property color dialColor: pressed ? palette.highlight : "#eee"
31+
32+
background: Rectangle {
33+
border.width: 2
34+
radius: width / 2
35+
color: "transparent"
36+
border.color: control.dialColor
37+
x: control.width / 2 - width / 2
38+
y: control.height / 2 - height / 2
39+
width: Math.min(control.width, control.height)
40+
height: Math.min(control.width, control.height)
41+
42+
Label {
43+
font.pixelSize: 12
44+
text: control.text
45+
color: control.dialColor
46+
anchors.centerIn: parent
47+
font.family: app.monoFont
48+
}
49+
}
50+
51+
handle: ToolButton {
52+
id: handleItem
53+
54+
width: 42
55+
height: 42
56+
enabled: false
57+
icon.width: width
58+
icon.height: height
59+
icon.color: control.dialColor
60+
icon.source: "qrc:/icons/scroll-up.svg"
61+
x: control.background.x + control.background.width / 2 - width / 2
62+
y: control.background.y + control.background.height / 2 - height / 2
63+
64+
transform: [
65+
Translate {
66+
y: -Math.min(control.background.width, control.background.height) * 0.55 + handleItem.height / 2
67+
},
68+
Rotation {
69+
angle: control.angle
70+
origin.x: handleItem.width / 2
71+
origin.y: handleItem.height / 2
72+
}
73+
]
74+
}
75+
}

assets/qml/Windows/DataGrid.qml

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Control {
4141
// Settings
4242
//
4343
Settings {
44-
property alias numPoints: slider.value
45-
property alias multiplier: mult.value
44+
property alias numPoints: points.value
45+
property alias multiplier: scale.value
4646
}
4747

4848
//
@@ -164,45 +164,72 @@ Control {
164164
// Horizontal range slider
165165
//
166166
RowLayout {
167-
spacing: 0
167+
id: ranges
168+
spacing: app.spacing * 2
168169
visible: graphGenerator.count > 0
169170

170-
Slider {
171-
id: slider
172-
to: 25
173-
from: 1
174-
value: 10
175-
live: false
176-
Layout.fillWidth: true
177-
Layout.alignment: Qt.AlignVCenter
178-
onValueChanged: Cpp_UI_GraphProvider.displayedPoints = value * Math.pow(10, mult.value)
171+
function updateGraphValue() {
172+
Cpp_UI_GraphProvider.displayedPoints = points.value * Math.pow(10, scale.value)
179173
}
180174

181-
Item {
182-
width: app.spacing
183-
}
175+
ColumnLayout {
176+
spacing: app.spacing
177+
Layout.fillWidth: true
178+
Layout.fillHeight: true
179+
Layout.alignment: Qt.AlignHCenter
184180

185-
Label {
186-
font.pixelSize: 12
187-
font.family: app.monoFont
188-
Layout.alignment: Qt.AlignVCenter
189-
text: Math.ceil(slider.position * (slider.to)) + "×10^"
190-
}
181+
Widgets.SimpleDial {
182+
id: points
191183

192-
Item {
193-
width: app.spacing
184+
to: 25
185+
from: 1
186+
value: 10
187+
Layout.fillWidth: true
188+
Layout.fillHeight: true
189+
Layout.alignment: Qt.AlignHCenter
190+
onPressedChanged: ranges.updateGraphValue()
191+
Component.onCompleted: ranges.updateGraphValue()
192+
}
193+
194+
Label {
195+
font.pixelSize: 12
196+
text: qsTr("Points")
197+
Layout.fillWidth: true
198+
font.family: app.monoFont
199+
Layout.alignment: Qt.AlignHCenter
200+
horizontalAlignment: Label.AlignHCenter
201+
}
194202
}
195203

196-
SpinBox {
197-
id: mult
198-
to: 6
199-
from: 0
200-
value: 1
201-
editable: true
202-
Layout.maximumWidth: 42
203-
font.family: app.monoFont
204-
Layout.alignment: Qt.AlignVCenter
205-
onValueChanged: Cpp_UI_GraphProvider.displayedPoints = slider.value * Math.pow(10, mult.value)
204+
ColumnLayout {
205+
spacing: app.spacing
206+
Layout.fillWidth: true
207+
Layout.fillHeight: true
208+
Layout.alignment: Qt.AlignHCenter
209+
210+
Widgets.SimpleDial {
211+
id: scale
212+
213+
to: 6
214+
from: 0
215+
value: 1
216+
Layout.fillWidth: true
217+
Layout.fillHeight: true
218+
snapMode: Dial.SnapOnRelease
219+
text: "10^" + Math.ceil(scale.value)
220+
Layout.alignment: Qt.AlignHCenter
221+
onPressedChanged: ranges.updateGraphValue()
222+
Component.onCompleted: ranges.updateGraphValue()
223+
}
224+
225+
Label {
226+
font.pixelSize: 12
227+
Layout.fillWidth: true
228+
font.family: app.monoFont
229+
Layout.alignment: Qt.AlignHCenter
230+
horizontalAlignment: Label.AlignHCenter
231+
text: qsTr("Scale")
232+
}
206233
}
207234
}
208235

assets/translations/de.qm

243 Bytes
Binary file not shown.

assets/translations/de.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<name>Console</name>
138138
<message>
139139
<source>No data received so far...</source>
140-
<translation type="vanished">Noch keine Daten verfügbar...</translation>
140+
<translation>Noch keine Daten verfügbar...</translation>
141141
</message>
142142
<message>
143143
<source>Send data to device</source>
@@ -241,6 +241,14 @@
241241
<source>Data</source>
242242
<translation>Daten</translation>
243243
</message>
244+
<message>
245+
<source>Points</source>
246+
<translation>Punkte</translation>
247+
</message>
248+
<message>
249+
<source>Scale</source>
250+
<translation>Multiplikator</translation>
251+
</message>
244252
</context>
245253
<context>
246254
<name>DeviceManager</name>

assets/translations/en.qm

147 Bytes
Binary file not shown.

assets/translations/en.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@
163163
<source>Save as</source>
164164
<translation></translation>
165165
</message>
166+
<message>
167+
<source>No data received so far...</source>
168+
<translation></translation>
169+
</message>
166170
</context>
167171
<context>
168172
<name>CsvPlayer</name>
@@ -197,6 +201,14 @@
197201
<source>Data</source>
198202
<translation></translation>
199203
</message>
204+
<message>
205+
<source>Points</source>
206+
<translation></translation>
207+
</message>
208+
<message>
209+
<source>Scale</source>
210+
<translation></translation>
211+
</message>
200212
</context>
201213
<context>
202214
<name>DeviceManager</name>

assets/translations/es.qm

251 Bytes
Binary file not shown.

assets/translations/es.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<name>Console</name>
142142
<message>
143143
<source>No data received so far...</source>
144-
<translation type="vanished">No se han recibido datos hasta ahora ...</translation>
144+
<translation>No se han recibido datos hasta ahora ...</translation>
145145
</message>
146146
<message>
147147
<source>Autoscroll</source>
@@ -249,6 +249,14 @@
249249
<source>Data</source>
250250
<translation>Datos</translation>
251251
</message>
252+
<message>
253+
<source>Points</source>
254+
<translation>Puntos</translation>
255+
</message>
256+
<message>
257+
<source>Scale</source>
258+
<translation>Escala</translation>
259+
</message>
252260
</context>
253261
<context>
254262
<name>DeviceManager</name>

0 commit comments

Comments
 (0)