mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-29 20:54:45 +00:00
Replace unsigned open document with signed
Rather than opening a new window/tab with an extra document when signing a document, replace current active unsigned document with the signed version. At least for some users, including me when testing, it gives annoyance or confusion.
This commit is contained in:
parent
4ab61f47cb
commit
a9bb5b7c95
|
@ -783,7 +783,7 @@ void PageView::setupActions(KActionCollection *ac)
|
|||
}
|
||||
});
|
||||
connect(d->annotator, &PageViewAnnotator::toolActive, d->mouseAnnotation, &MouseAnnotation::reset);
|
||||
connect(d->annotator, &PageViewAnnotator::requestOpenFile, this, &PageView::requestOpenFile);
|
||||
connect(d->annotator, &PageViewAnnotator::requestOpenNewlySignedFile, this, &PageView::requestOpenNewlySignedFile);
|
||||
d->annotator->setupActions(ac);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,12 @@ Q_SIGNALS:
|
|||
void escPressed();
|
||||
void fitWindowToPage(const QSize pageViewPortSize, const QSize pageSize);
|
||||
void triggerSearch(const QString &text);
|
||||
void requestOpenFile(const QString &filePath, int pageNumber);
|
||||
/**
|
||||
* Requests opening of a newly signed file
|
||||
* \param filePath path to signed file
|
||||
* \param pageNumber page to show (1-indexed)
|
||||
*/
|
||||
void requestOpenNewlySignedFile(const QString &filePath, int pageNumber);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
|
|
|
@ -1043,7 +1043,7 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E
|
|||
if (!newFilePath.isEmpty()) {
|
||||
const bool success = static_cast<PickPointEngineSignature *>(m_engine)->sign(newFilePath);
|
||||
if (success) {
|
||||
Q_EMIT requestOpenFile(newFilePath, m_lockedItem->pageNumber() + 1);
|
||||
Q_EMIT requestOpenNewlySignedFile(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));
|
||||
}
|
||||
|
|
|
@ -140,7 +140,12 @@ Q_SIGNALS:
|
|||
* This signal is emitted whenever an annotation tool is activated or all the tools get deactivated
|
||||
*/
|
||||
void toolActive(bool active);
|
||||
void requestOpenFile(const QString &filePath, int pageNumber);
|
||||
/**
|
||||
* Requests opening of a newly signed file
|
||||
* \param filePath path to signed file
|
||||
* \param pageNumber page to show (1-indexed)
|
||||
*/
|
||||
void requestOpenNewlySignedFile(const QString &filePath, int pageNumber);
|
||||
|
||||
private:
|
||||
void reparseBuiltinToolsConfig();
|
||||
|
|
|
@ -504,13 +504,7 @@ Part::Part(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, 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
|
||||
QUrl u = QUrl::fromLocalFile(filePath);
|
||||
u.setFragment(QStringLiteral("page=%1").arg(pageNumber));
|
||||
Q_EMIT urlsDropped({u});
|
||||
});
|
||||
connect(m_pageView.data(), &PageView::requestOpenNewlySignedFile, this, &Part::requestOpenNewlySignedFile);
|
||||
|
||||
connect(m_reviewsWidget.data(), &Reviews::openAnnotationWindow, m_pageView.data(), &PageView::openAnnotationWindow);
|
||||
|
||||
|
|
|
@ -193,6 +193,12 @@ Q_SIGNALS:
|
|||
void mimeTypeChanged(const QMimeType &mimeType);
|
||||
void urlsDropped(const QList<QUrl> &urls);
|
||||
void fitWindowToPage(const QSize pageViewPortSize, const QSize pageSize);
|
||||
/**
|
||||
* Request to open a newly signed file
|
||||
* \param path file to open
|
||||
* \param pageNumber page to show (1-indexed)
|
||||
*/
|
||||
void requestOpenNewlySignedFile(const QString &path, int pageNumber);
|
||||
|
||||
protected:
|
||||
// reimplemented from KParts::ReadWritePart
|
||||
|
|
|
@ -469,7 +469,7 @@ void signUnsignedSignature(const Okular::FormFieldSignature *form, PageView *pag
|
|||
if (!newFilePath.isEmpty()) {
|
||||
const bool success = form->sign(data, newFilePath);
|
||||
if (success) {
|
||||
Q_EMIT pageView->requestOpenFile(newFilePath, form->page()->number() + 1);
|
||||
Q_EMIT pageView->requestOpenNewlySignedFile(newFilePath, form->page()->number() + 1);
|
||||
} else {
|
||||
KMessageBox::error(pageView, i18nc("%1 is a file path", "Could not sign. Invalid certificate password or could not write to '%1'", newFilePath));
|
||||
}
|
||||
|
|
|
@ -416,6 +416,22 @@ bool Shell::openDocument(const QString &urlString, const QString &serializedOpti
|
|||
return openDocument(QUrl(urlString), serializedOptions);
|
||||
}
|
||||
|
||||
void Shell::openNewlySignedFile(const QString &path, int pageNumber)
|
||||
{
|
||||
// for now, this function just applies the "replace current document"
|
||||
// strategy for opening.
|
||||
// Given signing is slightly closer to annotating and saving, the over
|
||||
// all user experience should not be that different
|
||||
// The fact that we get a different file out of saving is a bit of a
|
||||
// implementation detail that shouldn't leak that much onto the users
|
||||
QUrl url = QUrl::fromLocalFile(path);
|
||||
url.setFragment(QStringLiteral("page=%1").arg(pageNumber));
|
||||
|
||||
const int activeTab = m_tabWidget->currentIndex();
|
||||
KParts::ReadWritePart *const activePart = m_tabs[activeTab].part;
|
||||
activePart->openUrl(url);
|
||||
}
|
||||
|
||||
bool Shell::canOpenDocs(int numDocs, int desktop)
|
||||
{
|
||||
if (m_tabs.size() <= 0 || numDocs <= 0 || m_unique) {
|
||||
|
@ -995,6 +1011,7 @@ void Shell::connectPart(const KParts::ReadWritePart *part)
|
|||
connect(part, SIGNAL(mimeTypeChanged(QMimeType)), this, SLOT(setTabIcon(QMimeType))); // clazy:exclude=old-style-connect
|
||||
connect(part, SIGNAL(urlsDropped(QList<QUrl>)), this, SLOT(handleDroppedUrls(QList<QUrl>))); // clazy:exclude=old-style-connect
|
||||
// clang-format off
|
||||
connect(part, SIGNAL(requestOpenNewlySignedFile(QString,int)), this, SLOT(openNewlySignedFile(QString,int))); // clazy:exclude=old-style-connect
|
||||
// Otherwise the QSize,QSize gets turned into QSize, QSize that is not normalized signals and is slightly slower
|
||||
connect(part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize))); // clazy:exclude=old-style-connect
|
||||
// clang-format on
|
||||
|
|
|
@ -128,6 +128,18 @@ private Q_SLOTS:
|
|||
void setCloseEnabled(bool enabled);
|
||||
void setTabIcon(const QMimeType &mimeType);
|
||||
void handleDroppedUrls(const QList<QUrl> &urls);
|
||||
/**
|
||||
* Opens of a newly signed file
|
||||
*
|
||||
* This is separated out from the "normal" open url
|
||||
* to be allowed to have different rules for this
|
||||
* (rules could be open in tab, open in new window, replace
|
||||
* current document)
|
||||
*
|
||||
* \param filePath path to signed file
|
||||
* \param pageNumber page to show (1-indexed)
|
||||
*/
|
||||
void openNewlySignedFile(const QString &path, int pageNumber);
|
||||
|
||||
// Tab event handlers
|
||||
void setActiveTab(int tab);
|
||||
|
|
Loading…
Reference in a new issue