Put an "Add Bookmark" button on the Bookmarks sidebar

Previously, the only ways to add a bookmark were with the menu item or
keyboard shortcut. This commit adds a button at the bottom of the
bookmarks sidebar to do the same thing, which seems like a logical place
for such functionality.

setupViewerActions() was moved to earlier in the setup process to ensure
that m_addBookmark is assigned by the time the bookmarks sidebar is
created, since it gets passed that action in its constructor.

BUG: 357625
FIXED-IN: 21.12
remotes/origin/work/aacid/android_nss_plugins
Nate Graham 5 years ago
parent 218edc6f4a
commit 01557c16c4
  1. 4
      part/bookmarklist.cpp
  2. 2
      part/bookmarklist.h
  3. 6
      part/part.cpp

@ -115,7 +115,7 @@ public:
}
};
BookmarkList::BookmarkList(Okular::Document *document, QWidget *parent)
BookmarkList::BookmarkList(Okular::Document *document, QAction *addBookmarkAction, QWidget *parent)
: QWidget(parent)
, m_document(document)
, m_currentDocumentItem(nullptr)
@ -162,6 +162,8 @@ BookmarkList::BookmarkList(Okular::Document *document, QWidget *parent)
m_showBoomarkOnlyAction = bookmarkController->addAction(QIcon::fromTheme(QStringLiteral("bookmarks")), i18n("Current document only"));
m_showBoomarkOnlyAction->setCheckable(true);
connect(m_showBoomarkOnlyAction, &QAction::toggled, this, &BookmarkList::slotFilterBookmarks);
// insert a button to bookmark/un-bookmark the current page
bookmarkController->addAction(addBookmarkAction);
connect(m_document->bookmarkManager(), &Okular::BookmarkManager::bookmarksChanged, this, &BookmarkList::slotBookmarksChanged);

@ -29,7 +29,7 @@ class BookmarkList : public QWidget, public Okular::DocumentObserver
Q_OBJECT
public:
explicit BookmarkList(Okular::Document *document, QWidget *parent = nullptr);
explicit BookmarkList(Okular::Document *document, QAction *addBookmarkAction, QWidget *parent = nullptr);
~BookmarkList() override;
// inherited from DocumentObserver

@ -377,6 +377,8 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args)
// sLabel->setBuddy( m_searchWidget );
// m_searchToolBar->setStretchableWidget( m_searchWidget );
setupViewerActions();
// [left toolbox optional item: Table of Contents] | []
m_toc = new TOC(nullptr, m_document);
connect(m_toc.data(), &TOC::hasTOC, this, &Part::enableTOC);
@ -404,7 +406,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args)
m_sidebar->addItem(m_reviewsWidget, QIcon::fromTheme(QStringLiteral("draw-freehand")), i18n("Annotations"));
// [left toolbox: Bookmarks] | []
m_bookmarkList = new BookmarkList(m_document, nullptr);
m_bookmarkList = new BookmarkList(m_document, m_addBookmark, nullptr);
m_sidebar->addItem(m_bookmarkList, QIcon::fromTheme(QStringLiteral("bookmarks")), i18n("Bookmarks"));
// [left toolbox optional item: Signature Panel] | []
@ -536,8 +538,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args)
connect(m_document->bookmarkManager(), &BookmarkManager::saved, this, &Part::slotRebuildBookmarkMenu);
setupViewerActions();
if (m_embedMode != ViewerWidgetMode) {
setupActions();
} else {

Loading…
Cancel
Save