From 94d9c257ec3a037c7df59a66f75581bf1fb1aa31 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:17:30 +0300 Subject: [PATCH] Skip widget updates on spontaneous events. Spontaneous are events external to the application such as the window manager showing or hiding the application. We don't want to update on those. --- rare/components/dialogs/install_dialog.py | 2 ++ rare/components/tabs/games/game_widgets/game_widget.py | 2 ++ rare/components/tabs/games/game_widgets/library_widget.py | 3 +++ rare/components/tabs/games/integrations/ubisoft_group.py | 3 +++ rare/components/tabs/settings/about.py | 2 ++ rare/widgets/loading_widget.py | 3 +++ 6 files changed, 15 insertions(+) diff --git a/rare/components/dialogs/install_dialog.py b/rare/components/dialogs/install_dialog.py index 050c57847..98383ec1d 100644 --- a/rare/components/dialogs/install_dialog.py +++ b/rare/components/dialogs/install_dialog.py @@ -173,6 +173,8 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None): self.ui.install_dialog_layout.setSizeConstraint(QLayout.SetFixedSize) def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) self.save_install_edit(self.install_dir_edit.text()) super().showEvent(a0) diff --git a/rare/components/tabs/games/game_widgets/game_widget.py b/rare/components/tabs/games/game_widgets/game_widget.py index d71bc20bf..3390a3ac9 100644 --- a/rare/components/tabs/games/game_widgets/game_widget.py +++ b/rare/components/tabs/games/game_widgets/game_widget.py @@ -107,6 +107,8 @@ def __init__(self, rgame: RareGame, parent=None): __slots__ = "ui" def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) if self.rgame.pixmap.isNull(): QTimer.singleShot(random.randrange(42, 361, 7), self.rgame.load_pixmap) super().showEvent(a0) diff --git a/rare/components/tabs/games/game_widgets/library_widget.py b/rare/components/tabs/games/game_widgets/library_widget.py index 3cc108a75..15f69e49e 100644 --- a/rare/components/tabs/games/game_widgets/library_widget.py +++ b/rare/components/tabs/games/game_widgets/library_widget.py @@ -32,7 +32,10 @@ def event(self, e: QEvent) -> bool: return super().event(e) def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) self.__center_on_parent() + super().showEvent(a0) def eventFilter(self, a0: QObject, a1: QEvent) -> bool: if a0 is self.parent() and a1.type() == QEvent.Resize: diff --git a/rare/components/tabs/games/integrations/ubisoft_group.py b/rare/components/tabs/games/integrations/ubisoft_group.py index 010e0669a..ca4070d36 100644 --- a/rare/components/tabs/games/integrations/ubisoft_group.py +++ b/rare/components/tabs/games/integrations/ubisoft_group.py @@ -184,6 +184,9 @@ def __init__(self, parent=None): layout.addWidget(self.loading_widget) def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) + if self.worker is not None: return diff --git a/rare/components/tabs/settings/about.py b/rare/components/tabs/settings/about.py index fa5d79440..2157134e9 100644 --- a/rare/components/tabs/settings/about.py +++ b/rare/components/tabs/settings/about.py @@ -46,6 +46,8 @@ def __init__(self, parent=None): self.update_available = False def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) self.manager.get( "https://api.github.com/repos/Dummerle/Rare/releases/latest", self.update_available_finished, diff --git a/rare/widgets/loading_widget.py b/rare/widgets/loading_widget.py index 24d5e542f..fc3d6fc53 100644 --- a/rare/widgets/loading_widget.py +++ b/rare/widgets/loading_widget.py @@ -32,7 +32,10 @@ def event(self, e: QEvent) -> bool: return super().event(e) def showEvent(self, a0: QShowEvent) -> None: + if a0.spontaneous(): + return super().showEvent(a0) self.__center_on_parent() + super().showEvent(a0) def eventFilter(self, a0: QObject, a1: QEvent) -> bool: if a0 is self.parent() and a1.type() == QEvent.Resize: