src/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkRenameDialog.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 get the data to rename a bookmark.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgBookmarkRenameDialog import Ui_HgBookmarkRenameDialog
14
15
16 class HgBookmarkRenameDialog(QDialog, Ui_HgBookmarkRenameDialog):
17 """
18 Class implementing a dialog to get the data to rename a bookmark.
19 """
20 def __init__(self, bookmarksList, parent=None):
21 """
22 Constructor
23
24 @param bookmarksList list of bookmarks (list of strings)
25 @param parent reference to the parent widget (QWidget)
26 """
27 super().__init__(parent)
28 self.setupUi(self)
29
30 self.buttonBox.button(
31 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
32
33 self.bookmarkCombo.addItems(sorted(bookmarksList))
34
35 msh = self.minimumSizeHint()
36 self.resize(max(self.width(), msh.width()), msh.height())
37
38 def __updateUI(self):
39 """
40 Private slot to update the UI.
41 """
42 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
43 self.nameEdit.text() != "" and
44 self.bookmarkCombo.currentText() != ""
45 )
46
47 @pyqtSlot(str)
48 def on_nameEdit_textChanged(self, txt):
49 """
50 Private slot to handle changes of the bookmark name.
51
52 @param txt text of the edit (string)
53 """
54 self.__updateUI()
55
56 @pyqtSlot(str)
57 def on_bookmarkCombo_editTextChanged(self, txt):
58 """
59 Private slot to handle changes of the selected bookmark.
60
61 @param txt name of the selected bookmark (string)
62 """
63 self.__updateUI()
64
65 def getData(self):
66 """
67 Public method to retrieve the entered data.
68
69 @return tuple naming the old and new bookmark names
70 (string, string)
71 """
72 return (
73 self.bookmarkCombo.currentText().replace(" ", "_"),
74 self.nameEdit.text().replace(" ", "_"),
75 )

eric ide

mercurial