Fix org.telegram.desktop identification

Summary:
The code we have that adds .desktop at the end of the resource name did not take
into account that it might be the case that the application ends with .desktop
like it happens on telegram's desktop client

This patch looks for the file instead of just checking the name to account for
it. Otherwise the look up happens in KConfig.

Fixes flathub/org.telegram.desktop#27 on github

Test Plan: Tested locally, works.

Reviewers: #plasma, #kwin, ngraham

Reviewed By: ngraham

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29728
This commit is contained in:
Aleix Pol 2020-05-13 19:54:03 +02:00
parent d7687ce277
commit 7ea7aa1ee9

View file

@ -2544,14 +2544,15 @@ void AbstractClient::setDesktopFileName(QByteArray name)
QString AbstractClient::iconFromDesktopFile() const QString AbstractClient::iconFromDesktopFile() const
{ {
if (m_desktopFileName.isEmpty()) { const QString desktopFileName = QString::fromUtf8(m_desktopFileName);
return QString(); QString desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName);
if (desktopFilePath.isEmpty()) {
desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName + QLatin1String(".desktop"));
} }
QString desktopFile = QString::fromUtf8(m_desktopFileName);
if (!desktopFile.endsWith(QLatin1String(".desktop"))) { KDesktopFile df(desktopFilePath);
desktopFile.append(QLatin1String(".desktop"));
}
KDesktopFile df(desktopFile);
return df.readIcon(); return df.readIcon();
} }