forked from fieldOfView/Cura-OctoPrintPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonitorItem3x.qml
83 lines (78 loc) · 2.57 KB
/
MonitorItem3x.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
// Copyright (c) 2019 Aldo Hoeben / fieldOfView
// OctoPrintPlugin is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2
import OctoPrintPlugin 1.0 as OctoPrintPlugin
Component
{
Item
{
OctoPrintPlugin.NetworkMJPGImage
{
id: cameraImage
visible: OutputDevice != null ? OutputDevice.showCamera : false
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) > (maximumWidth / maximumHeight);
}
else
{
return (imageWidth / imageHeight) > (maximumHeight / maximumWidth);
}
}
property real _width:
{
if (!rotatedImage)
{
return Math.min(maximumWidth, 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: parent.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
}
}
}