Onetime sync thumbnail

Added context menu entry to quick sync thumbnails with the current page. This is handy in case the user is not using "Link the thumbnails with the page" and wants quick sync thumbnails without changing settings or search for the page in the thumbnails view.

Before
![image](/uploads/389216ce4720f1891ddc4f2bf8ee14ea/image.png)

After
![image](/uploads/b4804d11992695d3a6be6642c9d7ac16/image.png)
remotes/origin/work/fhek/foreground_background_text
Huu-Tinh Pham 4 years ago committed by Albert Astals Cid
parent 4cd6bfd30e
commit a3fde02232
  1. 2
      part/part.cpp
  2. 9
      part/thumbnaillist.cpp
  3. 3
      part/thumbnaillist.h

@ -2975,6 +2975,8 @@ void Part::showMenu(const Okular::Page *page, const QPoint point, const QString
QAction *fitPageWidth = nullptr;
if (page) {
popup->addAction(new OKMenuTitle(popup, i18n("Page %1", page->number() + 1)));
if (m_thumbnailList->isVisible() && !Okular::Settings::syncThumbnailsViewport())
popup->addAction(QIcon::fromTheme(QStringLiteral("action-synchronize")), i18n("Sync Thumbnail with Page"), m_thumbnailList.data(), &ThumbnailList::syncThumbnail);
if ((!currentPage && m_document->bookmarkManager()->isBookmarked(page->number())) || (currentPage && m_document->bookmarkManager()->isBookmarked(m_document->viewport())))
removeBookmark = popup->addAction(QIcon::fromTheme(QStringLiteral("bookmark-remove"), QIcon::fromTheme(QStringLiteral("edit-delete-bookmark"))), i18n("Remove Bookmark"));
else

@ -372,8 +372,7 @@ void ThumbnailList::notifyCurrentPageChanged(int previousPage, int currentPage)
d->m_selected = *tIt;
d->m_selected->setSelected(true);
if (Okular::Settings::syncThumbnailsViewport()) {
int yOffset = qMax(viewport()->height() / 4, d->m_selected->height() / 2);
ensureVisible(0, d->m_selected->pos().y() + d->m_selected->height() / 2, 0, yOffset);
syncThumbnail();
}
break;
}
@ -381,6 +380,12 @@ void ThumbnailList::notifyCurrentPageChanged(int previousPage, int currentPage)
}
}
void ThumbnailList::syncThumbnail()
{
int yOffset = qMax(viewport()->height() / 4, d->m_selected->height() / 2);
ensureVisible(0, d->m_selected->pos().y() + d->m_selected->height() / 2, 0, yOffset);
}
void ThumbnailList::notifyPageChanged(int pageNumber, int changedFlags)
{
static const int interestingFlags = DocumentObserver::Pixmap | DocumentObserver::Bookmark | DocumentObserver::Highlights | DocumentObserver::Annotations;

@ -47,6 +47,9 @@ public:
// redraw visible widgets (useful for refreshing contents...)
void updateWidgets();
// show current page in Thumbnails view
void syncThumbnail();
public Q_SLOTS:
// these are connected to ThumbnailController buttons
void slotFilterBookmarks(bool filterOn);

Loading…
Cancel
Save