mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-03 16:05:57 +00:00
Fix gtk dialog condition + make it more readable
This commit is contained in:
@@ -125,19 +125,26 @@ constexpr auto kPreviewHeight = 512;
|
|||||||
using Type = ::FileDialog::internal::Type;
|
using Type = ::FileDialog::internal::Type;
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
bool NativeSupported(Type type = Type::ReadFile) {
|
bool UseNative(Type type = Type::ReadFile) {
|
||||||
// use gtk file dialog on gtk-based desktop environments
|
// use gtk file dialog on gtk-based desktop environments
|
||||||
// or if QT_QPA_PLATFORMTHEME=(gtk2|gtk3)
|
// or if QT_QPA_PLATFORMTHEME=(gtk2|gtk3)
|
||||||
// or if portals is used and operation is to open folder
|
// or if portals are used and operation is to open folder
|
||||||
// and portal doesn't support folder choosing
|
// and portal doesn't support folder choosing
|
||||||
return (Platform::DesktopEnvironment::IsGtkBased()
|
const auto neededForPortal = UseXDGDesktopPortal()
|
||||||
|| Platform::IsGtkIntegrationForced()
|
&& type == Type::ReadFolder
|
||||||
|| Platform::UseXDGDesktopPortal())
|
&& !CanOpenDirectoryWithPortal();
|
||||||
&& ((!Platform::UseXDGDesktopPortal() &&
|
|
||||||
((!Platform::InFlatpak() && !Platform::InSnap())
|
const auto neededNonForced = DesktopEnvironment::IsGtkBased()
|
||||||
|| Platform::IsGtkIntegrationForced()))
|
|| neededForPortal;
|
||||||
|| (type == Type::ReadFolder && !Platform::CanOpenDirectoryWithPortal()))
|
|
||||||
&& Platform::internal::GdkHelperLoaded()
|
const auto excludeNonForced = InFlatpak() || InSnap();
|
||||||
|
|
||||||
|
return IsGtkIntegrationForced()
|
||||||
|
|| (neededNonForced && !excludeNonForced);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeSupported() {
|
||||||
|
return Platform::internal::GdkHelperLoaded()
|
||||||
&& (Libs::gtk_widget_hide_on_delete != nullptr)
|
&& (Libs::gtk_widget_hide_on_delete != nullptr)
|
||||||
&& (Libs::gtk_clipboard_store != nullptr)
|
&& (Libs::gtk_clipboard_store != nullptr)
|
||||||
&& (Libs::gtk_clipboard_get != nullptr)
|
&& (Libs::gtk_clipboard_get != nullptr)
|
||||||
@@ -241,7 +248,7 @@ bool Get(
|
|||||||
parent = parent->window();
|
parent = parent->window();
|
||||||
}
|
}
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
if (NativeSupported(type)) {
|
if (UseNative(type) && NativeSupported()) {
|
||||||
return GetNative(
|
return GetNative(
|
||||||
parent,
|
parent,
|
||||||
files,
|
files,
|
||||||
|
Reference in New Issue
Block a user