Get rid of workarounds for old flatpak versions

The minimal supported flatpak version since Qt 6.x is 1.14.0.
Flatpak shares temp directory and runtime directory between launches since 1.11.1.
FLATPAK_ID is defined since 1.1.2.
This commit is contained in:
Ilya Fedin 2022-11-07 12:39:07 +04:00 committed by John Preston
parent bd8b90055e
commit a507edb67a
3 changed files with 3 additions and 48 deletions

View file

@ -51,22 +51,10 @@ inline QList<QUrl> GetMimeUrls(const QMimeData *data) {
}
#endif
#if __has_include(<ksandbox.h>) && defined DeclareReadSetting
inline QString FlatpakID() {
static const auto Result = [] {
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
return qEnvironmentVariable("FLATPAK_ID");
} else {
return cExeName();
}
}();
return Result;
}
#if __has_include(<ksandbox.h>)
inline QString IconName() {
static const auto Result = KSandbox::isFlatpak()
? FlatpakID()
? qEnvironmentVariable("FLATPAK_ID")
: qsl("telegram");
return Result;
}

View file

@ -247,29 +247,6 @@ bool GenerateDesktopFile(
}
}
QString AppRuntimeDirectory() {
static const auto Result = [&] {
auto runtimeDir = QStandardPaths::writableLocation(
QStandardPaths::RuntimeLocation);
if (KSandbox::isFlatpak()) {
runtimeDir += qsl("/app/") + base::FlatpakID();
}
if (!QFileInfo::exists(runtimeDir)) { // non-systemd distros
runtimeDir = QDir::tempPath();
}
if (!runtimeDir.endsWith('/')) {
runtimeDir += '/';
}
return runtimeDir;
}();
return Result;
}
} // namespace
void SetApplicationIcon(const QIcon &icon) {
@ -277,16 +254,7 @@ void SetApplicationIcon(const QIcon &icon) {
}
QString SingleInstanceLocalServerName(const QString &hash) {
const auto idealSocketPath = AppRuntimeDirectory()
+ hash
+ '-'
+ cGUIDStr();
if ((idealSocketPath.size() + 1) >= sizeof(sockaddr_un().sun_path)) {
return AppRuntimeDirectory() + hash;
} else {
return idealSocketPath;
}
return QDir::tempPath() + '/' + hash + '-' + cGUIDStr();
}
std::optional<bool> IsDarkMode() {

View file

@ -119,7 +119,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/basic_types.h"
#include "logs.h"
#include "settings.h"
#include "core/utils.h"
#include "config.h"