Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoadingWidget: Start playing movie once the widget is visible if autostart is enabled #400

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rare/components/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from logging import getLogger

from PyQt5.QtCore import Qt, QSettings, QTimer, QSize, pyqtSignal, pyqtSlot
from PyQt5.QtGui import QCloseEvent, QCursor, QShowEvent
from PyQt5.QtGui import QCloseEvent, QCursor
from PyQt5.QtWidgets import (
QMainWindow,
QApplication,
Expand Down
1 change: 0 additions & 1 deletion rare/components/tabs/games/game_widgets/game_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def paintEvent(self, a0: QPaintEvent) -> None:
self.startTimer(random.randrange(42, 2361, 129), Qt.CoarseTimer)
# self.startTimer(random.randrange(42, 2361, 363), Qt.VeryCoarseTimer)
# self.rgame.load_pixmap()
# QTimer.singleShot(random.randrange(42, 2361, 7), Qt.VeryCoarseTimer, self.rgame.load_pixmap)
super().paintEvent(a0)

def timerEvent(self, a0):
Expand Down
9 changes: 6 additions & 3 deletions rare/widgets/loading_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def __init__(self, autostart=False, parent=None):
self.setMovie(self.movie)
if self.parent() is not None:
self.parent().installEventFilter(self)
if autostart:
self.movie.start()
self.autostart = autostart

def __center_on_parent(self):
rect = self.rect()
Expand All @@ -34,6 +33,9 @@ def event(self, e: QEvent) -> bool:
def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
if self.autostart:
self.movie.start()
self.autostart = False
self.__center_on_parent()
super().showEvent(a0)

Expand All @@ -45,7 +47,8 @@ def eventFilter(self, a0: QObject, a1: QEvent) -> bool:

def start(self):
self.setVisible(True)
self.movie.start()
if not self.autostart:
self.movie.start()

def stop(self):
self.setVisible(False)
Expand Down
Loading