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