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