Make orientation switch explicit on Symbian, too.
authorAkos Polster <akos@pipacs.com>
Sun, 9 Jan 2011 20:40:32 +0000 (21:40 +0100)
committerAkos Polster <akos@pipacs.com>
Sun, 9 Jan 2011 20:40:32 +0000 (21:40 +0100)
adopterwindow.cpp
bookview.cpp
bookview.h
dorian.pro
mainwindow.cpp
pkg/changelog
platform.cpp
platform.h
settingswindow.cpp
widgets/mainbase.cpp

index 173ed8b..d5f5337 100644 (file)
@@ -138,29 +138,12 @@ void AdopterWindow::resizeEvent(QResizeEvent *event)
     MainBase::resizeEvent(event);
     placeDecorations();
 
     MainBase::resizeEvent(event);
     placeDecorations();
 
-#if defined(Q_WS_MAEMO_5)
+#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
     // Restore previous reading position
     // Restore previous reading position
-    if (!bookView) {
-        return;
-    }
-    QTimer::singleShot(110, bookView, SLOT(restoreLastBookmark()));
-#endif // Q_WS_MAEMO_5
-
-#if defined(Q_OS_SYMBIAN)
-    // Adjust reading position after orientation change
-    if (!bookView) {
-        return;
-    }
-    if (event->oldSize().width() == -1) {
-        return;
-    }
-    bool oldPortrait = event->oldSize().width() < event->oldSize().height();
-    bool portrait = event->size().width() < event->size().height();
-    if (oldPortrait == portrait) {
-        return;
+    if (bookView) {
+        QTimer::singleShot(110, bookView, SLOT(restoreLastBookmark()));
     }
     }
-    QTimer::singleShot(990, bookView, SLOT(adjustPosition()));
-#endif // Q_OS_SYMBIAN
+#endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
 }
 
 void AdopterWindow::closeEvent(QCloseEvent *event)
 }
 
 void AdopterWindow::closeEvent(QCloseEvent *event)
@@ -230,9 +213,9 @@ void AdopterWindow::placeDecorations()
 #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
 #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();
-    }
+    // 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.
 
     // Work around another Symbian bug: When returning from full screen mode
     // in landscape, the book view widget's height is miscalculated.
index 3964afa..d94cb03 100644 (file)
@@ -516,27 +516,3 @@ void BookView::onMediaKeysPressed(MediaKeysObserver::MediaKeys key)
 }
 
 #endif // Q_OS_SYMBIAN
 }
 
 #endif // Q_OS_SYMBIAN
-
-#ifdef Q_OS_SYMBIAN
-
-void BookView::adjustPosition()
-{
-    TRACE;
-
-    // QWebView widget doesn't maintain reading positon during orientation
-    // switch. This heuristics tries to work around it.
-
-    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 current = frame->scrollPosition().y();
-        frame->scroll(0, (int)(current * ratio) - current);
-    }
-}
-
-#endif // Q_OS_SYMBIAN
index 1917d78..daf605b 100644 (file)
@@ -90,11 +90,6 @@ public slots:
     /** Restore book's last reading position. */
     void restoreLastBookmark();
 
     /** Restore book's last reading position. */
     void restoreLastBookmark();
 
-#ifdef Q_OS_SYMBIAN
-    /** Adjust web view position after orientation change. */
-    void adjustPosition();
-#endif
-
 protected slots:
 #ifdef Q_OS_SYMBIAN
     /** Observe media keys. */
 protected slots:
 #ifdef Q_OS_SYMBIAN
     /** Observe media keys. */
