2010-11-01 17:03:46 +01:00
|
|
|
/*
|
|
|
|
|
This file was generated by the Mobile Qt Application wizard of Qt Creator.
|
|
|
|
|
MainWindow is a convenience class containing mobile device specific code
|
|
|
|
|
such as screen orientation handling.
|
|
|
|
|
It is recommended not to modify this file, since newer versions of Qt Creator
|
|
|
|
|
may offer an updated version of it.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-09-13 11:20:13 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-01 17:03:46 +01:00
|
|
|
void MainWindow::setOrientation(ScreenOrientation orientation)
|
2010-09-13 11:20:13 +02:00
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_SYMBIAN
|
2010-11-01 17:03:46 +01:00
|
|
|
if (orientation != ScreenOrientationAuto) {
|
2010-09-13 11:20:13 +02:00
|
|
|
#if defined(ORIENTATIONLOCK)
|
|
|
|
|
const CAknAppUiBase::TAppUiOrientation uiOrientation =
|
2010-11-01 17:03:46 +01:00
|
|
|
(orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
|
2010-09-13 11:20:13 +02:00
|
|
|
: CAknAppUi::EAppUiOrientationLandscape;
|
|
|
|
|
CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
|
|
|
|
|
TRAPD(error,
|
|
|
|
|
if (appUi)
|
|
|
|
|
appUi->SetOrientationL(uiOrientation);
|
|
|
|
|
);
|
2010-11-01 19:25:19 +01:00
|
|
|
Q_UNUSED(error)
|
2010-09-13 11:20:13 +02:00
|
|
|
#else // ORIENTATIONLOCK
|
|
|
|
|
qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
|
|
|
|
|
#endif // ORIENTATIONLOCK
|
|
|
|
|
}
|
|
|
|
|
#elif defined(Q_WS_MAEMO_5)
|
|
|
|
|
Qt::WidgetAttribute attribute;
|
|
|
|
|
switch (orientation) {
|
2010-11-01 17:03:46 +01:00
|
|
|
case ScreenOrientationLockPortrait:
|
2010-09-13 11:20:13 +02:00
|
|
|
attribute = Qt::WA_Maemo5PortraitOrientation;
|
|
|
|
|
break;
|
2010-11-01 17:03:46 +01:00
|
|
|
case ScreenOrientationLockLandscape:
|
2010-09-13 11:20:13 +02:00
|
|
|
attribute = Qt::WA_Maemo5LandscapeOrientation;
|
|
|
|
|
break;
|
2010-11-01 17:03:46 +01:00
|
|
|
case ScreenOrientationAuto:
|
2010-09-13 11:20:13 +02:00
|
|
|
default:
|
|
|
|
|
attribute = Qt::WA_Maemo5AutoOrientation;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
setAttribute(attribute, true);
|
|
|
|
|
#else // Q_OS_SYMBIAN
|
|
|
|
|
Q_UNUSED(orientation);
|
|
|
|
|
#endif // Q_OS_SYMBIAN
|
|
|
|
|
}
|
2010-11-01 19:19:32 +01:00
|
|
|
|
|
|
|
|
void MainWindow::showExpanded()
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_SYMBIAN
|
|
|
|
|
showFullScreen();
|
|
|
|
|
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
|
|
|
|
showMaximized();
|
|
|
|
|
#else
|
|
|
|
|
show();
|
|
|
|
|
#endif
|
|
|
|
|
}
|