X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=adopterwindow.cpp;h=b60b61a16dbb54a88e12c8aec986aa7334e5cca5;hb=HEAD;hp=d5f5337dd88ef2ca7069ab6d23c41008c445309e;hpb=4f302c4427507fec544f32b9003035e93f32b2e2;p=dorian diff --git a/adopterwindow.cpp b/adopterwindow.cpp index d5f5337..b60b61a 100644 --- a/adopterwindow.cpp +++ b/adopterwindow.cpp @@ -20,7 +20,7 @@ AdopterWindow::AdopterWindow(QWidget *parent): MainBase(parent), bookView(0), { TRACE; - // Monitor settings + // Monitor settings changes connect(Settings::instance(), SIGNAL(valueChanged(const QString &)), this, SLOT(onSettingsChanged(const QString &))); @@ -38,12 +38,14 @@ void AdopterWindow::takeBookView(BookView *view, Q_ASSERT(previous); Q_ASSERT(next); - leaveBookView(); + if (bookView) { + return; + } bookView = view; bookView->setParent(this); centralWidget()->layout()->addWidget(bookView); - bookView->show(); + // bookView->show(); progress = prog; previousButton = previous; @@ -62,10 +64,13 @@ void AdopterWindow::takeBookView(BookView *view, void AdopterWindow::leaveBookView() { TRACE; - if (bookView) { - bookView->hide(); - centralWidget()->layout()->removeWidget(bookView); + + if (!bookView) { + return; } + + // bookView->hide(); + centralWidget()->layout()->removeWidget(bookView); bookView = 0; progress = 0; nextButton = 0; @@ -121,11 +126,11 @@ void AdopterWindow::doGrabVolumeKeys(bool grab) #endif // Q_WS_MAEMO_5 -void AdopterWindow::showEvent(QShowEvent *e) +void AdopterWindow::showEvent(QShowEvent *event) { Trace t("AdopterWindow::showEvent"); - MainBase::showEvent(e); + MainBase::showEvent(event); #if defined(Q_WS_MAEMO_5) doGrabVolumeKeys(grabbingVolumeKeys); #endif @@ -135,13 +140,13 @@ void AdopterWindow::showEvent(QShowEvent *e) void AdopterWindow::resizeEvent(QResizeEvent *event) { Trace t("AdopterWindow::resizeEvent"); + MainBase::resizeEvent(event); placeDecorations(); - #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) // Restore previous reading position if (bookView) { - QTimer::singleShot(110, bookView, SLOT(restoreLastBookmark())); + bookView->scheduleRestoreLastBookmark(); } #endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) } @@ -152,6 +157,7 @@ void AdopterWindow::closeEvent(QCloseEvent *event) if (bookView) { bookView->setLastBookmark(); } + hide(); MainBase::closeEvent(event); } @@ -166,7 +172,8 @@ void AdopterWindow::leaveEvent(QEvent *event) void AdopterWindow::keyPressEvent(QKeyEvent *event) { - TRACE; + Trace t("AdopterWindow::keyPressEvent"); + switch (event->key()) { case Qt::Key_PageDown: #ifdef Q_WS_MAEMO_5 @@ -202,38 +209,30 @@ void AdopterWindow::placeDecorations() Trace t("AdopterWindow::placeDecorations"); if (!hasBookView()) { + qDebug() << "Doesn't have the book view"; return; } + qDebug() << "Has the book view"; int extraHeight = 0; +#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5) + extraHeight += toolBarHeight(); +#endif + QRect geo = bookView->geometry(); qDebug() << "bookView:" << geo; -#ifdef Q_OS_SYMBIAN - // Work around Symbian bug: If tool bar is hidden, increase bottom - // decorator widgets' Y coordinates by the tool bar's height - // if (isToolBarHidden()) { - // extraHeight = toolBarHeight(); - // } - - // Work around another Symbian bug: When returning from full screen mode - // in landscape, the book view widget's height is miscalculated. - // My apologies for this kludge - if (geo.height() == 288) { - qDebug() << "Adjusting bottom Y"; - extraHeight -= 288 - 223; - } -#endif // Q_OS_SYMBIAN - progress->setGeometry(geo.x(), geo.y() + geo.height() - progress->thickness() + extraHeight, geo.width(), progress->thickness()); previousButton->setGeometry(geo.x(), geo.y() + geo.height() - TranslucentButton::pixels + extraHeight, TranslucentButton::pixels, TranslucentButton::pixels); - nextButton->setGeometry(geo.x() + geo.width() - TranslucentButton::pixels, - geo.y(), TranslucentButton::pixels, TranslucentButton::pixels); + nextButton->setGeometry( + geo.x() + geo.width() - TranslucentButton::pixels, + geo.y() + extraHeight, TranslucentButton::pixels, + TranslucentButton::pixels); progress->flash(); previousButton->flash(); nextButton->flash();