Commit d4e58902 authored by Alessandro Portale's avatar Alessandro Portale Committed by con

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
parent fce232a1
......@@ -4,10 +4,6 @@
# dir1.source = mydir
DEPLOYMENTFOLDERS = # file1 dir1
# Avoid auto screen rotation
# ORIENTATIONLOCK #
DEFINES += ORIENTATIONLOCK
# TARGETUID3 #
symbian:TARGET.UID3 = 0xE1111234
......
......@@ -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()
......
......@@ -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
......
......@@ -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()
......
......@@ -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) {
......
......@@ -262,9 +262,6 @@ QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const
while (!(line = in.readLine()).isNull()) {
if (line.contains(QLatin1String("# TARGETUID3"))) {
valueOnNextLine = symbianTargetUid();
} else if (line.contains(QLatin1String("# ORIENTATIONLOCK"))
&& orientation() == ScreenOrientationAuto) {
uncommentNextLine = true;
} else if (line.contains(QLatin1String("# NETWORKACCESS"))
&& !networkEnabled()) {
uncommentNextLine = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment