-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.qml
79 lines (74 loc) · 2.03 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import QtQuick 2.7
import QtQuick.Window 2.3
import QtQuick.Controls 2.3
Window {
visible: true
width: 1000
height: 600
title: qsTr("JSON Visualizer")
Rectangle{
id: jsonEditorFrame
anchors{
left: parent.left
top: parent.top
bottom: parent.bottom
margins: 20
}
width: 300
border.color: "black"
TextArea{
id: jsonEditor
anchors.fill: parent
text: $hub.demoJson
selectByMouse: true
}
}
Button{
id: visualizeButton
text: qsTr("Visualize")
anchors{
left: jsonEditorFrame.right
verticalCenter: parent.verticalCenter
margins: 10
}
onClicked: {
var jsonObj;
try {
jsonObj = JSON.parse(jsonEditor.text);
}catch(e){
console.log(e.name, e.message);
return;
}
if(visualizer.rootNode !== null){
$hub.destroyNode(visualizer.rootNode);
}
visualizer.rootNode = $hub.visualize(visualizer, jsonObj);
}
}
Rectangle{
id: visualizeFrame
anchors{
left: visualizeButton.right
top: parent.top
bottom: parent.bottom
right: parent.right
margins: 20
}
border.color: "black"
//Item{
ScrollView{
id: visualizeScrollView
anchors.centerIn: parent
clip: true
width: Math.min(parent.width, visualizer.width)
height: Math.min(parent.height, visualizer.height)
contentWidth: visualizer.width; contentHeight: visualizer.height
// ScrollBar.horizontal.policy: ScrollBar.AlwaysOn
// ScrollBar.vertical.policy: ScrollBar.AlwaysOn
Visualizer{
id: visualizer
anchors.centerIn: parent
}
}
}
}