//[RestInPeaceQmlComponent] import QtQuick 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.12 import QtMultimedia 5.8 import QtSensors 5.0 import '../Scripts/JDefines.js' as JDefines Dialog { id: dlg x: (parent.width - width) / 2 y: (parent.height - height) / 2 parent: Overlay.overlay property int orientation:base.isIOS()?90:270 focus: true modal: true property alias camera:camera property string completeImageSavedPath:'' property int picType leftMargin: 0 rightMargin: 0 topMargin: 0 bottomMargin: 0 leftPadding: 0 rightPadding: 0 topPadding: 0 bottomPadding: 0 leftInset: 0 rightInset: 0 topInset: 0 bottomInset: 0 header: undefined footer: undefined contentItem:Rectangle{ color:'#222A2D' anchors.fill: parent SoundEffect { id: captureSound source: "qrc:/Resources/btnsound.wav" } ColumnLayout{ id:columnLayout anchors{horizontalCenter: parent.horizontalCenter;top:parent.top} spacing: 0 Item{ height: base.vm1 } Label{ id:lblTitle font{pointSize: base.pointSize7;bold: true} color:JDefines.ColorUttiliYellow horizontalAlignment: Text.AlignHCenter Layout.fillWidth: true } Label{ id:lblSubtitle horizontalAlignment: Text.AlignHCenter Layout.fillWidth: true color: 'white' font{pointSize: base.pointSize2;} } Item{ height: base.height*0.01 } } Camera { id: camera viewfinder.resolution:Qt.size(800,600) position: Camera.BackFace imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash captureMode: Camera.CaptureStillImage exposure {exposureMode: Camera.ExposureAuto} flash.mode: Camera.FlashAuto focus.focusMode: CameraFocus.FocusAuto | CameraFocus.FocusContinuous onError: dlg.error(errorCode, errorString) imageCapture { onCaptureFailed: dlg.captureFailed(requestId, message); onImageSaved: dlg.imageSaved(requestId, path) onImageCaptured: dlg.imageCaptured(requestId, preview) } } VideoOutput { id:videoOutput source: camera anchors{left:parent.left;right: parent.right;top:columnLayout.bottom;bottom: parent.bottom} focus : visible // to receive focus and capture key events when visible autoOrientation: false orientation: dlg.orientation } Image { id: photoPreview cache: false anchors{left:parent.left;right: parent.right;top:columnLayout.bottom;bottom: parent.bottom} fillMode: Image.PreserveAspectFit smooth: true } VButton{ id: btnCapture btnRadius: 5 fontWeight: Font.Bold fontPointSize: base.pointSize4 Layout.fillWidth: true btnImplicitHeight: base.height*0.03 text: 'Fotografar' anchors{bottom:parent.bottom;bottomMargin: base.vm1;horizontalCenter: parent.horizontalCenter} backgroundColor: JDefines.ColorUttiliBlue pressedBackColor: JDefines.ButtonPressedColor textColor: 'white' onClicked: { captureSound.play(); camera.imageCapture.capture(); } z:50 } OrientationSensor { id: sensor active: true onReadingChanged: { console.log('alterou orientation', sensor.reading.orientation) switch (sensor.reading.orientation) { case OrientationReading.FaceUp: case OrientationReading.FaceDown: case OrientationReading.TopUp: videoOutput.orientation = 270; break; case OrientationReading.TopDown: videoOutput.orientation = 90; break; case OrientationReading.LeftUp: videoOutput.orientation = 180; break; case OrientationReading.RightUp: videoOutput.orientation = 0; break; } } } } function imageSaved(requestId, path){ console.log('(VCnhDlg)imageSaved:',path, '.Camera orientation:', camera.orientation); completeImageSavedPath=path; if(orientation!=0 && base.isIOS())base.rotateImageFile(path,orientation);//works fine photoPreview.source = path; // Show the preview in an Image photoPreview.visible=true accept();//nao tinha isso quando tinha o preview } }