mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-15 14:51:14 -08:00
revision of example 'camera'
This commit is contained in:
parent
dd61e73fd1
commit
eee2adf6a8
2 changed files with 14 additions and 14 deletions
|
|
@ -7,6 +7,9 @@ Rectangle {
|
|||
width: 640
|
||||
height: 360
|
||||
color: "black"
|
||||
Screen.orientationUpdateMask:
|
||||
Qt.LandscapeOrientation | Qt.PortraitOrientation |
|
||||
Qt.InvertedLandscapeOrientation | Qt.InvertedPortraitOrientation
|
||||
|
||||
property int rotation: 0 // iOS: saved image will be rotated by this angle
|
||||
|
||||
|
|
@ -30,26 +33,24 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
anchors.bottomMargin: listView.height + 10
|
||||
focus: visible // to receive focus and capture key events when visible
|
||||
autoOrientation: (Qt.platform.os === "android")
|
||||
autoOrientation: true
|
||||
|
||||
Component.onCompleted: adaptOrientation(Screen.orientation)
|
||||
Component.onCompleted: updateImageRotation(Screen.orientation)
|
||||
}
|
||||
|
||||
// for iOS
|
||||
function adaptOrientation(orientation) {
|
||||
function updateImageRotation(orientation) {
|
||||
if (Qt.platform.os === "ios") {
|
||||
var angle = 0
|
||||
switch (orientation) {
|
||||
case Qt.PortraitOrientation: angle = -90; break
|
||||
case Qt.InvertedLandscapeOrientation: angle = 180; break
|
||||
case Qt.InvertedPortraitOrientation: angle = 90; break
|
||||
case Qt.LandscapeOrientation: rotation = 0; break
|
||||
case Qt.PortraitOrientation: rotation = 90; break
|
||||
case Qt.InvertedLandscapeOrientation: rotation = 180; break
|
||||
case Qt.InvertedPortraitOrientation: rotation = -90; break
|
||||
}
|
||||
videoOutput.orientation = angle
|
||||
rotation = (Math.abs(angle) === 90) ? -angle : angle
|
||||
}
|
||||
}
|
||||
|
||||
Screen.onOrientationChanged: adaptOrientation(Screen.orientation)
|
||||
Screen.onOrientationChanged: updateImageRotation(Screen.orientation)
|
||||
|
||||
// menu buttons
|
||||
|
||||
|
|
|
|||
|
|
@ -40,10 +40,9 @@ Note
|
|||
----
|
||||
|
||||
While testing on different devices (phone/tablet), I discovered that they may
|
||||
behave differently regarding the orientation (both video output and saved
|
||||
images) even if running the same OS. So, to adapt to your device's behavior,
|
||||
you need to play around with `autoOrientation` and the angles in function
|
||||
`adaptOrientation()`; see also Lisp function `qt:rotate-image`.
|
||||
behave differently regarding the saved image orientation, even if running the
|
||||
same OS. So, to adapt to your device's behavior, you need to play around with
|
||||
`rotation` in `updateImageRotation()` (QML). See also `qt:rotate-image` (Lisp).
|
||||
|
||||
The current settings worked for me on both an android phone and an iPhone (both
|
||||
older models).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue