diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,10 @@ find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS Activities DocTools) # Optional +if(NOT Qt5WebEngineWidgets_VERSION VERSION_LESS "5.13.0") + add_definitions(-DWEBENGINE_PDF_VIEWER) +endif() + find_package(X11) set(KONQ_HAVE_X11 ${X11_FOUND}) diff --git a/settings/konqhtml/htmlopts.h b/settings/konqhtml/htmlopts.h --- a/settings/konqhtml/htmlopts.h +++ b/settings/konqhtml/htmlopts.h @@ -49,6 +49,9 @@ QCheckBox *m_pDoNotTrack; QCheckBox *m_pOfferToSaveWebsitePassword; KIntNumInput *m_pMaxFormCompletionItems; +#ifdef WEBENGINE_PDF_VIEWER + QCheckBox *m_pdfViewer; +#endif }; #endif // HTMLOPTS_H diff --git a/settings/konqhtml/htmlopts.cpp b/settings/konqhtml/htmlopts.cpp --- a/settings/konqhtml/htmlopts.cpp +++ b/settings/konqhtml/htmlopts.cpp @@ -138,6 +138,13 @@ connect(m_pOfferToSaveWebsitePassword, SIGNAL(toggled(bool)), SLOT(changed())); fl->addRow(m_pOfferToSaveWebsitePassword); +#ifdef WEBENGINE_PDF_VIEWER + m_pdfViewer = new QCheckBox(i18n("Display online PDF files using WebEngine")); + m_pdfViewer->setWhatsThis(i18n("Uncheck this box to display online PDF files as configured in System Settings")); + fl->addRow(m_pdfViewer); + connect(m_pdfViewer, &QCheckBox::toggled, this, QOverload<>::of(&KMiscHTMLOptions::changed)); +#endif + lay->addWidget(bgMisc); lay->addStretch(5); @@ -167,6 +174,10 @@ m_pMaxFormCompletionItems->setEnabled(m_pFormCompletionCheckBox->isChecked()); m_pOfferToSaveWebsitePassword->setChecked(cg.readEntry("OfferToSaveWebsitePassword", true)); +#ifdef WEBENGINE_PDF_VIEWER + m_pdfViewer->setChecked(cg.readEntry("InternalPdfViewer", false)); +#endif + cg2 = KConfigGroup(khtmlrcConfig, "Access Keys"); m_pAccessKeys->setChecked(cg2.readEntry("Enabled", true)); @@ -188,6 +199,10 @@ m_pOnlyMarkedBookmarksCheckBox->setChecked(false); m_pDoNotTrack->setChecked(false); m_pOfferToSaveWebsitePassword->setChecked(true); + +#ifdef WEBENGINE_PDF_VIEWER + m_pdfViewer->setChecked(false); +#endif } void KMiscHTMLOptions::save() @@ -202,6 +217,9 @@ cg.writeEntry("FormCompletion", m_pFormCompletionCheckBox->isChecked()); cg.writeEntry("MaxFormCompletionItems", m_pMaxFormCompletionItems->value()); cg.writeEntry("OfferToSaveWebsitePassword", m_pOfferToSaveWebsitePassword->isChecked()); +#ifdef WEBENGINE_PDF_VIEWER + cg.writeEntry("InternalPdfViewer", m_pdfViewer->isChecked()); +#endif cg.sync(); // Writes the value of m_pAccessKeys into khtmlrc to affect all applications using KHTML diff --git a/webenginepart/src/settings/webenginesettings.h b/webenginepart/src/settings/webenginesettings.h --- a/webenginepart/src/settings/webenginesettings.h +++ b/webenginepart/src/settings/webenginesettings.h @@ -125,6 +125,9 @@ bool alowActiveMixedContent() const; bool allowMixedContentDisplay() const; + //Internal PDF viewer + bool internalPdfViewer() const; + // Global config object stuff. static WebEngineSettings* self(); diff --git a/webenginepart/src/settings/webenginesettings.cpp b/webenginepart/src/settings/webenginesettings.cpp --- a/webenginepart/src/settings/webenginesettings.cpp +++ b/webenginepart/src/settings/webenginesettings.cpp @@ -131,6 +131,7 @@ QList< QPair< QString, QChar > > m_fallbackAccessKeysAssignments; KSharedConfig::Ptr nonPasswordStorableSites; + bool m_internalPdfViewer; }; class WebEngineSettingsPrivate : public QObject, public WebEngineSettingsData @@ -298,6 +299,11 @@ return d->m_hoverLink; } +bool WebEngineSettings::internalPdfViewer() const +{ + return d->m_internalPdfViewer; +} + void WebEngineSettings::init() { initWebEngineSettings(); @@ -485,6 +491,10 @@ d->m_userSheet.clear(); } + if (reset || cgHtml.hasKey("InternalPdfViewer")) { + d->m_internalPdfViewer = cgHtml.readEntry("InternalPdfViewer", false); + } + d->m_formCompletionEnabled = cgHtml.readEntry("FormCompletion", true); d->m_maxFormCompletionItems = cgHtml.readEntry("MaxFormCompletionItems", 10); d->m_autoDelayedActionsEnabled = cgHtml.readEntry ("AutoDelayedActions", true); @@ -706,6 +716,10 @@ QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, smoothScrolling() != KSmoothScrollingDisabled); +#ifdef WEBENGINE_PDF_VIEWER + QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, internalPdfViewer()); +#endif + // These numbers should be calculated from real "logical" DPI/72, using a default dpi of 96 for now computeFontSizes(96); }