Commit 7bde4dff authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Emit completedWithPendingAction when loading a page with http-equiv="refresh"

parent 87bca4c4
......@@ -48,8 +48,10 @@
#include <QDropEvent>
#include <QDBusConnection>
#include <QMimeData>
#ifdef KActivities_FOUND
#endif
#include <kparts_version.h>
#include <KJobWidgets>
#include <KParts/Part>
......@@ -366,8 +368,12 @@ void KonqView::connectPart()
this, SLOT(slotStarted(KIO::Job*)));
connect(m_pPart, SIGNAL(completed()),
this, SLOT(slotCompleted()));
connect(m_pPart, SIGNAL(completed(bool)),
this, SLOT(slotCompleted(bool)));
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 81, 0)
connect(m_pPart, QOverload<bool>::of(&KParts::ReadOnlyPart::completed), this, QOverload<bool>::of(&KonqView::slotCompleted));
#else
connect(m_pPart, &KParts::ReadOnlyPart::completedWithPendingAction, this, [this](){slotCompleted(true);});
connect(m_pPart, &KParts::ReadOnlyPart::completed, this, &KonqView::slotCompleted);
  • This broke compile : /home/jenkins/workspace/Applications/konqueror/kf5-qt5 SUSEQt5.15/src/konqview.cpp: In member function ���void KonqView::connectPart()���: 12:00:32 /home/jenkins/workspace/Applications/konqueror/kf5-qt5 SUSEQt5.15/src/konqview.cpp:375:86: error: no matching function for call to ���KonqView::connect(KParts::ReadOnlyPart*&, , KonqView*, )��� 12:00:32 375 | connect(m_pPart, &KParts::ReadOnlyPart::completed, this, &KonqView::slotCompleted);

  • It should be fixed now. Unfortunately, I don't have KParts 5.81 installed to check whether it compiles or not.

  • you can see through CI's logs and yes it fixed the compile now : https://build.kde.org/view/Failing/job/Applications/job/konqueror/job/kf5-qt5%20SUSEQt5.15/

Please register or sign in to reply
#endif
connect(m_pPart, SIGNAL(canceled(QString)),
this, SLOT(slotCanceled(QString)));
connect(m_pPart, SIGNAL(setWindowCaption(QString)),
......
function hasRefreshAttribute() {
const metas = document.getElementsByTagName("meta");
for (const m of metas) {
if (m.getAttribute("http-equiv") == "refresh") return true;
}
return false;
}
......@@ -88,6 +88,7 @@
#include <QStatusBar>
#include <QWebEngineScriptCollection>
#include <QWebEngineUrlScheme>
#include <QWebEngineScript>
#include "utils.h"
#include <kio_version.h>
......@@ -112,6 +113,18 @@ void WebEnginePart::initWebEngineUrlSchemes()
}
}
static QWebEngineScript detectRefreshScript() {
static QWebEngineScript s_detectRefreshScript;
if (s_detectRefreshScript.isNull()) {
QFile jsfile(":/hasrefresh.js");
jsfile.open(QIODevice::ReadOnly);
s_detectRefreshScript.setSourceCode(QString(jsfile.readAll()));
s_detectRefreshScript.setInjectionPoint(QWebEngineScript::DocumentCreation);
s_detectRefreshScript.setWorldId(QWebEngineScript::ApplicationWorld);
}
return s_detectRefreshScript;
}
WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
......@@ -218,6 +231,7 @@ WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
connect(m_webView, &QWebEngineView::loadFinished,
this, &WebEnginePart::slotLoadFinished);
page()->scripts().insert(detectRefreshScript());
// Connect the signals from the page...
connectWebEnginePageSignals(page());
......@@ -546,19 +560,15 @@ void WebEnginePart::slotLoadFinished (bool ok)
m_wallet->detectAndFillPageForms(page());
}
bool pending = false;
// QWebFrame* frame = (page() ? page()->currentFrame() : 0);
// if (ok &&
// frame == page()->mainFrame() &&
// !frame->findFirstElement(QL1S("head>meta[http-equiv=refresh]")).isNull()) {
// if (WebEngineSettings::self()->autoPageRefresh()) {
// pending = true;
// } else {
// frame->page()->triggerAction(QWebEnginePage::Stop);
// }
// }
emit completed ((ok && pending));
auto callback = [this](const QVariant &res) {
bool hasRefresh = res.toBool();
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 81, 0)
emit completed(hasRefresh);
#else
emit hasRefresh ? completedWithPendingAction() : completed();
#endif
};
page()->runJavaScript("hasRefreshAttribute()", QWebEngineScript::ApplicationWorld, callback);
updateActions();
}
......
......@@ -2,5 +2,6 @@
<RCC version="1.0">
<qresource>
<file>formautofiller.js</file>
<file>hasrefresh.js</file>
</qresource>
</RCC>
  • Broke the compile : @stefanocrocco /home/jenkins/workspace/Applications/konqueror/kf5-qt5 SUSEQt5.15/src/konqview.cpp: In member function ���void KonqView::connectPart()���: 12:00:32 /home/jenkins/workspace/Applications/konqueror/kf5-qt5 SUSEQt5.15/src/konqview.cpp:375:86: error: no matching function for call to ���KonqView::connect(KParts::ReadOnlyPart*&, , KonqView*, )��� 12:00:32 375 | connect(m_pPart, &KParts::ReadOnlyPart::completed, this, &KonqView::slotCompleted);

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment