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)
#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.
}
#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
/** 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. */
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
#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);
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()
* 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
# 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 "trace.h"
#if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
# define DORIAN_BASE "dorian"
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
+ }
+}
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();
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);
} else {
orientationBox->toggle(OrientationLandscape);
}
-#endif // !Q_OS_SYMBIAN
+#endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
layout->addStretch();
scroller->setWidget(contents);
void SettingsWindow::onOrientationButtonClicked(int id)
{
-#ifdef Q_WS_MAEMO_5
- Q_UNUSED(id);
-#else
QString orientation;
switch (id) {
case OrientationLandscape:
break;
}
Settings::instance()->setValue("orientation", orientation);
-#endif // Q_WS_MAEMO_5
}
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();
}
// 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
\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