src/eric7/Plugins/VcsPlugins/vcsGit/GitCopyDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
24 class GitCopyDialog(QDialog, Ui_GitCopyDialog): 24 class GitCopyDialog(QDialog, Ui_GitCopyDialog):
25 """ 25 """
26 Class implementing a dialog to enter the data for a copy or rename 26 Class implementing a dialog to enter the data for a copy or rename
27 operation. 27 operation.
28 """ 28 """
29
29 def __init__(self, source, parent=None, move=False): 30 def __init__(self, source, parent=None, move=False):
30 """ 31 """
31 Constructor 32 Constructor
32 33
33 @param source name of the source file/directory (string) 34 @param source name of the source file/directory (string)
34 @param parent parent widget (QWidget) 35 @param parent parent widget (QWidget)
35 @param move flag indicating a move operation (boolean) 36 @param move flag indicating a move operation (boolean)
36 """ 37 """
37 super().__init__(parent) 38 super().__init__(parent)
38 self.setupUi(self) 39 self.setupUi(self)
39 40
40 self.dirButton.setIcon(UI.PixmapCache.getIcon("open")) 41 self.dirButton.setIcon(UI.PixmapCache.getIcon("open"))
41 42
42 self.source = source 43 self.source = source
43 if os.path.isdir(self.source): 44 if os.path.isdir(self.source):
44 self.targetCompleter = EricDirCompleter(self.targetEdit) 45 self.targetCompleter = EricDirCompleter(self.targetEdit)
45 else: 46 else:
46 self.targetCompleter = EricFileCompleter(self.targetEdit) 47 self.targetCompleter = EricFileCompleter(self.targetEdit)
47 48
48 if move: 49 if move:
49 self.setWindowTitle(self.tr('Git Move')) 50 self.setWindowTitle(self.tr("Git Move"))
50 else: 51 else:
51 self.forceCheckBox.setEnabled(False) 52 self.forceCheckBox.setEnabled(False)
52 53
53 self.sourceEdit.setText(source) 54 self.sourceEdit.setText(source)
54 55
55 self.buttonBox.button( 56 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
56 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 57
57
58 msh = self.minimumSizeHint() 58 msh = self.minimumSizeHint()
59 self.resize(max(self.width(), msh.width()), msh.height()) 59 self.resize(max(self.width(), msh.width()), msh.height())
60 60
61 def getData(self): 61 def getData(self):
62 """ 62 """
63 Public method to retrieve the copy data. 63 Public method to retrieve the copy data.
64 64
65 @return the target name (string) and a flag indicating 65 @return the target name (string) and a flag indicating
66 the operation should be enforced (boolean) 66 the operation should be enforced (boolean)
67 """ 67 """
68 target = self.targetEdit.text() 68 target = self.targetEdit.text()
69 if not os.path.isabs(target): 69 if not os.path.isabs(target):
70 sourceDir = os.path.dirname(self.sourceEdit.text()) 70 sourceDir = os.path.dirname(self.sourceEdit.text())
71 target = os.path.join(sourceDir, target) 71 target = os.path.join(sourceDir, target)
72 return ( 72 return (Utilities.toNativeSeparators(target), self.forceCheckBox.isChecked())
73 Utilities.toNativeSeparators(target), 73
74 self.forceCheckBox.isChecked()
75 )
76
77 @pyqtSlot() 74 @pyqtSlot()
78 def on_dirButton_clicked(self): 75 def on_dirButton_clicked(self):
79 """ 76 """
80 Private slot to handle the button press for selecting the target via a 77 Private slot to handle the button press for selecting the target via a
81 selection dialog. 78 selection dialog.
83 target = ( 80 target = (
84 EricFileDialog.getExistingDirectory( 81 EricFileDialog.getExistingDirectory(
85 self, 82 self,
86 self.tr("Select target"), 83 self.tr("Select target"),
87 self.targetEdit.text(), 84 self.targetEdit.text(),
88 EricFileDialog.ShowDirsOnly) 85 EricFileDialog.ShowDirsOnly,
89 if os.path.isdir(self.source) else 86 )
90 EricFileDialog.getSaveFileName( 87 if os.path.isdir(self.source)
88 else EricFileDialog.getSaveFileName(
91 self, 89 self,
92 self.tr("Select target"), 90 self.tr("Select target"),
93 self.targetEdit.text(), 91 self.targetEdit.text(),
94 "", 92 "",
95 EricFileDialog.DontConfirmOverwrite) 93 EricFileDialog.DontConfirmOverwrite,
94 )
96 ) 95 )
97 96
98 if target: 97 if target:
99 self.targetEdit.setText(Utilities.toNativeSeparators(target)) 98 self.targetEdit.setText(Utilities.toNativeSeparators(target))
100 99
101 @pyqtSlot(str) 100 @pyqtSlot(str)
102 def on_targetEdit_textChanged(self, txt): 101 def on_targetEdit_textChanged(self, txt):
103 """ 102 """
104 Private slot to handle changes of the target. 103 Private slot to handle changes of the target.
105 104
106 @param txt contents of the target edit (string) 105 @param txt contents of the target edit (string)
107 """ 106 """
108 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( 107 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
109 os.path.isabs(txt) or os.path.dirname(txt) == "") 108 os.path.isabs(txt) or os.path.dirname(txt) == ""
109 )

eric ide

mercurial