diff options
Diffstat (limited to 'tools/qml/qmlruntime.cpp')
-rw-r--r-- | tools/qml/qmlruntime.cpp | 74 |
1 files changed, 62 insertions, 12 deletions
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() |