Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/rpm/lipstick-qt5.spec b/rpm/lipstick-qt5.spec
- index 5136ec6..be19691 100644
- --- a/rpm/lipstick-qt5.spec
- +++ b/rpm/lipstick-qt5.spec
- @@ -27,6 +27,7 @@ BuildRequires: pkgconfig(Qt5Xml)
- BuildRequires: pkgconfig(Qt5Sql)
- BuildRequires: pkgconfig(Qt5SystemInfo)
- BuildRequires: pkgconfig(Qt5Test)
- +BuildRequires: pkgconfig(Qt5Sensors)
- BuildRequires: pkgconfig(contentaction5)
- BuildRequires: pkgconfig(mlite5) >= 0.0.6
- BuildRequires: pkgconfig(mce) >= 1.12.2
- diff --git a/src/compositor/lipstickcompositor.cpp b/src/compositor/lipstickcompositor.cpp
- index a926c1a..5082f9f 100644
- --- a/src/compositor/lipstickcompositor.cpp
- +++ b/src/compositor/lipstickcompositor.cpp
- @@ -19,6 +19,7 @@
- #include <QWaylandInputDevice>
- #include <QDesktopServices>
- +#include <QtSensors/QOrientationSensor>
- #include "homeapplication.h"
- #include "windowmodel.h"
- #include "lipstickcompositorprocwindow.h"
- @@ -39,11 +40,15 @@ LipstickCompositor::LipstickCompositor()
- QObject::connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(clearUpdateRequest()));
- connect(m_displayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState)));
- + m_orientationSensor = new QOrientationSensor(this);
- + QObject::connect(m_orientationSensor,SIGNAL(readingChanged()),this,SLOT(orientationSensorChanged()));
- +
- emit HomeApplication::instance()->homeActiveChanged();
- QDesktopServices::setUrlHandler("http", this, "openUrl");
- QDesktopServices::setUrlHandler("https", this, "openUrl");
- QDesktopServices::setUrlHandler("mailto", this, "openUrl");
- +
- }
- LipstickCompositor::~LipstickCompositor()
- @@ -466,3 +471,32 @@ void LipstickCompositor::reactOnDisplayStateChanges(MeeGo::QmDisplayState::Displ
- emit displayOn();
- }
- }
- +
- +void LipstickCompositor::orientationSensorChanged()
- +{
- + QOrientationReading* reading = m_orientationSensor->reading();
- +
- + if (debug())
- + qDebug() << "Screen orientation changed "<<reading->orientation();
- +
- + switch(reading->orientation()){
- + case QOrientationReading::TopUp:
- + setScreenOrientation(Qt::PortraitOrientation);
- + break;
- + case QOrientationReading::TopDown:
- + setScreenOrientation(Qt::InvertedPortraitOrientation);
- + break;
- + case QOrientationReading::LeftUp:
- + setScreenOrientation(Qt::InvertedLandscapeOrientation);
- + break;
- + case QOrientationReading::RightUp:
- + setScreenOrientation(Qt::LandscapeOrientation);
- + break;
- + case QOrientationReading::Undefined:
- + case QOrientationReading::FaceUp:
- + case QOrientationReading::FaceDown:
- + default:
- + //ignore
- + break;
- + }
- +}
- diff --git a/src/compositor/lipstickcompositor.h b/src/compositor/lipstickcompositor.h
- index ccddfa7..b83646f 100644
- --- a/src/compositor/lipstickcompositor.h
- +++ b/src/compositor/lipstickcompositor.h
- @@ -26,6 +26,7 @@
- class WindowModel;
- class LipstickCompositorWindow;
- class LipstickCompositorProcWindow;
- +class QOrientationSensor;
- class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandCompositor,
- public QQmlParserStatus
- @@ -119,6 +120,7 @@ private slots:
- void windowPropertyChanged(const QString &);
- void openUrl(const QUrl &);
- void reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState state);
- + void orientationSensorChanged();
- private:
- friend class LipstickCompositorWindow;
- @@ -155,6 +157,7 @@ private:
- Qt::ScreenOrientation m_screenOrientation;
- MeeGo::QmDisplayState *m_displayState;
- QAtomicInt m_updateRequestPosted;
- + QOrientationSensor* m_orientationSensor;
- };
- #endif // LIPSTICKCOMPOSITOR_H
- diff --git a/src/src.pro b/src/src.pro
- index b62106c..1774eab 100644
- --- a/src/src.pro
- +++ b/src/src.pro
- @@ -116,7 +116,7 @@ packagesExist(contextkit-statefs) {
- warning("Contextsubscriber not found")
- }
- -QT += dbus xml qml quick sql gui gui-private
- +QT += dbus xml qml quick sql gui gui-private sensors
- QMAKE_CXXFLAGS += \
- -Werror \
- diff --git a/tests/stubs/lipstickcompositor_stub.h b/tests/stubs/lipstickcompositor_stub.h
- index 361d066..af219b8 100644
- --- a/tests/stubs/lipstickcompositor_stub.h
- +++ b/tests/stubs/lipstickcompositor_stub.h
- @@ -46,6 +46,7 @@ class LipstickCompositorStub : public StubBase {
- virtual void windowDestroyed();
- virtual void windowPropertyChanged(const QString &);
- virtual void reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState);
- + virtual void orientationSensorChanged();
- };
- // 2. IMPLEMENT STUB
- @@ -239,6 +240,10 @@ void LipstickCompositorStub::reactOnDisplayStateChanges(MeeGo::QmDisplayState::D
- stubMethodEntered("reactOnDisplayStateChanges",params);
- }
- +void LipstickCompositorStub::orientationSensorChanged( ) {
- + stubMethodEntered("orientationSensorChanged");
- +}
- +
- // 3. CREATE A STUB INSTANCE
- @@ -395,6 +400,10 @@ void LipstickCompositor::reactOnDisplayStateChanges(MeeGo::QmDisplayState::Displ
- gLipstickCompositorStub->reactOnDisplayStateChanges(state);
- }
- +void LipstickCompositor::orientationSensorChanged() {
- + gLipstickCompositorStub->orientationSensorChanged();
- +}
- +
- QWaylandCompositor::QWaylandCompositor(QWindow *, const char *)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement