1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Enable page sharing

Summary:
Use the new ShareUrl support from Purpose to share pages. ATM only sending the page via KDE Connect and Email is supported, but more can be added easily by extending Purpose.

{F6449845}

Depends on D17285
Bug: 393543

Test Plan: Send page to phone via KDE Connect

Reviewers: #falkon, drosca

Reviewed By: #falkon, drosca

Subscribers: drosca, falkon

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D17286
This commit is contained in:
Nicolas Fella 2018-12-02 13:38:23 +01:00
parent 519764f421
commit 7bca744cab
4 changed files with 30 additions and 2 deletions

View File

@ -103,7 +103,7 @@ if (PKG_CONFIG_FOUND)
endif() endif()
# Optional: KWallet, KIO, KCrash, KCoreAddons # 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) find_package(KF5Wallet ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG) 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) set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) 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) set(ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN TRUE)
endif() endif()

View File

@ -20,4 +20,5 @@ target_link_libraries(KDEFrameworksIntegration
KF5::KIOWidgets KF5::KIOWidgets
KF5::Crash KF5::Crash
KF5::CoreAddons KF5::CoreAddons
KF5::PurposeWidgets
) )

View File

@ -26,17 +26,25 @@
#include "desktopfile.h" #include "desktopfile.h"
#include "kioschemehandler.h" #include "kioschemehandler.h"
#include "webpage.h" #include "webpage.h"
#include "webview.h"
#include <KCrash> #include <KCrash>
#include <KAboutData> #include <KAboutData>
#include <KProtocolInfo> #include <KProtocolInfo>
#include <PurposeWidgets/Menu>
#include <Purpose/AlternativesModel>
#include <QWebEngineProfile> #include <QWebEngineProfile>
#include <QMenu>
KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin() KDEFrameworksIntegrationPlugin::KDEFrameworksIntegrationPlugin()
: QObject() : QObject()
, m_backend(0) , 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 DesktopFile KDEFrameworksIntegrationPlugin::metaData() const
@ -88,6 +96,19 @@ void KDEFrameworksIntegrationPlugin::unload()
m_kioSchemeHandlers.clear(); 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() bool KDEFrameworksIntegrationPlugin::testPlugin()
{ {
// Require the version that the plugin was built with // Require the version that the plugin was built with

View File

@ -19,6 +19,8 @@
#include "plugininterface.h" #include "plugininterface.h"
#include <PurposeWidgets/Menu>
class KWalletPasswordBackend; class KWalletPasswordBackend;
class KIOSchemeHandler; class KIOSchemeHandler;
@ -35,8 +37,10 @@ public:
void init(InitState state, const QString &settingsPath) override; void init(InitState state, const QString &settingsPath) override;
void unload() override; void unload() override;
bool testPlugin() override; bool testPlugin() override;
void populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) override;
private: private:
KWalletPasswordBackend* m_backend; KWalletPasswordBackend* m_backend;
QVector<KIOSchemeHandler*> m_kioSchemeHandlers; QVector<KIOSchemeHandler*> m_kioSchemeHandlers;
Purpose::Menu *m_sharePageMenu;
}; };