Fix forward navigation control on Linux.
[dorian] / adopterwindow.cpp
index d5f5337..b60b61a 100644 (file)
@@ -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();