diff --git a/src/konqmainwindow.h b/src/konqmainwindow.h --- a/src/konqmainwindow.h +++ b/src/konqmainwindow.h @@ -437,6 +437,8 @@ void slotOpenWith(); + void updateProxyForWebEngine(bool updateProtocolManager = true); + #if 0 void slotGoMenuAboutToShow(); #endif diff --git a/src/konqmainwindow.cpp b/src/konqmainwindow.cpp --- a/src/konqmainwindow.cpp +++ b/src/konqmainwindow.cpp @@ -89,6 +89,7 @@ #include #include #include +#include #include #include @@ -147,6 +148,8 @@ #include #include +#include + template class QList; template class QList; @@ -290,6 +293,10 @@ } resize(700, 480); + + updateProxyForWebEngine(false); + QDBusConnection::sessionBus().connect("", QStringLiteral("/KIO/Scheduler"), QStringLiteral("org.kde.KIO.Scheduler"), + QStringLiteral("reparseSlaveConfiguration"), this, SLOT(updateProxyForWebEngine())); setAutoSaveSettings(); //qCDebug(KONQUEROR_LOG) << this << "created"; @@ -5463,7 +5470,7 @@ } return true; } - + if (KParts::OpenUrlEvent::test(e)) { KParts::OpenUrlEvent *ev = static_cast(e); @@ -5503,3 +5510,23 @@ return m_combo ? m_combo->lineEdit() : nullptr; } +void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager) +{ + if (updateProtocolManager) { + KProtocolManager::reparseConfiguration(); + } + QString httpProxy = KProtocolManager::proxyForUrl(QUrl("http://fakeurl.test.com")); + QString httpsProxy = KProtocolManager::proxyForUrl(QUrl("https://fakeurl.test.com")); + if (httpProxy == "DIRECT" && httpsProxy == "DIRECT") { + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy)); + } else { + QUrl url(httpsProxy); + if (httpProxy != httpsProxy) { + KMessageBox::ButtonCode ans = KMessageBox::questionYesNo(this, i18n("QtWebEngine doesn't support different proxies for HTTP and HTTPs protocols. Which settings do you want to use?"), i18n("Conflicting proxy configuration"), KGuiItem(i18n("Settings for HTTP proxy")), KGuiItem(i18n("Settings for HTTPS proxy")), "WebEngineConflictingProxy"); + if (ans == KMessageBox::Yes) { + url = QUrl(httpProxy); + } + } + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, url.host(), url.port(), url.userName(), url.password())); + } +}