Fix forward navigation control on Linux.
[dorian] / fullscreenwindow.cpp
1 #include <QtGui>
2
3 #include "fullscreenwindow.h"
4 #include "translucentbutton.h"
5 #include "progress.h"
6 #include "trace.h"
7 #include "settings.h"
8 #include "platform.h"
9
10 static const int MARGIN = 9;
11
12 FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
13 {
14     TRACE;
15
16 #if defined(Q_WS_MAEMO_5)
17     setAttribute(Qt::WA_Maemo5StackedWindow, true);
18     setAttribute(Qt::WA_Maemo5NonComposited, true);
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(
28         screen.width() - TranslucentButton::pixels - MARGIN,
29         screen.height() - TranslucentButton::pixels - MARGIN,
30         TranslucentButton::pixels,
31         TranslucentButton::pixels);
32     connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
33 }
34
35 void FullScreenWindow::showEvent(QShowEvent *e)
36 {
37     Trace t("FullScreenWindow::showEvent");
38     qDebug() << "Softkeys visible?"
39              << (windowFlags() & Qt::WindowSoftkeysVisibleHint);
40     placeChildren();
41     AdopterWindow::showEvent(e);
42 }
43
44 void FullScreenWindow::resizeEvent(QResizeEvent *e)
45 {
46     Trace t("FullScreenWindow::resizeEvent");
47     placeChildren();
48     AdopterWindow::resizeEvent(e);
49 }
50
51 void FullScreenWindow::closeEvent(QCloseEvent *e)
52 {
53     Trace t("FullscreenWindow::closeEvent");
54     AdopterWindow::closeEvent(e);
55 }
56
57 void FullScreenWindow::placeChildren()
58 {
59     Trace t("FullScreenWindow::placeChildren");
60
61     QRect screen = QApplication::desktop()->screenGeometry();
62     int w = screen.width();
63     int h = screen.height();
64
65 #ifdef Q_WS_MAEMO_5
66     // Hack: FullScreenWindow can lose orientation on Maemo...
67     QString orientation = Settings::instance()->value("orientation",
68         Platform::instance()->defaultOrientation()).toString();
69     if (((orientation == "portrait") && (w > h)) ||
70         ((orientation == "landscape") && (w < h))) {
71         int tmp = w;
72         w = h;
73         h = tmp;
74     }
75 #endif // Q_WS_MAEMO_5
76
77     restoreButton->setGeometry(
78         w - TranslucentButton::pixels - MARGIN,
79         h - TranslucentButton::pixels - MARGIN,
80         TranslucentButton::pixels,
81         TranslucentButton::pixels);
82     restoreButton->flash(3000);
83 }