X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=platform.cpp;h=873d4fbfeb8f035b7c4fa83bf5057455d3b1e816;hb=7a3717897911dc312fc22afe687a42ed0afd1da1;hp=ee7f5d9bc56ec8358c31de6e5dcb81afcd2e94ab;hpb=b72c0798bfde194a8f87ecd15956bbe99b184db8;p=dorian diff --git a/platform.cpp b/platform.cpp index ee7f5d9..873d4fb 100644 --- a/platform.cpp +++ b/platform.cpp @@ -6,7 +6,15 @@ # include #endif +#ifdef Q_OS_SYMBIAN +# include +# include +# include +# include +#endif + #include "platform.h" +#include "trace.h" #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN) # define DORIAN_BASE "dorian" @@ -145,3 +153,75 @@ QString Platform::defaultOrientation() return QString("landscape"); #endif } + +void Platform::setOrientation(QWidget *widget, const QString &orientation) +{ + TRACE; + qDebug() << "To" << orientation; + + Q_UNUSED(widget); + +#if defined(Q_OS_SYMBIAN) + CAknAppUi *appUi = dynamic_cast(CEikonEnv::Static()->AppUi()); + if (!appUi) { + qCritical() << "Platform::setOrientation: Couldn't get AppUi pointer"; + return; + } +#endif + + if (orientation == "portrait") { +#if defined(Q_WS_MAEMO_5) + widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false); + widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); +#elif defined(Q_OS_SYMBIAN) + TRAPD(error, + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);); +#endif + } else { +#if defined(Q_WS_MAEMO_5) + widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, false); + widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); +#elif defined(Q_OS_SYMBIAN) + TRAPD(error, + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);); +#endif + } +} + +int Platform::softKeyHeight() +{ +#if defined(Q_OS_SYMBIAN) + return 62; +#else + return 0; +#endif +} + +int Platform::toolBarIconHeight() +{ +#if defined(Q_OS_SYMBIAN) + return 60; +#elif defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5) + return 40; +#else + return 0; +#endif +} + +QSize Platform::size() +{ + return QApplication::desktop()->geometry().size(); +} + +QSize Platform::availableSize() +{ + QSize s = QApplication::desktop()->availableGeometry().size(); +#if defined(Q_OS_SYMBIAN) + // Work around a Qt bug on Symbian which sometimes forgets to reduce the + // available height by the soft key area height + if (s.height() == 548) { + s.setHeight(s.height() - softKeyHeight()); + } +#endif + return s; +}