┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorShubham Jangra <[email protected]>2018-11-08 14:18:36 +0530
committerShubham Jangra <[email protected]>2018-11-08 14:18:59 +0530
commitb08cea86c9729a46ced10a7074b5fc5327ed619d (patch)
tree320aa6c76e2114f9b35382220e8a36185d8676c4 /src/views/dolphinview.cpp
parent159eb6b4a6693235c972012c3c2db933c1bd6875 (diff)
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
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 3e966792d..617c41ace 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -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