X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=fullscreenwindow.cpp;h=ca8baba7f82256ef952b7e821dcfe8a07dd37d11;hb=549e8d8b51f631005863aa7f4f3cb2683a901669;hp=4aff5d04b3193e083eb500a84cceb5ffbc4f6239;hpb=156e40ef8337b8c0d668fb33a9c8bf2b6b34ba79;p=dorian diff --git a/fullscreenwindow.cpp b/fullscreenwindow.cpp index 4aff5d0..ca8baba 100644 --- a/fullscreenwindow.cpp +++ b/fullscreenwindow.cpp @@ -2,9 +2,15 @@ #include "fullscreenwindow.h" #include "translucentbutton.h" +#include "progress.h" #include "trace.h" +#include "settings.h" +#include "platform.h" -FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) +static const int MARGIN = 9; + +FullScreenWindow::FullScreenWindow(QWidget *parent): + AdopterWindow(parent), progress(0), previousButton(0), nextButton(0) { TRACE; Q_ASSERT(parent); @@ -22,31 +28,80 @@ 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() { 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(); + AdopterWindow::showFullScreen(); restoreButton->flash(3000); } void FullScreenWindow::resizeEvent(QResizeEvent *e) { TRACE; - Q_UNUSED(e); + 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); + + if (hasChild(progress)) { + progress->setGeometry(0, h - progress->thickness(), + w, progress->thickness()); + } + if (hasChild(previousButton)) { + previousButton->setGeometry( + MARGIN, + h - TranslucentButton::pixels - MARGIN, + TranslucentButton::pixels, + TranslucentButton::pixels); + } + if (hasChild(nextButton)) { + nextButton->setGeometry( + w - TranslucentButton::pixels - MARGIN, + MARGIN, + TranslucentButton::pixels, + TranslucentButton::pixels); + } + + restoreButton->flash(3000); + AdopterWindow::resizeEvent(e); +} + +void FullScreenWindow::takeChildren(BookView *view, + Progress *prog, + TranslucentButton *previous, + TranslucentButton *next) +{ + TRACE; + progress = prog; + previousButton = previous; + nextButton = next; + QList otherChildren; + otherChildren << progress << previousButton << nextButton; + AdopterWindow::takeChildren(view, otherChildren); }