From 2c50129cce41f080e0beb99055cb7fa89106dbf0 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Sat, 22 Nov 2025 23:02:59 +0100 Subject: DolphinView: when creating a dir hierarchy only select dir in current path If you are in ~ And create at once ~/1/2 Select the 1 folder afterwards --- src/views/dolphinview.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/views') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 70b32968a..47a5461ff 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1818,7 +1818,7 @@ void DolphinView::selectFileOnceAvailable(const QUrl &url, std::function }); } -void DolphinView::observeCreatedDirectory(const QUrl &url) +void DolphinView::observeCreatedDirectory(const QUrl &newDirectoryUrl) { if (!m_active) { return; @@ -1830,8 +1830,8 @@ void DolphinView::observeCreatedDirectory(const QUrl &url) } // select the new directory - if (!m_model->fileItem(url).isNull()) { - forceUrlsSelection(url, {url}); + if (!m_model->fileItem(newDirectoryUrl).isNull()) { + forceUrlsSelection(newDirectoryUrl, {newDirectoryUrl}); return; } @@ -1840,8 +1840,16 @@ void DolphinView::observeCreatedDirectory(const QUrl &url) return !m_container->controller()->selectionManager()->hasSelection(); }); + // in case, a new hiercachy was created, select the first folder in its parent path + auto targetUrl = newDirectoryUrl; + auto parentUrl = targetUrl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); + while (parentUrl != m_url) { + targetUrl = parentUrl; + parentUrl = targetUrl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); + } + // need to wait for the item to be added to the model - selectFileOnceAvailable(url, condition); + selectFileOnceAvailable(targetUrl, condition); } void DolphinView::observeCreatedItem(const QUrl &url) -- cgit v1.3