diff --git a/autotests/knewfilemenutest.cpp b/autotests/knewfilemenutest.cpp --- a/autotests/knewfilemenutest.cpp +++ b/autotests/knewfilemenutest.cpp @@ -103,7 +103,8 @@ QTest::newRow("symlink") << "Basic link" << "" << "thelink" << "thelink"; QTest::newRow("folder") << "Folder..." << "New Folder" << "folder1" << "folder1"; QTest::newRow("folder_default_name") << "Folder..." << "New Folder" << "New Folder" << "New Folder"; - QTest::newRow("folder_with_suggested_name") << "Folder..." << "New Folder (1)" << "New Folder" << "New Folder"; + QTest::newRow("folder_with_suggested_name") << "Folder..." << "New Folder (1)" << "New Folder (1)" << "New Folder (1)"; + QTest::newRow("folder_with_suggested_name_but_user_overrides") << "Folder..." << "New Folder (2)" << "New Folder" << ""; QTest::newRow("application") << "Link to Application..." << "Link to Application" << "app1" << "app1.desktop"; } @@ -160,11 +161,18 @@ QSignalSpy spy(&menu, SIGNAL(fileCreated(QUrl))); QSignalSpy folderSpy(&menu, SIGNAL(directoryCreated(QUrl))); dialog->accept(); - const QString path = m_tmpDir.path() + QLatin1Char('/') + expectedFilename; + QString path = m_tmpDir.path() + QLatin1Char('/') + expectedFilename; if (actionText == QLatin1String("Folder...")) { - QVERIFY(folderSpy.wait(1000)); - emittedUrl = folderSpy.at(0).at(0).toUrl(); - QVERIFY(QFileInfo(path).isDir()); + if (expectedFilename.isEmpty()) { + // This is the "Folder already exists" case; expect an error dialog + dialog = parentWidget.findChild(); + dialog->accept(); + path.clear(); + } else { + QVERIFY(folderSpy.wait(1000)); + emittedUrl = folderSpy.at(0).at(0).toUrl(); + QVERIFY(QFileInfo(path).isDir()); + } } else { if (spy.isEmpty()) { QVERIFY(spy.wait(1000)); diff --git a/src/filewidgets/knewfilemenu.cpp b/src/filewidgets/knewfilemenu.cpp --- a/src/filewidgets/knewfilemenu.cpp +++ b/src/filewidgets/knewfilemenu.cpp @@ -1329,13 +1329,11 @@ // Called in the storedPut() case org::kde::KDirNotify::emitFilesAdded(simpleJob->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash)); emit fileCreated(simpleJob->url()); - } else { + } + + if (job->property("newDirectoryURL").isValid()) { QUrl newDirectoryURL = job->property("newDirectoryURL").toUrl(); - if (newDirectoryURL.isValid()) { - emit directoryCreated(newDirectoryURL); - } else { - qWarning() << "Neither copy, put nor mkdir, internal error"; - } + emit directoryCreated(newDirectoryURL); } } if (!d->m_tempFileToDelete.isEmpty()) {