12 import os |
12 import os |
13 |
13 |
14 from PyQt5.QtCore import pyqtSlot, QDir |
14 from PyQt5.QtCore import pyqtSlot, QDir |
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
16 |
16 |
17 from E5Gui import E5FileDialog |
17 from E5Gui.E5PathPicker import E5PathPickerModes |
18 from E5Gui.E5Completers import E5DirCompleter |
|
19 |
18 |
20 from .Ui_HgExportDialog import Ui_HgExportDialog |
19 from .Ui_HgExportDialog import Ui_HgExportDialog |
21 |
20 |
22 import Utilities |
|
23 import UI.PixmapCache |
|
24 |
21 |
25 |
22 |
26 class HgExportDialog(QDialog, Ui_HgExportDialog): |
23 class HgExportDialog(QDialog, Ui_HgExportDialog): |
27 """ |
24 """ |
28 Class documentation goes here. |
25 Class documentation goes here. |
34 @param parent reference to the parent widget (QWidget) |
31 @param parent reference to the parent widget (QWidget) |
35 """ |
32 """ |
36 super(HgExportDialog, self).__init__(parent) |
33 super(HgExportDialog, self).__init__(parent) |
37 self.setupUi(self) |
34 self.setupUi(self) |
38 |
35 |
39 self.directoryButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
36 self.directoryPicker.setMode(E5PathPickerModes.DirectoryMode) |
40 |
37 |
41 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
38 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
42 |
39 |
43 self.__directoryCompleter = E5DirCompleter(self.directoryEdit) |
|
44 |
|
45 # set default values for directory and pattern |
40 # set default values for directory and pattern |
46 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff") |
41 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff") |
47 self.directoryEdit.setText(QDir.tempPath()) |
42 self.directoryPicker.setText(QDir.tempPath()) |
48 |
43 |
49 def __updateOK(self): |
44 def __updateOK(self): |
50 """ |
45 """ |
51 Private slot to update the OK button. |
46 Private slot to update the OK button. |
52 """ |
47 """ |
53 enabled = True |
48 enabled = True |
54 |
49 |
55 if self.directoryEdit.text() == "": |
50 if self.directoryPicker.text() == "": |
56 enabled = False |
51 enabled = False |
57 elif self.patternEdit.text() == "": |
52 elif self.patternEdit.text() == "": |
58 enabled = False |
53 enabled = False |
59 elif self.changesetsEdit.toPlainText() == "": |
54 elif self.changesetsEdit.toPlainText() == "": |
60 enabled = False |
55 enabled = False |
61 |
56 |
62 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
57 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
63 |
58 |
64 @pyqtSlot(str) |
59 @pyqtSlot(str) |
65 def on_directoryEdit_textChanged(self, txt): |
60 def on_directoryPicker_textChanged(self, txt): |
66 """ |
61 """ |
67 Private slot to react on changes of the export directory edit. |
62 Private slot to react on changes of the export directory edit. |
68 |
63 |
69 @param txt contents of the line edit (string) |
64 @param txt contents of the line edit (string) |
70 """ |
65 """ |
71 self.__updateOK() |
66 self.__updateOK() |
72 |
|
73 @pyqtSlot() |
|
74 def on_directoryButton_clicked(self): |
|
75 """ |
|
76 Private slot called by pressing the export directory selection button. |
|
77 """ |
|
78 dn = E5FileDialog.getExistingDirectory( |
|
79 self, |
|
80 self.tr("Export Patches"), |
|
81 self.directoryEdit.text(), |
|
82 E5FileDialog.Options(E5FileDialog.Option(0))) |
|
83 |
|
84 if dn: |
|
85 self.directoryEdit.setText(Utilities.toNativeSeparators(dn)) |
|
86 |
67 |
87 @pyqtSlot(str) |
68 @pyqtSlot(str) |
88 def on_patternEdit_textChanged(self, txt): |
69 def on_patternEdit_textChanged(self, txt): |
89 """ |
70 """ |
90 Private slot to react on changes of the export file name pattern edit. |
71 Private slot to react on changes of the export file name pattern edit. |
110 to use the git extended diff format (string, list of strings, |
91 to use the git extended diff format (string, list of strings, |
111 boolean, boolean, boolean, boolean) |
92 boolean, boolean, boolean, boolean) |
112 """ |
93 """ |
113 return ( |
94 return ( |
114 os.path.join( |
95 os.path.join( |
115 Utilities.toNativeSeparators(self.directoryEdit.text()), |
96 self.directoryPicker.text(), |
116 self.patternEdit.text()), |
97 self.patternEdit.text()), |
117 self.changesetsEdit.toPlainText().splitlines(), |
98 self.changesetsEdit.toPlainText().splitlines(), |
118 self.switchParentCheckBox.isChecked(), |
99 self.switchParentCheckBox.isChecked(), |
119 self.textCheckBox.isChecked(), |
100 self.textCheckBox.isChecked(), |
120 self.datesCheckBox.isChecked(), |
101 self.datesCheckBox.isChecked(), |