Commit b08cea86 authored by Shubham  .'s avatar Shubham .
Browse files

Warn user before renaming the file/folder to start with a ' . '

Summary: For normal "casual" linux users, renaming the file/folder starting with dot may get irritating, they will be wondering their file is deleted.

Test Plan:
1. Make new file/folder.
2. Rename it to .foo
3. Question dialog appears.

Reviewers: elvisangelaccio, ngraham, pino

Reviewed By: elvisangelaccio, ngraham

Subscribers: cfeck, emateli, elvisangelaccio, pino, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D15980
parent 159eb6b4
......@@ -1575,6 +1575,29 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
#ifndef Q_OS_WIN
//Confirm hiding file/directory by renaming inline
if (!hiddenFilesShown() && newName.startsWith(QLatin1Char('.')) && !oldItem.name().startsWith(QLatin1Char('.'))) {
KGuiItem yesGuiItem(KStandardGuiItem::yes());
yesGuiItem.setText(i18nc("@action:button", "Rename and Hide"));
const auto code = KMessageBox::questionYesNo(this,
oldItem.isFile() ? i18n("Adding a dot to the beginning of this file's name will hide it from view.\n"
"Do you still want to rename it?")
: i18n("Adding a dot to the beginning of this folder's name will hide it from view.\n"
"Do you still want to rename it?"),
oldItem.isFile() ? i18n("Hide this File?") : i18n("Hide this Folder?"),
yesGuiItem,
KStandardGuiItem::cancel(),
QStringLiteral("ConfirmHide")
);
if (code == KMessageBox::No) {
return;
}
}
#endif
const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
if (!newNameExistsAlready) {
// Only change the data in the model if no item with the new name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment