From 65d56b3f832cc09872ff63a361956c6d2417d5be Mon Sep 17 00:00:00 2001 From: Kern Attila Germain <5556461+KernAttila@users.noreply.github.com> Date: Tue, 28 Mar 2023 22:42:10 +0200 Subject: [PATCH] feat: update `setter` attribute on `CueSelectPulldown` and add a function `setCheckedFromText` --- cuesubmit/cuesubmit/ui/Widgets.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cuesubmit/cuesubmit/ui/Widgets.py b/cuesubmit/cuesubmit/ui/Widgets.py index 395362818..d2c1ad666 100644 --- a/cuesubmit/cuesubmit/ui/Widgets.py +++ b/cuesubmit/cuesubmit/ui/Widgets.py @@ -189,7 +189,7 @@ def __init__( self.setOptions(options) self.signals = [self.optionsMenu.triggered] self.getter = self.text - self.setter = self.setText + self.setter = self.setCheckedFromText if self.multiselect: self.toolButton.setText(self.emptyText) else: @@ -248,6 +248,16 @@ def setChecked(self, actionNames): self.optionsMenu.actions()[0].setChecked(True) self.updateLabelText() + def setCheckedFromText(self, actionsAstext): + """Set the given actionNames to be checked and update the label. + @type actionNames: str + @param actionNames: list of action names to set to checked separated by a comma and a space + """ + if ', ' in text and self.multiselect: + self.setChecked(actionsAstext.split(', ')) + else: + self.setChecked([actionsAstext]) + def text(self): """Return the tool button's current text value. @rtype: str