macOS: Allow duplicate entries in file dialog name filter
Using QFileDialog::setMimeTypeFilters() with a list of mime types may in some cases result in the same name for two different mime types, for example both "image/heic" and "image/heif" will result in the name "HEIF image (*.heic *.heif)". When the resulting name filter is propagated to the platform layer, we add entries to a NSPopUpButton, but the convenience API we used, addItemWithTitle:, does not allow duplicates. As a result, the entries in the menu didn't match the list of name filters we then looked up and applied to the actual file name filtering, causing off by one errors. Ideally we'd make sure the name filters are unique and well formed all the way from the QFileDialog to the platform and back, but for now we work around issue by using the NSMenu API directly, which does allow for duplicate entires. Fixes: QTBUG-101361 Pick-to: 6.2 6.3 Change-Id: Iee3db4e6c5adfdbdd7f0094b4efd65aa2ecc0f57 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
0709803416
commit
e702b64b34
|
|
@ -303,7 +303,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
|||
if (filters.size() > 0){
|
||||
for (int i = 0; i < filters.size(); ++i) {
|
||||
QString filter = hideDetails ? [self removeExtensions:filters.at(i)] : filters.at(i);
|
||||
[m_popupButton addItemWithTitle:filter.toNSString()];
|
||||
[m_popupButton.menu addItemWithTitle:filter.toNSString() action:nil keyEquivalent:@""];
|
||||
}
|
||||
[m_popupButton selectItemAtIndex:0];
|
||||
m_panel.accessoryView = m_accessoryView;
|
||||
|
|
@ -497,7 +497,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
|||
(filterToUse == -1 && currentFilter.startsWith(selectedFilter)))
|
||||
filterToUse = i;
|
||||
QString filter = hideDetails ? [self removeExtensions:currentFilter] : currentFilter;
|
||||
[m_popupButton addItemWithTitle:filter.toNSString()];
|
||||
[m_popupButton.menu addItemWithTitle:filter.toNSString() action:nil keyEquivalent:@""];
|
||||
}
|
||||
if (filterToUse != -1)
|
||||
[m_popupButton selectItemAtIndex:filterToUse];
|
||||
|
|
|
|||
Loading…
Reference in New Issue