diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index 9ab852d56..433776aad 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1263,11 +1263,15 @@ def enable(self): self.toggled.connect(self.on_toggle) def eventFilter(self, obj, event): + checkable = self.isCheckable() t = event.type() - if t == QEvent.HoverEnter: + if t == QEvent.HoverEnter and checkable: self.setIcon(load_icon('star_hover.svg')) elif t == QEvent.HoverLeave: - self.set_icon(on='star_on.svg', off='star_off.svg') + if checkable: + self.set_icon(on='star_on.svg', off='star_off.svg') + else: + self.set_icon(on='star_on.svg', off='star_on.svg') return QObject.event(obj, event) def on_authentication_changed(self, authenticated: bool): diff --git a/tests/gui/test_widgets.py b/tests/gui/test_widgets.py index c7b3fa7cb..745c58326 100644 --- a/tests/gui/test_widgets.py +++ b/tests/gui/test_widgets.py @@ -1107,6 +1107,12 @@ def test_StarToggleButton_eventFilter(mocker): stb.eventFilter(stb, test_event) stb.set_icon.assert_called_once_with(on='star_on.svg', off='star_off.svg') + # Hover leave when disabled + stb.disable() + test_event = QEvent(QEvent.HoverLeave) + stb.eventFilter(stb, test_event) + stb.set_icon.assert_called_with(on='star_on.svg', off='star_on.svg') + def test_StarToggleButton_on_authentication_changed_while_authenticated_and_checked(mocker): """