mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-25 01:36:48 +00:00
Use XDG Desktop Portal only when variable is set
This commit is contained in:
parent
bbc516cf43
commit
ca1623f34a
@ -87,7 +87,7 @@ bool NativeSupported() {
|
||||
#ifndef TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
return false;
|
||||
#endif // TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
return !Platform::IsXDGDesktopPortalPresent()
|
||||
return !Platform::UseXDGDesktopPortal()
|
||||
&& Platform::internal::GdkHelperLoaded()
|
||||
&& (Libs::gtk_widget_hide_on_delete != nullptr)
|
||||
&& (Libs::gtk_clipboard_store != nullptr)
|
||||
|
@ -45,8 +45,6 @@ namespace {
|
||||
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
||||
constexpr auto kSnapLauncherDir = "/var/lib/snapd/desktop/applications/"_cs;
|
||||
|
||||
bool XDGDesktopPortalPresent = false;
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
void SandboxAutostart(bool autostart) {
|
||||
QVariantMap options;
|
||||
@ -203,9 +201,22 @@ bool InSnap() {
|
||||
}
|
||||
|
||||
bool IsXDGDesktopPortalPresent() {
|
||||
#ifdef TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
static const auto XDGDesktopPortalPresent = false;
|
||||
#else // TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
static const auto XDGDesktopPortalPresent = QDBusInterface(
|
||||
"org.freedesktop.portal.Desktop",
|
||||
"/org/freedesktop/portal/desktop").isValid();
|
||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
return XDGDesktopPortalPresent;
|
||||
}
|
||||
|
||||
bool UseXDGDesktopPortal() {
|
||||
static const auto UsePortal = qEnvironmentVariableIsSet("TDESKTOP_USE_PORTAL")
|
||||
&& IsXDGDesktopPortalPresent();
|
||||
return UsePortal;
|
||||
}
|
||||
|
||||
QString ProcessNameByPID(const QString &pid) {
|
||||
constexpr auto kMaxPath = 1024;
|
||||
char result[kMaxPath] = { 0 };
|
||||
@ -414,20 +425,21 @@ namespace Platform {
|
||||
void start() {
|
||||
FallbackFontConfig();
|
||||
|
||||
#if !defined(TDESKTOP_DISABLE_DBUS_INTEGRATION) && defined(TDESKTOP_FORCE_GTK_FILE_DIALOG)
|
||||
#ifdef TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
LOG(("Checking for XDG Desktop Portal..."));
|
||||
XDGDesktopPortalPresent = QDBusInterface(
|
||||
"org.freedesktop.portal.Desktop",
|
||||
"/org/freedesktop/portal/desktop").isValid();
|
||||
|
||||
// this can give us a chance to use a proper file dialog for current session
|
||||
if(XDGDesktopPortalPresent) {
|
||||
if(IsXDGDesktopPortalPresent()) {
|
||||
LOG(("XDG Desktop Portal is present!"));
|
||||
qputenv("QT_QPA_PLATFORMTHEME", "xdgdesktopportal");
|
||||
if(UseXDGDesktopPortal()) {
|
||||
LOG(("Usage of XDG Desktop Portal is enabled."));
|
||||
qputenv("QT_QPA_PLATFORMTHEME", "xdgdesktopportal");
|
||||
} else {
|
||||
LOG(("Usage of XDG Desktop Portal is disabled."));
|
||||
}
|
||||
} else {
|
||||
LOG(("XDG Desktop Portal is not present :("));
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION && TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
#endif // TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
}
|
||||
|
||||
void finish() {
|
||||
|
@ -24,6 +24,7 @@ bool InSandbox();
|
||||
bool InSnap();
|
||||
|
||||
bool IsXDGDesktopPortalPresent();
|
||||
bool UseXDGDesktopPortal();
|
||||
|
||||
QString ProcessNameByPID(const QString &pid);
|
||||
QString CurrentExecutablePath(int argc, char *argv[]);
|
||||
|
Loading…
Reference in New Issue
Block a user