Commit 7cb92dce authored by Marius Pa's avatar Marius Pa
Browse files

Warning "error loading page" contains wrong URL

Fixes https://bugs.kde.org/show_bug.cgi?id=438934
parent 8b909458
Pipeline #192955 passed with stage
in 38 seconds
......@@ -61,8 +61,11 @@ public:
ConsolePage(ConsoleHtml* parent) : QWebEnginePage(parent), m_console(parent) {}
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool /*isMainFrame*/) override {
m_console->setActualUrl(url);
if (url.scheme() == QLatin1String("data"))
return true;
qDebug() << "navigating to" << url << type;
m_console->openClickedUrl(url);
return false;
......@@ -73,7 +76,7 @@ public:
ConsoleHtml::ConsoleHtml(QWidget *parent)
: QWebEngineView(parent)
, m_model(new ConsoleModel(this))
, m_actualUrl(), m_model(new ConsoleModel(this))
{
connect(m_model.data(), &ConsoleModel::updateView, this, &ConsoleHtml::updateView);
connect(m_model.data(), &ConsoleModel::operationSuccessful, this, &ConsoleHtml::includeOperation);
......@@ -85,6 +88,11 @@ ConsoleHtml::~ConsoleHtml()
qDeleteAll(m_options);
}
void ConsoleHtml::setActualUrl(const QUrl& url)
{
m_actualUrl = url;
}
void ConsoleHtml::openClickedUrl(const QUrl& url)
{
QUrlQuery query(url);
......@@ -201,9 +209,10 @@ void ConsoleHtml::updateView()
Q_EMIT changed();
connect(this, &QWebEngineView::loadFinished, this, [this](bool ok){
if (!ok) {
qWarning() << "error loading page" << url();
if (!ok && (m_actualUrl.scheme() != QLatin1String("kalgebra"))) {
qWarning() << "error loading page" << m_actualUrl;
}
page()->runJavaScript(QStringLiteral("window.scrollTo(0, document.body.scrollHeight);"));
});
}
......
......@@ -87,6 +87,8 @@ class ConsoleHtml : public QWebEngineView
void copy() const;
void openClickedUrl(const QUrl& url);
void setActualUrl(const QUrl& url);
Q_SIGNALS:
/** Emits a notification that tells that the widget status. */
......@@ -108,6 +110,7 @@ class ConsoleHtml : public QWebEngineView
void updateView();
QString m_optionsString;
QUrl m_actualUrl;
QList<InlineOptions*> m_options;
QScopedPointer<ConsoleModel> m_model;
};
......
Supports Markdown
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