summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-07 05:45:33 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-07-07 06:23:15 (GMT)
commitaf5fc41e27f068604453a927cac4d81886d1987e (patch)
tree5315176c3680f844a9e86213334234996a65dd80 /tools
parent44d78dca77b8a5f4f0d1bb67e84c21a4c57345b6 (diff)
downloadQt-af5fc41e27f068604453a927cac4d81886d1987e.zip
Qt-af5fc41e27f068604453a927cac4d81886d1987e.tar.gz
Qt-af5fc41e27f068604453a927cac4d81886d1987e.tar.bz2
Add Symbian support for runtime.orientation property
Task-number: Reviewed-by: Martin Jones
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/deviceorientation_symbian.cpp166
-rw-r--r--tools/qml/main.cpp11
-rw-r--r--tools/qml/qml.pri2
-rw-r--r--tools/qml/qml.pro4
4 files changed, 183 insertions, 0 deletions
diff --git a/tools/qml/deviceorientation_symbian.cpp b/tools/qml/deviceorientation_symbian.cpp
new file mode 100644
index 0000000..48bfc72
--- /dev/null
+++ b/tools/qml/deviceorientation_symbian.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "deviceorientation.h"
+
+#include <e32base.h>
+#include <sensrvchannelfinder.h>
+#include <sensrvdatalistener.h>
+#include <sensrvchannel.h>
+#include <sensrvorientationsensor.h>
+
+class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
+{
+ Q_OBJECT
+public:
+ SymbianOrientation()
+ : DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0)
+ {
+ TRAP_IGNORE(initL());
+ if (!m_sensorChannel)
+ qWarning("No valid sensors found.");
+ }
+
+ ~SymbianOrientation()
+ {
+ if (m_sensorChannel) {
+ m_sensorChannel->StopDataListening();
+ m_sensorChannel->CloseChannel();
+ delete m_sensorChannel;
+ }
+ }
+
+ void initL()
+ {
+ CSensrvChannelFinder *channelFinder = CSensrvChannelFinder::NewLC();
+ RSensrvChannelInfoList channelInfoList;
+ CleanupClosePushL(channelInfoList);
+
+ TSensrvChannelInfo searchConditions;
+ searchConditions.iChannelType = KSensrvChannelTypeIdOrientationData;
+ channelFinder->FindChannelsL(channelInfoList, searchConditions);
+
+ for (int i = 0; i < channelInfoList.Count(); ++i) {
+ TRAPD(error, m_sensorChannel = CSensrvChannel::NewL(channelInfoList[i]));
+ if (!error)
+ TRAP(error, m_sensorChannel->OpenChannelL());
+ if (!error) {
+ TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
+ break;
+ }
+ if (error) {
+ delete m_sensorChannel;
+ m_sensorChannel = 0;
+ }
+ }
+
+ channelInfoList.Close();
+ CleanupStack::Pop(&channelInfoList);
+ CleanupStack::PopAndDestroy(channelFinder);
+ }
+
+ Orientation orientation() const
+ {
+ return m_current;
+ }
+
+ void setOrientation(Orientation) { }
+
+private:
+ DeviceOrientation::Orientation m_current;
+ CSensrvChannel *m_sensorChannel;
+
+ void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
+ {
+ if (channel.GetChannelInfo().iChannelType == KSensrvChannelTypeIdOrientationData) {
+ TSensrvOrientationData data;
+ for (int i = 0; i < count; ++i) {
+ TPckgBuf<TSensrvOrientationData> dataBuf;
+ channel.GetData(dataBuf);
+ data = dataBuf();
+ Orientation o = UnknownOrientation;
+ switch (data.iDeviceOrientation) {
+ case TSensrvOrientationData::EOrientationDisplayRightUp:
+ o = LandscapeInverted;
+ break;
+ case TSensrvOrientationData::EOrientationDisplayUp:
+ o = Portrait;
+ break;
+ case TSensrvOrientationData::EOrientationDisplayDown:
+ o = PortraitInverted;
+ break;
+ case TSensrvOrientationData::EOrientationDisplayLeftUp:
+ o = Landscape;
+ break;
+ case TSensrvOrientationData::EOrientationUndefined:
+ case TSensrvOrientationData::EOrientationDisplayUpwards:
+ case TSensrvOrientationData::EOrientationDisplayDownwards:
+ default:
+ break;
+ }
+
+ if (m_current != o) {
+ m_current = o;
+ emit orientationChanged();
+ }
+ }
+ }
+ }
+
+ void DataError(CSensrvChannel& /* channel */, TSensrvErrorSeverity /* error */)
+ {
+ }
+
+ void GetDataListenerInterfaceL(TUid /* interfaceUid */, TAny*& /* interface */)
+ {
+ }
+};
+
+
+DeviceOrientation* DeviceOrientation::instance()
+{
+ static SymbianOrientation *o = 0;
+ if (!o)
+ o = new SymbianOrientation;
+ return o;
+}
+
+#include "deviceorientation_symbian.moc"
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index d5ad9ad..dfd1726 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -56,6 +56,10 @@ QT_USE_NAMESPACE
QtMsgHandler systemMsgOutput = 0;
+#if defined(Q_WS_S60)
+#include <aknappui.h> // For locking app to portrait
+#endif
+
#if defined (Q_OS_SYMBIAN)
#include <unistd.h>
#include <sys/types.h>
@@ -207,6 +211,13 @@ int main(int argc, char ** argv)
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
+#if defined(Q_WS_S60)
+ CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
+ if (appUi) {
+ appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
+ }
+#endif
+
QDeclarativeViewer::registerTypes();
QDeclarativeTester::registerTypes();
diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri
index 3e5a88b..0d01f70 100644
--- a/tools/qml/qml.pri
+++ b/tools/qml/qml.pri
@@ -23,6 +23,8 @@ maemo5 {
SOURCES += $$PWD/deviceorientation_maemo5.cpp
FORMS = $$PWD/recopts_maemo5.ui \
$$PWD/proxysettings_maemo5.ui
+} symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
+ SOURCES += $$PWD/deviceorientation_symbian.cpp
} else {
SOURCES += $$PWD/deviceorientation.cpp
FORMS = $$PWD/recopts.ui \
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index 63efff1..0a51c0b 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -37,6 +37,10 @@ symbian {
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
TARGET.CAPABILITY = NetworkServices ReadUserData
+ !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
+ LIBS += -lsensrvclient -lsensrvutil
+ contains(QT_CONFIG, s60): LIBS += -lavkon -lcone
+ }
}
mac {
QMAKE_INFO_PLIST=Info_mac.plist