Restore to the correct reading position after orientation change.
authorAkos Polster <akos@pipacs.com>
Mon, 8 Nov 2010 21:03:45 +0000 (22:03 +0100)
committerAkos Polster <akos@pipacs.com>
Mon, 8 Nov 2010 21:03:45 +0000 (22:03 +0100)
bookview.cpp
bookview.h
fullscreenwindow.cpp
mainwindow.cpp
pkg/changelog

index 503b40e..aaa3326 100644 (file)
@@ -411,20 +411,11 @@ void BookView::addJavaScriptObjects()
 void BookView::leaveEvent(QEvent *e)
 {
     TRACE;
-    // Save current position, to be restored later
+    // Save current position, to be restored later, in MainWindow::resizeEvent()
     setLastBookmark();
     QWebView::leaveEvent(e);
 }
 
-void BookView::resizeEvent(QEvent *e)
-{
-    TRACE;
-    // Restore position saved at Leave event. This seems to be required,
-    // after temporarily switching from portrait to landscape and back
-    restoreLastBookmark();
-    QWebView::enterEvent(e);
-}
-
 #endif // Q_WS_MAEMO_5
 
 void BookView::goToPosition(qreal position)
index e2e1d17..8465f3c 100644 (file)
@@ -27,13 +27,26 @@ class BookView: public QWebView
 
 public:
     explicit BookView(QWidget *parent = 0);
+
+    /** Set current book. */
     void setBook(Book *book);
+
+    /** Get current book. */
     Book *book();
+
+    /** Go to the position decribed by "bookmark". */
     void goToBookmark(const Book::Bookmark &bookmark);
+
+    /** Add bookmark to book at the current position. */
     void addBookmark(const QString &note);
+
+    /** Save current reading position into book. */
     void setLastBookmark();
-    void restoreLastBookmark();
+
+    /** Go to given part + part fragment URL. */
     void goToPart(int part, const QString &fragment);
+
+    /** Go to given fragment URL in current part. */
     void goToFragment(const QString &fragment);
 
     /** If grab is true, volume keys will generate act as page up/down. */
@@ -77,6 +90,9 @@ public slots:
     /** Restore saved position after URL loading finished. */
     void restoreAfterLoad();
 
+    /** Restore book's last reading position. */
+    void restoreLastBookmark();
+
 protected slots:
 #ifdef Q_OS_SYMBIAN
     /** Observe media keys. */
@@ -91,7 +107,6 @@ protected:
     void timerEvent(QTimerEvent *e);
 #ifdef Q_WS_MAEMO_5
     void leaveEvent(QEvent *e);
-    void resizeEvent(QEvent *e);
 #endif // Q_WS_MAEMO_5
 
     /** Load given part. */
index 4aff5d0..507600b 100644 (file)
@@ -45,6 +45,7 @@ void FullScreenWindow::resizeEvent(QResizeEvent *e)
 {
     TRACE;
     Q_UNUSED(e);
+    restoreButton->raise();
     QRect screen = QApplication::desktop()->screenGeometry();
     restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
         screen.height() - TranslucentButton::pixels - 9,
index 42e7e77..c3ef1a6 100755 (executable)
@@ -435,6 +435,12 @@ void MainWindow::resizeEvent(QResizeEvent *e)
         toolBar->height(), TranslucentButton::pixels, TranslucentButton::pixels);
 #endif // Q_WS_MAEMO_5
     qDebug() << "previousButton geometry" << previousButton->geometry();
+
+#ifdef Q_WS_MAEMO_5
+    // This is needed on Maemo, in order not to lose current reading position
+    // after orientation change
+    QTimer::singleShot(250, view, SLOT(restoreLastBookmark()));
+#endif
     previousButton->flash();
     nextButton->flash();
     QMainWindow::resizeEvent(e);
index f5dfd19..351b765 100644 (file)
@@ -1,6 +1,6 @@
 dorian (0.3.5-1) unstable; urgency=low
 
-  *
+  * Fix chapter navigation on Maemo
 
  -- Akos Polster <akos@pipacs.com>  Sun,  7 Nov 2010 02:00:00 +0100