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 <volker.hilsheimer@qt.io>
This commit is contained in:
Mitch Curtis 2021-11-25 15:45:47 +01:00
parent b13ee89d20
commit 75abba6487
3 changed files with 10 additions and 1 deletions

View File

@ -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();
}

View File

@ -122,6 +122,7 @@ public:
MouseQuickSelectionThreshold,
InteractiveResizeAcrossScreens,
ShowDirectoriesFirst,
PreselectFirstFileInDirectory,
};
Q_ENUM(ThemeHint)

View File

@ -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);
}