From ff5f4cbc453d37f5c70e7c31a6c22105cee994fc Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 14 Apr 2021 16:42:26 +0200 Subject: [PATCH] Open the signed document on the page with the new signature It's still not perfect because it probably won't show the signature since signatures "usually" go to the bottom of the page and we're only focusing on that page, which means the beginning which depending on zoom settings may very well not include the signature, but at least it's closer --- part/pageview.h | 2 +- part/pageviewannotator.cpp | 2 +- part/pageviewannotator.h | 2 +- part/part.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/part/pageview.h b/part/pageview.h index 29faa26a1..6ea741a76 100644 --- a/part/pageview.h +++ b/part/pageview.h @@ -143,7 +143,7 @@ Q_SIGNALS: void escPressed(); void fitWindowToPage(const QSize pageViewPortSize, const QSize pageSize); void triggerSearch(const QString &text); - void requestOpenFile(const QString &filePath); + void requestOpenFile(const QString &filePath, int pageNumber); protected: bool event(QEvent *event) override; diff --git a/part/pageviewannotator.cpp b/part/pageviewannotator.cpp index b9a0d10c1..575be6b29 100644 --- a/part/pageviewannotator.cpp +++ b/part/pageviewannotator.cpp @@ -1049,7 +1049,7 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E if (!newFilePath.isEmpty()) { const bool success = static_cast(m_engine)->sign(newFilePath); if (success) { - emit requestOpenFile(newFilePath); + emit requestOpenFile(newFilePath, m_lockedItem->pageNumber() + 1); } else { KMessageBox::error(m_pageView, i18nc("%1 is a file path", "Could not sign. Invalid certificate password or could not write to '%1'", newFilePath)); } diff --git a/part/pageviewannotator.h b/part/pageviewannotator.h index e19c31131..eff1f4e67 100644 --- a/part/pageviewannotator.h +++ b/part/pageviewannotator.h @@ -139,7 +139,7 @@ public Q_SLOTS: Q_SIGNALS: void toolSelected(); - void requestOpenFile(const QString &filePath); + void requestOpenFile(const QString &filePath, int pageNumber); private: void reparseBuiltinToolsConfig(); diff --git a/part/part.cpp b/part/part.cpp index f99c74724..9c75f5674 100644 --- a/part/part.cpp +++ b/part/part.cpp @@ -503,10 +503,12 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args) connect(m_miniBar, &MiniBar::forwardKeyPressEvent, m_pageView, &PageView::externalKeyPressEvent); connect(m_pageView.data(), &PageView::escPressed, m_findBar, &FindBar::resetSearch); connect(m_pageNumberTool, &MiniBar::forwardKeyPressEvent, m_pageView, &PageView::externalKeyPressEvent); - connect(m_pageView.data(), &PageView::requestOpenFile, this, [this](const QString &filePath) { + connect(m_pageView.data(), &PageView::requestOpenFile, this, [this](const QString &filePath, int pageNumber) { // We cheat a bit here reusing the urlsDropped signal, but at the end the output is the same, we want to open some files // urlsDropped should have just had a different name - Q_EMIT urlsDropped({QUrl::fromLocalFile(filePath)}); + QUrl u = QUrl::fromLocalFile(filePath); + u.setFragment(QStringLiteral("page=%1").arg(pageNumber)); + Q_EMIT urlsDropped({u}); }); connect(m_reviewsWidget.data(), &Reviews::openAnnotationWindow, m_pageView.data(), &PageView::openAnnotationWindow);