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

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

eric ide

mercurial