Clean up volume key handling code.
[dorian] / fullscreenwindow.cpp
1 #include <QtGui>
2
3 #include "fullscreenwindow.h"
4 #include "translucentbutton.h"
5 #include "trace.h"
6
7 FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
8 {
9     Q_ASSERT(parent);
10 #ifdef Q_WS_MAEMO_5
11     setAttribute(Qt::WA_Maemo5StackedWindow, true);
12     setAttribute(Qt::WA_Maemo5NonComposited, true);
13 #endif // Q_WS_MAEMO_5
14 #ifndef Q_OS_SYMBIAN
15     toolBar->hide();
16 #endif
17     QFrame *frame = new QFrame(this);
18     QVBoxLayout *layout = new QVBoxLayout(frame);
19     layout->setMargin(0);
20     frame->setLayout(layout);
21     setCentralWidget(frame);
22     restoreButton = new TranslucentButton("view-normal", this);
23     QRect screen = QApplication::desktop()->screenGeometry();
24     restoreButton->setGeometry((screen.width() - TranslucentButton::pixels) / 2,
25         screen.height() - TranslucentButton::pixels - 9,
26         TranslucentButton::pixels, TranslucentButton::pixels);
27     connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
28 }
29
30 void FullScreenWindow::showFullScreen()
31 {
32 #ifdef Q_WS_MAEMO_5
33     setAttribute(Qt::WA_Maemo5PortraitOrientation, parentWidget()->
34                  testAttribute(Qt::WA_Maemo5PortraitOrientation));
35     setAttribute(Qt::WA_Maemo5LandscapeOrientation, parentWidget()->
36                  testAttribute(Qt::WA_Maemo5LandscapeOrientation));
37 #endif // Q_WS_MAEMO_5
38     QWidget::showFullScreen();
39     restoreButton->flash(3000);
40 }
41
42 void FullScreenWindow::resizeEvent(QResizeEvent *e)
43 {
44     Q_UNUSED(e);
45     QRect screen = QApplication::desktop()->screenGeometry();
46     restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
47         screen.height() - TranslucentButton::pixels - 9,
48         TranslucentButton::pixels, TranslucentButton::pixels);
49 }