forked from VMaxx/RepetierIntegration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonitorItem.qml
153 lines (135 loc) · 4.83 KB
/
MonitorItem.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import QtQuick 2.2
import RepetierIntegration 1.0 as RepetierIntegration
import UM 1.2 as UM
import Cura 1.0 as Cura
Component
{
id: monitorItem
Item
{
RepetierIntegration.NetworkMJPGImage
{
id: cameraImage
visible: OutputDevice != null ? OutputDevice.showCamera : false
property real maximumWidthMinusSidebar: maximumWidth - sidebar.width - 2 * UM.Theme.getSize("default_margin").width
property real maximumZoom: 2
property bool rotatedImage: (OutputDevice.cameraOrientation.rotation / 90) % 2
property bool proportionalHeight:
{
if (imageHeight == 0 || maximumHeight == 0)
{
return true;
}
if (!rotatedImage)
{
return (imageWidth / imageHeight) > (maximumWidthMinusSidebar / maximumHeight);
}
else
{
return (imageWidth / imageHeight) > (maximumHeight / maximumWidthMinusSidebar);
}
}
property real _width:
{
if (!rotatedImage)
{
return Math.min(maximumWidthMinusSidebar, imageWidth * screenScaleFactor * maximumZoom);
}
else
{
return Math.min(maximumHeight, imageWidth * screenScaleFactor * maximumZoom);
}
}
property real _height:
{
if (!rotatedImage)
{
return Math.min(maximumHeight, imageHeight * screenScaleFactor * maximumZoom);
}
else
{
return Math.min(maximumWidth, imageHeight * screenScaleFactor * maximumZoom);
}
}
width: proportionalHeight ? _width : imageWidth * _height / imageHeight
height: !proportionalHeight ? _height : imageHeight * _width / imageWidth
anchors.horizontalCenter: horizontalCenterItem.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted:
{
if (visible)
{
start();
}
}
onVisibleChanged:
{
if (visible)
{
start();
} else
{
stop();
}
}
source: OutputDevice.cameraUrl
rotation: OutputDevice.cameraOrientation.rotation
mirror: OutputDevice.cameraOrientation.mirror
}
Item
{
id: horizontalCenterItem
anchors.left: parent.left
anchors.right: sidebar.left
}
Cura.RoundedRectangle
{
id: sidebar
width: UM.Theme.getSize("print_setup_widget").width
anchors
{
right: parent.right
top: parent.top
topMargin: UM.Theme.getSize("default_margin").height
bottom: actionsPanel.top
bottomMargin: UM.Theme.getSize("default_margin").height
}
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
color: UM.Theme.getColor("main_background")
cornerSide: Cura.RoundedRectangle.Direction.Left
radius: UM.Theme.getSize("default_radius").width
Cura.PrintMonitor {
width: parent.width
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
}
}
}
Cura.RoundedRectangle
{
id: actionsPanel
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
color: UM.Theme.getColor("main_background")
cornerSide: Cura.RoundedRectangle.Direction.Left
radius: UM.Theme.getSize("default_radius").width
anchors.bottom: parent.bottom
anchors.right: parent.right
width: UM.Theme.getSize("print_setup_widget").width
height: monitorButton.height + UM.Theme.getSize("default_margin").height
// MonitorButton is actually the bottom footer panel.
Cura.MonitorButton
{
id: monitorButton
width: parent.width
anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("default_margin").height
}
}
}
}