fix: fix card overlap on display_filter change

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
2025-10-13 12:14:54 +05:00
parent 987199d8e6
commit b1047ba18e
2 changed files with 51 additions and 19 deletions

View File

@@ -56,6 +56,16 @@ class GameLibraryManager:
self.is_filtering = False
self.dirty = False
def force_update_cards_library(self):
if self.gamesListWidget and self.gamesListLayout:
self.gamesListLayout.invalidate()
self.gamesListWidget.updateGeometry()
widget = self.gamesListWidget
QTimer.singleShot(0, lambda: (
widget.adjustSize(),
widget.updateGeometry()
))
def create_games_library_widget(self):
"""Creates the games library widget with search, grid, and slider."""
self.gamesLibraryWidget = QWidget()
@@ -346,6 +356,8 @@ class GameLibraryManager:
self.gamesListWidget.updateGeometry()
self.main_window._last_card_width = self.card_width
self.force_update_cards_library()
self.is_filtering = False # Reset flag in any case
def _apply_filter_visibility(self, search_text: str):
@@ -453,11 +465,3 @@ class GameLibraryManager:
def filter_games_delayed(self):
"""Filters games based on search text and updates the grid."""
self.update_game_grid(is_filter=True)
def calculate_columns(self, card_width: int) -> int:
"""Calculate the number of columns based on card width and assumed container width."""
# Assuming a typical container width; adjust as needed
available_width = 1200 # Example width, can be dynamic if widget access is added
spacing = 15 # Assumed spacing between cards
columns = max(1, (available_width - spacing) // (card_width + spacing))
return min(columns, 8) # Cap at reasonable max

View File

@@ -100,6 +100,7 @@ class MainWindow(QMainWindow):
self.games_load_timer.timeout.connect(self.finalize_game_loading)
self.games_loaded.connect(self.on_games_loaded)
self.current_add_game_dialog = None
self.current_display_filter = read_display_filter()
self.settingsDebounceTimer = QTimer(self)
self.settingsDebounceTimer.setSingleShot(True)
@@ -820,6 +821,24 @@ class MainWindow(QMainWindow):
for i, btn in self.tabButtons.items():
btn.setChecked(i == index)
self.stackedWidget.setCurrentIndex(index)
if hasattr(self, "game_library_manager"):
mgr = self.game_library_manager
if mgr.gamesListWidget and mgr.gamesListLayout:
layout = mgr.gamesListLayout
widget = mgr.gamesListWidget
QTimer.singleShot(0, lambda: (
layout.invalidate(),
widget.adjustSize(),
widget.updateGeometry()
))
if hasattr(self, "autoInstallContainer") and hasattr(self, "autoInstallContainerLayout"):
layout = self.autoInstallContainerLayout
widget = self.autoInstallContainer
QTimer.singleShot(0, lambda: (
layout.invalidate(),
widget.adjustSize(),
widget.updateGeometry()
))
def openSystemOverlay(self):
"""Opens the system overlay dialog."""
@@ -1978,9 +1997,12 @@ class MainWindow(QMainWindow):
def applySettingsDelayed(self):
read_time_config()
display_filter = read_display_filter()
reload_needed = display_filter != self.current_display_filter
if reload_needed:
self.games = []
self.loadGames()
display_filter = read_display_filter()
self.current_display_filter = display_filter
for card in self.game_library_manager.game_card_cache.values():
card.update_badge_visibility(display_filter)
@@ -1995,6 +2017,10 @@ class MainWindow(QMainWindow):
filter_idx = self.gamesDisplayCombo.currentIndex()
filter_key = self.filter_keys[filter_idx]
old_filter = self.current_display_filter
save_display_filter(filter_key)
save_display_filter(filter_key)
proxy_url = self.proxyUrlEdit.text().strip()
@@ -2011,6 +2037,7 @@ class MainWindow(QMainWindow):
rumble_enabled = self.gamepadRumbleCheckBox.isChecked()
save_rumble_config(rumble_enabled)
if filter_key != old_filter:
for card in self.game_library_manager.game_card_cache.values():
card.update_badge_visibility(filter_key)
@@ -2022,6 +2049,7 @@ class MainWindow(QMainWindow):
self.currentDetailPage = None
self.openGameDetailPage(*current_game)
self.current_display_filter = filter_key
self.settingsDebounceTimer.start()
gamepad_connected = self.input_manager.find_gamepad() is not None