Fix TestXdgShellClient::testDesktopFileName

Summary:
Allows AbstractClient::m_desktopFileName be an absolute path, which is
used by tests.

Test Plan: Test passes, other things still work, including telegram.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29758
master
Aleix Pol 2020-05-14 17:25:32 +02:00
parent d6e119f49e
commit 5b5a9957a5
1 changed files with 11 additions and 2 deletions

View File

@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDesktopFile>
#include <QDir>
#include <QMouseEvent>
#include <QStyleHints>
@ -2545,8 +2546,16 @@ void AbstractClient::setDesktopFileName(QByteArray name)
QString AbstractClient::iconFromDesktopFile() const
{
const QString desktopFileName = QString::fromUtf8(m_desktopFileName);
QString desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName);
QString desktopFilePath;
if (QDir::isAbsolutePath(desktopFileName)) {
desktopFilePath = desktopFileName;
}
if (desktopFilePath.isEmpty()) {
desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName);
}
if (desktopFilePath.isEmpty()) {
desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName + QLatin1String(".desktop"));