From a356e26d4825fc5a3cf877c3570af9414a7601e6 Mon Sep 17 00:00:00 2001 From: Adriano Rezende Date: Tue, 17 Nov 2009 15:45:44 -0300 Subject: Shared: Added Hildon portrait/landscape support Signed-off-by: Adriano Rezende --- shared/system.cpp | 27 ++++++++++++++++++++------- shared/system.h | 7 ++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/shared/system.cpp b/shared/system.cpp index 51d21dc..4029816 100644 --- a/shared/system.cpp +++ b/shared/system.cpp @@ -30,6 +30,7 @@ ****************************************************************************/ #include +#include #include "system.h" @@ -57,32 +58,44 @@ System *System::instance() return &result; } -void System::setViewMode(ViewMode mode) +void System::setViewMode(QWidget *window, ViewMode mode) { +#if defined(Q_OS_SYMBIAN) + Q_UNUSED(window); + + // we need to use singleshot since CAknAppUi object is only + // available in the main loop if (mode == PortraitMode) QTimer::singleShot(0, instance(), SLOT(setPortraitMode())); else QTimer::singleShot(0, instance(), SLOT(setLandscapeMode())); + +#elif defined(Q_WS_MAEMO_5) + bool enabled = (mode == PortraitMode); + widget->setAttribute(Qt::WA_Maemo5ForcePortraitOrientation, enabled); + widget->setAttribute(Qt::WA_Maemo5ForceLandscapeOrientation, !enabled); +#else + Q_UNUSED(window); + Q_UNUSED(mode); +#endif } +#ifdef Q_OS_SYMBIAN + void System::setPortraitMode() { -#ifdef Q_OS_SYMBIAN CAknAppUi *aknAppUi = dynamic_cast(CEikonEnv::Static()->AppUi()); if (aknAppUi) aknAppUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); -#endif - // XXX: add support to hildon portrait mode } void System::setLandscapeMode() { -#ifdef Q_OS_SYMBIAN CAknAppUi *aknAppUi = dynamic_cast(CEikonEnv::Static()->AppUi()); if (aknAppUi) aknAppUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape); -#endif - // XXX: add support to hildon landscape mode } + +#endif diff --git a/shared/system.h b/shared/system.h index f5bea7d..1e0ff22 100644 --- a/shared/system.h +++ b/shared/system.h @@ -35,6 +35,9 @@ #include +class QWidget; + + class System : public QObject { Q_OBJECT @@ -42,11 +45,13 @@ class System : public QObject public: enum ViewMode { PortraitMode, LandscapeMode }; - static void setViewMode(ViewMode mode); + static void setViewMode(QWidget *window, ViewMode mode); +#ifdef Q_OS_SYMBIAN private slots: void setPortraitMode(); void setLandscapeMode(); +#endif private: System(); -- cgit v1.2.3