Use constants.h to store app's constants. Created a setup dialog.
[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 <setupdialog.h>
14
15 #include <QtCore/QCoreApplication>
16
17 #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
18 #include <eikenv.h>
19 #include <eikappui.h>
20 #include <aknenv.h>
21 #include <aknappui.h>
22 #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
23
24 MainWindow::MainWindow(QWidget *parent)
25     : QMainWindow(parent), ui(new Ui::MainWindow)
26 {
27     ui->setupUi(this);
28 }
29
30 MainWindow::~MainWindow()
31 {
32     delete ui;
33 }
34
35 void MainWindow::setOrientation(ScreenOrientation orientation)
36 {
37 #ifdef Q_OS_SYMBIAN
38     if (orientation != ScreenOrientationAuto) {
39 #if defined(ORIENTATIONLOCK)
40         const CAknAppUiBase::TAppUiOrientation uiOrientation =
41                 (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
42                     : CAknAppUi::EAppUiOrientationLandscape;
43         CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
44         TRAPD(error,
45             if (appUi)
46                 appUi->SetOrientationL(uiOrientation);
47         );
48         Q_UNUSED(error)
49 #else // ORIENTATIONLOCK
50         qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
51 #endif // ORIENTATIONLOCK
52     }
53 #elif defined(Q_WS_MAEMO_5)
54     Qt::WidgetAttribute attribute;
55     switch (orientation) {
56     case ScreenOrientationLockPortrait:
57         attribute = Qt::WA_Maemo5PortraitOrientation;
58         break;
59     case ScreenOrientationLockLandscape:
60         attribute = Qt::WA_Maemo5LandscapeOrientation;
61         break;
62     case ScreenOrientationAuto:
63     default:
64         attribute = Qt::WA_Maemo5AutoOrientation;
65         break;
66     }
67     setAttribute(attribute, true);
68 #else // Q_OS_SYMBIAN
69     Q_UNUSED(orientation);
70 #endif // Q_OS_SYMBIAN
71 }
72
73 void MainWindow::showExpanded()
74 {
75 #ifdef Q_OS_SYMBIAN
76     showFullScreen();
77 #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
78     showMaximized();
79 #else
80     show();
81 #endif
82 }
83
84 void MainWindow::on_actionSetup_triggered()
85 {
86     SetupDialog dialog;
87     dialog.load();
88     if(dialog.exec() == QDialog::Accepted) {
89         dialog.save();
90     }
91 }