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.
This commit is contained in:
parent
c658c8eefd
commit
b5b188b830
1 changed files with 11 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue