src/eric7/EricWidgets/EricFileSaveConfirmDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
--- a/src/eric7/EricWidgets/EricFileSaveConfirmDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/EricWidgets/EricFileSaveConfirmDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -9,9 +9,7 @@
 
 import os
 
-from PyQt6.QtWidgets import (
-    QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QLineEdit
-)
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QLineEdit
 
 from .EricPathPicker import EricPathPicker, EricPathPickerModes
 
@@ -21,10 +19,11 @@
     Class implementing a dialog to enter a file system path using a file
     picker.
     """
+
     def __init__(self, filename, title, message="", picker=True, parent=None):
         """
         Constructor
-        
+
         @param filename file name to be shown
         @type str
         @param title title for the dialog
@@ -37,54 +36,57 @@
         @type QWidget
         """
         super().__init__(parent)
-        
+
         self.setMinimumWidth(400)
-        
+
         self.__selectedAction = "cancel"
         self.__filename = filename
-        
+
         self.__layout = QVBoxLayout(self)
-        
+
         self.__label = QLabel(self)
         self.__label.setWordWrap(True)
         if message:
             self.__label.setText(message)
         else:
             self.__label.setText(self.tr("The given file exists already."))
-        
+
         if picker:
             self.__pathPicker = EricPathPicker(self)
             self.__pathPicker.setMode(EricPathPickerModes.SAVE_FILE_MODE)
         else:
             self.__pathPicker = QLineEdit(self)
             self.__pathPicker.setClearButtonEnabled(True)
-        
+
         self.__buttonBox = QDialogButtonBox(self)
         self.__cancelButton = self.__buttonBox.addButton(
-            QDialogButtonBox.StandardButton.Cancel)
+            QDialogButtonBox.StandardButton.Cancel
+        )
         self.__overwriteButton = self.__buttonBox.addButton(
-            self.tr("Overwrite"), QDialogButtonBox.ButtonRole.AcceptRole)
+            self.tr("Overwrite"), QDialogButtonBox.ButtonRole.AcceptRole
+        )
         self.__renameButton = self.__buttonBox.addButton(
-            self.tr("Rename"), QDialogButtonBox.ButtonRole.AcceptRole)
-        
+            self.tr("Rename"), QDialogButtonBox.ButtonRole.AcceptRole
+        )
+
         self.__layout.addWidget(self.__label)
         self.__layout.addWidget(self.__pathPicker)
         self.__layout.addWidget(self.__buttonBox)
-        
+
         # set values and states
         self.__pathPicker.setText(filename)
         if picker:
             self.__pathPicker.setDefaultDirectory(os.path.dirname(filename))
         self.__renameButton.setEnabled(False)
         self.__cancelButton.setDefault(True)
-        
+
         self.__buttonBox.clicked.connect(self.__buttonBoxClicked)
         self.__pathPicker.textChanged.connect(self.__filenameChanged)
-    
+
     def __buttonBoxClicked(self, button):
         """
         Private slot to handle the user clicking a button.
-        
+
         @param button reference to the clicked button
         @type QAbstractButton
         """
@@ -97,20 +99,20 @@
         elif button == self.__overwriteButton:
             self.__selectedAction = "overwrite"
             self.accept()
-    
+
     def __filenameChanged(self, text):
         """
         Private slot to handle a change of the file name.
-        
+
         @param text new file name
         @type str
         """
         self.__renameButton.setEnabled(text != self.__filename)
-    
+
     def selectedAction(self):
         """
         Public method to get the selected action and associated data.
-        
+
         @return tuple containing the selected action (cancel, rename,
             overwrite) and the filename (in case of 'rename' or 'overwrite')
         @rtype tuple of (str, str)
@@ -127,7 +129,7 @@
 def confirmOverwrite(filename, title, message="", picker=True, parent=None):
     """
     Function to confirm that a file shall be overwritten.
-    
+
     @param filename file name to be shown
     @type str
     @param title title for the dialog
@@ -142,7 +144,8 @@
         overwrite) and the filename (in case of 'rename' or 'overwrite')
     @rtype tuple of (str, str)
     """
-    dlg = EricFileSaveConfirmDialog(filename, title, message=message,
-                                    picker=picker, parent=parent)
+    dlg = EricFileSaveConfirmDialog(
+        filename, title, message=message, picker=picker, parent=parent
+    )
     dlg.exec()
     return dlg.selectedAction()

eric ide

mercurial