Skip to content

Commit

Permalink
Skip widget updates on spontaneous events.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
loathingKernel committed Nov 20, 2023
1 parent 64b9acf commit 94d9c25
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rare/components/dialogs/install_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions rare/components/tabs/games/game_widgets/game_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions rare/components/tabs/games/game_widgets/library_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions rare/components/tabs/games/integrations/ubisoft_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions rare/components/tabs/settings/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions rare/widgets/loading_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 94d9c25

Please sign in to comment.