Show reading progress.
[dorian] / bookmarkinfodialog.cpp
1 #include <QtGui>
2
3 #include "bookmarkinfodialog.h"
4 #include "book.h"
5
6 BookmarkInfoDialog::BookmarkInfoDialog(Book *b, int i, QWidget *parent):
7     Dialog(parent),
8     book(b),
9     index(i)
10 {
11     setWindowTitle(tr("Bookmark Details"));
12
13     Book::Bookmark bookmark = book->bookmarks()[index];
14     QString contentId = book->parts[bookmark.part];
15     QString contentTitle = book->content[contentId].name;
16     QLabel *info = new QLabel(contentTitle + "\nAt " +
17         QString::number((int)(bookmark.pos*100)) + "%", this);
18     addWidget(info);
19     addStretch();
20
21     QPushButton *read = new QPushButton(tr("Go to"), this);
22     QPushButton *remove = new QPushButton(tr("Delete"), this);
23     connect(read, SIGNAL(clicked()), this, SLOT(onRead()));
24     connect(remove, SIGNAL(clicked()), this, SLOT(onRemove()));
25     addButton(read, QDialogButtonBox::ActionRole);
26     addButton(remove, QDialogButtonBox::DestructiveRole);
27 }
28
29 void BookmarkInfoDialog::onRead()
30 {
31     done(GoTo);
32 }
33
34 void BookmarkInfoDialog::onRemove()
35 {
36     if (QMessageBox::Yes ==
37         QMessageBox::question(this, tr("Delete bookmark"),
38                               tr("Delete bookmark?"),
39                               QMessageBox::Yes | QMessageBox::No)) {
40         done(Delete);
41     }
42 }