summaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-22 20:19:53 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-22 20:19:53 -0600
commitdfa1c2dab99115a1ad97f4e2e93ac07e2d0705fd (patch)
treedf28c8dc60e9718e12093425497268b5021a0a1d /applications
parent2844ef37db4c498f39ba9804483831a27b8aa412 (diff)
downloadkube-dfa1c2dab99115a1ad97f4e2e93ac07e2d0705fd.tar.gz
kube-dfa1c2dab99115a1ad97f4e2e93ac07e2d0705fd.zip
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
Diffstat (limited to 'applications')
-rw-r--r--applications/kube/main.cpp42
1 files changed, 19 insertions, 23 deletions
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 @@
1/*
2 Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
1#include <QApplication> 20#include <QApplication>
2#include <QQmlApplicationEngine> 21#include <QQmlApplicationEngine>
3 22
@@ -6,7 +25,6 @@
6#include <QQuickImageProvider> 25#include <QQuickImageProvider>
7#include <QIcon> 26#include <QIcon>
8#include <QtWebEngine> 27#include <QtWebEngine>
9#include <QDesktopServices>
10 28
11#include <QDebug> 29#include <QDebug>
12 30
@@ -48,32 +66,11 @@ public:
48 } 66 }
49}; 67};
50 68
51class WebUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor
52{
53 Q_OBJECT
54public:
55 WebUrlRequestInterceptor(QObject *p = Q_NULLPTR) : QWebEngineUrlRequestInterceptor{p}
56 {}
57
58 void interceptRequest(QWebEngineUrlRequestInfo &info)
59 {
60 qDebug() << info.requestMethod() << info.requestUrl() << info.resourceType() << info.navigationType();
61 const bool isNavigationRequest = info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame;
62 if (isNavigationRequest) {
63 QDesktopServices::openUrl(info.requestUrl());
64 info.block(true);
65 }
66 //TODO handle mailto to open a composer
67 }
68};
69
70int main(int argc, char *argv[]) 69int main(int argc, char *argv[])
71{ 70{
72 QApplication app(argc, argv); 71 QApplication app(argc, argv);
73 72
74 QtWebEngine::initialize(); 73 QtWebEngine::initialize();
75 WebUrlRequestInterceptor *wuri = new WebUrlRequestInterceptor();
76 QQuickWebEngineProfile::defaultProfile()->setRequestInterceptor(wuri);
77 QIcon::setThemeName("kube"); 74 QIcon::setThemeName("kube");
78 75
79 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.components.kube"); 76 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.components.kube");
@@ -84,4 +81,3 @@ int main(int argc, char *argv[])
84 return app.exec(); 81 return app.exec();
85} 82}
86 83
87#include "main.moc"