diff -r 640778fcd474 -r 9fe8cfa14542 eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py --- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py Wed Apr 13 18:16:23 2022 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py Wed Apr 13 19:49:25 2022 +0200 @@ -25,11 +25,16 @@ """ Constructor - @param mode of the dialog (integer) - @param tagsList list of tags (list of strings) - @param branchesList list of branches (list of strings) - @param bookmarksList list of bookmarks (list of strings) - @param parent reference to the parent widget (QWidget) + @param mode of the dialog + @type int + @param tagsList list of tags + @type list of str + @param branchesList list of branches + @type list of str + @param bookmarksList list of bookmarks + @type list of str + @param parent parent widget + @type QWidget """ super().__init__(parent) self.setupUi(self) @@ -52,26 +57,48 @@ self.branchCombo.addItems(["default"] + sorted(branchesList)) self.bookmarkCombo.addItems(sorted(bookmarksList)) + # connect various radio buttons and input fields + self.idButton.toggled.connect(self.__updateOK) + self.tagButton.toggled.connect(self.__updateOK) + self.branchButton.toggled.connect(self.__updateOK) + self.bookmarkButton.toggled.connect(self.__updateOK) + self.expressionButton.toggled.connect(self.__updateOK) + + self.nameCombo.activated.connect(self.__updateOK) + self.nameCombo.activated.connect(self.__updateBookmarksCombo) + + self.nameEdit.textChanged.connect(self.__updateOK) + self.idEdit.textChanged.connect(self.__updateOK) + self.expressionEdit.textChanged.connect(self.__updateOK) + + self.tagCombo.editTextChanged.connect(self.__updateOK) + self.branchCombo.editTextChanged.connect(self.__updateOK) + self.bookmarkCombo.editTextChanged.connect(self.__updateOK) + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) + @pyqtSlot() def __updateOK(self): """ Private slot to update the OK button. """ enabled = ( - self.nameCombo.currentText() != "" + bool(self.nameCombo.currentText()) if self.__mode == self.MOVE_MODE else - self.nameEdit.text() != "" + bool(self.nameEdit.text()) ) + if self.idButton.isChecked(): - enabled = enabled and self.idEdit.text() != "" + enabled = bool(self.idEdit.text()) elif self.tagButton.isChecked(): - enabled = enabled and self.tagCombo.currentText() != "" + enabled = bool(self.tagCombo.currentText()) elif self.branchButton.isChecked(): - enabled = enabled and self.branchCombo.currentText() != "" + enabled = bool(self.branchCombo.currentText()) elif self.bookmarkButton.isChecked(): - enabled = enabled and self.bookmarkCombo.currentText() != "" + enabled = bool(self.bookmarkCombo.currentText()) + elif self.expressionButton.isChecked(): + enabled = enabled and bool(self.expressionEdit.text()) self.buttonBox.button( QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) @@ -94,104 +121,12 @@ if index > -1: self.bookmarkCombo.setCurrentIndex(index) - @pyqtSlot(int) - def on_nameCombo_activated(self, index): - """ - Private slot to handle changes of the selected bookmark name. - - @param index index of the selected entry - @type int - """ - self.__updateOK() - self.__updateBookmarksCombo() - - @pyqtSlot(str) - def on_nameEdit_textChanged(self, txt): - """ - Private slot to handle changes of the bookmark name. - - @param txt text of the edit (string) - """ - self.__updateOK() - - @pyqtSlot(bool) - def on_idButton_toggled(self, checked): - """ - Private slot to handle changes of the ID select button. - - @param checked state of the button (boolean) - """ - self.__updateOK() - - @pyqtSlot(bool) - def on_tagButton_toggled(self, checked): - """ - Private slot to handle changes of the Tag select button. - - @param checked state of the button (boolean) - """ - self.__updateOK() - - @pyqtSlot(bool) - def on_branchButton_toggled(self, checked): - """ - Private slot to handle changes of the Branch select button. - - @param checked state of the button (boolean) - """ - self.__updateOK() - - @pyqtSlot(bool) - def on_bookmarkButton_toggled(self, checked): - """ - Private slot to handle changes of the Bookmark select button. - - @param checked state of the button (boolean) - """ - self.__updateOK() - - @pyqtSlot(str) - def on_idEdit_textChanged(self, txt): - """ - Private slot to handle changes of the ID edit. - - @param txt text of the edit (string) - """ - self.__updateOK() - - @pyqtSlot(str) - def on_tagCombo_editTextChanged(self, txt): - """ - Private slot to handle changes of the Tag combo. - - @param txt text of the combo (string) - """ - self.__updateOK() - - @pyqtSlot(str) - def on_branchCombo_editTextChanged(self, txt): - """ - Private slot to handle changes of the Branch combo. - - @param txt text of the combo (string) - """ - self.__updateOK() - - @pyqtSlot(str) - def on_bookmarkCombo_editTextChanged(self, txt): - """ - Private slot to handle changes of the Bookmark combo. - - @param txt text of the combo (string) - """ - self.__updateOK() - def getData(self): """ Public method to retrieve the entered data. @return tuple naming the revision and the bookmark name - (string, string) + @rtype tuple of (str, str) """ if self.numberButton.isChecked(): rev = "rev({0})".format(self.numberSpinBox.value()) @@ -203,6 +138,8 @@ rev = self.branchCombo.currentText() elif self.bookmarkButton.isChecked(): rev = self.bookmarkCombo.currentText() + elif self.expressionButton.isChecked(): + rev = self.expressionEdit.text() else: rev = ""