Support SaveAs action

If a new enough (unreleases as of now) poppler is available

BUGS: 451010
This commit is contained in:
Albert Astals Cid 2022-03-02 00:03:34 +01:00
parent 1d64fea660
commit 1aa175cf3f
7 changed files with 29 additions and 1 deletions

View file

@ -293,7 +293,8 @@ public:
Find = 10, ///< Open find dialog
GoToPage = 11, ///< Goto page
Close = 12, ///< Close document
Print = 13 ///< Print the document @since 22.04
Print = 13, ///< Print the document @since 22.04
SaveAs = 14 ///< SaveAs the document @since 22.04
};
/**

View file

@ -4018,6 +4018,9 @@ void Document::processAction(const Action *action)
case DocumentAction::Print:
emit requestPrint();
break;
case DocumentAction::SaveAs:
emit requestSaveAs();
break;
}
} break;

View file

@ -1133,6 +1133,13 @@ Q_SIGNALS:
*/
void requestPrint();
/**
* This signal is emitted whenever an action requests a
* document save as operation.
* @since 22.04
*/
void requestSaveAs();
/**
* This signal is emitted whenever an action requests an
* application quit operation.

View file

@ -66,6 +66,15 @@ int main()
}
" HAVE_POPPLER_22_02)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
(void)Poppler::LinkAction::SaveAs;
}
" HAVE_POPPLER_22_04)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h

View file

@ -15,3 +15,6 @@
/* Defined if we have the 22.02 version of the Poppler library or later */
#cmakedefine HAVE_POPPLER_22_02 1
/* Defined if we have the 22.04 version of the Poppler library or later */
#cmakedefine HAVE_POPPLER_22_04 1

View file

@ -367,6 +367,10 @@ static Okular::DocumentAction::DocumentActionType popplerToOkular(Poppler::LinkA
return Okular::DocumentAction::Close;
case Poppler::LinkAction::Print:
return Okular::DocumentAction::Print;
#ifdef HAVE_POPPLER_22_04
case Poppler::LinkAction::SaveAs:
return Okular::DocumentAction::SaveAs;
#endif
}
qWarning() << "Unsupported Poppler::LinkAction::ActionType" << pat;

View file

@ -360,6 +360,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &args)
connect(m_document->bookmarkManager(), &BookmarkManager::openUrl, this, &Part::openUrlFromBookmarks);
connect(m_document, &Document::close, this, &Part::close);
connect(m_document, &Document::requestPrint, this, &Part::slotPrint);
connect(m_document, &Document::requestSaveAs, this, [this] { slotSaveFileAs(); });
connect(m_document, &Document::undoHistoryCleanChanged, this, [this](bool clean) {
setModified(!clean);
setWindowTitleFromDocument();