blob: c34e9e92a702a2c7129f1dae73a6039f08a6361f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (C) 2016 Research In Motion
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qvideooutputorientationhandler_p.h"
#include <QGuiApplication>
#include <QScreen>
QT_BEGIN_NAMESPACE
bool QVideoOutputOrientationHandler::m_isRecording = false;
QVideoOutputOrientationHandler::QVideoOutputOrientationHandler(QObject *parent)
: QObject(parent)
, m_currentOrientation(0)
{
QScreen *screen = QGuiApplication::primaryScreen();
if (!screen)
return;
connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
this, SLOT(screenOrientationChanged(Qt::ScreenOrientation)));
screenOrientationChanged(screen->orientation());
}
int QVideoOutputOrientationHandler::currentOrientation() const
{
return m_currentOrientation;
}
void QVideoOutputOrientationHandler::screenOrientationChanged(Qt::ScreenOrientation orientation)
{
if (m_isRecording)
return;
const QScreen *screen = QGuiApplication::primaryScreen();
if (!screen)
return;
const int angle = (360 - screen->angleBetween(screen->nativeOrientation(), orientation)) % 360;
if (angle == m_currentOrientation)
return;
m_currentOrientation = angle;
emit orientationChanged(m_currentOrientation);
}
QT_END_NAMESPACE
#include "moc_qvideooutputorientationhandler_p.cpp"
|