Make indicator-application hack work in flatpak

Flatpak doesn't share $XDG_RUNTIME_DIR with the host making
QSystemTrayIcon not to work on Xubuntu/Ubuntu MATE/Ubuntu Budgie.

Although, it shares a subfolder, according to
https://docs.flatpak.org/en/latest/sandbox-permissions.html

Amends 0baa26638d

Pick-to: 6.3 6.2 5.15
Change-Id: I2d0043fc5a4c2c51e8fa1a920f3cada3b07eba6d
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
bb10
Ilya Fedin 2022-02-10 02:18:30 +04:00
parent 46e9852a1d
commit bc3723d462
1 changed files with 6 additions and 1 deletions

View File

@ -46,6 +46,7 @@
#include <QRect>
#include <QLoggingCategory>
#include <QStandardPaths>
#include <QFileInfo>
#include <QDir>
#include <QMetaObject>
#include <QMetaEnum>
@ -76,8 +77,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
static QString iconTempPath()
{
QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
if (!tempPath.isEmpty())
if (!tempPath.isEmpty()) {
QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
tempPath += QLatin1String("/app/") + flatpakId;
return tempPath;
}
tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);