--- /dev/null
+#include <QtGui>
+
+#include "chaptersdialog.h"
+#include "book.h"
+
+ChaptersDialog::ChaptersDialog(Book *b, QWidget *parent):
+ QMainWindow(parent), book(b)
+{
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow, true);
+#endif
+ setWindowTitle(tr("Bookmarks"));
+
+ QFrame *frame = new QFrame(this);
+ setCentralWidget(frame);
+ QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
+ frame->setLayout(horizontalLayout);
+
+ list = new QListWidget(this);
+ list->setSelectionMode(QAbstractItemView::SingleSelection);
+ foreach (QString id, book->toc) {
+ QString contentTitle = book->content[id].name;
+ (void)new QListWidgetItem(contentTitle, list);
+ }
+ horizontalLayout->addWidget(list);
+ connect(list, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(onItemActivated(QListWidgetItem*)));
+
+#ifndef Q_WS_MAEMO_5
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
+ QPushButton *closeButton = buttonBox->addButton(QDialogButtonBox::Close);
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(onClose()));
+ horizontalLayout->addWidget(buttonBox);
+#endif // Q_WS_MAEMO_5
+}
+
+void ChaptersDialog::onItemActivated(QListWidgetItem *item)
+{
+ emit goToChapter(list->row(item));
+ close();
+}
+
+void ChaptersDialog::onClose()
+{
+ close();
+}
#include "settingswindow.h"
#include "bookmarksdialog.h"
#include "settings.h"
+#include "chaptersdialog.h"
#ifdef DORIAN_TEST_MODEL
#include "modeltest.h"
#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)
toolBar->setIconSize(QSize(42, 42));
#endif
+
previousAction = addToolBarAction(view, SLOT(goPrevious()), "previous");
nextAction = addToolBarAction(view, SLOT(goNext()), "next");
- bookmarksAction = addToolBarAction(this, SLOT(showBookmarks()),
- "bookmarks");
+ chaptersAction = addToolBarAction(this, SLOT(showChapters()), "chapters");
+ bookmarksAction = addToolBarAction(this, SLOT(showBookmarks()), "bookmarks");
+
#ifdef Q_WS_MAEMO_5
- infoAction = new QAction(this);
+ infoAction = menuBar()->addAction(tr("Book details"));
+ connect(infoAction, SIGNAL(triggered()), this, SLOT(showInfo()));
+ libraryAction = menuBar()->addAction(tr("Library"));
+ connect(libraryAction, SIGNAL(triggered()), this, SLOT(showLibrary()));
+ settingsAction = menuBar()->addAction(tr("Settings"));
+ connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
+ devToolsAction = menuBar()->addAction(tr("Developer"));
+ connect(devToolsAction, SIGNAL(triggered()), this, SLOT(showDevTools()));
#else
infoAction = addToolBarAction(this, SLOT(showInfo()), "document-properties");
-#endif
libraryAction = addToolBarAction(this, SLOT(showLibrary()),
"system-file-manager");
settingsAction = addToolBarAction(this, SLOT(showSettings()),
"preferences-system");
-#ifdef Q_WS_MAEMO_5
- devToolsAction = new QAction(this);
-#else
devToolsAction = addToolBarAction(this, SLOT(showDevTools()), "developer");
+#endif // Q_WS_MAEMO_5
+
QFrame *frame = new QFrame(toolBar);
frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
toolBar->addWidget(frame);
-#endif
+
fullScreenAction = addToolBarAction(this, SLOT(showFullScreen()),
"view-fullscreen");
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)
+{
+ view->goToBookmark(Book::Bookmark(index, 0));
+}
+