Merge remote-tracking branch 'origin/9.0' into 10.0

Change-Id: I7e171601cd7317b48d5074bbc0ead127813d596c
This commit is contained in:
David Schulz
2023-02-01 08:16:30 +01:00
5 changed files with 55 additions and 21 deletions

View File

@@ -398,26 +398,30 @@ static FilePath qUrlToFilePath(const QUrl &url)
static QUrl filePathToQUrl(const FilePath &filePath)
{
return QUrl::fromLocalFile(filePath.toFSPathString());
return QUrl::fromLocalFile(filePath.toFSPathString());
}
void prepareNonNativeDialog(QFileDialog &dialog)
{
const auto isValidSideBarPath = [](const FilePath &fp) {
return !fp.needsDevice() || fp.hasFileAccess();
};
// Checking QFileDialog::itemDelegate() seems to be the only way to determine
// whether the dialog is native or not.
if (dialog.itemDelegate()) {
FilePaths sideBarPaths;
// Check existing urls, remove paths that need a device and no longer exist.
// Check existing urls, remove paths that need a device and are no longer valid.
for (const QUrl &url : dialog.sidebarUrls()) {
FilePath path = qUrlToFilePath(url);
if (!path.needsDevice() || path.exists())
if (isValidSideBarPath(path))
sideBarPaths.append(path);
}
// Add all device roots that are not already in the sidebar and exist.
// Add all device roots that are not already in the sidebar and valid.
for (const FilePath &path : FSEngine::registeredDeviceRoots()) {
if (!sideBarPaths.contains(path) && path.exists())
if (!sideBarPaths.contains(path) && isValidSideBarPath(path))
sideBarPaths.append(path);
}