From 3aa1a7fad1913acaa69601e1e28bf7702639a778 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 21 Oct 2021 13:29:42 +0200 Subject: [PATCH] Add ShowDirectoriesFirst platform theme hint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows Qt Quick Dialogs to accurately check how it should show files and directories. Change-Id: I0f5102553ff9a0484b3714ba176f7e5e668fd05c Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformtheme.cpp | 6 ++++++ src/gui/kernel/qplatformtheme.h | 1 + src/plugins/platforms/cocoa/qcocoatheme.mm | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index f8d580ca79..02610ac31b 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -167,6 +167,10 @@ QT_BEGIN_NAMESPACE as basis for the resize. This enum value has been added in Qt 6.2. + \value ShowDirectoriesFirst (bool) Whether directories should be shown + first (before files) in file dialogs. + This enum value was added in Qt 6.2. + \sa themeHint(), QStyle::pixelMetric() */ @@ -574,6 +578,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(10); case InteractiveResizeAcrossScreens: return true; + case ShowDirectoriesFirst: + return true; } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 011f8d548c..2fdd45b910 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -119,6 +119,7 @@ public: IconFallbackSearchPaths, MouseQuickSelectionThreshold, InteractiveResizeAcrossScreens, + ShowDirectoriesFirst, }; enum DialogType { diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 6b2dfafd92..dfc1c8197b 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -527,6 +527,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const return QVariant(bool([[NSApplication sharedApplication] presentationOptions] & NSApplicationPresentationFullScreen)); case QPlatformTheme::InteractiveResizeAcrossScreens: return !NSScreen.screensHaveSeparateSpaces; + case QPlatformTheme::ShowDirectoriesFirst: + return false; default: break; }