index 7dd27a1..c1ca627 100644 (file)
@@ -162,7 +162,7 @@ symbian {
     SOURCES += \\r
         widgets/flickcharm.cpp \\r
         widgets/mediakeysobserver.cpp\r
     SOURCES += \\r
         widgets/flickcharm.cpp \\r
         widgets/mediakeysobserver.cpp\r
-    LIBS += -lremconinterfacebase -lremconcoreapi\r
+    LIBS += -lremconinterfacebase -lremconcoreapi -lcone -leikcore -lavkon\r
 }\r
 \r
 maemo5 {\r
 }\r
 \r
 maemo5 {\r
index 2119452..e20bf84 100755 (executable)
@@ -48,7 +48,7 @@ MainWindow::MainWindow(QWidget *parent):
 #endif
 
     // Central widget. Must be an intermediate, because the book view widget
 #endif
 
     // Central widget. Must be an intermediate, because the book view widget
-    // can be re-parented later
+    // might be re-parented later
     QFrame *central = new QFrame(this);
     QVBoxLayout *layout = new QVBoxLayout(central);
     layout->setMargin(0);
     QFrame *central = new QFrame(this);
     QVBoxLayout *layout = new QVBoxLayout(central);
     layout->setMargin(0);
@@ -257,36 +257,27 @@ void MainWindow::showBookmarks()
 
 void MainWindow::onSettingsChanged(const QString &key)
 {
 
 void MainWindow::onSettingsChanged(const QString &key)
 {
-#if defined(Q_WS_MAEMO_5)
+    TRACE;
+    qDebug() << "Key" << key;
+
     if (key == "orientation") {
     if (key == "orientation") {
+        view->setLastBookmark();
         QString value = Settings::instance()->value(key,
             Platform::instance()->defaultOrientation()).toString();
         QString value = Settings::instance()->value(key,
             Platform::instance()->defaultOrientation()).toString();
-        qDebug() << "MainWindow::onSettingsChanged: orientation" << value;
-        if (value == "portrait") {
-            setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
-            setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
-            fullScreenWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,
-                                           false);
-            fullScreenWindow->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
-        } else {
-            setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
-            setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
-            fullScreenWindow->setAttribute(Qt::WA_Maemo5PortraitOrientation,
-                                           false);
-            fullScreenWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,
-                                           true);
-        }
-    } else if (key == "lightson") {
+        qDebug() << "Value: orientation" << value;
+        Platform::instance()->setOrientation(this, value);
+        Platform::instance()->setOrientation(fullScreenWindow, value);
+    }
+
+#if defined(Q_WS_MAEMO_5)
+    else if (key == "lightson") {
         bool enable = Settings::instance()->value(key, false).toBool();
         bool enable = Settings::instance()->value(key, false).toBool();
-        qDebug() << "MainWindow::onSettingsChanged: lightson" << enable;
         killTimer(preventBlankingTimer);
         if (enable) {
             preventBlankingTimer = startTimer(29 * 1000);
         }
     }
         killTimer(preventBlankingTimer);
         if (enable) {
             preventBlankingTimer = startTimer(29 * 1000);
         }
     }
-#else
-    Q_UNUSED(key);
-#endif // Q_WS_MAEMO_5
+#endif // defined(Q_WS_MAEMO_5)
 }
 
 void MainWindow::onPartLoadStart()
 }
 
 void MainWindow::onPartLoadStart()
index f46ed20..0e3bf68 100644 (file)
@@ -7,7 +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 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
+  * Make orientation switch explicit on Symbian, too
 
  -- Akos Polster <akos@pipacs.com>  Sun,  5 Dec 2010 02:00:00 +0100
 
 
  -- Akos Polster <akos@pipacs.com>  Sun,  5 Dec 2010 02:00:00 +0100
 
index ee7f5d9..ac25039 100644 (file)
@@ -6,7 +6,15 @@
 #   include <unistd.h>
 #endif
 
 #   include <unistd.h>
 #endif
 
+#ifdef Q_OS_SYMBIAN
+#   include <eikenv.h>
+#   include <eikappui.h>
+#   include <aknenv.h>
+#   include <aknappui.h>
+#endif
+
 #include "platform.h"
 #include "platform.h"
+#include "trace.h"
 
 #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
 #   define DORIAN_BASE "dorian"
 
 #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
 #   define DORIAN_BASE "dorian"
@@ -145,3 +153,37 @@ QString Platform::defaultOrientation()
     return QString("landscape");
 #endif
 }
     return QString("landscape");
 #endif
 }
+
+void Platform::setOrientation(QWidget *widget, const QString &orientation)
+{
+    TRACE;
+    qDebug() << "To" << orientation;
+
+    Q_UNUSED(widget);
+
+#if defined(Q_OS_SYMBIAN)
+    CAknAppUi *appUi = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
+    if (!appUi) {
+        qCritical() << "Platform::setOrientation: Couldn't get AppUi pointer";
+        return;
+    }
+#endif
+
+    if (orientation == "portrait") {
+#if defined(Q_WS_MAEMO_5)
+        widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
+        widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+#elif defined(Q_OS_SYMBIAN)
+        TRAPD(error,
+              appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait););
+#endif
+    } else {
+#if defined(Q_WS_MAEMO_5)
+        widget->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
+        widget->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+#elif defined(Q_OS_SYMBIAN)
+        TRAPD(error,
+              appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape););
+#endif
+    }
+}
index 00cdac1..f920f80 100644 (file)
@@ -20,6 +20,7 @@ public:
     QString defaultFont();
     int defaultZoom();
     QString defaultOrientation();
     QString defaultFont();
     int defaultZoom();
     QString defaultOrientation();
