+ TRACE;
+
+ Book *book = Library::instance()->book(mCurrent);
+ if (book) {
+ QString fragment;
+ int partIndex = book->partFromChapter(index, fragment);
+ if (partIndex != -1) {
+ view->goToPart(partIndex, fragment);
+ }
+ }
+}
+
+void MainWindow::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == preventBlankingTimer) {
+#ifdef Q_WS_MAEMO_5
+ QDBusInterface mce(MCE_SERVICE, MCE_REQUEST_PATH,
+ MCE_REQUEST_IF, QDBusConnection::systemBus());
+ mce.call(MCE_PREVENT_BLANK_REQ);
+#endif // Q_WS_MAEMO_5
+ qDebug() << "MainWindow::timerEvent: Prevent display blanking";
+ }
+ AdopterWindow::timerEvent(event);
+}
+
+void MainWindow::resizeEvent(QResizeEvent *e)
+{
+ Trace t("MainWindow::resizeEvent");
+#ifdef Q_OS_SYMBIAN
+ // Tool bar is only useful in portrait mode
+ bool isPortrait =
+ (QApplication::desktop()->width() < QApplication::desktop()->height());
+ toolBar->setVisible(isPortrait);
+#endif
+ QTimer::singleShot(100, this, SLOT(placeChildren()));
+ AdopterWindow::resizeEvent(e);
+}
+
+void MainWindow::placeChildren()
+{
+ Trace t("MainWindow::placeChildren");
+
+ int toolBarHeight = 0;
+
+#ifdef Q_OS_SYMBIAN
+ // Tool bar is only useful in portrait mode
+ bool isPortrait =
+ (QApplication::desktop()->width() < QApplication::desktop()->height());
+ // toolBar->setVisible(isPortrait);
+
+ // Work around Symbian bug: If there is no tool bar, increase decorator
+ // widgets' Y coordinates
+ if (!isPortrait) {
+ toolBarHeight = toolBar->height();
+ }
+#endif // Q_OS_SYMBIAN
+
+ if (hasChild(view)) {
+ QRect geo = centralWidget()->geometry();
+ qDebug() << "centralWidget (MainWindow::resizeEvent)" << geo;
+#ifdef Q_OS_SYMBIAN
+ // FIXME: When returning from full screen in landscape mode,
+ // the central widget's height is miscalculated on Symbian.
+ // My apologies for this kludge
+ if (geo.height() == 288) {
+ geo.setHeight(223);
+ }
+#endif // Q_OS_SYMBIAN
+ progress->setGeometry(geo.x(),
+ geo.y() + geo.height() - progress->thickness() + toolBarHeight,
+ geo.width(), progress->thickness());
+ previousButton->setGeometry(geo.x(),
+ geo.y() + geo.height() - TranslucentButton::pixels + toolBarHeight,
+ TranslucentButton::pixels, TranslucentButton::pixels);
+ nextButton->setGeometry(
+ geo.x() + geo.width() - TranslucentButton::pixels,
+ geo.y(), TranslucentButton::pixels, TranslucentButton::pixels);
+ progress->flash();
+ previousButton->flash();
+ nextButton->flash();
+ qDebug() << "Progress (MainWindow::resizeEvent)"
+ << progress->geometry();
+ }
+
+}
+
+void MainWindow::about()
+{
+ Dyalog *aboutDialog = new Dyalog(this, false);
+ aboutDialog->setWindowTitle(tr("About Dorian"));
+ QString version = Platform::instance()->version();
+ QLabel *label = new QLabel(aboutDialog);
+ label->setTextFormat(Qt::RichText);
+ label->setOpenExternalLinks(true);
+ label->setWordWrap(true);
+ label->setText(tr("<b>Dorian %1</b><br><br>Copyright © 2010 "
+ "Akos Polster <akos@pipacs.com><br>"
+ "Licensed under GNU General Public License, Version 3<br>"
+ "Source code:<br><a href='https://garage.maemo.org/projects/dorian/'>"
+ "garage.maemo.org/projects/dorian</a>").arg(version));
+ aboutDialog->addWidget(label);
+ aboutDialog->addStretch();
+ aboutDialog->show();
+}
+
+void MainWindow::goToNextPage()
+{
+ nextButton->flash();
+ previousButton->flash();
+ view->goNextPage();
+}
+
+void MainWindow::goToPreviousPage()
+{
+ nextButton->flash();
+ previousButton->flash();
+ view->goPreviousPage();
+}
+
+void MainWindow::onBeginUpgrade(int total)
+{
+ libraryProgress->setVisible(total > 0);
+ libraryProgress->setWindowTitle(tr("Upgrading library"));
+ libraryProgress->setMaximum(total);
+}
+
+void MainWindow::onUpgrading(const QString &path)
+{
+ libraryProgress->setLabelText(tr("Upgrading %1").
+ arg(QFileInfo(path).fileName()));
+ libraryProgress->setValue(libraryProgress->value() + 1);
+}
+
+void MainWindow::onEndUpgrade()
+{
+ libraryProgress->hide();
+ libraryProgress->reset();
+}
+
+void MainWindow::onBeginLoad(int total)
+{
+ libraryProgress->setVisible(total > 0);
+ libraryProgress->setWindowTitle(tr("Loading library"));
+ libraryProgress->setMaximum(total);
+}
+
+void MainWindow::onLoading(const QString &path)
+{
+ libraryProgress->setLabelText(tr("Loading %1").
+ arg(QFileInfo(path).fileName()));
+ libraryProgress->setValue(libraryProgress->value() + 1);
+}
+
+void MainWindow::onEndLoad()
+{
+ libraryProgress->hide();
+ libraryProgress->reset();