From 3cbc168158c28a1ae9c30bdf2dc16504c9dab16c Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Thu, 15 Jul 2010 00:21:57 +0200 Subject: [PATCH] Update from old repository. --- bookview.cpp | 11 ++++++----- bookview.h | 3 +++ dorian.qrc | 2 ++ mainwindow.cpp | 29 ++++++++++++++++++++++++++--- mainwindow.h | 1 + pkg/acknowledgements.txt | 4 ++++ pkg/changelog | 8 ++++++++ pkg/version.txt | 2 +- settingswindow.cpp | 23 +++++++++++++++++++++-- settingswindow.h | 9 +++++++++ 10 files changed, 81 insertions(+), 11 deletions(-) diff --git a/bookview.cpp b/bookview.cpp index 271370e..12626e8 100644 --- a/bookview.cpp +++ b/bookview.cpp @@ -140,6 +140,7 @@ void BookView::onLoadFinished(bool ok) loadFinished = true; addNavigationBar(); onSettingsChanged("scheme"); + emit chapterLoaded(contentIndex); if (restore) { restore = false; if (ok && mBook) { @@ -227,8 +228,9 @@ void BookView::addBookmark() void BookView::addNavigationBar() { - QWebFrame *frame = page()->currentFrame(); - frame->addToJavaScriptWindowObject("bv", this); + if (!mBook) { + return; + } QString naviPrev = "" @@ -244,7 +246,6 @@ void BookView::addNavigationBar() + tmpPath() + "/next.png\" />" ""; - if (contentIndex == 0) { naviPrev = ""; } @@ -252,6 +253,8 @@ void BookView::addNavigationBar() naviNext = ""; } + QWebFrame *frame = page()->currentFrame(); + frame->addToJavaScriptWindowObject("bv", this); QString headerScript = "document.body.innerHTML = '" + naviPrev + naviNext + "
" + "' + document.body.innerHTML;"; QString trailerScript = "document.body.innerHTML += '

" + @@ -259,8 +262,6 @@ void BookView::addNavigationBar() frame->evaluateJavaScript(headerScript); frame->evaluateJavaScript(trailerScript); - - // qDebug() << page()->currentFrame()->toHtml(); } QString BookView::tmpPath() diff --git a/bookview.h b/bookview.h index 349965d..bb32698 100644 --- a/bookview.h +++ b/bookview.h @@ -22,6 +22,9 @@ public: void addBookmark(); void setLastBookmark(); +signals: + void chapterLoaded(int index); + public slots: void goPrevious(); void goNext(); diff --git a/dorian.qrc b/dorian.qrc index a4d4101..c716cf1 100644 --- a/dorian.qrc +++ b/dorian.qrc @@ -33,5 +33,7 @@ icons/previous.png icons/settings-portrait.png icons/settings-landscape.png + icons/next-disabled.png + icons/previous-disabled.png diff --git a/mainwindow.cpp b/mainwindow.cpp index fffffb1..36a88fd 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -34,8 +34,6 @@ MainWindow::MainWindow(QWidget *parent): { #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"); @@ -112,6 +110,9 @@ MainWindow::MainWindow(QWidget *parent): 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() @@ -241,6 +242,28 @@ void MainWindow::onSettingsChanged(const QString &key) } } #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); } diff --git a/mainwindow.h b/mainwindow.h index bfa2a05..8698e8c 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,6 +27,7 @@ public slots: void showNormal(); void showFullScreen(); void onSettingsChanged(const QString &key); + void onChapterLoaded(int index); protected: #ifdef Q_WS_MAEMO5 diff --git a/pkg/acknowledgements.txt b/pkg/acknowledgements.txt index f09901a..e8c4396 100644 --- a/pkg/acknowledgements.txt +++ b/pkg/acknowledgements.txt @@ -2,3 +2,7 @@ Book icon by bmson (http://bmson.deviantart.com/) 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 diff --git a/pkg/changelog b/pkg/changelog index 5be5bfe..ceeb7f3 100644 --- a/pkg/changelog +++ b/pkg/changelog @@ -1,3 +1,11 @@ +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 Tue, 13 Jul 2010 19:00:00 +0200 + dorian (0.0.5-1) unstable; urgency=low * Improve full-screen navigation even further diff --git a/pkg/version.txt b/pkg/version.txt index bbdeab6..1750564 100644 --- a/pkg/version.txt +++ b/pkg/version.txt @@ -1 +1 @@ -0.0.5 +0.0.6 diff --git a/settingswindow.cpp b/settingswindow.cpp index 033ed67..dfd60b6 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -33,7 +33,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) 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()); @@ -43,7 +43,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) 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); @@ -172,12 +172,20 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) 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) @@ -201,3 +209,14 @@ void SettingsWindow::onOrientationButtonClicked(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 diff --git a/settingswindow.h b/settingswindow.h index 581657e..613e3ad 100644 --- a/settingswindow.h +++ b/settingswindow.h @@ -6,6 +6,8 @@ class QPushButton; class QFontComboBox; class QFont; +class QSlider; +class QFontComboBox; class SettingsWindow: public QMainWindow { @@ -24,7 +26,14 @@ public slots: 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 -- 1.7.9.5