|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter data to be used for a fetch operation. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import pyqtSlot |
|
13 from PyQt5.QtWidgets import QDialog |
|
14 |
|
15 from .Ui_HgFetchDialog import Ui_HgFetchDialog |
|
16 |
|
17 |
|
18 class HgFetchDialog(QDialog, Ui_HgFetchDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter data to be used for a fetch operation. |
|
21 """ |
|
22 def __init__(self, vcs, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param vcs reference to the Mercurial vcs object |
|
27 @type Hg |
|
28 @param parent reference to the parent widget |
|
29 @type QWidget |
|
30 """ |
|
31 super(HgFetchDialog, self).__init__(parent) |
|
32 self.setupUi(self) |
|
33 |
|
34 self.__vcs = vcs |
|
35 |
|
36 commitMessages = self.__vcs.getPlugin().getPreferences('Commits') |
|
37 self.recentComboBox.clear() |
|
38 self.recentComboBox.addItem("") |
|
39 for message in commitMessages: |
|
40 abbrMsg = message[:60] |
|
41 if len(message) > 60: |
|
42 abbrMsg += "..." |
|
43 self.recentComboBox.addItem(abbrMsg, message) |
|
44 |
|
45 @pyqtSlot(str) |
|
46 def on_recentComboBox_activated(self, txt): |
|
47 """ |
|
48 Private slot to select a commit message from recent ones. |
|
49 |
|
50 @param txt text of the selected entry (string) |
|
51 """ |
|
52 if txt: |
|
53 self.messageEdit.setPlainText(self.recentComboBox.currentData()) |
|
54 |
|
55 def getData(self): |
|
56 """ |
|
57 Public method to get the data for the fetch operation. |
|
58 |
|
59 @return tuple with the commit message and a flag indicating to switch |
|
60 the merge order (string, boolean) |
|
61 """ |
|
62 msg = self.messageEdit.toPlainText() |
|
63 if msg: |
|
64 commitMessages = self.__vcs.getPlugin().getPreferences('Commits') |
|
65 if msg in commitMessages: |
|
66 commitMessages.remove(msg) |
|
67 commitMessages.insert(0, msg) |
|
68 no = self.__vcs.getPlugin().getPreferences("CommitMessages") |
|
69 del commitMessages[no:] |
|
70 self.__vcs.getPlugin().setPreferences( |
|
71 'Commits', commitMessages) |
|
72 |
|
73 return msg, self.switchCheckBox.isChecked() |