Avoid complex types as statics.
[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     TRACE;
10     Q_ASSERT(parent);
11 #ifdef Q_WS_MAEMO_5
12     setAttribute(Qt::WA_Maemo5StackedWindow, true);
13     setAttribute(Qt::WA_Maemo5NonComposited, true);
14 #endif // Q_WS_MAEMO_5
15 #ifndef Q_OS_SYMBIAN
16     toolBar->hide();
17 #endif
18     QFrame *frame = new QFrame(this);
19     QVBoxLayout *layout = new QVBoxLayout(frame);
20     layout->setMargin(0);
21     frame->setLayout(layout);
22     setCentralWidget(frame);
23     restoreButton = new TranslucentButton("view-normal", this);
24     QRect screen = QApplication::desktop()->screenGeometry();
25     restoreButton->setGeometry((screen.width() - TranslucentButton::pixels) / 2,
26         screen.height() - TranslucentButton::pixels - 9,
27         TranslucentButton::pixels, TranslucentButton::pixels);
28     connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
29 }
30
31 void FullScreenWindow::showFullScreen()
32 {
33     TRACE;
34 #ifdef Q_WS_MAEMO_5
35     setAttribute(Qt::WA_Maemo5PortraitOrientation, parentWidget()->
36                  testAttribute(Qt::WA_Maemo5PortraitOrientation));
37     setAttribute(Qt::WA_Maemo5LandscapeOrientation, parentWidget()->
38                  testAttribute(Qt::WA_Maemo5LandscapeOrientation));
39 #endif // Q_WS_MAEMO_5
40     QWidget::showFullScreen();
41     restoreButton->flash(3000);
42 }
43
44 void FullScreenWindow::resizeEvent(QResizeEvent *e)
45 {
46     TRACE;
47     Q_UNUSED(e);
48     QRect screen = QApplication::desktop()->screenGeometry();
49     restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
50         screen.height() - TranslucentButton::pixels - 9,
51         TranslucentButton::pixels, TranslucentButton::pixels);
52 }