SHARE
TWEET

Untitled

a guest Sep 30th, 2013 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/rpm/lipstick-qt5.spec b/rpm/lipstick-qt5.spec
  2. index 5136ec6..be19691 100644
  3. --- a/rpm/lipstick-qt5.spec
  4. +++ b/rpm/lipstick-qt5.spec
  5. @@ -27,6 +27,7 @@ BuildRequires:  pkgconfig(Qt5Xml)
  6.  BuildRequires:  pkgconfig(Qt5Sql)
  7.  BuildRequires:  pkgconfig(Qt5SystemInfo)
  8.  BuildRequires:  pkgconfig(Qt5Test)
  9. +BuildRequires:  pkgconfig(Qt5Sensors)
  10.  BuildRequires:  pkgconfig(contentaction5)
  11.  BuildRequires:  pkgconfig(mlite5) >= 0.0.6
  12.  BuildRequires:  pkgconfig(mce) >= 1.12.2
  13. diff --git a/src/compositor/lipstickcompositor.cpp b/src/compositor/lipstickcompositor.cpp
  14. index a926c1a..5082f9f 100644
  15. --- a/src/compositor/lipstickcompositor.cpp
  16. +++ b/src/compositor/lipstickcompositor.cpp
  17. @@ -19,6 +19,7 @@
  18.  
  19.  #include <QWaylandInputDevice>
  20.  #include <QDesktopServices>
  21. +#include <QtSensors/QOrientationSensor>
  22.  #include "homeapplication.h"
  23.  #include "windowmodel.h"
  24.  #include "lipstickcompositorprocwindow.h"
  25. @@ -39,11 +40,15 @@ LipstickCompositor::LipstickCompositor()
  26.      QObject::connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(clearUpdateRequest()));
  27.      connect(m_displayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState)));
  28.  
  29. +    m_orientationSensor = new QOrientationSensor(this);
  30. +    QObject::connect(m_orientationSensor,SIGNAL(readingChanged()),this,SLOT(orientationSensorChanged()));
  31. +
  32.      emit HomeApplication::instance()->homeActiveChanged();
  33.  
  34.      QDesktopServices::setUrlHandler("http", this, "openUrl");
  35.      QDesktopServices::setUrlHandler("https", this, "openUrl");
  36.      QDesktopServices::setUrlHandler("mailto", this, "openUrl");
  37. +
  38.  }
  39.  
  40.  LipstickCompositor::~LipstickCompositor()
  41. @@ -466,3 +471,32 @@ void LipstickCompositor::reactOnDisplayStateChanges(MeeGo::QmDisplayState::Displ
  42.          emit displayOn();
  43.      }
  44.  }
  45. +
  46. +void LipstickCompositor::orientationSensorChanged()
  47. +{
  48. +    QOrientationReading* reading = m_orientationSensor->reading();
  49. +
  50. +    if (debug())
  51. +        qDebug() << "Screen orientation changed "<<reading->orientation();
  52. +
  53. +    switch(reading->orientation()){
  54. +        case QOrientationReading::TopUp:
  55. +            setScreenOrientation(Qt::PortraitOrientation);
  56. +            break;
  57. +        case QOrientationReading::TopDown:
  58. +            setScreenOrientation(Qt::InvertedPortraitOrientation);
  59. +            break;
  60. +        case QOrientationReading::LeftUp:
  61. +            setScreenOrientation(Qt::InvertedLandscapeOrientation);
  62. +            break;
  63. +        case QOrientationReading::RightUp:
  64. +            setScreenOrientation(Qt::LandscapeOrientation);
  65. +            break;
  66. +        case QOrientationReading::Undefined:
  67. +        case QOrientationReading::FaceUp:
  68. +        case QOrientationReading::FaceDown:
  69. +        default:
  70. +        //ignore
  71. +        break;
  72. +    }
  73. +}
  74. diff --git a/src/compositor/lipstickcompositor.h b/src/compositor/lipstickcompositor.h
  75. index ccddfa7..b83646f 100644
  76. --- a/src/compositor/lipstickcompositor.h
  77. +++ b/src/compositor/lipstickcompositor.h
  78. @@ -26,6 +26,7 @@
  79.  class WindowModel;
  80.  class LipstickCompositorWindow;
  81.  class LipstickCompositorProcWindow;
  82. +class QOrientationSensor;
  83.  
  84.  class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandCompositor,
  85.                                             public QQmlParserStatus
  86. @@ -119,6 +120,7 @@ private slots:
  87.      void windowPropertyChanged(const QString &);
  88.      void openUrl(const QUrl &);
  89.      void reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState state);
  90. +    void orientationSensorChanged();
  91.  
  92.  private:
  93.      friend class LipstickCompositorWindow;
  94. @@ -155,6 +157,7 @@ private:
  95.      Qt::ScreenOrientation m_screenOrientation;
  96.      MeeGo::QmDisplayState *m_displayState;
  97.      QAtomicInt m_updateRequestPosted;
  98. +    QOrientationSensor* m_orientationSensor;
  99.  };
  100.  
  101.  #endif // LIPSTICKCOMPOSITOR_H
  102. diff --git a/src/src.pro b/src/src.pro
  103. index b62106c..1774eab 100644
  104. --- a/src/src.pro
  105. +++ b/src/src.pro
  106. @@ -116,7 +116,7 @@ packagesExist(contextkit-statefs) {
  107.      warning("Contextsubscriber not found")
  108.  }
  109.  
  110. -QT += dbus xml qml quick sql gui gui-private
  111. +QT += dbus xml qml quick sql gui gui-private sensors
  112.  
  113.  QMAKE_CXXFLAGS += \
  114.      -Werror \
  115. diff --git a/tests/stubs/lipstickcompositor_stub.h b/tests/stubs/lipstickcompositor_stub.h
  116. index 361d066..af219b8 100644
  117. --- a/tests/stubs/lipstickcompositor_stub.h
  118. +++ b/tests/stubs/lipstickcompositor_stub.h
  119. @@ -46,6 +46,7 @@ class LipstickCompositorStub : public StubBase {
  120.    virtual void windowDestroyed();
  121.    virtual void windowPropertyChanged(const QString &);
  122.    virtual void reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState);
  123. +  virtual void orientationSensorChanged();
  124.  };
  125.  
  126.  // 2. IMPLEMENT STUB
  127. @@ -239,6 +240,10 @@ void LipstickCompositorStub::reactOnDisplayStateChanges(MeeGo::QmDisplayState::D
  128.    stubMethodEntered("reactOnDisplayStateChanges",params);
  129.  }
  130.  
  131. +void LipstickCompositorStub::orientationSensorChanged( ) {
  132. +  stubMethodEntered("orientationSensorChanged");
  133. +}
  134. +
  135.  
  136.  
  137.  // 3. CREATE A STUB INSTANCE
  138. @@ -395,6 +400,10 @@ void LipstickCompositor::reactOnDisplayStateChanges(MeeGo::QmDisplayState::Displ
  139.    gLipstickCompositorStub->reactOnDisplayStateChanges(state);
  140.  }
  141.  
  142. +void LipstickCompositor::orientationSensorChanged() {
  143. +  gLipstickCompositorStub->orientationSensorChanged();
  144. +}
  145. +
  146.  QWaylandCompositor::QWaylandCompositor(QWindow *, const char *)
  147.  {
  148.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top