12 import os.path |
12 import os.path |
13 |
13 |
14 from PyQt5.QtCore import pyqtSlot |
14 from PyQt5.QtCore import pyqtSlot |
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
16 |
16 |
17 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter |
17 from E5Gui.E5PathPicker import E5PathPickerModes |
18 from E5Gui import E5FileDialog |
|
19 |
18 |
20 from .Ui_HgCopyDialog import Ui_HgCopyDialog |
19 from .Ui_HgCopyDialog import Ui_HgCopyDialog |
21 |
|
22 import Utilities |
|
23 import UI.PixmapCache |
|
24 |
20 |
25 |
21 |
26 class HgCopyDialog(QDialog, Ui_HgCopyDialog): |
22 class HgCopyDialog(QDialog, Ui_HgCopyDialog): |
27 """ |
23 """ |
28 Class implementing a dialog to enter the data for a copy or rename |
24 Class implementing a dialog to enter the data for a copy or rename |
37 @param move flag indicating a move operation (boolean) |
33 @param move flag indicating a move operation (boolean) |
38 """ |
34 """ |
39 super(HgCopyDialog, self).__init__(parent) |
35 super(HgCopyDialog, self).__init__(parent) |
40 self.setupUi(self) |
36 self.setupUi(self) |
41 |
37 |
42 self.dirButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
|
43 |
|
44 self.source = source |
38 self.source = source |
45 if os.path.isdir(self.source): |
39 if os.path.isdir(self.source): |
46 self.targetCompleter = E5DirCompleter(self.targetEdit) |
40 self.targetPicker.setMode(E5PathPickerModes.DirectoryMode) |
47 else: |
41 else: |
48 self.targetCompleter = E5FileCompleter(self.targetEdit) |
42 self.targetPicker.setMode(E5PathPickerModes.SaveFileMode) |
49 |
43 |
50 if move: |
44 if move: |
51 self.setWindowTitle(self.tr('Mercurial Move')) |
45 self.setWindowTitle(self.tr('Mercurial Move')) |
52 else: |
46 else: |
53 self.forceCheckBox.setEnabled(False) |
47 self.forceCheckBox.setEnabled(False) |
64 Public method to retrieve the copy data. |
58 Public method to retrieve the copy data. |
65 |
59 |
66 @return the target name (string) and a flag indicating |
60 @return the target name (string) and a flag indicating |
67 the operation should be enforced (boolean) |
61 the operation should be enforced (boolean) |
68 """ |
62 """ |
69 target = self.targetEdit.text() |
63 target = self.targetPicker.text() |
70 if not os.path.isabs(target): |
64 if not os.path.isabs(target): |
71 sourceDir = os.path.dirname(self.sourceEdit.text()) |
65 sourceDir = os.path.dirname(self.sourceEdit.text()) |
72 target = os.path.join(sourceDir, target) |
66 target = os.path.join(sourceDir, target) |
73 return Utilities.toNativeSeparators(target), \ |
67 return target, self.forceCheckBox.isChecked() |
74 self.forceCheckBox.isChecked() |
|
75 |
|
76 @pyqtSlot() |
|
77 def on_dirButton_clicked(self): |
|
78 """ |
|
79 Private slot to handle the button press for selecting the target via a |
|
80 selection dialog. |
|
81 """ |
|
82 if os.path.isdir(self.source): |
|
83 target = E5FileDialog.getExistingDirectory( |
|
84 self, |
|
85 self.tr("Select target"), |
|
86 self.targetEdit.text(), |
|
87 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
|
88 else: |
|
89 target = E5FileDialog.getSaveFileName( |
|
90 self, |
|
91 self.tr("Select target"), |
|
92 self.targetEdit.text(), |
|
93 "", |
|
94 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
|
95 |
|
96 if target: |
|
97 self.targetEdit.setText(Utilities.toNativeSeparators(target)) |
|
98 |
68 |
99 @pyqtSlot(str) |
69 @pyqtSlot(str) |
100 def on_targetEdit_textChanged(self, txt): |
70 def on_targetPicker_textChanged(self, txt): |
101 """ |
71 """ |
102 Private slot to handle changes of the target. |
72 Private slot to handle changes of the target. |
103 |
73 |
104 @param txt contents of the target edit (string) |
74 @param txt contents of the target edit (string) |
105 """ |
75 """ |