summaryrefslogtreecommitdiffstats
path: root/tools/qml/deviceorientation_symbian.cpp
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-09-06 08:04:13 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-09-07 04:16:55 (GMT)
commitead14cd61da071ac10e7a83b9c1d05098cf2a679 (patch)
tree3da3f83459fde89afab69de35d22e0ee8baea801 /tools/qml/deviceorientation_symbian.cpp
parent3113a91f50f12c8ee53f2e84f6b46fde6c2c1693 (diff)
downloadQt-ead14cd61da071ac10e7a83b9c1d05098cf2a679.zip
Qt-ead14cd61da071ac10e7a83b9c1d05098cf2a679.tar.gz
Qt-ead14cd61da071ac10e7a83b9c1d05098cf2a679.tar.bz2
Pause orientation sensors in Qml Viewer when the application window is not active
Task-number: QTBUG-13347 Reviewed-by: Martin Jones
Diffstat (limited to 'tools/qml/deviceorientation_symbian.cpp')
-rw-r--r--tools/qml/deviceorientation_symbian.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/qml/deviceorientation_symbian.cpp b/tools/qml/deviceorientation_symbian.cpp
index 307c417..7710cf9 100644
--- a/tools/qml/deviceorientation_symbian.cpp
+++ b/tools/qml/deviceorientation_symbian.cpp
@@ -52,7 +52,7 @@ class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
Q_OBJECT
public:
SymbianOrientation()
- : DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0)
+ : DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0), m_channelOpen(false)
{
TRAP_IGNORE(initL());
if (!m_sensorChannel)
@@ -84,6 +84,7 @@ public:
TRAP(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
+ m_channelOpen = true;
break;
}
if (error) {
@@ -107,6 +108,30 @@ public:
private:
DeviceOrientation::Orientation m_current;
CSensrvChannel *m_sensorChannel;
+ bool m_channelOpen;
+ void pauseListening() {
+ if (m_sensorChannel && m_channelOpen) {
+ m_sensorChannel->StopDataListening();
+ m_sensorChannel->CloseChannel();
+ m_channelOpen = false;
+ }
+ }
+
+ void resumeListening() {
+ if (m_sensorChannel && !m_channelOpen) {
+ TRAPD(error, m_sensorChannel->OpenChannelL());
+ if (!error) {
+ TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
+ if (!error) {
+ m_channelOpen = true;
+ }
+ }
+ if (error) {
+ delete m_sensorChannel;
+ m_sensorChannel = 0;
+ }
+ }
+ }
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
{