X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=bookview.cpp;h=30a1499e98e4c1385b5fd29689e786142c544618;hb=5b90676a3adb2b9df8504684093c165f684eac29;hp=e4b4773e80f8a97dd8a580cb6f0746f2cfb98eb6;hpb=156e40ef8337b8c0d668fb33a9c8bf2b6b34ba79;p=dorian diff --git a/bookview.cpp b/bookview.cpp index e4b4773..30a1499 100644 --- a/bookview.cpp +++ b/bookview.cpp @@ -58,13 +58,8 @@ BookView::BookView(QWidget *parent): QWebView(parent), contentIndex(-1), bookmarkImage = QImage(":/icons/bookmark.png"); // Handle settings changes, force handling initial settings - Settings *s = Settings::instance(); - connect(s, SIGNAL(valueChanged(const QString &)), + connect(Settings::instance(), SIGNAL(valueChanged(const QString &)), this, SLOT(onSettingsChanged(const QString &))); - s->setValue("zoom", s->value("zoom", 160)); - s->setValue("font", s->value("font", Platform::instance()->defaultFont())); - s->setValue("scheme", s->value("scheme", "default")); - s->setValue("usevolumekeys", s->value("usevolumekeys", false)); setBook(0); // Enable kinetic scrolling @@ -262,14 +257,17 @@ void BookView::restoreAfterLoad() void BookView::onSettingsChanged(const QString &key) { - TRACE; - qDebug() << key << Settings::instance()->value(key); + Settings *s = Settings::instance(); + Platform *p = Platform::instance(); if (key == "zoom") { - setZoomFactor(Settings::instance()->value(key).toFloat() / 100.); + int value = s->value(key, p->defaultZoom()).toInt(); + qDebug() << "BookView::onSettingsChanged: zoom" << value; + setZoomFactor(value / 100.); } else if (key == "font") { - QString face = Settings::instance()->value(key).toString(); + QString face = s->value(key, p->defaultFont()).toString(); + qDebug() << "BookView::onSettingsChanged: font" << face; settings()->setFontFamily(QWebSettings::StandardFont, face); } else if (key == "scheme") { @@ -279,14 +277,17 @@ void BookView::onSettingsChanged(const QString &key) (scheme != "default")) { scheme = "default"; } + qDebug() << "BookView::onSettingsChanged: scheme" << scheme; QFile script(":/styles/" + scheme + ".js"); script.open(QFile::ReadOnly); QString scriptText = script.readAll(); script.close(); - QVariant ret = frame->evaluateJavaScript(scriptText); + (void)frame->evaluateJavaScript(scriptText); } else if (key == "usevolumekeys") { - grabVolumeKeys(Settings::instance()->value(key).toBool()); + bool grab = s->value(key, false).toBool(); + qDebug() << "BookView::onSettingsChanged: usevolumekeys" << grab; + grabVolumeKeys(grab); } } @@ -405,27 +406,6 @@ void BookView::addJavaScriptObjects() page()->mainFrame()->addToJavaScriptWindowObject("bv", this); } -#ifdef Q_WS_MAEMO_5 - -void BookView::leaveEvent(QEvent *e) -{ - TRACE; - // Save current position, to be restored later - setLastBookmark(); - QWebView::leaveEvent(e); -} - -void BookView::resizeEvent(QEvent *e) -{ - TRACE; - // Restore position saved at Leave event. This seems to be required, - // after temporarily switching from portrait to landscape and back - restoreLastBookmark(); - QWebView::enterEvent(e); -} - -#endif // Q_WS_MAEMO_5 - void BookView::goToPosition(qreal position) { int contentsHeight = page()->mainFrame()->contentsSize().height(); @@ -488,7 +468,7 @@ void BookView::goNextPage() if (pos == frame->scrollPosition().y()) { goNext(); } else { - setLastBookmark(); + // setLastBookmark(); showProgress(); } }