18 class HgQueuesHeaderDialog(QDialog, Ui_HgQueuesHeaderDialog): |
18 class HgQueuesHeaderDialog(QDialog, Ui_HgQueuesHeaderDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to show the commit message of the current |
20 Class implementing a dialog to show the commit message of the current |
21 patch. |
21 patch. |
22 """ |
22 """ |
|
23 |
23 def __init__(self, vcs, parent=None): |
24 def __init__(self, vcs, parent=None): |
24 """ |
25 """ |
25 Constructor |
26 Constructor |
26 |
27 |
27 @param vcs reference to the vcs object |
28 @param vcs reference to the vcs object |
28 @param parent reference to the parent widget (QWidget) |
29 @param parent reference to the parent widget (QWidget) |
29 """ |
30 """ |
30 super().__init__(parent) |
31 super().__init__(parent) |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 |
33 |
33 self.buttonBox.button( |
34 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
34 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
35 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
35 self.buttonBox.button( |
36 |
36 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
|
37 |
|
38 self.vcs = vcs |
37 self.vcs = vcs |
39 self.__hgClient = vcs.getClient() |
38 self.__hgClient = vcs.getClient() |
40 |
39 |
41 self.show() |
40 self.show() |
42 QCoreApplication.processEvents() |
41 QCoreApplication.processEvents() |
43 |
42 |
44 def closeEvent(self, e): |
43 def closeEvent(self, e): |
45 """ |
44 """ |
46 Protected slot implementing a close event handler. |
45 Protected slot implementing a close event handler. |
47 |
46 |
48 @param e close event (QCloseEvent) |
47 @param e close event (QCloseEvent) |
49 """ |
48 """ |
50 if self.__hgClient.isExecuting(): |
49 if self.__hgClient.isExecuting(): |
51 self.__hgClient.cancel() |
50 self.__hgClient.cancel() |
52 |
51 |
53 e.accept() |
52 e.accept() |
54 |
53 |
55 def start(self): |
54 def start(self): |
56 """ |
55 """ |
57 Public slot to start the list command. |
56 Public slot to start the list command. |
58 """ |
57 """ |
59 self.activateWindow() |
58 self.activateWindow() |
60 |
59 |
61 args = self.vcs.initCommand("qheader") |
60 args = self.vcs.initCommand("qheader") |
62 |
61 |
63 out, err = self.__hgClient.runcommand( |
62 out, err = self.__hgClient.runcommand( |
64 args, output=self.__showOutput, error=self.__showError) |
63 args, output=self.__showOutput, error=self.__showError |
|
64 ) |
65 if err: |
65 if err: |
66 self.__showError(err) |
66 self.__showError(err) |
67 if out: |
67 if out: |
68 self.__showOutPut(out) |
68 self.__showOutPut(out) |
69 self.__finish() |
69 self.__finish() |
70 |
70 |
71 def __finish(self): |
71 def __finish(self): |
72 """ |
72 """ |
73 Private slot called when the process finished or the user pressed |
73 Private slot called when the process finished or the user pressed |
74 the button. |
74 the button. |
75 """ |
75 """ |
76 self.buttonBox.button( |
76 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
77 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
77 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
78 self.buttonBox.button( |
78 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
79 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
79 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus( |
80 self.buttonBox.button( |
80 Qt.FocusReason.OtherFocusReason |
81 QDialogButtonBox.StandardButton.Close).setDefault(True) |
81 ) |
82 self.buttonBox.button( |
82 |
83 QDialogButtonBox.StandardButton.Close).setFocus( |
|
84 Qt.FocusReason.OtherFocusReason) |
|
85 |
|
86 def on_buttonBox_clicked(self, button): |
83 def on_buttonBox_clicked(self, button): |
87 """ |
84 """ |
88 Private slot called by a button of the button box clicked. |
85 Private slot called by a button of the button box clicked. |
89 |
86 |
90 @param button button that was clicked (QAbstractButton) |
87 @param button button that was clicked (QAbstractButton) |
91 """ |
88 """ |
92 if button == self.buttonBox.button( |
89 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
93 QDialogButtonBox.StandardButton.Close |
|
94 ): |
|
95 self.close() |
90 self.close() |
96 elif button == self.buttonBox.button( |
91 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
97 QDialogButtonBox.StandardButton.Cancel |
|
98 ): |
|
99 if self.__hgClient: |
92 if self.__hgClient: |
100 self.__hgClient.cancel() |
93 self.__hgClient.cancel() |
101 else: |
94 else: |
102 self.__finish() |
95 self.__finish() |
103 |
96 |
104 def __showOutput(self, out): |
97 def __showOutput(self, out): |
105 """ |
98 """ |
106 Private slot to show some output. |
99 Private slot to show some output. |
107 |
100 |
108 @param out output to be shown (string) |
101 @param out output to be shown (string) |
109 """ |
102 """ |
110 self.messageEdit.appendPlainText(Utilities.filterAnsiSequences(out)) |
103 self.messageEdit.appendPlainText(Utilities.filterAnsiSequences(out)) |
111 |
104 |
112 def __showError(self, out): |
105 def __showError(self, out): |
113 """ |
106 """ |
114 Private slot to show some error. |
107 Private slot to show some error. |
115 |
108 |
116 @param out error to be shown (string) |
109 @param out error to be shown (string) |
117 """ |
110 """ |
118 self.messageEdit.appendPlainText(self.tr("Error: ")) |
111 self.messageEdit.appendPlainText(self.tr("Error: ")) |
119 self.messageEdit.appendPlainText(Utilities.filterAnsiSequences(out)) |
112 self.messageEdit.appendPlainText(Utilities.filterAnsiSequences(out)) |