Differential D17286 Diff 46822 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> | ||||
35 | 39 | | |||
36 | KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() | 40 | KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() | ||
37 | : QObject() | 41 | : QObject() | ||
38 | , m_backend(0) | 42 | , m_backend(0) | ||
43 | , m_sharePageMenu(new Purpose::Menu(this)) | ||||
drosca: Can you pass `this` as parent, otherwise it leaks. | |||||
39 | { | 44 | { | ||
45 | m_sharePageMenu->setTitle(tr("Share page")); | ||||
46 | m_sharePageMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); | ||||
47 | m_sharePageMenu->model()->setPluginType(QStringLiteral("ShareUrl")); | ||||
40 | } | 48 | } | ||
41 | 49 | | |||
42 | DesktopFile KDEFrameworksIntegrationPlugin::metaData() const | 50 | DesktopFile KDEFrameworksIntegrationPlugin::metaData() const | ||
43 | { | 51 | { | ||
44 | return DesktopFile(QSL(":kdeframeworksintegration/metadata.desktop")); | 52 | return DesktopFile(QSL(":kdeframeworksintegration/metadata.desktop")); | ||
45 | } | 53 | } | ||
46 | 54 | | |||
47 | void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settingsPath) | 55 | void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settingsPath) | ||
Show All 35 Lines | 87 | { | |||
83 | for (KIOSchemeHandler *handler : qAsConst(m_kioSchemeHandlers)) { | 91 | for (KIOSchemeHandler *handler : qAsConst(m_kioSchemeHandlers)) { | ||
84 | mApp->webProfile()->removeUrlSchemeHandler(handler); | 92 | mApp->webProfile()->removeUrlSchemeHandler(handler); | ||
85 | WebPage::removeSupportedScheme(handler->protocol()); | 93 | WebPage::removeSupportedScheme(handler->protocol()); | ||
86 | delete handler; | 94 | delete handler; | ||
87 | } | 95 | } | ||
88 | m_kioSchemeHandlers.clear(); | 96 | m_kioSchemeHandlers.clear(); | ||
89 | } | 97 | } | ||
90 | 98 | | |||
99 | void KDEFrameworksIntegrationPlugin::populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) | ||||
100 | { | ||||
101 | Q_UNUSED(r) | ||||
102 | | ||||
103 | m_sharePageMenu->model()->setInputData(QJsonObject{ | ||||
104 | { QStringLiteral("urls"), QJsonValue(view->url()) }, | ||||
105 | { QStringLiteral("title"), QJsonValue(view->title()) } | ||||
106 | }); | ||||
107 | m_sharePageMenu->reload(); | ||||
108 | | ||||
109 | menu->addAction(m_sharePageMenu->menuAction()); | ||||
110 | } | ||||
111 | | ||||
91 | bool KDEFrameworksIntegrationPlugin::testPlugin() | 112 | bool KDEFrameworksIntegrationPlugin::testPlugin() | ||
92 | { | 113 | { | ||
93 | // Require the version that the plugin was built with | 114 | // Require the version that the plugin was built with | ||
94 | return (Qz::VERSION == QLatin1String(FALKON_VERSION)); | 115 | return (Qz::VERSION == QLatin1String(FALKON_VERSION)); | ||
95 | } | 116 | } |
Can you pass this as parent, otherwise it leaks.