diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index 5bb691f230..d1676cdba5 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -21,9 +21,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #ifndef TDESKTOP_DISABLE_GTK_INTEGRATION #include -#endif // TDESKTOP_DISABLE_GTK_INTEGRATION QStringList qt_make_filter_list(const QString &filter); +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION namespace Platform { namespace File { @@ -87,7 +87,8 @@ bool NativeSupported() { #ifndef TDESKTOP_FORCE_GTK_FILE_DIALOG return false; #endif // TDESKTOP_FORCE_GTK_FILE_DIALOG - return Platform::internal::GdkHelperLoaded() + return !Platform::IsXDGDesktopPortalPresent() + && Platform::internal::GdkHelperLoaded() && (Libs::gtk_widget_hide_on_delete != nullptr) && (Libs::gtk_clipboard_store != nullptr) && (Libs::gtk_clipboard_get != nullptr) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 51fc1e9024..f079fce8ed 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -44,6 +44,8 @@ namespace { constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs; +bool XDGDesktopPortalIsPresent = false; + #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION void SandboxAutostart(bool autostart) { QVariantMap options; @@ -193,6 +195,10 @@ bool InSnap() { return Snap; } +bool IsXDGDesktopPortalPresent() { + return XDGDesktopPortalIsPresent; +}; + QString CurrentExecutablePath(int argc, char *argv[]) { constexpr auto kMaxPath = 1024; char result[kMaxPath] = { 0 }; @@ -372,6 +378,21 @@ namespace Platform { void start() { FallbackFontConfig(); + +#if !defined(TDESKTOP_DISABLE_DBUS_INTEGRATION) && defined(TDESKTOP_FORCE_GTK_FILE_DIALOG) + LOG(("Checking for XDG Desktop Portal...")); + XDGDesktopPortalIsPresent = 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(XDGDesktopPortalIsPresent) { + LOG(("XDG Desktop Portal is present!")); + qputenv("QT_QPA_PLATFORMTHEME", "xdgdesktopportal"); + } else { + LOG(("XDG Desktop Portal is not present :(")); + } +#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION && TDESKTOP_FORCE_GTK_FILE_DIALOG } void finish() { diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 51a7c54644..5836a33ad3 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -23,6 +23,8 @@ inline void SetWatchingMediaKeys(bool watching) { bool InSandbox(); bool InSnap(); +bool IsXDGDesktopPortalPresent(); + QString CurrentExecutablePath(int argc, char *argv[]); QString SingleInstanceLocalServerName(const QString &hash); diff --git a/Telegram/SourceFiles/qt_static_plugins.cpp b/Telegram/SourceFiles/qt_static_plugins.cpp index cc1a767cf4..fb68f24398 100644 --- a/Telegram/SourceFiles/qt_static_plugins.cpp +++ b/Telegram/SourceFiles/qt_static_plugins.cpp @@ -21,12 +21,15 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) Q_IMPORT_PLUGIN(QGenericEnginePlugin) #elif defined Q_OS_LINUX // Q_OS_WIN | Q_OS_MAC Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) -Q_IMPORT_PLUGIN(QConnmanEnginePlugin) Q_IMPORT_PLUGIN(QGenericEnginePlugin) -Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) +#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION +Q_IMPORT_PLUGIN(QConnmanEnginePlugin) +Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) Q_IMPORT_PLUGIN(NimfInputContextPlugin) +Q_IMPORT_PLUGIN(QXdgDesktopPortalThemePlugin) +#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION #endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX