460fd88ccc16163905350066a84cd01f5a3cc71c
[simple-xmbc-rem] / src / mainwindow.cpp
1 // checksum 0xfd0b version 0x20001
2 /*
3   This file was generated by the Mobile Qt Application wizard of Qt Creator.
4   MainWindow is a convenience class containing mobile device specific code
5   such as screen orientation handling.
6   It is recommended not to modify this file, since newer versions of Qt Creator
7   may offer an updated version of it.
8 */
9
10 #include "mainwindow.h"
11 #include "ui_mainwindow.h"
12
13 #include <QtCore/QCoreApplication>
14
15 #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
16 #include <eikenv.h>
17 #include <eikappui.h>
18 #include <aknenv.h>
19 #include <aknappui.h>
20 #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
21
22 MainWindow::MainWindow(QWidget *parent)
23     : QMainWindow(parent), ui(new Ui::MainWindow)
24 {
25     ui->setupUi(this);
26 }
27
28 MainWindow::~MainWindow()
29 {
30     delete ui;
31 }
32
33 void MainWindow::setOrientation(ScreenOrientation orientation)
34 {
35 #ifdef Q_OS_SYMBIAN
36     if (orientation != ScreenOrientationAuto) {
37 #if defined(ORIENTATIONLOCK)
38         const CAknAppUiBase::TAppUiOrientation uiOrientation =
39                 (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
40                     : CAknAppUi::EAppUiOrientationLandscape;
41         CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
42         TRAPD(error,
43             if (appUi)
44                 appUi->SetOrientationL(uiOrientation);
45         );
46         Q_UNUSED(error)
47 #else // ORIENTATIONLOCK
48         qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
49 #endif // ORIENTATIONLOCK
50     }
51 #elif defined(Q_WS_MAEMO_5)
52     Qt::WidgetAttribute attribute;
53     switch (orientation) {
54     case ScreenOrientationLockPortrait:
55         attribute = Qt::WA_Maemo5PortraitOrientation;
56         break;
57     case ScreenOrientationLockLandscape:
58         attribute = Qt::WA_Maemo5LandscapeOrientation;
59         break;
60     case ScreenOrientationAuto:
61     default:
62         attribute = Qt::WA_Maemo5AutoOrientation;
63         break;
64     }
65     setAttribute(attribute, true);
66 #else // Q_OS_SYMBIAN
67     Q_UNUSED(orientation);
68 #endif // Q_OS_SYMBIAN
69 }
70
71 void MainWindow::showExpanded()
72 {
73 #ifdef Q_OS_SYMBIAN
74     showFullScreen();
75 #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
76     showMaximized();
77 #else
78     show();
79 #endif
80 }