diff --git a/CMakeLists.txt b/CMakeLists.txt index 4badb64f0..8410fb570 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,7 +103,7 @@ if (PKG_CONFIG_FOUND) endif() # Optional: KWallet, KIO, KCrash, KCoreAddons -set(KF5_MIN_VERSION "5.27.0") +set(KF5_MIN_VERSION "5.54.0") find_package(KF5Wallet ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG) @@ -112,7 +112,9 @@ find_package(KF5Crash ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND) +find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG) +set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND AND KF5Purpose_FOUND) set(ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN TRUE) endif() diff --git a/src/plugins/KDEFrameworksIntegration/CMakeLists.txt b/src/plugins/KDEFrameworksIntegration/CMakeLists.txt index 226d8da76..86a6786cb 100644 --- a/src/plugins/KDEFrameworksIntegration/CMakeLists.txt +++ b/src/plugins/KDEFrameworksIntegration/CMakeLists.txt @@ -20,4 +20,5 @@ target_link_libraries(KDEFrameworksIntegration KF5::KIOWidgets KF5::Crash KF5::CoreAddons + KF5::PurposeWidgets ) diff --git a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp index a2cf79dd8..f08c4dd24 100644 --- a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp +++ b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp @@ -26,17 +26,25 @@ #include "desktopfile.h" #include "kioschemehandler.h" #include "webpage.h" +#include "webview.h" #include #include #include +#include +#include #include +#include KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() : QObject() , m_backend(0) + , m_sharePageMenu(new Purpose::Menu(this)) { + m_sharePageMenu->setTitle(tr("Share page")); + m_sharePageMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); + m_sharePageMenu->model()->setPluginType(QStringLiteral("ShareUrl")); } DesktopFile KDEFrameworksIntegrationPlugin::metaData() const @@ -88,6 +96,19 @@ void KDEFrameworksIntegrationPlugin::unload() m_kioSchemeHandlers.clear(); } +void KDEFrameworksIntegrationPlugin::populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) +{ + Q_UNUSED(r) + + m_sharePageMenu->model()->setInputData(QJsonObject{ + { QStringLiteral("urls"), QJsonValue(view->url()) }, + { QStringLiteral("title"), QJsonValue(view->title()) } + }); + m_sharePageMenu->reload(); + + menu->addAction(m_sharePageMenu->menuAction()); +} + bool KDEFrameworksIntegrationPlugin::testPlugin() { // Require the version that the plugin was built with diff --git a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h index c44621aa1..b108f9e54 100644 --- a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h +++ b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h @@ -19,6 +19,8 @@ #include "plugininterface.h" +#include + class KWalletPasswordBackend; class KIOSchemeHandler; @@ -35,8 +37,10 @@ public: void init(InitState state, const QString &settingsPath) override; void unload() override; bool testPlugin() override; + void populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) override; private: KWalletPasswordBackend* m_backend; QVector m_kioSchemeHandlers; + Purpose::Menu *m_sharePageMenu; };