X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=fullscreenwindow.cpp;h=c63f003a0edd04b6e050926ed594795dcb694f4a;hb=4f302c4427507fec544f32b9003035e93f32b2e2;hp=507600b9ed6ef016b9295ed8640a7e8f182557a0;hpb=8f61c1b666e9c4ad58d4689094c074c9cd05e387;p=dorian diff --git a/fullscreenwindow.cpp b/fullscreenwindow.cpp index 507600b..c63f003 100644 --- a/fullscreenwindow.cpp +++ b/fullscreenwindow.cpp @@ -2,7 +2,12 @@ #include "fullscreenwindow.h" #include "translucentbutton.h" +#include "progress.h" #include "trace.h" +#include "settings.h" +#include "platform.h" + +static const int MARGIN = 9; FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) { @@ -12,9 +17,7 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) setAttribute(Qt::WA_Maemo5StackedWindow, true); setAttribute(Qt::WA_Maemo5NonComposited, true); #endif // Q_WS_MAEMO_5 -#ifndef Q_OS_SYMBIAN - toolBar->hide(); -#endif + hideToolBar(); QFrame *frame = new QFrame(this); QVBoxLayout *layout = new QVBoxLayout(frame); layout->setMargin(0); @@ -22,32 +25,52 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) setCentralWidget(frame); restoreButton = new TranslucentButton("view-normal", this); QRect screen = QApplication::desktop()->screenGeometry(); - restoreButton->setGeometry((screen.width() - TranslucentButton::pixels) / 2, - screen.height() - TranslucentButton::pixels - 9, - TranslucentButton::pixels, TranslucentButton::pixels); + 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) { - TRACE; -#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(3000); + Trace t("FullScreenWindow::showEvent"); + AdopterWindow::showEvent(e); + placeChildren(); } void FullScreenWindow::resizeEvent(QResizeEvent *e) { - TRACE; - Q_UNUSED(e); - restoreButton->raise(); + Trace t("FullScreenWindow::resizeEvent"); + AdopterWindow::resizeEvent(e); + placeChildren(); +} + +void FullScreenWindow::placeChildren() +{ + Trace t("FullScreenWindow::placeChildren"); + QRect screen = QApplication::desktop()->screenGeometry(); - restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9, - screen.height() - TranslucentButton::pixels - 9, - TranslucentButton::pixels, TranslucentButton::pixels); + int w = screen.width(); + int h = screen.height(); + +#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 + + restoreButton->setGeometry( + w - TranslucentButton::pixels - MARGIN, + h - TranslucentButton::pixels - MARGIN, + TranslucentButton::pixels, + TranslucentButton::pixels); + restoreButton->flash(3000); }