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