diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,16 +103,18 @@ 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) set_package_properties(KF5KIO PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) 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 --- a/src/plugins/KDEFrameworksIntegration/CMakeLists.txt +++ b/src/plugins/KDEFrameworksIntegration/CMakeLists.txt @@ -20,4 +20,5 @@ KF5::KIOWidgets KF5::Crash KF5::CoreAddons + KF5::PurposeWidgets ) diff --git a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.h --- 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 @@ 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; }; diff --git a/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp b/src/plugins/KDEFrameworksIntegration/kdeframeworksintegrationplugin.cpp --- 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 @@ 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