Change the preview by using wheel instead of just upgrading the scale twice.

Right clicking reset the position and the size.
This commit is contained in:
Julien Wadel 2020-07-21 16:16:45 +02:00
parent 79b9d94514
commit 093261d432
3 changed files with 45 additions and 19 deletions

View file

@ -19,6 +19,7 @@ Item {
// ---------------------------------------------------------------------------
signal clicked (var mouse)
signal pressed (var mouse)
signal released (var mouse)
signal wheel (var wheel)
@ -57,7 +58,20 @@ Item {
_mouseArea = null
}
}
function updateBoundaries(){
var container = dragBox.container
if (parent.x < 0) {
parent.x = 0
} else if (parent.x + parent.width >= container.width) {
parent.x = container.width - parent.width
}
if (parent.y < 0) {
parent.y = 0
} else if (parent.y + parent.height >= container.height) {
parent.y = container.height - parent.height
}
}
// ---------------------------------------------------------------------------
Component.onCompleted: enabled && _create()
@ -81,11 +95,13 @@ Item {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
drag {
axis: Drag.XandYAxis
target: parent
}
onClicked:dragBox.clicked(mouse)
onPressed: {
dragBox.pressed(mouse)
held = true
@ -94,20 +110,7 @@ Item {
onReleased: {
dragBox.released(mouse)
held = false
var container = dragBox.container
if (parent.x < 0) {
parent.x = 0
} else if (parent.x + parent.width >= container.width) {
parent.x = container.width - parent.width
}
if (parent.y < 0) {
parent.y = 0
} else if (parent.y + parent.height >= container.height) {
parent.y = container.height - parent.height
}
updateBoundaries()
}
onWheel: dragBox.wheel(wheel)

View file

@ -422,7 +422,8 @@ Window {
id: cameraPreview
Camera {
property bool scale: false
id:cameraPreviewItem
property double scale: 1.0
function xPosition () {
return window.width / 2 - width / 2
@ -431,12 +432,17 @@ Window {
function yPosition () {
return window.height - height
}
function resetPosition(){
x = xPosition ();
y = yPosition ();
}
call: window.call
isPreview: true
height: CallStyle.actionArea.userVideo.height * (scale ? 2 : 1)
width: CallStyle.actionArea.userVideo.width * (scale ? 2 : 1)
height: (CallStyle.actionArea.userVideo.height * window.height/CallStyle.actionArea.userVideo.heightReference) * scale
width: (CallStyle.actionArea.userVideo.width * window.width/CallStyle.actionArea.userVideo.widthReference) * scale
DragBox {
container: window
@ -444,8 +450,23 @@ Window {
xPosition: parent.xPosition
yPosition: parent.yPosition
property double startTime: 0
onWheel: parent.scale = wheel.angleDelta.y > 0
onWheel: {
var acceleration = 0.1;
if(startTime == 0){
startTime = new Date().getTime();
}else
acceleration = Math.max(0.005,10/(new Date().getTime() - startTime));
parent.scale = Math.max(0.5 , parent.scale+acceleration*(wheel.angleDelta.y >0 ? 1 : -1) );
updateBoundaries();
startTime = new Date().getTime();
}
onClicked: if(mouse.button == Qt.RightButton) {
parent.scale = 1;
resetPosition();
}
}
}
}

View file

@ -19,6 +19,8 @@ QtObject {
property QtObject userVideo: QtObject {
property int height: 200
property int width: 130
property int heightReference: 1200 // height and width are fixed from these references
property int widthReference: 780
}
property QtObject vu: QtObject {