From b8317663753c6a16942843147c7b39ce1ed499ce Mon Sep 17 00:00:00 2001 From: Konstantin Popov Date: Sun, 21 Jul 2019 21:55:53 +0300 Subject: [PATCH] Make .desktop file search respect TDESKTOP_LAUNCHER_FILENAME --- .../platform/linux/main_window_linux.cpp | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 1b482984b5..ebd3934411 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "lang/lang_keys.h" #include "storage/localstorage.h" +#include #include namespace Platform { @@ -549,15 +550,25 @@ void MainWindow::psFirstShow() { if (QDBusInterface("com.canonical.Unity", "/").isValid()) { auto snapName = QString::fromLatin1(qgetenv("SNAP_NAME")); if(snapName.isEmpty()) { - if(!QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "telegramdesktop.desktop").isEmpty()) { - _desktopFile = "telegramdesktop.desktop"; - LOG(("Found Unity Launcher entry telegramdesktop.desktop!")); - useUnityCount=true; - } else if(!QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "Telegram.desktop").isEmpty()) { - _desktopFile = "Telegram.desktop"; - LOG(("Found Unity Launcher entry Telegram.desktop!")); - useUnityCount=true; - } else { + std::vector possibleDesktopFiles = { +#ifdef TDESKTOP_LAUNCHER_FILENAME +#define TDESKTOP_LAUNCHER_FILENAME_TO_STRING_HELPER(V) #V +#define TDESKTOP_LAUNCHER_FILENAME_TO_STRING(V) TDESKTOP_LAUNCHER_FILENAME_TO_STRING_HELPER(V) + TDESKTOP_LAUNCHER_FILENAME_TO_STRING(TDESKTOP_LAUNCHER_FILENAME), +#endif // TDESKTOP_LAUNCHER_FILENAME + "telegramdesktop.desktop", + "Telegram.desktop" + }; + + for (auto it = possibleDesktopFiles.begin(); it != possibleDesktopFiles.end(); it++) { + if (!QStandardPaths::locate(QStandardPaths::ApplicationsLocation, *it).isEmpty()) { + _desktopFile = *it; + LOG(("Found Unity Launcher entry %1!").arg(_desktopFile)); + useUnityCount = true; + break; + } + } + if (!useUnityCount) { LOG(("Could not get Unity Launcher entry!")); } } else {