diff options
author | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2022-10-12 14:52:15 +0200 |
---|---|---|
committer | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2022-10-12 13:41:09 +0000 |
commit | a0af1fa9278919f978b9cd26dfad69193f2dff30 (patch) | |
tree | 867ebe81159708c651db515353f19779042c6130 /src/libs/utils/fileutils.cpp | |
parent | 9e659ac759a4ce996bf44feb1686e75e9bc59fae (diff) |
Utils: Keep User specified SideBar entries in file dialogs
Change-Id: I0b218e889f351a2dc635aca147b82d752ba85205
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 821a31caf0..42d8f55389 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -494,12 +494,22 @@ void prepareNonNativeDialog(QFileDialog &dialog) // Checking QFileDialog::itemDelegate() seems to be the only way to determine // whether the dialog is native or not. if (dialog.itemDelegate()) { - QList<QUrl> sideBarUrls; + FilePaths sideBarPaths; + + // Check existing urls, remove paths that need a device and no longer exist. + for (const QUrl &url : dialog.sidebarUrls()) { + FilePath path = qUrlToFilePath(url); + if (!path.needsDevice() || path.exists()) + sideBarPaths.append(path); + } + + // Add all device roots that are not already in the sidebar and exist. for (const FilePath &path : FSEngine::registeredDeviceRoots()) { - if (path.exists()) - sideBarUrls.append(filePathToQUrl(path)); + if (!sideBarPaths.contains(path) && path.exists()) + sideBarPaths.append(path); } - dialog.setSidebarUrls(sideBarUrls); + + dialog.setSidebarUrls(Utils::transform(sideBarPaths, filePathToQUrl)); dialog.setIconProvider(Utils::FileIconProvider::iconProvider()); } } |