┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp18
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();
}
}