mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-22 00:57:09 +02:00
Fix gtk dialog condition + make it more readable
This commit is contained in:
parent
7ff99cdbf7
commit
022fc9a779
1 changed files with 18 additions and 11 deletions
|
@ -125,19 +125,26 @@ constexpr auto kPreviewHeight = 512;
|
|||
using Type = ::FileDialog::internal::Type;
|
||||
|
||||
#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
|
||||
// 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
|
||||
return (Platform::DesktopEnvironment::IsGtkBased()
|
||||
|| Platform::IsGtkIntegrationForced()
|
||||
|| Platform::UseXDGDesktopPortal())
|
||||
&& ((!Platform::UseXDGDesktopPortal() &&
|
||||
((!Platform::InFlatpak() && !Platform::InSnap())
|
||||
|| Platform::IsGtkIntegrationForced()))
|
||||
|| (type == Type::ReadFolder && !Platform::CanOpenDirectoryWithPortal()))
|
||||
&& Platform::internal::GdkHelperLoaded()
|
||||
const auto neededForPortal = UseXDGDesktopPortal()
|
||||
&& type == Type::ReadFolder
|
||||
&& !CanOpenDirectoryWithPortal();
|
||||
|
||||
const auto neededNonForced = DesktopEnvironment::IsGtkBased()
|
||||
|| neededForPortal;
|
||||
|
||||
const auto excludeNonForced = InFlatpak() || InSnap();
|
||||
|
||||
return IsGtkIntegrationForced()
|
||||
|| (neededNonForced && !excludeNonForced);
|
||||
}
|
||||
|
||||
bool NativeSupported() {
|
||||
return Platform::internal::GdkHelperLoaded()
|
||||
&& (Libs::gtk_widget_hide_on_delete != nullptr)
|
||||
&& (Libs::gtk_clipboard_store != nullptr)
|
||||
&& (Libs::gtk_clipboard_get != nullptr)
|
||||
|
@ -241,7 +248,7 @@ bool Get(
|
|||
parent = parent->window();
|
||||
}
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
if (NativeSupported(type)) {
|
||||
if (UseNative(type) && NativeSupported()) {
|
||||
return GetNative(
|
||||
parent,
|
||||
files,
|
||||
|
|
Loading…
Add table
Reference in a new issue