10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot, QDateTime |
12 from PyQt5.QtCore import pyqtSlot, QDateTime |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
14 |
14 |
15 from E5Gui import E5FileDialog |
15 from E5Gui.E5PathPicker import E5PathPickerModes |
16 from E5Gui.E5Completers import E5FileCompleter |
|
17 |
16 |
18 from .Ui_HgImportDialog import Ui_HgImportDialog |
17 from .Ui_HgImportDialog import Ui_HgImportDialog |
19 |
|
20 import Utilities |
|
21 import UI.PixmapCache |
|
22 |
18 |
23 |
19 |
24 class HgImportDialog(QDialog, Ui_HgImportDialog): |
20 class HgImportDialog(QDialog, Ui_HgImportDialog): |
25 """ |
21 """ |
26 Class implementing a dialog to enter data for the Mercurial import command. |
22 Class implementing a dialog to enter data for the Mercurial import command. |
32 @param parent reference to the parent widget (QWidget) |
28 @param parent reference to the parent widget (QWidget) |
33 """ |
29 """ |
34 super(HgImportDialog, self).__init__(parent) |
30 super(HgImportDialog, self).__init__(parent) |
35 self.setupUi(self) |
31 self.setupUi(self) |
36 |
32 |
37 self.patchFileButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
33 self.patchFilePicker.setMode(E5PathPickerModes.OpenFileMode) |
|
34 self.patchFilePicker.setFilters(self.tr( |
|
35 "Patch Files (*.diff *.patch);;All Files (*)")) |
38 |
36 |
39 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
37 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
40 |
|
41 self.__patchFileCompleter = E5FileCompleter(self.patchFileEdit) |
|
42 |
38 |
43 self.__initDateTime = QDateTime.currentDateTime() |
39 self.__initDateTime = QDateTime.currentDateTime() |
44 self.dateEdit.setDateTime(self.__initDateTime) |
40 self.dateEdit.setDateTime(self.__initDateTime) |
45 |
41 |
46 def __updateOK(self): |
42 def __updateOK(self): |
47 """ |
43 """ |
48 Private slot to update the OK button. |
44 Private slot to update the OK button. |
49 """ |
45 """ |
50 enabled = True |
46 enabled = True |
51 if self.patchFileEdit.text() == "": |
47 if self.patchFilePicker.text() == "": |
52 enabled = False |
48 enabled = False |
53 |
49 |
54 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
50 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
55 |
51 |
56 @pyqtSlot(str) |
52 @pyqtSlot(str) |
57 def on_patchFileEdit_textChanged(self, txt): |
53 def on_patchFilePicker_textChanged(self, txt): |
58 """ |
54 """ |
59 Private slot to react on changes of the patch file edit. |
55 Private slot to react on changes of the patch file edit. |
60 |
56 |
61 @param txt contents of the line edit (string) |
57 @param txt contents of the line edit (string) |
62 """ |
58 """ |
63 self.__updateOK() |
59 self.__updateOK() |
64 |
|
65 @pyqtSlot() |
|
66 def on_patchFileButton_clicked(self): |
|
67 """ |
|
68 Private slot called by pressing the file selection button. |
|
69 """ |
|
70 fn = E5FileDialog.getOpenFileName( |
|
71 self, |
|
72 self.tr("Select patch file"), |
|
73 self.patchFileEdit.text(), |
|
74 self.tr("Patch Files (*.diff *.patch);;All Files (*)")) |
|
75 |
|
76 if fn: |
|
77 self.patchFileEdit.setText(Utilities.toNativeSeparators(fn)) |
|
78 |
60 |
79 def getParameters(self): |
61 def getParameters(self): |
80 """ |
62 """ |
81 Public method to retrieve the import data. |
63 Public method to retrieve the import data. |
82 |
64 |
88 if self.dateEdit.dateTime() != self.__initDateTime: |
70 if self.dateEdit.dateTime() != self.__initDateTime: |
89 date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
71 date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
90 else: |
72 else: |
91 date = "" |
73 date = "" |
92 |
74 |
93 return (self.patchFileEdit.text(), self.noCommitCheckBox.isChecked(), |
75 return (self.patchFilePicker.text(), self.noCommitCheckBox.isChecked(), |
94 self.messageEdit.toPlainText(), date, self.userEdit.text(), |
76 self.messageEdit.toPlainText(), date, self.userEdit.text(), |
95 self.stripSpinBox.value(), self.forceCheckBox.isChecked()) |
77 self.stripSpinBox.value(), self.forceCheckBox.isChecked()) |