From 372b2761574491b7799382650749d17ec18d8b00 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Thu, 2 Mar 2023 19:57:31 +0200 Subject: [PATCH] [Icon/List]Widget: Disable focus on buttons When the button gets clicked on, it receives keyboard focus. Disabling the button afterwards leads to `focusNextChild` getting called. This makes the scrollarea trying to ensure that `nextChild` is visible, essentially scrolling to a random widget --- rare/components/tabs/games/game_widgets/icon_widget.py | 7 +++++++ rare/components/tabs/games/game_widgets/list_widget.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/rare/components/tabs/games/game_widgets/icon_widget.py b/rare/components/tabs/games/game_widgets/icon_widget.py index 4584002a..0cbf6ac1 100644 --- a/rare/components/tabs/games/game_widgets/icon_widget.py +++ b/rare/components/tabs/games/game_widgets/icon_widget.py @@ -69,6 +69,13 @@ class IconWidget(object): self.install_btn.setIconSize(QSize(20, 20)) self.install_btn.setFixedSize(QSize(widget.width() // 4, widget.width() // 4)) + # lk: do not focus on button + # When the button gets clicked on, it receives keyboard focus. Disabling the button + # afterwards leads to `focusNextChild` getting called. This makes the scrollarea + # trying to ensure that `nextChild` is visible, essentially scrolling to a random widget + self.launch_btn.setFocusPolicy(Qt.NoFocus) + self.install_btn.setFocusPolicy(Qt.NoFocus) + # Create layouts # layout on top of the image, holds the status label, a spacer item and the mini widget image_layout = QVBoxLayout() diff --git a/rare/components/tabs/games/game_widgets/list_widget.py b/rare/components/tabs/games/game_widgets/list_widget.py index 402d580f..78cfcbf3 100644 --- a/rare/components/tabs/games/game_widgets/list_widget.py +++ b/rare/components/tabs/games/game_widgets/list_widget.py @@ -50,6 +50,13 @@ class ListWidget(object): self.launch_btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.launch_btn.setFixedWidth(120) + # lk: do not focus on button + # When the button gets clicked on, it receives keyboard focus. Disabling the button + # afterwards leads to `focusNextChild` getting called. This makes the scrollarea + # trying to ensure that `nextChild` is visible, essentially scrolling to a random widget + self.launch_btn.setFocusPolicy(Qt.NoFocus) + self.install_btn.setFocusPolicy(Qt.NoFocus) + self.developer_label = ElideLabel(parent=widget) self.developer_label.setObjectName(f"{type(self).__name__}DeveloperLabel") self.developer_label.setFixedWidth(120)