Compare commits

...

1 commit

Author SHA1 Message Date
Bharadwaj Raju
b5b188b830 Handle link sharing behavior of some apps properly
Some apps (Google News, some RSS readers, probably others), when
you share a link from them, they send it in the form of "title \n url".

Handle that case by opening the URL in a browser instead of the whole message in a text editor.
2022-07-28 02:21:49 +05:30

View file

@ -145,6 +145,17 @@ bool SharePlugin::receivePacket(const NetworkPacket& np)
} else if (np.has(QStringLiteral("text"))) {
QString text = np.get<QString>(QStringLiteral("text"));
/* Handle apps which share links as 'Title\nurl' */
QStringList lines = text.split(QStringLiteral("\n"), Qt::SkipEmptyParts);
if (lines.count() == 2) {
QUrl url (lines[1]);
if (url.isValid() && !url.scheme().isEmpty()) {
QDesktopServices::openUrl(url);
Q_EMIT shareReceived(url.toString());
return true;
}
}
KService::Ptr service = KApplicationTrader::preferredService(QStringLiteral("text/plain"));
const QString defaultApp = service ? service->desktopEntryName() : QString();