diff options
author | Alessandro Portale <alessandro.portale@nokia.com> | 2011-02-02 13:41:22 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2011-02-03 12:50:01 +0100 |
commit | d4e5890286f56c1976a187e75eb48fdf64269e55 (patch) | |
tree | 0bd6b6dbadfa35339711cbb47748d8e7ddf12e91 /share | |
parent | fce232a1652362d7909c98c3a0ee0881fbcef91f (diff) | |
download | qt-creator-d4e5890286f56c1976a187e75eb48fdf64269e55.tar.gz |
Removing the usage of Avkon to lock the screen orientation
Locking the screen orientation was not a Qt feature of the Symbian
port till Qt 4.7.2. Therefore, client applications had to do the
locking themselves. That locking is right now only achievable by
using Avkon Api. The template code of the Qt Quick App wizard did
exactly that.
Now, Qt 4.7.2 has the screen orientation lock built in. That
implementation was done for QTBUG-11785. No need to do that in the
application code, anymore.
This patch removes Avkon usage from the templates, using new enum keys
and setting QWidget flags, just like Maemo5 does.
Two Qt version checks/fixes:
1) If the application tries to lock the orientation on Qt < 4.7.2,
a warning is given that this won't work
2) If Qt < 4.7.2 is used to build the application, the enum keys are
not used directly but casted from constants
Task-Number: QTCREATORBUG-3598
Reviewed-by: ck
Diffstat (limited to 'share')
5 files changed, 54 insertions, 67 deletions
diff --git a/share/qtcreator/templates/mobileapp/app.pro b/share/qtcreator/templates/mobileapp/app.pro index ec826e61e6..5c1eacc114 100644 --- a/share/qtcreator/templates/mobileapp/app.pro +++ b/share/qtcreator/templates/mobileapp/app.pro @@ -4,10 +4,6 @@ # dir1.source = mydir DEPLOYMENTFOLDERS = # file1 dir1 -# Avoid auto screen rotation -# ORIENTATIONLOCK # -DEFINES += ORIENTATIONLOCK - # TARGETUID3 # symbian:TARGET.UID3 = 0xE1111234 diff --git a/share/qtcreator/templates/mobileapp/mainwindow.cpp b/share/qtcreator/templates/mobileapp/mainwindow.cpp index aad030d8aa..e719b5f916 100644 --- a/share/qtcreator/templates/mobileapp/mainwindow.cpp +++ b/share/qtcreator/templates/mobileapp/mainwindow.cpp @@ -11,13 +11,6 @@ #include <QtCore/QCoreApplication> -#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) -#include <eikenv.h> -#include <eikappui.h> -#include <aknenv.h> -#include <aknappui.h> -#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { @@ -31,40 +24,45 @@ MainWindow::~MainWindow() void MainWindow::setOrientation(ScreenOrientation orientation) { -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) + // If the version of Qt on the device is < 4.7.2, that attribute won't work if (orientation != ScreenOrientationAuto) { -#if defined(ORIENTATIONLOCK) - const CAknAppUiBase::TAppUiOrientation uiOrientation = - (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait - : CAknAppUi::EAppUiOrientationLandscape; - CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); - TRAPD(error, - if (appUi) - appUi->SetOrientationL(uiOrientation); - ); - Q_UNUSED(error) -#else // ORIENTATIONLOCK - qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); -#endif // ORIENTATIONLOCK + const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); + if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { + qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); + return; + } } -#elif defined(Q_WS_MAEMO_5) +#endif // Q_OS_SYMBIAN + Qt::WidgetAttribute attribute; switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes case ScreenOrientationLockPortrait: - attribute = Qt::WA_Maemo5PortraitOrientation; + attribute = static_cast<Qt::WidgetAttribute>(128); break; case ScreenOrientationLockLandscape: - attribute = Qt::WA_Maemo5LandscapeOrientation; + attribute = static_cast<Qt::WidgetAttribute>(129); break; + default: case ScreenOrientationAuto: + attribute = static_cast<Qt::WidgetAttribute>(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; default: - attribute = Qt::WA_Maemo5AutoOrientation; + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; break; - } +#endif // QT_VERSION < 0x040702 + }; setAttribute(attribute, true); -#else // Q_OS_SYMBIAN - Q_UNUSED(orientation); -#endif // Q_OS_SYMBIAN } void MainWindow::showExpanded() diff --git a/share/qtcreator/templates/qmlapp/app.pro b/share/qtcreator/templates/qmlapp/app.pro index cc8c334645..1ba2bce823 100644 --- a/share/qtcreator/templates/qmlapp/app.pro +++ b/share/qtcreator/templates/qmlapp/app.pro @@ -9,10 +9,6 @@ DEPLOYMENTFOLDERS = folder_01 # QML_IMPORT_PATH # QML_IMPORT_PATH = -# Avoid auto screen rotation -# ORIENTATIONLOCK # -DEFINES += ORIENTATIONLOCK - # TARGETUID3 # symbian:TARGET.UID3 = 0xE1111234 diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp index 59d9750edd..4298aa7467 100644 --- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -27,13 +27,6 @@ #include <qdeclarativeviewobserver.h> #endif -#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) -#include <eikenv.h> -#include <eikappui.h> -#include <aknenv.h> -#include <aknappui.h> -#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK - #if defined(QMLJSDEBUGGER) // Enable debugging before any QDeclarativeEngine is created @@ -108,40 +101,45 @@ void QmlApplicationViewer::addImportPath(const QString &path) void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) { -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) + // If the version of Qt on the device is < 4.7.2, that attribute won't work if (orientation != ScreenOrientationAuto) { -#if defined(ORIENTATIONLOCK) - const CAknAppUiBase::TAppUiOrientation uiOrientation = - (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait - : CAknAppUi::EAppUiOrientationLandscape; - CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); - TRAPD(error, - if (appUi) - appUi->SetOrientationL(uiOrientation); - ); - Q_UNUSED(error) -#else // ORIENTATIONLOCK - qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); -#endif // ORIENTATIONLOCK + const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); + if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { + qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); + return; + } } -#elif defined(Q_WS_MAEMO_5) +#endif // Q_OS_SYMBIAN + Qt::WidgetAttribute attribute; switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes case ScreenOrientationLockPortrait: - attribute = Qt::WA_Maemo5PortraitOrientation; + attribute = static_cast<Qt::WidgetAttribute>(128); break; case ScreenOrientationLockLandscape: - attribute = Qt::WA_Maemo5LandscapeOrientation; + attribute = static_cast<Qt::WidgetAttribute>(129); break; + default: case ScreenOrientationAuto: + attribute = static_cast<Qt::WidgetAttribute>(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; default: - attribute = Qt::WA_Maemo5AutoOrientation; + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; break; - } +#endif // QT_VERSION < 0x040702 + }; setAttribute(attribute, true); -#else // Q_OS_SYMBIAN - Q_UNUSED(orientation); -#endif // Q_OS_SYMBIAN } void QmlApplicationViewer::showExpanded() diff --git a/share/qtcreator/templates/shared/deployment.pri b/share/qtcreator/templates/shared/deployment.pri index c225424f19..10c36f748a 100644 --- a/share/qtcreator/templates/shared/deployment.pri +++ b/share/qtcreator/templates/shared/deployment.pri @@ -21,7 +21,6 @@ MAINPROFILEPWD = $$PWD symbian { isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 - contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone } else:win32 { copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { |