diff --git a/src/filewidgets/knewfilemenu.cpp b/src/filewidgets/knewfilemenu.cpp --- a/src/filewidgets/knewfilemenu.cpp +++ b/src/filewidgets/knewfilemenu.cpp @@ -249,9 +249,9 @@ bool checkSourceExists(const QString &src); /** - * Asks user whether to create a hidden directory with a dialog + * Asks user depending on whether they wants to create a hidden directory or a directory named "~" with a dialog */ - void confirmCreatingHiddenDir(const QString &name); + void confirmCreatingDir(const QString &name); /** * The strategy used for other desktop files than Type=Link. Example: Application, Device. @@ -405,7 +405,7 @@ return true; } -void KNewFileMenuPrivate::confirmCreatingHiddenDir(const QString &name) +void KNewFileMenuPrivate::confirmCreatingDir(const QString &name) { if (!KMessageBox::shouldBeShownContinue(QStringLiteral("confirm_create_hidden_dir"))) { _k_slotCreateHiddenDirectory(); @@ -428,12 +428,23 @@ KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), continueGuiItem); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), cancelGuiItem); - KMessageBox::createKMessageBox(confirmDialog, buttonBox, QMessageBox::Warning, + if (name.startsWith(QLatin1Char('.'))) { + confirmDialog->setWindowTitle(i18n("Create hidden directory?")); + KMessageBox::createKMessageBox(confirmDialog, buttonBox, QMessageBox::Warning, i18n("The name \"%1\" starts with a dot, so the directory will be hidden by default.", name), QStringList(), i18n("Do not ask again"), nullptr, KMessageBox::NoExec); + } else if (name.operator==(QLatin1String("~"))) { + confirmDialog->setWindowTitle(i18n("Create directory named ~?")); + KMessageBox::createKMessageBox(confirmDialog, buttonBox, QMessageBox::Warning, + i18n("A directory named tilde("~") is not recommended because it may be confusing or dangerous if directories are deleted using the terminal", name), + QStringList(), + i18n("Do not ask again"), + nullptr, + KMessageBox::NoExec); + } QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(_k_slotCreateHiddenDirectory())); QObject::connect(buttonBox, &QDialogButtonBox::rejected, q, &KNewFileMenu::createDirectory); @@ -856,7 +867,7 @@ QUrl url; QUrl baseUrl = m_popupFiles.first(); - QString name = expandTilde(m_text); + QString name = m_text; if (!name.isEmpty()) { if (QDir::isAbsolutePath(name)) { @@ -890,12 +901,14 @@ _k_slotAbortDialog(); return; } - if (!m_viewShowsHiddenFiles && name.startsWith(QLatin1Char('.'))) { + + if ((!m_viewShowsHiddenFiles && name.startsWith(QLatin1Char('.'))) || (name.operator==(QLatin1String("~")))) { if (!writeHiddenDir) { - confirmCreatingHiddenDir(name); + confirmCreatingDir(name); return; } } + url = baseUrl; url.setPath(concatPaths(url.path(), name)); }