2 #include <QOrientationReading>
3 #include <QOrientationSensor>
8 Rotation::Rotation(QObject *parent) :
14 void Rotation::onReadingChanged()
17 switch (m_sensor->reading()->orientation()) {
18 case QOrientationReading::TopUp:
19 case QOrientationReading::TopDown:
20 if( m_orientation == "potrait") {
22 emit orientationChanged();
25 case QOrientationReading::LeftUp:
26 case QOrientationReading::RightUp:
27 if (m_orientation == "") {
28 m_orientation = "potrait";
29 emit orientationChanged();
39 QTimer::singleShot(1000, this, SLOT(startReading()));
43 const QString& Rotation::orientation() const
48 void Rotation::startReading()
50 m_sensor = new QOrientationSensor(this);
51 connect(m_sensor, SIGNAL(readingChanged()), this, SLOT(onReadingChanged()));