[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kfile
From:       David Faure <faure () kde ! org>
Date:       2009-11-18 22:27:35
Message-ID: 1258583255.971308.18384.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1051125 by dfaure:

Usability improvement: warn before creating a directory that would be hidden \
immediately.


 M  +34 -10    kdiroperator.cpp  


--- trunk/KDE/kdelibs/kfile/kdiroperator.cpp #1051124:1051125
@@ -728,23 +728,47 @@
     d->sorting = d->fileView->sorting();*/
 }
 
+// Duplicated in libkonq's KonqOperations
+static bool confirmCreatingHiddenDir(const QString& name, QWidget* parent)
+{
+    KGuiItem continueGuiItem(KStandardGuiItem::cont());
+    continueGuiItem.setText(i18nc("@action:button", "Create directory"));
+    KGuiItem cancelGuiItem(KStandardGuiItem::cancel());
+    cancelGuiItem.setText(i18nc("@action:button", "Enter a different name"));
+    return KMessageBox::warningContinueCancel(
+        parent,
+        i18n("The name \"%1\" starts with a dot and will therefore the directory \
will be hidden by default.", name), +        i18n("Create hidden directory?"),
+        continueGuiItem,
+        cancelGuiItem,
+        "confirm_create_hidden_dir") == KMessageBox::Continue;
+}
+
 void KDirOperator::mkdir()
 {
     bool ok;
     QString where = url().pathOrUrl();
     QString name = i18n("New Folder");
-#ifdef Q_WS_WIN
-    if (url().isLocalFile() && QFileInfo(url().toLocalFile() + name).exists())
-#else
-    if (url().isLocalFile() && QFileInfo(url().path(KUrl::AddTrailingSlash) + \
                name).exists())
-#endif
+    if (url().isLocalFile() && QFileInfo(url().toLocalFile(KUrl::AddTrailingSlash) + \
name).exists())  name = KIO::RenameDialog::suggestName(url(), name);
 
-    QString folder = KInputDialog::getText(i18n("New Folder"),
-                                           i18n("Create new folder in:\n%1" ,  \
                where),
-                                           name, &ok, this);
-    if (ok)
-        KDirOperator::mkdir(KIO::encodeFileName(folder), true);
+    bool askAgain;
+    do {
+        askAgain = false;
+        name = KInputDialog::getText(i18n("New Folder"),
+                                     i18n("Create new folder in:\n%1" ,  where),
+                                     name, &ok, this);
+        if (ok) {
+            if (name.startsWith('.') && !showHiddenFiles()) {
+                if (!confirmCreatingHiddenDir(name, this)) {
+                    askAgain = true;
+                    continue;
+                }
+            }
+            KDirOperator::mkdir(KIO::encodeFileName(name), true);
+            break;
+        }
+    } while (askAgain);
 }
 
 bool KDirOperator::mkdir(const QString& directory, bool enterDirectory)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic