diff options
| author | Méven Car <[email protected]> | 2025-11-02 15:49:47 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-11-21 13:25:55 +0000 |
| commit | 60e109632fd63b335ca1cc037c5d5c3e291349f5 (patch) | |
| tree | 70f824fee05fbad2fc3de6d086900055ead749d4 /src/dolphinmainwindow.cpp | |
| parent | e114f654ed1216aaa64593354ca1306a53fefef0 (diff) | |
context menu: use selected item as containing folder for New file menu
Use current view url as fallback.
Don't update the selection after a directory is created, except if there
was no selection.
CCBUG: 508196
BUG: 512020
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index dd11b67f7..72ed98f77 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -830,7 +830,14 @@ void DolphinMainWindow::createDirectory() // just check if we are already running one. This prevents opening multiple // dialogs. BUG:481401 if (!m_newFileMenu->isCreateDirectoryRunning()) { - m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); + QUrl targetDirectory = activeViewContainer()->view()->url(); + if (const auto itemOpt = activeViewContainer()->view()->firstSelectedItem()) { + if (itemOpt->isDir()) { + targetDirectory = itemOpt->url(); + } + } + + m_newFileMenu->setWorkingDirectory(targetDirectory); m_newFileMenu->createDirectory(); } } @@ -839,7 +846,14 @@ void DolphinMainWindow::createFile() { // Use the same logic as in createDirectory() if (!m_newFileMenu->isCreateFileRunning()) { - m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); + QUrl targetDirectory = activeViewContainer()->view()->url(); + if (const auto itemOpt = activeViewContainer()->view()->firstSelectedItem()) { + if (itemOpt->isDir()) { + targetDirectory = itemOpt->url(); + } + } + + m_newFileMenu->setWorkingDirectory(targetDirectory); m_newFileMenu->createFile(); } } |
