Differential D17286 Diff 46640 src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp
Show All 20 Lines | |||||
21 | #include "browserwindow.h" | 21 | #include "browserwindow.h" | ||
22 | #include "../config.h" | 22 | #include "../config.h" | ||
23 | #include "mainapplication.h" | 23 | #include "mainapplication.h" | ||
24 | #include "autofill.h" | 24 | #include "autofill.h" | ||
25 | #include "passwordmanager.h" | 25 | #include "passwordmanager.h" | ||
26 | #include "desktopfile.h" | 26 | #include "desktopfile.h" | ||
27 | #include "kioschemehandler.h" | 27 | #include "kioschemehandler.h" | ||
28 | #include "webpage.h" | 28 | #include "webpage.h" | ||
29 | #include "webview.h" | ||||
29 | 30 | | |||
30 | #include <KCrash> | 31 | #include <KCrash> | ||
31 | #include <KAboutData> | 32 | #include <KAboutData> | ||
32 | #include <KProtocolInfo> | 33 | #include <KProtocolInfo> | ||
34 | #include <PurposeWidgets/Menu> | ||||
35 | #include <Purpose/AlternativesModel> | ||||
33 | 36 | | |||
34 | #include <QWebEngineProfile> | 37 | #include <QWebEngineProfile> | ||
38 | #include <QMenu> | ||||
39 | #include <QJsonArray> | ||||
35 | 40 | | |||
36 | KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() | 41 | KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() | ||
37 | : QObject() | 42 | : QObject() | ||
38 | , m_backend(0) | 43 | , m_backend(0) | ||
44 | , m_sharePageMenu(new Purpose::Menu()) | ||||
drosca: Can you pass `this` as parent, otherwise it leaks. | |||||
39 | { | 45 | { | ||
46 | m_sharePageMenu->setTitle(tr("Share page")); | ||||
47 | m_sharePageMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | ||||
48 | m_sharePageMenu->model()->setPluginType(QStringLiteral("ShareUrl")); | ||||
40 | } | 49 | } | ||
41 | 50 | | |||
42 | DesktopFile KDEFrameworksIntegrationPlugin::metaData() const | 51 | DesktopFile KDEFrameworksIntegrationPlugin::metaData() const | ||
43 | { | 52 | { | ||
44 | return DesktopFile(QSL(":kdeframeworksintegration/metadata.desktop")); | 53 | return DesktopFile(QSL(":kdeframeworksintegration/metadata.desktop")); | ||
45 | } | 54 | } | ||
46 | 55 | | |||
47 | void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settingsPath) | 56 | void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settingsPath) | ||
Show All 35 Lines | 88 | { | |||
83 | for (KIOSchemeHandler *handler : qAsConst(m_kioSchemeHandlers)) { | 92 | for (KIOSchemeHandler *handler : qAsConst(m_kioSchemeHandlers)) { | ||
84 | mApp->webProfile()->removeUrlSchemeHandler(handler); | 93 | mApp->webProfile()->removeUrlSchemeHandler(handler); | ||
85 | WebPage::removeSupportedScheme(handler->protocol()); | 94 | WebPage::removeSupportedScheme(handler->protocol()); | ||
86 | delete handler; | 95 | delete handler; | ||
87 | } | 96 | } | ||
88 | m_kioSchemeHandlers.clear(); | 97 | m_kioSchemeHandlers.clear(); | ||
89 | } | 98 | } | ||
90 | 99 | | |||
100 | void KDEFrameworksIntegrationPlugin::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTestResult &r) | ||||
101 | { | ||||
102 | Q_UNUSED(r) | ||||
103 | | ||||
104 | QJsonArray urlsJson; | ||||
105 | urlsJson.append(view->url().toString()); | ||||
106 | | ||||
107 | m_sharePageMenu->model()->setInputData(QJsonObject{ | ||||
108 | { QStringLiteral("urls"), urlsJson }, | ||||
109 | { QStringLiteral("title"), QJsonValue(view->title()) } | ||||
110 | }); | ||||
111 | m_sharePageMenu->reload(); | ||||
112 | | ||||
113 | menu->addAction(m_sharePageMenu->menuAction()); | ||||
114 | } | ||||
115 | | ||||
91 | bool KDEFrameworksIntegrationPlugin::testPlugin() | 116 | bool KDEFrameworksIntegrationPlugin::testPlugin() | ||
92 | { | 117 | { | ||
93 | // Require the version that the plugin was built with | 118 | // Require the version that the plugin was built with | ||
94 | return (Qz::VERSION == QLatin1String(FALKON_VERSION)); | 119 | return (Qz::VERSION == QLatin1String(FALKON_VERSION)); | ||
95 | } | 120 | } |
Can you pass this as parent, otherwise it leaks.