Maintain reading position on Symbian between orientations.
[dorian] / bookview.cpp
index 3e38ea6..9f3daf5 100644 (file)
@@ -514,13 +514,19 @@ void BookView::onMediaKeysPressed(MediaKeysObserver::MediaKeys key)
 
 #endif // Q_OS_SYMBIAN
 
-void BookView::adjustPosition(const QSize &size, const QSize &oldSize)
+void BookView::adjustPosition()
 {
+    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();
-        qDebug() << QString("At %1 (%2%, height %3)").
-                arg(pos).arg((qreal)pos / (qreal)height * 100).arg(height);
+        int current = frame->scrollPosition().y();
+        qDebug() << "From" << current << "to" << (int)(current * ratio);
+        frame->scroll(0, (int)(current * ratio) - current);
     }
 }