loadFinished = true;
addNavigationBar();
onSettingsChanged("scheme");
+ emit chapterLoaded(contentIndex);
if (restore) {
restore = false;
if (ok && mBook) {
void BookView::addNavigationBar()
{
- QWebFrame *frame = page()->currentFrame();
- frame->addToJavaScriptWindowObject("bv", this);
+ if (!mBook) {
+ return;
+ }
QString naviPrev =
"<a href=\"javascript:bv.goPrevious();\">"
+ tmpPath() +
"/next.png\" />"
"</a>";
-
if (contentIndex == 0) {
naviPrev = "";
}
naviNext = "";
}
+ QWebFrame *frame = page()->currentFrame();
+ frame->addToJavaScriptWindowObject("bv", this);
QString headerScript = "document.body.innerHTML = '" +
naviPrev + naviNext + "<br />" + "' + document.body.innerHTML;";
QString trailerScript = "document.body.innerHTML += '<br /><br />" +
frame->evaluateJavaScript(headerScript);
frame->evaluateJavaScript(trailerScript);
-
- // qDebug() << page()->currentFrame()->toHtml();
}
QString BookView::tmpPath()
void addBookmark();
void setLastBookmark();
+signals:
+ void chapterLoaded(int index);
+
public slots:
void goPrevious();
void goNext();
<file>icons/previous.png</file>
<file>icons/settings-portrait.png</file>
<file>icons/settings-landscape.png</file>
+ <file>icons/next-disabled.png</file>
+ <file>icons/previous-disabled.png</file>
</qresource>
</RCC>
{
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow, true);
- // setAttribute(Qt::WA_Maemo5AutoOrientation, true);
- // FIXME: There is not enough space for the toolbar in portrait mode
#endif
setWindowTitle("Dorian");
this, SLOT(onSettingsChanged(const QString &)));
Settings::instance()->setValue("orientation",
Settings::instance()->value("orientation"));
+
+ // Handle loading chapters
+ connect(view, SIGNAL(chapterLoaded(int)), this, SLOT(onChapterLoaded(int)));
}
void MainWindow::onCurrentBookChanged()
}
}
#else
- (void)key;
+ Q_UNUSED(key);
+#endif // Q_WS_MAEMO_5
+}
+
+void MainWindow::onChapterLoaded(int index)
+{
+ bool enablePrevious = false;
+ bool enableNext = false;
+ if (book) {
+ if (index > 0) {
+ enablePrevious = true;
+ }
+ if (index < (book->toc.size() - 1)) {
+ enableNext = true;
+ }
+ }
+#ifdef Q_WS_MAEMO_5
+ previousAction->setIcon(QIcon(enablePrevious?
+ ":/icons/previous.png" : ":/icons/previous-disabled.png"));
+ nextAction->setIcon(QIcon(enableNext?
+ ":/icons/next.png": ":/icons/next-disabled.png"));
#endif // Q_WS_MAEMO_5
+ previousAction->setEnabled(enablePrevious);
+ nextAction->setEnabled(enableNext);
}
void showNormal();
void showFullScreen();
void onSettingsChanged(const QString &key);
+ void onChapterLoaded(int index);
protected:
#ifdef Q_WS_MAEMO5
Basic Icons by PixelMixer (http://pixel-mixer.com/)
Sample book "2 B R 0 2 B" by Kurt Vonnegut, digitized by
Project Gutenberg (http://www.gutenberg.org/)
+Zlib data compression library are copyright (C) 1995-2010 Jean-loup Gailly and
+ Mark Adler (http://zlib.net/)
+Minizip library copyright (C) 1998-2010 Gilles Vollant, Even Rouault and
+ Mathias Svensson (http://www.winimage.com/zLibDll/minizip.html)q
+dorian (0.0.6-1) unstable; urgency=low
+
+ * Fix crash when deleting book: https://code.nokia.com/dorian/ticket/1
+ * Fix slow zooming on N900: https://code.nokia.com/dorian/ticket/2
+ * Disable arrows when can't be used: https://code.nokia.com/dorian/ticket/4
+
+ -- Akos Polster <akos@pipacs.com> Tue, 13 Jul 2010 19:00:00 +0200
+
dorian (0.0.5-1) unstable; urgency=low
* Improve full-screen navigation even further
QLabel *zoomLabel = new QLabel(tr("Zoom level:"), contents);
layout->addWidget(zoomLabel);
- QSlider *zoomSlider = new QSlider(Qt::Horizontal, contents);
+ zoomSlider = new QSlider(Qt::Horizontal, contents);
zoomSlider->setMinimum(50);
zoomSlider->setMaximum(300);
zoomSlider->setValue(Settings::instance()->value("zoom").toInt());
layout->addWidget(fontLabel);
QString defaultFamily = fontLabel->fontInfo().family();
QString family = Settings::instance()->value("font", defaultFamily).toString();
- QFontComboBox *fontButton = new QFontComboBox(contents);
+ fontButton = new QFontComboBox(contents);
fontButton->setCurrentFont(QFont(family));
fontButton->setEditable(false);
layout->addWidget(fontButton);
void SettingsWindow::onSliderValueChanged(int value)
{
+#ifdef Q_WS_MAEMO_5 // Re-scaling the book view is too much for the N900
+ Q_UNUSED(value);
+#else
Settings::instance()->setValue("zoom", value);
+#endif // Q_WS_MAEMO_5
}
void SettingsWindow::onCurrentFontChanged(const QFont &font)
{
+#ifdef Q_WS_MAEMO_5
+ Q_UNUSED(font);
+#else
Settings::instance()->setValue("font", font.family());
+#endif // Q_WS_MAEMO_5
}
void SettingsWindow::onSchemeButtonClicked(int id)
}
Settings::instance()->setValue("orientation", orientation);
}
+
+#ifdef Q_WS_MAEMO_5
+
+void SettingsWindow::closeEvent(QCloseEvent *e)
+{
+ Settings::instance()->setValue("zoom", zoomSlider->value());
+ Settings::instance()->setValue("font", fontButton->currentFont().family());
+ e->accept();
+}
+
+#endif // Q_WS_MAEMO_5
class QPushButton;
class QFontComboBox;
class QFont;
+class QSlider;
+class QFontComboBox;
class SettingsWindow: public QMainWindow
{
void onSchemeButtonClicked(int id);
void onOrientationButtonClicked(int id);
+protected:
+#ifdef Q_WS_MAEMO_5
+ void closeEvent(QCloseEvent *e);
+#endif
+
private:
+ QSlider *zoomSlider;
+ QFontComboBox *fontButton;
};
#endif // SETTINGSWINDOW_H