Maintain reading position on Symbian between orientations.
authorAkos Polster <akos@pipacs.com>
Sun, 2 Jan 2011 16:30:17 +0000 (17:30 +0100)
committerAkos Polster <akos@pipacs.com>
Sun, 2 Jan 2011 16:30:17 +0000 (17:30 +0100)
adopterwindow.cpp
bookview.cpp
pkg/changelog

index 2230675..735d37c 100644 (file)
@@ -143,7 +143,7 @@ void AdopterWindow::resizeEvent(QResizeEvent *event)
     }
 #elif defined(Q_OS_SYMBIAN)
     if (bookView) {
-        QTimer::singleShot(110, bookView, SLOT(adjustPosition()));
+        QTimer::singleShot(1000, bookView, SLOT(adjustPosition()));
     }
 #endif
 }
index bda16e4..9f3daf5 100644 (file)
@@ -516,13 +516,17 @@ void BookView::onMediaKeysPressed(MediaKeysObserver::MediaKeys key)
 
 void BookView::adjustPosition()
 {
-    QSize desktop = QApplication::desktop()->size();
-    qreal ratio = (qreal)(desktop.width()) / (qreal)(desktop.height());
+    TRACE;
+    const qreal portraitMagic = 1.66;
+    const qreal landscapeMagic = 0.655;
     if (mBook) {
+        QSize desktop = QApplication::desktop()->size();
+        int screenHeight = desktop.height();
+        int screenWidth = desktop.width();
+        qreal ratio = (screenWidth<screenHeight)? portraitMagic: landscapeMagic;
         QWebFrame *frame = page()->mainFrame();
-        int height = frame->contentsSize().height();
-        int pos = frame->scrollPosition().y();
-        qreal relativePos = (qreal)pos / (qreal)height;
-        // FIXME: Finish me
+        int current = frame->scrollPosition().y();
+        qDebug() << "From" << current << "to" << (int)(current * ratio);
+        frame->scroll(0, (int)(current * ratio) - current);
     }
 }
index 78f4548..f46ed20 100644 (file)
@@ -7,6 +7,7 @@ dorian (0.4.4-1) unstable; urgency=low
   * Maintain date book added to the library and date book last read
   * Show presence of extra book parts
   * Allow editing bookmark notes
+  * Maintain reading position between orientations
 
  -- Akos Polster <akos@pipacs.com>  Sun,  5 Dec 2010 02:00:00 +0100