macOS: Disable currentChanged signal for NSSavePanels

The panelSelectionDidChange callback is only called when the user selects
a directory in the save panel, as all other files are not selectable.
And when that happens, the reported selection is not the directory,
but the current file name (which may be based on clicking an exsiting
file, but that doesn't cause selection changes).

To avoid this confusing and inconsistent behavior we disable the signal
entirely when showing an NSSavePanel.

Pick-to: 6.7
Change-Id: If706b8faa7027ca284ec8398f5c6e2a110e01f91
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2024-01-03 15:32:50 +01:00
parent 4ec386eeea
commit 942f5b23c2

View File

@ -376,6 +376,14 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
if (!m_helper)
return;
// Save panels only allow you to select directories, which
// means currentChanged will only be emitted when selecting
// a directory, and if so, with the latest chosen file name,
// which is confusing and inconsistent. We choose to bail
// out entirely for save panels, to give consistent behavior.
if (!openpanel_cast(m_panel))
return;
if (m_panel.visible) {
const QString selection = QString::fromNSString(m_panel.URL.path);
if (selection != m_currentSelection) {