20 class HgCopyDialog(QDialog, Ui_HgCopyDialog): |
20 class HgCopyDialog(QDialog, Ui_HgCopyDialog): |
21 """ |
21 """ |
22 Class implementing a dialog to enter the data for a copy or rename |
22 Class implementing a dialog to enter the data for a copy or rename |
23 operation. |
23 operation. |
24 """ |
24 """ |
|
25 |
25 def __init__(self, source, parent=None, move=False): |
26 def __init__(self, source, parent=None, move=False): |
26 """ |
27 """ |
27 Constructor |
28 Constructor |
28 |
29 |
29 @param source name of the source file/directory (string) |
30 @param source name of the source file/directory (string) |
30 @param parent parent widget (QWidget) |
31 @param parent parent widget (QWidget) |
31 @param move flag indicating a move operation (boolean) |
32 @param move flag indicating a move operation (boolean) |
32 """ |
33 """ |
33 super().__init__(parent) |
34 super().__init__(parent) |
34 self.setupUi(self) |
35 self.setupUi(self) |
35 |
36 |
36 self.source = source |
37 self.source = source |
37 if os.path.isdir(self.source): |
38 if os.path.isdir(self.source): |
38 self.targetPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
39 self.targetPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
39 else: |
40 else: |
40 self.targetPicker.setMode(EricPathPickerModes.SAVE_FILE_MODE) |
41 self.targetPicker.setMode(EricPathPickerModes.SAVE_FILE_MODE) |
41 |
42 |
42 if move: |
43 if move: |
43 self.setWindowTitle(self.tr('Mercurial Move')) |
44 self.setWindowTitle(self.tr("Mercurial Move")) |
44 else: |
45 else: |
45 self.forceCheckBox.setEnabled(False) |
46 self.forceCheckBox.setEnabled(False) |
46 |
47 |
47 self.sourceEdit.setText(source) |
48 self.sourceEdit.setText(source) |
48 |
49 |
49 self.buttonBox.button( |
50 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
50 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
51 |
51 |
|
52 msh = self.minimumSizeHint() |
52 msh = self.minimumSizeHint() |
53 self.resize(max(self.width(), msh.width()), msh.height()) |
53 self.resize(max(self.width(), msh.width()), msh.height()) |
54 |
54 |
55 def getData(self): |
55 def getData(self): |
56 """ |
56 """ |
57 Public method to retrieve the copy data. |
57 Public method to retrieve the copy data. |
58 |
58 |
59 @return the target name (string) and a flag indicating |
59 @return the target name (string) and a flag indicating |
60 the operation should be enforced (boolean) |
60 the operation should be enforced (boolean) |
61 """ |
61 """ |
62 target = self.targetPicker.text() |
62 target = self.targetPicker.text() |
63 if not os.path.isabs(target): |
63 if not os.path.isabs(target): |
64 sourceDir = os.path.dirname(self.sourceEdit.text()) |
64 sourceDir = os.path.dirname(self.sourceEdit.text()) |
65 target = os.path.join(sourceDir, target) |
65 target = os.path.join(sourceDir, target) |
66 return target, self.forceCheckBox.isChecked() |
66 return target, self.forceCheckBox.isChecked() |
67 |
67 |
68 @pyqtSlot(str) |
68 @pyqtSlot(str) |
69 def on_targetPicker_textChanged(self, txt): |
69 def on_targetPicker_textChanged(self, txt): |
70 """ |
70 """ |
71 Private slot to handle changes of the target. |
71 Private slot to handle changes of the target. |
72 |
72 |
73 @param txt contents of the target edit (string) |
73 @param txt contents of the target edit (string) |
74 """ |
74 """ |
75 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
75 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
76 os.path.isabs(txt) or os.path.dirname(txt) == "") |
76 os.path.isabs(txt) or os.path.dirname(txt) == "" |
|
77 ) |