Merge pull request #2200 from fieldOfView/fix_monitoritem_size

Adapt camera image to available space
This commit is contained in:
alekseisasin 2017-08-15 14:45:34 +02:00
parent da8b55cf62
commit 3116ff829c
3 changed files with 19 additions and 2 deletions

View file

@ -9,9 +9,20 @@ Component
Image
{
id: cameraImage
width: sourceSize.width
height: sourceSize.height * width / sourceSize.width
property bool proportionalHeight:
{
if(sourceSize.height == 0 || maximumHeight == 0)
{
return true;
}
return (sourceSize.width / sourceSize.height) > (maximumWidth / maximumHeight);
}
property real _width: Math.min(maximumWidth, sourceSize.width)
property real _height: Math.min(maximumHeight, sourceSize.height)
width: proportionalHeight ? _width : sourceSize.width * _height / sourceSize.height
height: !proportionalHeight ? _height : sourceSize.height * _width / sourceSize.width
anchors.horizontalCenter: parent.horizontalCenter
onVisibleChanged:
{
if(visible)