Convert TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION to runtime environment variable

This commit is contained in:
Ilya Fedin 2020-03-07 09:54:47 +04:00 committed by John Preston
parent 1dc6d942cf
commit 5927e8272c
2 changed files with 7 additions and 10 deletions

View File

@ -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;

View File

@ -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()