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.

Change-Id: If706b8faa7027ca284ec8398f5c6e2a110e01f91
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 942f5b23c2a279499e1e59ab283f5bafc54659e0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-01-03 15:32:50 +01:00 committed by Qt Cherry-pick Bot
parent 7b38b5e369
commit 2561c7cd65

View File

@ -368,6 +368,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) {