diff --git a/portprotonqt/dialogs.py b/portprotonqt/dialogs.py index b89a2bf..7dd6df2 100644 --- a/portprotonqt/dialogs.py +++ b/portprotonqt/dialogs.py @@ -510,8 +510,8 @@ class FileExplorer(QDialog): """Update the list of mounted drives and favorite folders.""" for i in reversed(range(self.drives_layout.count())): item = self.drives_layout.itemAt(i) - if item and item.widget(): - widget = item.widget() + widget = item.widget() if item else None + if widget: self.drives_layout.removeWidget(widget) widget.deleteLater() diff --git a/portprotonqt/game_card.py b/portprotonqt/game_card.py index e10e132..0ef20c1 100644 --- a/portprotonqt/game_card.py +++ b/portprotonqt/game_card.py @@ -1,7 +1,6 @@ from PySide6.QtGui import QPainter, QColor, QDesktopServices from PySide6.QtCore import Signal, Property, Qt, QUrl from PySide6.QtWidgets import QFrame, QGraphicsDropShadowEffect, QVBoxLayout, QWidget, QStackedLayout, QLabel -from collections.abc import Callable from portprotonqt.image_utils import load_pixmap_async, round_corners from portprotonqt.localization import _ from portprotonqt.config_utils import read_favorites, save_favorites, read_display_filter, read_theme_from_config @@ -10,7 +9,6 @@ from portprotonqt.custom_widgets import ClickableLabel from portprotonqt.portproton_api import PortProtonAPI from portprotonqt.downloader import Downloader from portprotonqt.animations import GameCardAnimations -from typing import cast class GameCard(QFrame): borderWidthChanged = Signal() @@ -443,9 +441,9 @@ class GameCard(QFrame): self.update_scale() self.scaleChanged.emit() - borderWidth = Property(int, getBorderWidth, setBorderWidth, None, "", notify=cast(Callable[[], None], borderWidthChanged)) - gradientAngle = Property(float, getGradientAngle, setGradientAngle, None, "", notify=cast(Callable[[], None], gradientAngleChanged)) - scale = Property(float, getScale, setScale, None, "", notify=cast(Callable[[], None], scaleChanged)) + borderWidth = Property(int, getBorderWidth, setBorderWidth, notify=borderWidthChanged) + gradientAngle = Property(float, getGradientAngle, setGradientAngle, notify=gradientAngleChanged) + scale = Property(float, getScale, setScale, notify=scaleChanged) def paintEvent(self, event): super().paintEvent(event) diff --git a/portprotonqt/main_window.py b/portprotonqt/main_window.py index 2d8ac84..48b4240 100644 --- a/portprotonqt/main_window.py +++ b/portprotonqt/main_window.py @@ -2066,10 +2066,19 @@ class MainWindow(QMainWindow): completionist_time = hltb.format_game_time(game, "completionist") # Очищаем layout перед добавлением новых элементов - while hltbLayout.count(): - child = hltbLayout.takeAt(0) - if child.widget(): - child.widget().deleteLater() + def clear_layout(layout): + while layout.count(): + item = layout.takeAt(0) + widget = item.widget() + sublayout = item.layout() + if widget: + widget.deleteLater() + elif sublayout: + clear_layout(sublayout) + + clear_layout(hltbLayout) + + has_data = False @@ -2537,7 +2546,7 @@ class MainWindow(QMainWindow): self.settingsDebounceTimer.stop() if hasattr(self, 'searchDebounceTimer') and self.searchDebounceTimer.isActive(): self.searchDebounceTimer.stop() - if hasattr(self, 'checkProcessTimer') and self.checkProcessTimer and self.checkProcessTimer.isActive(): + if hasattr(self, 'checkProcessTimer') and self.checkProcessTimer is not None and self.checkProcessTimer.isActive(): self.checkProcessTimer.stop() self.checkProcessTimer.deleteLater() self.checkProcessTimer = None