Skip to content

Commit

Permalink
Prevent re-firing settings toggle on very long press
Browse files Browse the repository at this point in the history
Use auto repeat to prevent re-triggering toggling the settings more than
once when very long pressing the Menu key.
  • Loading branch information
guyonvarch committed Sep 24, 2024
1 parent 3a7dba2 commit 891c1d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kiosk/kiosk_browser/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ def eventFilter(self, source, event):
# Toggle settings with a long press on the Menu key
if event.type() == QtCore.QEvent.ShortcutOverride:
if event.key() == QtCore.Qt.Key_Menu:
if self._menu_press_since is None:
if not event.isAutoRepeat():
self._menu_press_since = time.time()
elif time.time() - self._menu_press_since > self._menu_press_delay_seconds:
elif self._menu_press_since is not None and time.time() - self._menu_press_since > self._menu_press_delay_seconds:
self._menu_press_since = None
self._toggle_settings()
elif event.type() == QtCore.QEvent.KeyRelease:
if event.key() == QtCore.Qt.Key_Menu:
if event.key() == QtCore.Qt.Key_Menu and not event.isAutoRepeat():
self._menu_press_since = None

return super(MainWidget, self).eventFilter(source, event)

0 comments on commit 891c1d5

Please sign in to comment.