summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-28 08:45:23 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-08-03 01:45:34 (GMT)
commite62f266a7642e675e9d235a1f54a6b5746500d48 (patch)
tree7ed719f4539ecb0a634dad714105c70819683810 /tools
parent1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a (diff)
downloadQt-e62f266a7642e675e9d235a1f54a6b5746500d48.zip
Qt-e62f266a7642e675e9d235a1f54a6b5746500d48.tar.gz
Qt-e62f266a7642e675e9d235a1f54a6b5746500d48.tar.bz2
Make it possible to manually set the orientation of QML Viewer on Symbian
Task-number: QTBUG-12142 Reviewed-by: Warwick Allison This patch brings ability to switch QML Viewer's orientation between auto-orientation (=follow sensor), portrait and landscape orientations (lock orientation) on Symbian. It provides same orientation options as Qt Creator 2.1's Qt QML Standalone Application creation wizard. Also, menu item rotateOrientation now works on Symbian, but it's hidden when orientation mode is set to auto-orientation. Property runtime.orientation has been switched back to supporting four-way orientation on Symbian, previously it only updated values between portrait and landscape. If your application only supports landscape or portrait modes, just don't react to the inverted orientations. Added orientation example screenorientation under examples/declarative. The patch includes a fix for calculator example, which rotated to wrong direction when switching from portrait to landscape. Also, improved qdeclarativeviewer unit tests. Changes have been tested to work on Windows, Linux and Symbian^3.
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/deviceorientation_symbian.cpp15
-rw-r--r--tools/qml/qml.pro3
-rw-r--r--tools/qml/qmlruntime.cpp74
-rw-r--r--tools/qml/qmlruntime.h3
4 files changed, 76 insertions, 19 deletions
diff --git a/tools/qml/deviceorientation_symbian.cpp b/tools/qml/deviceorientation_symbian.cpp
index c305f94..307c417 100644
--- a/tools/qml/deviceorientation_symbian.cpp
+++ b/tools/qml/deviceorientation_symbian.cpp
@@ -110,22 +110,27 @@ private:
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
{
+ Q_UNUSED(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;
+ Orientation orientation = UnknownOrientation;
switch (data.iDeviceOrientation) {
case TSensrvOrientationData::EOrientationDisplayUp:
- o = Portrait;
+ orientation = Portrait;
break;
case TSensrvOrientationData::EOrientationDisplayRightUp:
- o = Landscape;
+ orientation = Landscape;
break;
case TSensrvOrientationData::EOrientationDisplayLeftUp:
+ orientation = LandscapeInverted;
+ break;
case TSensrvOrientationData::EOrientationDisplayDown:
+ orientation = PortraitInverted;
+ break;
case TSensrvOrientationData::EOrientationUndefined:
case TSensrvOrientationData::EOrientationDisplayUpwards:
case TSensrvOrientationData::EOrientationDisplayDownwards:
@@ -133,8 +138,8 @@ private:
break;
}
- if (m_current != o && o != UnknownOrientation) {
- m_current = o;
+ if (m_current != orientation && orientation != UnknownOrientation) {
+ m_current = orientation;
emit orientationChanged();
}
}
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index bb69e8a..efb82d1 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -40,6 +40,9 @@ symbian {
!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
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 08a578c..b9fd570 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -98,6 +98,10 @@
#include <QGLWidget>
#endif
+#if defined(Q_WS_S60)
+#include <aknappui.h> // For locking app orientation
+#endif
+
#include <qdeclarativetester.h>
QT_BEGIN_NAMESPACE
@@ -600,6 +604,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, loggerWindow(new LoggerWidget(this))
, frame_stream(0)
+ , rotateAction(0)
, orientation(0)
, showWarningsWindow(0)
, m_scriptOptions(0)
@@ -742,22 +747,28 @@ void QDeclarativeViewer::createMenu()
fullscreenAction->setCheckable(true);
connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
- QAction *rotateOrientation = new QAction(tr("Rotate orientation"), this);
- rotateOrientation->setShortcut(QKeySequence("Ctrl+T"));
- connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
+ rotateAction = new QAction(tr("Rotate orientation"), this);
+ rotateAction->setShortcut(QKeySequence("Ctrl+T"));
+ connect(rotateAction, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
orientation = new QActionGroup(this);
orientation->setExclusive(true);
connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*)));
+#if defined(Q_OS_SYMBIAN)
+ QAction *autoOrientationAction = new QAction(tr("Auto-orientation"), this);
+ autoOrientationAction->setCheckable(true);
+#endif
QAction *portraitAction = new QAction(tr("Portrait"), this);
portraitAction->setCheckable(true);
QAction *landscapeAction = new QAction(tr("Landscape"), this);
landscapeAction->setCheckable(true);
+#if !defined(Q_OS_SYMBIAN)
QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this);
portraitInvAction->setCheckable(true);
QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this);
landscapeInvAction->setCheckable(true);
+#endif
QAction *aboutAction = new QAction(tr("&About Qt..."), this);
aboutAction->setMenuRole(QAction::AboutQtRole);
@@ -801,9 +812,9 @@ void QDeclarativeViewer::createMenu()
fileMenu->addAction(reloadAction);
fileMenu->addSeparator();
fileMenu->addAction(closeAction);
+#if !defined(Q_OS_SYMBIAN)
fileMenu->addAction(quitAction);
-#if !defined(Q_OS_SYMBIAN)
QMenu *recordMenu = menu->addMenu(tr("&Recording"));
recordMenu->addAction(snapshotAction);
recordMenu->addAction(recordAction);
@@ -813,22 +824,27 @@ void QDeclarativeViewer::createMenu()
debugMenu->addAction(showWarningsWindow);
#endif // ! Q_OS_SYMBIAN
- QMenu *settingsMenu = menu->addMenu(tr("S&ettings"));
+ QMenu *settingsMenu = menu->addMenu(tr("&Settings"));
settingsMenu->addAction(proxyAction);
-#if !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_SYMBIAN)
+ settingsMenu->addAction(fullscreenAction);
+#else
settingsMenu->addAction(recordOptions);
settingsMenu->addMenu(loggerWindow->preferencesMenu());
-#else // ! Q_OS_SYMBIAN
- settingsMenu->addAction(fullscreenAction);
-#endif // Q_OS_SYMBIAN
- settingsMenu->addAction(rotateOrientation);
+#endif // !Q_OS_SYMBIAN
+ settingsMenu->addAction(rotateAction);
QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
+#if defined(Q_OS_SYMBIAN)
+ orientation->addAction(autoOrientationAction);
+#endif
orientation->addAction(portraitAction);
orientation->addAction(landscapeAction);
+#if !defined(Q_OS_SYMBIAN)
orientation->addAction(portraitInvAction);
orientation->addAction(landscapeInvAction);
+#endif
propertiesMenu->addActions(orientation->actions());
QMenu *helpMenu = menu->addMenu(tr("&Help"));
@@ -852,6 +868,23 @@ void QDeclarativeViewer::proxySettingsChanged()
void QDeclarativeViewer::rotateOrientation()
{
+#if defined(Q_WS_S60)
+ CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
+ if (appUi) {
+ CAknAppUi::TAppUiOrientation oldOrientation = appUi->Orientation();
+ QString newOrientation;
+ if (oldOrientation == CAknAppUi::EAppUiOrientationPortrait) {
+ newOrientation = QLatin1String("Landscape");
+ } else {
+ newOrientation = QLatin1String("Portrait");
+ }
+ foreach (QAction *action, orientation->actions()) {
+ if (action->text() == newOrientation) {
+ changeOrientation(action);
+ }
+ }
+ }
+#else
QAction *current = orientation->checkedAction();
QList<QAction *> actions = orientation->actions();
int index = actions.indexOf(current);
@@ -860,6 +893,7 @@ void QDeclarativeViewer::rotateOrientation()
QAction *newOrientation = actions[(index + 1) % actions.count()];
changeOrientation(newOrientation);
+#endif
}
void QDeclarativeViewer::toggleFullScreen()
@@ -1369,9 +1403,24 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
{
if (!action)
return;
- action->setChecked(true);
-
QString o = action->text();
+ action->setChecked(true);
+#if defined(Q_WS_S60)
+ CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
+ if (appUi) {
+ CAknAppUi::TAppUiOrientation orientation = appUi->Orientation();
+ if (o == QLatin1String("Auto-orientation")) {
+ appUi->SetOrientationL(CAknAppUi::EAppUiOrientationAutomatic);
+ rotateAction->setVisible(false);
+ } else if (o == QLatin1String("Portrait")) {
+ appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
+ rotateAction->setVisible(true);
+ } else if (o == QLatin1String("Landscape")) {
+ appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
+ rotateAction->setVisible(true);
+ }
+ }
+#else
if (o == QLatin1String("Portrait"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
else if (o == QLatin1String("Landscape"))
@@ -1380,6 +1429,7 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted);
else if (o == QLatin1String("Landscape (inverted)"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted);
+#endif
}
void QDeclarativeViewer::orientationChanged()
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 7385b14..6fa7d81 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -170,8 +170,6 @@ private:
int record_autotime;
bool devicemode;
QAction *recordAction;
- QString currentSkin;
- bool scaleSkin;
RecordingDialog *recdlg;
void senseImageMagick();
@@ -180,6 +178,7 @@ private:
bool ffmpegAvailable;
bool convertAvailable;
+ QAction *rotateAction;
QActionGroup *orientation;
QAction *showWarningsWindow;