diff --git a/src/konqmainwindow.h b/src/konqmainwindow.h --- a/src/konqmainwindow.h +++ b/src/konqmainwindow.h @@ -366,7 +366,7 @@ void slotAddClosedUrl(KonqFrameBase *tab); - void slotConfigure(); + void slotConfigure(QString startingModule = QString()); void slotConfigureDone(); void slotConfigureToolbars(); void slotConfigureExtensions(); @@ -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"; @@ -1720,8 +1727,9 @@ extensionManager.exec(); } -void KonqMainWindow::slotConfigure() +void KonqMainWindow::slotConfigure(const QString startingModule) { + KPageWidgetItem *startingItem = Q_NULLPTR; if (!m_configureDialog) { m_configureDialog = new KCMultiDialog(this); m_configureDialog->setObjectName(QStringLiteral("configureDialog")); @@ -1754,7 +1762,10 @@ }; for (uint i = 0; i < sizeof(fmModules) / sizeof(char *); ++i) if (KAuthorized::authorizeControlModule(fmModules[i])) { - m_configureDialog->addModule(KCModuleInfo(QString(fmModules[i]) + ".desktop"), fileManagementGroup); + KPageWidgetItem *it = m_configureDialog->addModule(KCModuleInfo(QString(fmModules[i]) + ".desktop"), fileManagementGroup); + if (!startingItem && !startingModule.isEmpty() && startingModule == fmModules[i]) { + startingItem = it; + } } } else { qCWarning(KONQUEROR_LOG) << "Unable to load the \"File Management\" configuration module"; @@ -1780,7 +1791,10 @@ }; for (uint i = 0; i < sizeof(webModules) / sizeof(char *); ++i) if (KAuthorized::authorizeControlModule(webModules[i])) { - m_configureDialog->addModule(KCModuleInfo(QString(webModules[i]) + ".desktop"), webGroup); + KPageWidgetItem *it= m_configureDialog->addModule(KCModuleInfo(QString(webModules[i]) + ".desktop"), webGroup); + if (!startingItem && !startingModule.isEmpty() && startingModule == webModules[i]) { + startingItem = it; + } } } else { qCWarning(KONQUEROR_LOG) << "Unable to load the \"Web Browsing\" configuration module"; @@ -1790,7 +1804,9 @@ //END SYNC with initActions() } - + if (startingItem) { + m_configureDialog->setCurrentPage(startingItem); + } m_configureDialog->show(); } @@ -5463,7 +5479,7 @@ } return true; } - + if (KParts::OpenUrlEvent::test(e)) { KParts::OpenUrlEvent *ev = static_cast(e); @@ -5503,3 +5519,44 @@ return m_combo ? m_combo->lineEdit() : nullptr; } +void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager) +{ + if (updateProtocolManager) { + KProtocolManager::reparseConfiguration(); + } + KProtocolManager::ProxyType proxyType = KProtocolManager::proxyType(); + if (proxyType == KProtocolManager::WPADProxy || proxyType == KProtocolManager::PACProxy) { + QString msg = i18n("Your proxy configuration can't be used with the QtWebEngine HTML engine. " + "No proxy will be used\n\n QtWebEngine only support a fixed proxy, so proxy auto-configuration (PAC) " + "and Web Proxy Auto-Discovery protocol can't be used with QtWebEngine. If you need a proxy, please select " + "the system proxy configuration or specify a proxy URL manually in the settings dialog. Do you want to " + "change proxy settings now?"); + KMessageBox::ButtonCode ans = KMessageBox::warningYesNo(this, msg, i18n("Unsupported proxy configuration"), KGuiItem(i18n("Don't use a proxy")), + KGuiItem(i18n("Show proxy configuration dialog")), "WebEngineUnsupportedProxyType"); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy)); + if (ans == KMessageBox::No) { + slotConfigure("proxy"); + } + return; + } + 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) { + QString msg = i18n("QtWebEngine doesn't support different proxies for HTTP and HTTPs protocols. Which settings do you want to use?"); + KMessageBox::ButtonCode ans = KMessageBox::questionYesNoCancel(this, msg, i18n("Conflicting proxy configuration"), + KGuiItem(i18n("Settings for HTTP proxy")), KGuiItem(i18n("Settings for HTTPS proxy")), KGuiItem(i18n("Show proxy configuration dialog")), + "WebEngineConflictingProxy"); + if (ans == KMessageBox::Yes) { + url = QUrl(httpProxy); + } else if (ans == KMessageBox::Cancel) { + slotConfigure("proxy"); + return; + } + } + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, url.host(), url.port(), url.userName(), url.password())); + } +}