From 5927e8272c8a3ea756fb4439d1a6afa49298b823 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 7 Mar 2020 09:54:47 +0400 Subject: [PATCH] Convert TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION to runtime environment variable --- .../SourceFiles/platform/linux/specific_linux.cpp | 12 +++++++----- Telegram/cmake/telegram_options.cmake | 5 ----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 4b715d0eea..7f3e226158 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -524,18 +524,21 @@ void finish() { void RegisterCustomScheme(bool force) { #ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME - auto home = getHomeDir(); + const auto home = getHomeDir(); if (home.isEmpty() || cExeName().isEmpty()) return; + static const auto disabledByEnv = qEnvironmentVariableIsSet( + "TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION"); + // don't update desktop file for alpha version or if updater is disabled - if ((cAlphaVersion() || Core::UpdaterDisabled()) && !force) + if ((cAlphaVersion() || Core::UpdaterDisabled() || disabledByEnv) + && !force) return; const auto applicationsPath = QStandardPaths::writableLocation( QStandardPaths::ApplicationsLocation) + '/'; -#ifndef TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION GenerateDesktopFile(applicationsPath, qsl("-- %u")); const auto icons = @@ -558,7 +561,6 @@ void RegisterCustomScheme(bool force) { DEBUG_LOG(("App Info: Icon copied to '%1'").arg(icon)); } } -#endif // !TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION RunShellCommand("update-desktop-database " + EscapeShell(QFile::encodeName(applicationsPath))); @@ -629,7 +631,7 @@ bool psShowOpenWithMenu(int x, int y, const QString &file) { } void psAutoStart(bool start, bool silent) { - auto home = getHomeDir(); + const auto home = getHomeDir(); if (home.isEmpty() || cExeName().isEmpty()) return; diff --git a/Telegram/cmake/telegram_options.cmake b/Telegram/cmake/telegram_options.cmake index 9bc19e5ae7..bb63d3730b 100644 --- a/Telegram/cmake/telegram_options.cmake +++ b/Telegram/cmake/telegram_options.cmake @@ -7,7 +7,6 @@ option(TDESKTOP_FORCE_GTK_FILE_DIALOG "Force using GTK file dialog (Linux only)." OFF) option(TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME "Disable automatic 'tg://' URL scheme handler registration." ${DESKTOP_APP_USE_PACKAGED}) option(TDESKTOP_DISABLE_NETWORK_PROXY "Disable all code for working through Socks5 or MTProxy." OFF) -option(TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION "Disable automatic '.desktop' file generation (Linux only)." ${DESKTOP_APP_USE_PACKAGED}) option(TDESKTOP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." ON) option(TDESKTOP_USE_PACKAGED_TGVOIP "Find libtgvoip using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED}) option(TDESKTOP_API_TEST "Use test API credentials." OFF) @@ -77,10 +76,6 @@ if (TDESKTOP_DISABLE_NETWORK_PROXY) target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_NETWORK_PROXY) endif() -if (TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION) - target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION) -endif() - if (TDESKTOP_DISABLE_GTK_INTEGRATION) target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_GTK_INTEGRATION) endif()