Skip to content

Commit 4f263cd

Browse files
committed
added camera stop
1 parent 36d520d commit 4f263cd

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

Diff for: qml/Neuronify.qml

+19-21
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,6 @@ Rectangle {
229229
activeObject.destroy(1)
230230
}
231231

232-
233-
/*stop camera if last retina ************************/
234-
if(activeObject.toString().indexOf("Retina")> -1){
235-
var lastRetinaObject = true
236-
237-
for(var i in graphEngine.nodes) {
238-
var listObject = graphEngine.nodes[i]
239-
if(listObject.toString().indexOf("Retina")> -1 && listObject!== activeObject){
240-
lastRetinaObject = false
241-
console.log(i)
242-
continue
243-
}
244-
}
245-
if(lastRetinaObject){
246-
videoSurface.camera.stop()
247-
}
248-
}
249-
/*****************************************************/
250-
251232
deselectAll()
252233
}
253234

@@ -295,8 +276,9 @@ Rectangle {
295276
return
296277
}
297278

298-
if(fileUrl.toString().indexOf("Retina.qml")> -1){
299-
console.log(videoSurface)
279+
var isRetina = fileUrl.toString().indexOf("Retina.qml")> -1
280+
if(isRetina){
281+
camera.retinaCounter += 1
300282
properties.videoSurface = videoSurface
301283
}
302284

@@ -308,6 +290,12 @@ Rectangle {
308290
return
309291
}
310292

293+
if(isRetina){
294+
entity.aboutToDie.connect(function(dead){
295+
camera.retinaCounter-=1
296+
})
297+
}
298+
311299
entity.dragStarted.connect(resetOrganize)
312300
entity.widthChanged.connect(resetOrganize)
313301
entity.heightChanged.connect(resetOrganize)
@@ -610,6 +598,16 @@ Rectangle {
610598
id: videoSurface
611599
camera: Camera{
612600
id:camera
601+
property bool active: retinaCounter > 0
602+
property int retinaCounter: 0
603+
604+
onActiveChanged: {
605+
if(active){
606+
camera.start()
607+
}else{
608+
camera.stop()
609+
}
610+
}
613611
}
614612
}
615613

Diff for: qml/sensors/Retina.qml

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ Node {
1717
property VideoSurface videoSurface: null;
1818
property int fieldIndex: 0
1919

20-
width:20
21-
height: 20
20+
width:50
21+
height: 50
2222

2323
dumpableProperties: [
2424
"x",
2525
"y"
2626
]
2727

28-
Component.onCompleted: {
28+
onVideoSurfaceChanged: {
29+
if(!videoSurface){
30+
return
31+
}
2932
if(!videoSurface.camera.ActiveState){
3033
videoSurface.camera.start()
3134
}
@@ -107,8 +110,8 @@ Node {
107110
id: retinaPainter
108111
visible: Qt.platform.os !== "android"
109112
enabled: Qt.platform.os !== "android"
110-
width: 100
111-
height: 100
113+
width: 200
114+
height: 200
112115
retinaEngine: retinaEngine
113116

114117
// MouseArea {

0 commit comments

Comments
 (0)