Make full screen truly full screen.
[dorian] / fullscreenwindow.cpp
1 #include <QtGui>
2
3 #include "fullscreenwindow.h"
4 #include "translucentbutton.h"
5
6 FullScreenWindow::FullScreenWindow(QWidget *child, QWidget *parent):
7         QMainWindow(parent)
8 {
9     Q_ASSERT(parent);
10 #ifdef Q_WS_MAEMO_5
11     setAttribute(Qt::WA_Maemo5StackedWindow, true);
12     setAttribute(Qt::WA_Maemo5PortraitOrientation,
13                  parent->testAttribute(Qt::WA_Maemo5PortraitOrientation));
14     setAttribute(Qt::WA_Maemo5LandscapeOrientation,
15                  parent->testAttribute(Qt::WA_Maemo5LandscapeOrientation));
16 #endif // Q_WS_MAEMO_5
17     child->setParent(this);
18     setCentralWidget(child);
19     restoreButton = new TranslucentButton("view-fullscreen", this);
20 }
21
22 void FullScreenWindow::showFullScreen()
23 {
24     QWidget::showFullScreen();
25     restoreButton->flash();
26 }
27
28 void FullScreenWindow::MOUSE_ACTIVATE_EVENT(QMouseEvent *event)
29 {
30     if (fullScreenZone().contains(event->x(), event->y())) {
31         emit restore();
32     }
33     QMainWindow::MOUSE_ACTIVATE_EVENT(event);
34 }
35
36 QRect FullScreenWindow::fullScreenZone() const
37 {
38     return QRect(width() / 2 - 45, height() - 104, 95, 95);
39 }
40
41 void FullScreenWindow::resizeEvent(QResizeEvent *e)
42 {
43     restoreButton->setGeometry(fullScreenZone());
44     QMainWindow::resizeEvent(e);
45 }