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
This commit is contained in:
Aleix Pol 2020-05-14 17:25:32 +02:00
parent d6e119f49e
commit 5b5a9957a5

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"));