X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=fullscreenwindow.cpp;h=c63f003a0edd04b6e050926ed594795dcb694f4a;hb=ee43811f99a9f2f047ed4aceeea2bdbf411f2fe0;hp=fa3446bfb71f8072268d938d4c1d31ca8b0ab252;hpb=77e2fb13d4293405ea15e33b061dd915a56469d2;p=dorian diff --git a/fullscreenwindow.cpp b/fullscreenwindow.cpp index fa3446b..c63f003 100644 --- a/fullscreenwindow.cpp +++ b/fullscreenwindow.cpp @@ -2,73 +2,75 @@ #include "fullscreenwindow.h" #include "translucentbutton.h" +#include "progress.h" #include "trace.h" +#include "settings.h" +#include "platform.h" -FullScreenWindow::FullScreenWindow(QWidget *parent): QMainWindow(parent), child(0) +static const int MARGIN = 9; + +FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) { + TRACE; Q_ASSERT(parent); #ifdef Q_WS_MAEMO_5 setAttribute(Qt::WA_Maemo5StackedWindow, true); setAttribute(Qt::WA_Maemo5NonComposited, true); #endif // Q_WS_MAEMO_5 + hideToolBar(); QFrame *frame = new QFrame(this); QVBoxLayout *layout = new QVBoxLayout(frame); layout->setMargin(0); frame->setLayout(layout); setCentralWidget(frame); - restoreButton = new TranslucentButton("view-fullscreen", this); + restoreButton = new TranslucentButton("view-normal", this); + QRect screen = QApplication::desktop()->screenGeometry(); + restoreButton->setGeometry( + screen.width() - TranslucentButton::pixels - MARGIN, + screen.height() - TranslucentButton::pixels - MARGIN, + TranslucentButton::pixels, + TranslucentButton::pixels); + connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore())); } -void FullScreenWindow::showFullScreen() +void FullScreenWindow::showEvent(QShowEvent *e) { -#ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5PortraitOrientation, parentWidget()-> - testAttribute(Qt::WA_Maemo5PortraitOrientation)); - setAttribute(Qt::WA_Maemo5LandscapeOrientation, parentWidget()-> - testAttribute(Qt::WA_Maemo5LandscapeOrientation)); -#endif // Q_WS_MAEMO_5 - QWidget::showFullScreen(); - restoreButton->flash(); + Trace t("FullScreenWindow::showEvent"); + AdopterWindow::showEvent(e); + placeChildren(); } -void FullScreenWindow::MOUSE_ACTIVATE_EVENT(QMouseEvent *event) +void FullScreenWindow::resizeEvent(QResizeEvent *e) { - Trace t("FullScreenWindow::MOUSE_ACTIVATE_EVENT"); - if (fullScreenZone().contains(event->x(), event->y())) { - emit restore(); - } else { - restoreButton->flash(); - } - QMainWindow::MOUSE_ACTIVATE_EVENT(event); + Trace t("FullScreenWindow::resizeEvent"); + AdopterWindow::resizeEvent(e); + placeChildren(); } -QRect FullScreenWindow::fullScreenZone() const +void FullScreenWindow::placeChildren() { - return QRect(width() / 2 - 45, height() - 104, 95, 95); -} + Trace t("FullScreenWindow::placeChildren"); -void FullScreenWindow::resizeEvent(QResizeEvent *e) -{ - restoreButton->setGeometry(fullScreenZone()); - QMainWindow::resizeEvent(e); -} + QRect screen = QApplication::desktop()->screenGeometry(); + int w = screen.width(); + int h = screen.height(); -void FullScreenWindow::takeChild(QWidget *c) -{ - leaveChild(); - if (c) { - child = c; - child->setParent(centralWidget()); - centralWidget()->layout()->addWidget(child); - connect(child, SIGNAL(suppressedMouseButtonPress()), - restoreButton, SLOT(flash())); +#ifdef Q_WS_MAEMO_5 + // Hack: FullScreenWindow can lose orientation on Maemo... + QString orientation = Settings::instance()->value("orientation", + Platform::instance()->defaultOrientation()).toString(); + if (((orientation == "portrait") && (w > h)) || + ((orientation == "landscape") && (w < h))) { + int tmp = w; + w = h; + h = tmp; } -} +#endif // Q_WS_MAEMO_5 -void FullScreenWindow::leaveChild() -{ - if (child) { - centralWidget()->layout()->removeWidget(child); - child = 0; - } + restoreButton->setGeometry( + w - TranslucentButton::pixels - MARGIN, + h - TranslucentButton::pixels - MARGIN, + TranslucentButton::pixels, + TranslucentButton::pixels); + restoreButton->flash(3000); }