From: Akos Polster Date: Sun, 9 Jan 2011 20:40:32 +0000 (+0100) Subject: Make orientation switch explicit on Symbian, too. X-Git-Url: http://git.maemo.org/git/?p=dorian;a=commitdiff_plain;h=4f302c4427507fec544f32b9003035e93f32b2e2 Make orientation switch explicit on Symbian, too. --- diff --git a/adopterwindow.cpp b/adopterwindow.cpp index 173ed8b..d5f5337 100644 --- a/adopterwindow.cpp +++ b/adopterwindow.cpp @@ -138,29 +138,12 @@ void AdopterWindow::resizeEvent(QResizeEvent *event) MainBase::resizeEvent(event); placeDecorations(); -#if defined(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) // 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) @@ -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 - 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. diff --git a/bookview.cpp b/bookview.cpp index 3964afa..d94cb03 100644 --- a/bookview.cpp +++ b/bookview.cpp @@ -516,27 +516,3 @@ void BookView::onMediaKeysPressed(MediaKeysObserver::MediaKeys key) } #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 = (screenWidthmainFrame(); - int current = frame->scrollPosition().y(); - frame->scroll(0, (int)(current * ratio) - current); - } -} - -#endif // Q_OS_SYMBIAN diff --git a/bookview.h b/bookview.h index 1917d78..daf605b 100644 --- a/bookview.h +++ b/bookview.h @@ -90,11 +90,6 @@ public slots: /** 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. */ diff --git a/dorian.pro b/dorian.pro index 7dd27a1..c1ca627 100644 --- a/dorian.pro +++ b/dorian.pro @@ -162,7 +162,7 @@ symbian { SOURCES += \ widgets/flickcharm.cpp \ widgets/mediakeysobserver.cpp - LIBS += -lremconinterfacebase -lremconcoreapi + LIBS += -lremconinterfacebase -lremconcoreapi -lcone -leikcore -lavkon } maemo5 { diff --git a/mainwindow.cpp b/mainwindow.cpp index 2119452..e20bf84 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -48,7 +48,7 @@ MainWindow::MainWindow(QWidget *parent): #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); @@ -257,36 +257,27 @@ void MainWindow::showBookmarks() void MainWindow::onSettingsChanged(const QString &key) { -#if defined(Q_WS_MAEMO_5) + TRACE; + qDebug() << "Key" << key; + if (key == "orientation") { + view->setLastBookmark(); 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(); - qDebug() << "MainWindow::onSettingsChanged: lightson" << enable; 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() diff --git a/pkg/changelog b/pkg/changelog index f46ed20..0e3bf68 100644 --- a/pkg/changelog +++ b/pkg/changelog @@ -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 reading position between orientations + * Make orientation switch explicit on Symbian, too -- Akos Polster Sun, 5 Dec 2010 02:00:00 +0100 diff --git a/platform.cpp b/platform.cpp index ee7f5d9..ac25039 100644 --- a/platform.cpp +++ b/platform.cpp @@ -6,7 +6,15 @@ # include #endif +#ifdef Q_OS_SYMBIAN +# include +# include +# include +# include +#endif + #include "platform.h" +#include "trace.h" #if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN) # define DORIAN_BASE "dorian" @@ -145,3 +153,37 @@ QString Platform::defaultOrientation() 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(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 + } +} diff --git a/platform.h b/platform.h index 00cdac1..f920f80 100644 --- a/platform.h +++ b/platform.h @@ -20,6 +20,7 @@ public: 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(); diff --git a/settingswindow.cpp b/settingswindow.cpp index 524dc7d..f09f9b2 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -100,7 +100,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) 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); @@ -117,7 +117,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) } else { orientationBox->toggle(OrientationLandscape); } -#endif // !Q_OS_SYMBIAN +#endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) layout->addStretch(); scroller->setWidget(contents); @@ -180,9 +180,6 @@ void SettingsWindow::onSchemeButtonClicked(int id) void SettingsWindow::onOrientationButtonClicked(int id) { -#ifdef Q_WS_MAEMO_5 - Q_UNUSED(id); -#else QString orientation; switch (id) { case OrientationLandscape: @@ -193,7 +190,6 @@ void SettingsWindow::onOrientationButtonClicked(int id) break; } Settings::instance()->setValue("orientation", orientation); -#endif // Q_WS_MAEMO_5 } 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()); -#ifndef Q_OS_SYMBIAN settings->setValue("orientation", (orientationBox->checkedId() == OrientationLandscape)? "landscape": "portrait"); -#endif // Q_OS_SYMBIAN e->accept(); } diff --git a/widgets/mainbase.cpp b/widgets/mainbase.cpp index 54343b6..4a9b4fb 100755 --- a/widgets/mainbase.cpp +++ b/widgets/mainbase.cpp @@ -57,7 +57,7 @@ QAction *MainBase::addToolBarAction(QObject *receiver, // Add tool bar action QPushButton *button = new QPushButton(this); button->setIconSize(QSize(60, 60)); - button->setFixedSize(89, 60); + button->setFixedHeight(60); button->setIcon(QIcon(Platform::instance()->icon(iconName))); button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); @@ -88,7 +88,7 @@ void MainBase::addToolBarSpace() void MainBase::updateToolBar() { -#ifdef Q_OS_SYMBIAN +#if 0 // ifdef Q_OS_SYMBIAN TRACE; if (toolBar) { QRect geometry = QApplication::desktop()->geometry();