summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriano Rezende <adriano.rezende@openbossa.org>2009-11-17 15:45:44 -0300
committerAdriano Rezende <adriano.rezende@openbossa.org>2009-11-17 17:46:10 -0300
commita356e26d4825fc5a3cf877c3570af9414a7601e6 (patch)
tree9617f5404d361e421c4e8f418e270a2bb3983ac7
parentbeb8de7e0d67462acb00878d2b6242e64a71e6a2 (diff)
Shared: Added Hildon portrait/landscape support
Signed-off-by: Adriano Rezende <adriano.rezende@openbossa.org>
-rw-r--r--shared/system.cpp27
-rw-r--r--shared/system.h7
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 <QTimer>
+#include <QWidget>
#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<CAknAppUi *>(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<CAknAppUi *>(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 <QObject>
+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();