changeset 30210:351dbe4da930

GUI: Display dialog if deleting or renaming a file fails (bug #61225). * libgui/src/files-dock-widget.cc (files_dock_widget::contextmenu_rename, files_dock_widget::contextmenu_delete): Display dialog if deleting or renaming a file fails.
author Markus Mützel <markus.muetzel@gmx.de>
date Mon, 27 Sep 2021 12:59:34 +0200
parents 54774a713d7c
children 54520422f056
files libgui/src/files-dock-widget.cc
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc	Thu Sep 23 21:06:41 2021 -0400
+++ b/libgui/src/files-dock-widget.cc	Mon Sep 27 12:59:34 2021 +0200
@@ -714,6 +714,10 @@
             // Do the renaming
             QFile f (old_name);  // Must use QFile, not QDir (bug #56298)
             bool st = f.rename (new_name);
+            if (! st)
+              QMessageBox::warning (this, tr ("Rename error"),
+                                    tr ("Could not rename file \"%1\" to \"%2\".").
+                                    arg (old_name).arg (new_name));
             // editor: load new/old file depending on success
             emit file_renamed_signal (st);
             // Clear cache of file browser
@@ -781,9 +785,14 @@
                 emit file_remove_signal (info.filePath (), QString ());
                 // Remove the file.
                 bool st = m_file_system_model->remove (index);
-                // Reload the old file if removing was not successful
                 if (! st)
-                  emit file_renamed_signal (false);
+                  {
+                    QMessageBox::warning (this, tr ("Deletion error"),
+                                          tr ("Could not delete file \"%1\".").
+                                          arg (info.filePath ()));
+                    // Reload the old file
+                    emit file_renamed_signal (false);
+                  }
               }
 
             m_file_system_model->revert ();