aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2018-03-21 15:20:09 -0400
committerZackaryWelch <welch.zackary@gmail.com>2018-03-21 15:20:09 -0400
commite41f68cc4576b8581466051319c94a1e840049c4 (patch)
tree60b72d0c5f36593d030730f5472141834c9956f2 /src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp
parentFix up the spacing/margins for the UI. (diff)
downloadlumina-e41f68cc4576b8581466051319c94a1e840049c4.tar.gz
lumina-e41f68cc4576b8581466051319c94a1e840049c4.tar.bz2
lumina-e41f68cc4576b8581466051319c94a1e840049c4.zip
Added a bookmarks menu, enabled on the MuPDF side.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp
new file mode 100644
index 00000000..0a8dd695
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp
@@ -0,0 +1,53 @@
+//===========================================
+// Lumina Desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+
+#include "BookmarkMenu.h"
+#include "ui_BookmarkMenu.h"
+#include <LuminaXDG.h>
+
+BookmarkMenu::BookmarkMenu(Renderer *Backend, QWidget *parent) : QWidget(parent), ui(new Ui::BookmarkMenu()), BACKEND(Backend){
+ ui->setupUi(this);
+ ui->closeButton->setIcon( LXDG::findIcon("dialog-close") );
+ connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(ui->bookmarks, &QTreeWidget::itemClicked, this, [=](QTreeWidgetItem *item) {
+ Backend->handleLink(item->data(1, Qt::UserRole).toString()); });
+
+ ui->bookmarks->setHeaderLabel("Title");
+}
+
+void BookmarkMenu::loadBookmarks() {
+ QTreeWidgetItem *item=nullptr, *parent=nullptr;
+ QList<Bookmark*> bookmarks = BACKEND->getBookmarks();
+
+ if(ui->bookmarks->topLevelItemCount() != 0) {
+ ui->bookmarks->clear();
+ }
+
+ //Modfiy for more than 2 levels
+ if(bookmarks.empty()) {
+ item = new QTreeWidgetItem(ui->bookmarks);
+ item->setText(0, "No Bookmarks");
+ item->setData(1, Qt::UserRole, "");
+ item->setIcon(0, LXDG::findIcon("bookmark-remove"));
+ }else{
+ foreach(Bookmark *bm, bookmarks) {
+ if(bm->level == 0) {
+ item = new QTreeWidgetItem(ui->bookmarks);
+ parent = item;
+ }else{
+ item = new QTreeWidgetItem(parent);
+ }
+
+ item->setText(0, bm->title);
+ item->setData(1, Qt::UserRole, bm->link);
+ if(!bm->link.isEmpty())
+ item->setIcon(0, LXDG::findIcon("bookmark-new"));
+ else
+ item->setIcon(0, LXDG::findIcon("bookmark-remove"));
+ }
+ }
+}
bgstack15