|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter data for the Mercurial import command. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot, QDateTime |
|
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from E5Gui.E5PathPicker import E5PathPickerModes |
|
14 |
|
15 from .Ui_HgImportDialog import Ui_HgImportDialog |
|
16 |
|
17 |
|
18 class HgImportDialog(QDialog, Ui_HgImportDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter data for the Mercurial import command. |
|
21 """ |
|
22 def __init__(self, vcs, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param vcs reference to the VCS object |
|
27 @type Hg |
|
28 @param parent reference to the parent widget |
|
29 @type QWidget |
|
30 """ |
|
31 super().__init__(parent) |
|
32 self.setupUi(self) |
|
33 |
|
34 self.patchFilePicker.setMode(E5PathPickerModes.OpenFileMode) |
|
35 self.patchFilePicker.setFilters(self.tr( |
|
36 "Patch Files (*.diff *.patch);;All Files (*)")) |
|
37 |
|
38 self.secretCheckBox.setEnabled(vcs.version >= (5, 3, 0)) |
|
39 |
|
40 self.buttonBox.button( |
|
41 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
42 |
|
43 self.__initDateTime = QDateTime.currentDateTime() |
|
44 self.dateEdit.setDateTime(self.__initDateTime) |
|
45 |
|
46 def __updateOK(self): |
|
47 """ |
|
48 Private slot to update the OK button. |
|
49 """ |
|
50 enabled = True |
|
51 if self.patchFilePicker.text() == "": |
|
52 enabled = False |
|
53 |
|
54 self.buttonBox.button( |
|
55 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
|
56 |
|
57 @pyqtSlot(str) |
|
58 def on_patchFilePicker_textChanged(self, txt): |
|
59 """ |
|
60 Private slot to react on changes of the patch file edit. |
|
61 |
|
62 @param txt contents of the line edit (string) |
|
63 """ |
|
64 self.__updateOK() |
|
65 |
|
66 def getParameters(self): |
|
67 """ |
|
68 Public method to retrieve the import data. |
|
69 |
|
70 @return tuple naming the patch file, a flag indicating to not commit, |
|
71 a commit message, a commit date, a commit user, a flag indicating |
|
72 to commit with the secret phase, a strip count and a flag |
|
73 indicating to enforce the import |
|
74 @rtype tuple of (str, bool, str, str, str, bool, int, bool) |
|
75 """ |
|
76 date = ( |
|
77 self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
|
78 if self.dateEdit.dateTime() != self.__initDateTime else |
|
79 "" |
|
80 ) |
|
81 |
|
82 return (self.patchFilePicker.text(), self.noCommitCheckBox.isChecked(), |
|
83 self.messageEdit.toPlainText(), date, self.userEdit.text(), |
|
84 self.secretCheckBox.isChecked(), self.stripSpinBox.value(), |
|
85 self.forceCheckBox.isChecked()) |