andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 39 forks source link

Add the filename in SaveAs dialog by default #416

Open dglent opened 7 years ago

dglent commented 7 years ago

Hi, some times i find useful to save the current file in another place but with the same file name. What do you think about this ?

diff --git a/enki/core/document.py b/enki/core/document.py
index 4b3acb8..769e496 100644
--- a/enki/core/document.py
+++ b/enki/core/document.py
@@ -391,7 +391,11 @@ class Document(QWidget):
     def saveFileAs(self):
         """Ask for new file name with dialog. Save file
         """
-        path, _ = QFileDialog.getSaveFileName(self, self.tr('Save file as...'))
+        if self._filePath:
+            default_filename = os.path.basename(self._filePath)
+        else:
+            default_filename = ''
+        path, _ = QFileDialog.getSaveFileName(self, self.tr('Save file as...'), default_filename)
         if not path:
             return
andreikop commented 7 years ago

Hi

I like the idea. Open a pull request with this code.