46742c7827eef5f14826e628c7a3bd679913158d
[dorian] / fullscreenwindow.cpp
1 #include <QtGui>
2
3 #include "fullscreenwindow.h"
4 #include "translucentbutton.h"
5 #include "trace.h"
6 #include "settings.h"
7 #include "platform.h"
8
9 FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
10 {
11     TRACE;
12     Q_ASSERT(parent);
13 #ifdef Q_WS_MAEMO_5
14     setAttribute(Qt::WA_Maemo5StackedWindow, true);
15     setAttribute(Qt::WA_Maemo5NonComposited, true);
16 #endif // Q_WS_MAEMO_5
17 #ifndef Q_OS_SYMBIAN
18     toolBar->hide();
19 #endif
20     QFrame *frame = new QFrame(this);
21     QVBoxLayout *layout = new QVBoxLayout(frame);
22     layout->setMargin(0);
23     frame->setLayout(layout);
24     setCentralWidget(frame);
25     restoreButton = new TranslucentButton("view-normal", this);
26     QRect screen = QApplication::desktop()->screenGeometry();
27     restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
28         screen.height() - TranslucentButton::pixels - 9,
29         TranslucentButton::pixels, TranslucentButton::pixels);
30     connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
31 }
32
33 void FullScreenWindow::showFullScreen()
34 {
35     TRACE;
36     AdopterWindow::showFullScreen();
37     restoreButton->flash(3000);
38 }
39
40 void FullScreenWindow::resizeEvent(QResizeEvent *e)
41 {
42     TRACE;
43
44     QRect screen = QApplication::desktop()->screenGeometry();
45     int w = screen.width();
46     int h = screen.height();
47
48 #ifdef Q_WS_MAEMO_5
49     // Hack: FullScreenWindow can lose orientation on Maemo...
50     QString orientation = Settings::instance()->value("orientation",
51         Platform::instance()->defaultOrientation()).toString();
52     if (((orientation == "portrait") && (w > h)) ||
53         ((orientation == "landscape") && (w < h))) {
54         int tmp = w;
55         w = h;
56         h = tmp;
57     }
58 #endif // Q_WS_MAEMO_5
59
60     restoreButton->setGeometry(w - TranslucentButton::pixels - 9,
61         h - TranslucentButton::pixels - 9,  TranslucentButton::pixels,
62         TranslucentButton::pixels);
63     restoreButton->flash(3000);
64     AdopterWindow::resizeEvent(e);
65 }