+ Q_UNUSED(key);
+#endif // Q_WS_MAEMO_5
+}
+
+void MainWindow::onPartLoadStart()
+{
+ Trace t("MainWindow::onPartLoadStart");
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+#endif
+}
+
+void MainWindow::onPartLoadEnd(int index)
+{
+ Trace t("MainWindow::onPartLoadEnd");
+ bool enablePrevious = false;
+ bool enableNext = false;
+ Book *book = Library::instance()->book(mCurrent);
+ if (book) {
+ if (index > 0) {
+ enablePrevious = true;
+ }
+ if (index < (book->parts.size() - 1)) {
+ enableNext = true;
+ }
+ }
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ 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 MainWindow::onAddBookmark()
+{
+ Trace t("MainWindow:onAddBookmark");
+ view->addBookmark();
+}
+
+void MainWindow::onGoToBookmark(int index)
+{
+ Trace t("MainWindow::onGoToBookmark");
+ Book *book = Library::instance()->book(mCurrent);
+ view->goToBookmark(book->bookmarks()[index]);
+}
+
+void MainWindow::showChapters()
+{
+ Book *book = Library::instance()->book(mCurrent);
+ if (book) {
+ ChaptersDialog *chapters = new ChaptersDialog(book, this);
+ chapters->setWindowModality(Qt::WindowModal);
+ connect(chapters, SIGNAL(goToChapter(int)),
+ this, SLOT(onGoToChapter(int)));
+ chapters->show();
+ }
+}
+
+void MainWindow::onGoToChapter(int index)
+{
+ Trace t("MainWindow::onGoToChapter");
+
+ Book *book = Library::instance()->book(mCurrent);
+ if (book) {
+ int partIndex = book->partFromChapter(index);
+ if (partIndex != -1) {
+ view->goToBookmark(Book::Bookmark(partIndex, 0));
+ }
+ }
+}
+
+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
+ Trace::trace("MainWindow::timerEvent: Prevent display blanking");
+ }
+}
+
+void MainWindow::resizeEvent(QResizeEvent *e)
+{
+ progress->setGeometry(QRect(0, 0, e->size().width(), PROGRESS_HEIGHT));
+ QMainWindow::resizeEvent(e);
+}
+
+void MainWindow::grabZoomKeys()
+{
+#ifdef Q_WS_MAEMO_5
+ if (!winId()) {
+ qCritical() << "Can't grab keys unless we have a window id";
+ return;
+ }
+ unsigned long val = 1;
+ Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
+ if (!atom) {
+ qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
+ return;
+ }
+ XChangeProperty(QX11Info::display(),
+ winId(),
+ atom,
+ XA_INTEGER,
+ 32,
+ PropModeReplace,
+ reinterpret_cast<unsigned char *>(&val),
+ 1);