From dfa1c2dab99115a1ad97f4e2e93ac07e2d0705fd Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 22 Aug 2017 20:19:53 -0600 Subject: Install the webengineprofile as singleton This fixes the bug that the main process would hang on exit as long as we have a requestinterceptor installed. It's most likely a bug that this does not work, but the new solution anyways cleans up the code a bit, so that's a nice sideeffect. Fixes T5570 --- applications/kube/main.cpp | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'applications') diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index ad7bac88..115e7b0d 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp @@ -1,3 +1,22 @@ +/* + Copyright (c) 2017 Christian Mollekopf + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + #include #include @@ -6,7 +25,6 @@ #include #include #include -#include #include @@ -48,32 +66,11 @@ public: } }; -class WebUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor -{ - Q_OBJECT -public: - WebUrlRequestInterceptor(QObject *p = Q_NULLPTR) : QWebEngineUrlRequestInterceptor{p} - {} - - void interceptRequest(QWebEngineUrlRequestInfo &info) - { - qDebug() << info.requestMethod() << info.requestUrl() << info.resourceType() << info.navigationType(); - const bool isNavigationRequest = info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame; - if (isNavigationRequest) { - QDesktopServices::openUrl(info.requestUrl()); - info.block(true); - } - //TODO handle mailto to open a composer - } -}; - int main(int argc, char *argv[]) { QApplication app(argc, argv); QtWebEngine::initialize(); - WebUrlRequestInterceptor *wuri = new WebUrlRequestInterceptor(); - QQuickWebEngineProfile::defaultProfile()->setRequestInterceptor(wuri); QIcon::setThemeName("kube"); auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.components.kube"); @@ -84,4 +81,3 @@ int main(int argc, char *argv[]) return app.exec(); } -#include "main.moc" -- cgit v1.2.3