+    void setOrientation(QWidget *widget, const QString &orientation);
     void information(const QString &label, QWidget *parent = 0);
     void showBusy(QWidget *w, bool isBusy);
     QString traceFileName();
     void information(const QString &label, QWidget *parent = 0);
     void showBusy(QWidget *w, bool isBusy);
     QString traceFileName();
index 524dc7d..f09f9b2 100644 (file)
@@ -100,7 +100,7 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
         box->toggle(SchemeDefault);
     }
 
         box->toggle(SchemeDefault);
     }
 
-#ifndef Q_OS_SYMBIAN
+#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
     QLabel *orientationLabel = new QLabel(tr("Orientation:"), contents);
     layout->addWidget(orientationLabel);
     orientationBox = new ToolButtonBox(this);
     QLabel *orientationLabel = new QLabel(tr("Orientation:"), contents);
     layout->addWidget(orientationLabel);
     orientationBox = new ToolButtonBox(this);
@@ -117,7 +117,7 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
     } else {
         orientationBox->toggle(OrientationLandscape);
     }
     } else {
         orientationBox->toggle(OrientationLandscape);
     }
-#endif // !Q_OS_SYMBIAN
+#endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
 
     layout->addStretch();
     scroller->setWidget(contents);
 
     layout->addStretch();
     scroller->setWidget(contents);
@@ -180,9 +180,6 @@ void SettingsWindow::onSchemeButtonClicked(int id)
 
 void SettingsWindow::onOrientationButtonClicked(int id)
 {
 
 void SettingsWindow::onOrientationButtonClicked(int id)
 {
-#ifdef Q_WS_MAEMO_5
-    Q_UNUSED(id);
-#else
     QString orientation;
     switch (id) {
     case OrientationLandscape:
     QString orientation;
     switch (id) {
     case OrientationLandscape:
@@ -193,7 +190,6 @@ void SettingsWindow::onOrientationButtonClicked(int id)
         break;
     }
     Settings::instance()->setValue("orientation", orientation);
         break;
     }
     Settings::instance()->setValue("orientation", orientation);
-#endif // Q_WS_MAEMO_5
 }
 
 void SettingsWindow::closeEvent(QCloseEvent *e)
 }
 
 void SettingsWindow::closeEvent(QCloseEvent *e)
@@ -202,11 +198,9 @@ void SettingsWindow::closeEvent(QCloseEvent *e)
     Settings *settings = Settings::instance();
     settings->setValue("zoom", zoomSlider->value());
     settings->setValue("font", fontButton->currentFont().family());
     Settings *settings = Settings::instance();
     settings->setValue("zoom", zoomSlider->value());
     settings->setValue("font", fontButton->currentFont().family());
-#ifndef Q_OS_SYMBIAN
     settings->setValue("orientation",
         (orientationBox->checkedId() == OrientationLandscape)?
         "landscape": "portrait");
     settings->setValue("orientation",
         (orientationBox->checkedId() == OrientationLandscape)?
         "landscape": "portrait");
-#endif // Q_OS_SYMBIAN
     e->accept();
 }
 
     e->accept();
 }
 
index 54343b6..4a9b4fb 100755 (executable)
@@ -57,7 +57,7 @@ QAction *MainBase::addToolBarAction(QObject *receiver,
         // Add tool bar action\r
         QPushButton *button = new QPushButton(this);\r
         button->setIconSize(QSize(60, 60));\r
         // Add tool bar action\r
         QPushButton *button = new QPushButton(this);\r
         button->setIconSize(QSize(60, 60));\r
-        button->setFixedSize(89, 60);\r
+        button->setFixedHeight(60);\r
         button->setIcon(QIcon(Platform::instance()->icon(iconName)));\r
         button->setSizePolicy(QSizePolicy::MinimumExpanding,\r
                               QSizePolicy::Maximum);\r
         button->setIcon(QIcon(Platform::instance()->icon(iconName)));\r
         button->setSizePolicy(QSizePolicy::MinimumExpanding,\r
                               QSizePolicy::Maximum);\r
@@ -88,7 +88,7 @@ void MainBase::addToolBarSpace()
 \r
 void MainBase::updateToolBar()\r
 {\r
 \r
 void MainBase::updateToolBar()\r
 {\r
-#ifdef Q_OS_SYMBIAN\r
+#if 0 // ifdef Q_OS_SYMBIAN\r
     TRACE;\r
     if (toolBar) {\r
         QRect geometry = QApplication::desktop()->geometry();\r
     TRACE;\r
     if (toolBar) {\r
         QRect geometry = QApplication::desktop()->geometry();\r