blob: eefeecddba9b3ad24d6aa155e42e70ba02c4be60 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "abstractdeviceorientation.h"
#include <QDateTime>
#include <QDebug>
#include <QtMath>
#include <QScreen>
AbstractDeviceOrientation::AbstractDeviceOrientation(QObject *parent)
: QObject(parent)
, m_roll(0)
, m_pitch(0)
, m_yaw(0)
, m_enabled(false)
{
}
bool AbstractDeviceOrientation::enabled() const
{
return m_enabled;
}
void AbstractDeviceOrientation::stop()
{
if (m_enabled) {
m_enabled = false;
emit enabledChanged(m_enabled);
}
}
void AbstractDeviceOrientation::setRoll(qreal v)
{
if (v != m_roll) {
m_roll = v;
emit rollChanged(v);
}
}
void AbstractDeviceOrientation::setPitch(qreal v)
{
if (v != m_pitch) {
m_pitch = v;
emit pitchChanged(v);
}
}
void AbstractDeviceOrientation::setYaw(qreal v)
{
if (v != m_yaw) {
m_yaw = v;
emit yawChanged(v);
}
}
void AbstractDeviceOrientation::setEnabled(bool v)
{
if (v && !m_enabled) {
start();
} else if (!v && m_enabled) {
stop();
}
}
|