| |   |
| 40 | 40 | |
| 41 | 41 | private: |
| 42 | 42 | void orientationUpdate(const QString& orientation, const QString& stand, const QString& face); |
| void enableAccelerometer(); |
| void disableAccelerometer(); |
| 43 | 45 | |
| 44 | 46 | private: |
| 45 | 47 | bool m_listenForOrientationChanges; |
| … | … | |
| 59 | 59 | // Update current orientation to portrait/landscape if desired |
| 60 | 60 | if (updateCurrentOrientation) |
| 61 | 61 | { |
| enableAccelerometer(); |
|
| 62 | 64 | // Query current device orientation to start in correct mode |
| QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET); |
| QDBusMessage msg = QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, |
| MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET); |
| 64 | 67 | |
| 65 | 68 | // Ignore the last three arguments of the orientation information (x, y and z axis) |
| 66 | 69 | QDBusConnection::systemBus().callWithCallback(msg, pub, SLOT(orientationUpdate(QString, QString, QString))); |
| … | … | |
| 74 | 74 | { |
| 75 | 75 | MAEMO_PUBLIC(QOrientationCapability); |
| 76 | 76 | Maemo::setIntXProperty(qobject_cast<QWidget *>(pub->parent()), PORTRAIT_MODE_SUPPORT, 0); |
|
| //request to stop accelerometer |
| if(m_listenForOrientationChanges) { |
| disableAccelerometer(); |
| } |
| 77 | 82 | } |
| 78 | 83 | |
| 79 | 84 | bool QOrientationCapabilityPrivate::islisteningOrientationChanges() const |
| … | … | |
| 91 | 91 | MAEMO_PUBLIC(QOrientationCapability); |
| 92 | 92 | |
| 93 | 93 | if (listening) |
| { |
| { |
| enableAccelerometer(); |
|
| 95 | 97 | QDBusConnection::systemBus().connect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF, |
| 96 | 98 | MCE_DEVICE_ORIENTATION_SIG, pub, SLOT(orientationUpdate(QString, QString, QString))); |
| 97 | 99 | } |
| … | … | |
| 101 | 101 | { |
| 102 | 102 | QDBusConnection::systemBus().disconnect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF, |
| 103 | 103 | MCE_DEVICE_ORIENTATION_SIG, pub, SLOT(orientationUpdate(QString,QString,QString))); |
|
| disableAccelerometer(); |
| 104 | 106 | } |
| 105 | 107 | |
| 106 | 108 | m_listenForOrientationChanges = listening; |
| … | … | |
| 145 | 145 | QOrientation QOrientationCapabilityPrivate::currentOrientation() const |
| 146 | 146 | { |
| 147 | 147 | return m_currentOrientation; |
| } |
|
| void QOrientationCapabilityPrivate::enableAccelerometer() |
| { |
| QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, |
| MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ)); |
| } |
|
| void QOrientationCapabilityPrivate::disableAccelerometer() |
| { |
| QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, |
| MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ)); |
| 148 | 160 | } |
| 149 | 161 | |
| 150 | 162 | |