macOS: Respect QDir::Hidden for native file dialogs

The default for showsHiddenFiles is NO, so we were not showing hidden
files unless the user toggled them via the keyboard shortcut.

Pick-to: 6.5 6.6
Change-Id: I796144452cf8f5a6cc46f1ba6747affcd0a35879
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-06-29 17:55:19 +02:00 committed by Volker Hilsheimer
parent 90345459fc
commit bc64864120

View File

@ -243,8 +243,12 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
return NO;
}
if (!(filter & QDir::Hidden) && fileInfo.isHidden())
return NO;
// We control the visibility of hidden files via the showsHiddenFiles
// property on the panel, based on QDir::Hidden being set. But the user
// can also toggle this via the Command+Shift+. keyboard shortcut,
// in which case they have explicitly requested to show hidden files,
// and we should enable them even if QDir::Hidden was not set. In
// effect, we don't need to filter on QDir::Hidden here.
return YES;
}
@ -350,6 +354,8 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
if (m_panel.allowedFileTypes.count > 2)
m_panel.extensionHidden = NO;
m_panel.showsHiddenFiles = m_options->filter().testFlag(QDir::Hidden);
if (m_panel.visible)
[m_panel validateVisibleColumns];
}