src/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesRenamePatchDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class HgQueuesRenamePatchDialog(QDialog, Ui_HgQueuesRenamePatchDialog): 16 class HgQueuesRenamePatchDialog(QDialog, Ui_HgQueuesRenamePatchDialog):
17 """ 17 """
18 Class implementing a dialog to enter the data to rename a patch. 18 Class implementing a dialog to enter the data to rename a patch.
19 """ 19 """
20
20 def __init__(self, currentPatch, patchesList, parent=None): 21 def __init__(self, currentPatch, patchesList, parent=None):
21 """ 22 """
22 Constructor 23 Constructor
23 24
24 @param currentPatch name of the current patch (string) 25 @param currentPatch name of the current patch (string)
25 @param patchesList list of patches to select from (list of strings) 26 @param patchesList list of patches to select from (list of strings)
26 @param parent reference to the parent widget (QWidget) 27 @param parent reference to the parent widget (QWidget)
27 """ 28 """
28 super().__init__(parent) 29 super().__init__(parent)
29 self.setupUi(self) 30 self.setupUi(self)
30 31
31 self.currentButton.setText( 32 self.currentButton.setText(self.tr("Current Patch ({0})").format(currentPatch))
32 self.tr("Current Patch ({0})").format(currentPatch))
33 self.nameCombo.addItems([""] + patchesList) 33 self.nameCombo.addItems([""] + patchesList)
34 34
35 self.buttonBox.button( 35 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
36 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 36
37
38 msh = self.minimumSizeHint() 37 msh = self.minimumSizeHint()
39 self.resize(max(self.width(), msh.width()), msh.height()) 38 self.resize(max(self.width(), msh.width()), msh.height())
40 39
41 def __updateUI(self): 40 def __updateUI(self):
42 """ 41 """
43 Private slot to update the UI. 42 Private slot to update the UI.
44 """ 43 """
45 enable = self.nameEdit.text() != "" 44 enable = self.nameEdit.text() != ""
46 if self.namedButton.isChecked(): 45 if self.namedButton.isChecked():
47 enable = enable and self.nameCombo.currentText() != "" 46 enable = enable and self.nameCombo.currentText() != ""
48 47
49 self.buttonBox.button( 48 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
50 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) 49
51
52 @pyqtSlot(str) 50 @pyqtSlot(str)
53 def on_nameEdit_textChanged(self, txt): 51 def on_nameEdit_textChanged(self, txt):
54 """ 52 """
55 Private slot to handle changes of the new name. 53 Private slot to handle changes of the new name.
56 54
57 @param txt text of the edit (string) 55 @param txt text of the edit (string)
58 """ 56 """
59 self.__updateUI() 57 self.__updateUI()
60 58
61 @pyqtSlot(bool) 59 @pyqtSlot(bool)
62 def on_namedButton_toggled(self, checked): 60 def on_namedButton_toggled(self, checked):
63 """ 61 """
64 Private slot to handle changes of the selection method. 62 Private slot to handle changes of the selection method.
65 63
66 @param checked state of the check box (boolean) 64 @param checked state of the check box (boolean)
67 """ 65 """
68 self.__updateUI() 66 self.__updateUI()
69 67
70 @pyqtSlot(int) 68 @pyqtSlot(int)
71 def on_nameCombo_currentIndexChanged(self, index): 69 def on_nameCombo_currentIndexChanged(self, index):
72 """ 70 """
73 Private slot to handle changes of the selected patch name. 71 Private slot to handle changes of the selected patch name.
74 72
75 @param index current index 73 @param index current index
76 @type int 74 @type int
77 """ 75 """
78 self.__updateUI() 76 self.__updateUI()
79 77
80 def getData(self): 78 def getData(self):
81 """ 79 """
82 Public method to retrieve the entered data. 80 Public method to retrieve the entered data.
83 81
84 @return tuple of new name and selected patch (string, string) 82 @return tuple of new name and selected patch (string, string)
85 """ 83 """
86 selectedPatch = "" 84 selectedPatch = ""
87 if self.namedButton.isChecked(): 85 if self.namedButton.isChecked():
88 selectedPatch = self.nameCombo.currentText() 86 selectedPatch = self.nameCombo.currentText()
89 87
90 return self.nameEdit.text().replace(" ", "_"), selectedPatch 88 return self.nameEdit.text().replace(" ", "_"), selectedPatch

eric ide

mercurial