985a62e6d6da86b97e9995822382fb6cc2657f78
[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 "xbmc.h"
15
16 #include <QGraphicsRectItem>
17 #include <QGraphicsEllipseItem>
18
19 #include <QCoreApplication>
20
21 #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
22 #include <eikenv.h>
23 #include <eikappui.h>
24 #include <aknenv.h>
25 #include <aknappui.h>
26 #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
27
28 MainWindow::MainWindow(QWidget *parent)
29     : QMainWindow(parent), m_ui(new Ui::MainWindow)
30 {
31     m_ui->setupUi(this);
32     m_xbmc = new Xbmc(this);
33 }
34
35 MainWindow::~MainWindow()
36 {
37     delete m_xbmc;
38     delete m_ui;
39 }
40
41 void MainWindow::setOrientation(ScreenOrientation orientation)
42 {
43 #ifdef Q_OS_SYMBIAN
44     if (orientation != ScreenOrientationAuto) {
45 #if defined(ORIENTATIONLOCK)
46         const CAknAppUiBase::TAppUiOrientation uiOrientation =
47                 (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
48                     : CAknAppUi::EAppUiOrientationLandscape;
49         CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
50         TRAPD(error,
51             if (appUi)
52                 appUi->SetOrientationL(uiOrientation);
53         );
54         Q_UNUSED(error)
55 #else // ORIENTATIONLOCK
56         qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
57 #endif // ORIENTATIONLOCK
58     }
59 #elif defined(Q_WS_MAEMO_5)
60     Qt::WidgetAttribute attribute;
61     switch (orientation) {
62     case ScreenOrientationLockPortrait:
63         attribute = Qt::WA_Maemo5PortraitOrientation;
64         break;
65     case ScreenOrientationLockLandscape:
66         attribute = Qt::WA_Maemo5LandscapeOrientation;
67         break;
68     case ScreenOrientationAuto:
69     default:
70         attribute = Qt::WA_Maemo5AutoOrientation;
71         break;
72     }
73     setAttribute(attribute, true);
74 #else // Q_OS_SYMBIAN
75     Q_UNUSED(orientation);
76 #endif // Q_OS_SYMBIAN
77 }
78
79 void MainWindow::showExpanded()
80 {
81 #ifdef Q_OS_SYMBIAN
82     showFullScreen();
83 #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
84     showMaximized();
85 #else
86     show();
87 #endif
88 }
89
90 void MainWindow::on_actionSetup_triggered()
91 {
92     SetupDialog dialog;
93     dialog.load();
94     if(dialog.exec() == QDialog::Accepted) {
95         dialog.save();
96     }
97 }
98
99 void MainWindow::on_rightBtn_clicked()
100 {
101     m_xbmc->actionRight();
102 }
103
104 void MainWindow::on_leftBtn_clicked()
105 {
106     m_xbmc->actionLeft();
107 }
108
109 void MainWindow::on_upBtn_clicked()
110 {
111     m_xbmc->actionUp();
112 }
113
114 void MainWindow::on_downBtn_clicked()
115 {
116     m_xbmc->actionDown();
117 }
118
119 void MainWindow::on_playBtn_clicked()
120 {
121     m_xbmc->actionPlay();
122 }
123
124 void MainWindow::on_muteBtn_clicked()
125 {
126     m_xbmc->actionMute();
127 }
128
129 void MainWindow::on_volumeUpBtn_clicked()
130 {
131     m_xbmc->actionVolumeUp();
132 }
133
134 void MainWindow::on_volumeDownBtn_clicked()
135 {
136     m_xbmc->actionVolumeDown();
137 }
138
139 void MainWindow::on_nextSubtitleBtn_clicked()
140 {
141     m_xbmc->actionNextSubtitle();
142 }
143
144 void MainWindow::on_nextLanguageBtn_clicked()
145 {
146     m_xbmc->actionNextLanguage();
147 }
148
149 void MainWindow::on_selectButton_clicked()
150 {
151     m_xbmc->actionSelect();
152 }
153
154 void MainWindow::on_stopBtn_clicked()
155 {
156     m_xbmc->actionStop();
157 }