From 75abba6487dccce9de304b5132e2ce6ff5171427 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 25 Nov 2021 15:45:47 +0100 Subject: [PATCH] Add PreselectFirstFileInDirectory platform theme hint This allows Qt Quick Dialogs to accurately check whether it should select the first file in a directory when a file dialog is opened. While we're here, fix an incorrect version on the last theme hint that was added. Task-number: QTBUG-98562 Change-Id: I08cc8a0fbed28a42d1212016c6ee7fc5459578bf Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qplatformtheme.cpp | 8 +++++++- src/gui/kernel/qplatformtheme.h | 1 + src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 02610ac31b..01a5e2c806 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -169,7 +169,11 @@ QT_BEGIN_NAMESPACE \value ShowDirectoriesFirst (bool) Whether directories should be shown first (before files) in file dialogs. - This enum value was added in Qt 6.2. + This enum value was added in Qt 6.3. + + \value PreselectFirstFileInDirectory (bool) Whether the first file in a directory + should be automatically selected when a file dialog opens. + This enum value was added in Qt 6.3. \sa themeHint(), QStyle::pixelMetric() */ @@ -580,6 +584,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return true; case ShowDirectoriesFirst: return true; + case PreselectFirstFileInDirectory: + return false; } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index fdd1141896..a6b3709548 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -122,6 +122,7 @@ public: MouseQuickSelectionThreshold, InteractiveResizeAcrossScreens, ShowDirectoriesFirst, + PreselectFirstFileInDirectory, }; Q_ENUM(ThemeHint) diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index a47720384c..f7ccbbd118 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -135,6 +135,8 @@ QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(gtkSetting("gtk-icon-theme-name")); case QPlatformTheme::SystemIconFallbackThemeName: return QVariant(gtkSetting("gtk-fallback-icon-theme")); + case QPlatformTheme::PreselectFirstFileInDirectory: + return true; default: return QGnomeTheme::themeHint(hint); }