3 #include "fullscreenwindow.h"
4 #include "translucentbutton.h"
10 static const int MARGIN = 9;
12 FullScreenWindow::FullScreenWindow(QWidget *parent):
13 AdopterWindow(parent), progress(0), previousButton(0), nextButton(0)
18 setAttribute(Qt::WA_Maemo5StackedWindow, true);
19 setAttribute(Qt::WA_Maemo5NonComposited, true);
20 #endif // Q_WS_MAEMO_5
24 QFrame *frame = new QFrame(this);
25 QVBoxLayout *layout = new QVBoxLayout(frame);
27 frame->setLayout(layout);
28 setCentralWidget(frame);
29 restoreButton = new TranslucentButton("view-normal", this);
30 QRect screen = QApplication::desktop()->screenGeometry();
31 restoreButton->setGeometry(
32 screen.width() - TranslucentButton::pixels - MARGIN,
33 screen.height() - TranslucentButton::pixels - MARGIN,
34 TranslucentButton::pixels,
35 TranslucentButton::pixels);
36 connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
39 void FullScreenWindow::showFullScreen()
41 Trace t("FullScreenWindow::showFullScreen");
42 AdopterWindow::showFullScreen();
46 void FullScreenWindow::resizeEvent(QResizeEvent *e)
48 Trace t("FullScreenWindow::resizeEvent");
49 QTimer::singleShot(100, this, SLOT(placeChildren()));
50 AdopterWindow::resizeEvent(e);
53 void FullScreenWindow::takeChildren(BookView *view,
55 TranslucentButton *previous,
56 TranslucentButton *next)
60 previousButton = previous;
62 QList<QWidget *> otherChildren;
63 otherChildren << progress << previousButton << nextButton;
64 AdopterWindow::takeChildren(view, otherChildren);
67 void FullScreenWindow::placeChildren()
69 Trace t("FullScreenWindow::placeChildren");
71 QRect screen = QApplication::desktop()->screenGeometry();
72 int w = screen.width();
73 int h = screen.height();
76 // Hack: FullScreenWindow can lose orientation on Maemo...
77 QString orientation = Settings::instance()->value("orientation",
78 Platform::instance()->defaultOrientation()).toString();
79 if (((orientation == "portrait") && (w > h)) ||
80 ((orientation == "landscape") && (w < h))) {
85 #endif // Q_WS_MAEMO_5
87 restoreButton->setGeometry(
88 w - TranslucentButton::pixels - MARGIN,
89 h - TranslucentButton::pixels - MARGIN,
90 TranslucentButton::pixels,
91 TranslucentButton::pixels);
93 if (hasChild(progress)) {
94 progress->setGeometry(0, h - progress->thickness(),
95 w, progress->thickness());
96 qDebug() << "Screen (FullScreenWindow::resizeEvent)" << w << "x" << h;
97 qDebug() << "Progress (FullScreenWindow::resizeEvent)"
98 << progress->geometry();
100 if (hasChild(previousButton)) {
101 previousButton->setGeometry(
103 h - TranslucentButton::pixels - MARGIN,
104 TranslucentButton::pixels,
105 TranslucentButton::pixels);
107 if (hasChild(nextButton)) {
108 nextButton->setGeometry(
109 w - TranslucentButton::pixels - MARGIN,
111 TranslucentButton::pixels,
112 TranslucentButton::pixels);
115 restoreButton->flash(3000);