Compare commits
2 Commits
61115411e7
...
b0ec4487ca
Author | SHA1 | Date | |
---|---|---|---|
b0ec4487ca
|
|||
68a52d6980
|
@@ -102,6 +102,7 @@ class MainWindow(QMainWindow):
|
||||
self.setMinimumSize(800, 600)
|
||||
|
||||
self.games = []
|
||||
self.filtered_games = self.games
|
||||
self.game_processes = []
|
||||
self.target_exe = None
|
||||
self.current_running_button = None
|
||||
@@ -543,10 +544,10 @@ class MainWindow(QMainWindow):
|
||||
"""Filters games based on search text and updates the grid."""
|
||||
text = self.searchEdit.text().strip().lower()
|
||||
if text == "":
|
||||
self.updateGameGrid() # Use self.games directly
|
||||
self.filtered_games = self.games
|
||||
else:
|
||||
filtered = [game for game in self.games if text in game[0].lower()]
|
||||
self.updateGameGrid(filtered)
|
||||
self.filtered_games = [game for game in self.games if text in game[0].lower()]
|
||||
self.updateGameGrid(self.filtered_games)
|
||||
|
||||
def createInstalledTab(self):
|
||||
self.gamesLibraryWidget = QWidget()
|
||||
@@ -620,22 +621,37 @@ class MainWindow(QMainWindow):
|
||||
if games_list is None:
|
||||
games_list = self.games
|
||||
if not games_list:
|
||||
self.clearLayout(self.gamesListLayout)
|
||||
# Скрываем все карточки, если список пуст
|
||||
for card in self.game_card_cache.values():
|
||||
card.hide()
|
||||
self.game_card_cache.clear()
|
||||
self.pending_images.clear()
|
||||
self.gamesListWidget.updateGeometry()
|
||||
return
|
||||
|
||||
# Create a set of game names for quick lookup
|
||||
# Создаем словарь текущих игр для быстрого поиска
|
||||
current_games = {game_data[0]: game_data for game_data in games_list}
|
||||
|
||||
# Check if the grid is already up-to-date
|
||||
if set(current_games.keys()) == set(self.game_card_cache.keys()) and self.card_width == getattr(self, '_last_card_width', None):
|
||||
return # No changes needed, skip update
|
||||
# Проверяем, изменился ли список игр или размер карточек
|
||||
current_game_names = set(current_games.keys())
|
||||
cached_game_names = set(self.game_card_cache.keys())
|
||||
card_width_changed = self.card_width != getattr(self, '_last_card_width', None)
|
||||
|
||||
# Track if layout has changed to decide if geometry update is needed
|
||||
if current_game_names == cached_game_names and not card_width_changed:
|
||||
# Список игр и размер карточек не изменились, обновляем только видимость
|
||||
search_text = self.searchEdit.text().strip().lower()
|
||||
for game_name, card in self.game_card_cache.items():
|
||||
card.setVisible(search_text in game_name.lower() or not search_text)
|
||||
self.loadVisibleImages()
|
||||
return
|
||||
|
||||
# Обновляем размер карточек, если он изменился
|
||||
if card_width_changed:
|
||||
for card in self.game_card_cache.values():
|
||||
card.setFixedWidth(self.card_width + 20) # Учитываем extra_margin в GameCard
|
||||
|
||||
# Удаляем карточки, которых больше нет в списке
|
||||
layout_changed = False
|
||||
|
||||
# Remove cards for games no longer in the list
|
||||
for card_key in list(self.game_card_cache.keys()):
|
||||
if card_key not in current_games:
|
||||
card = self.game_card_cache.pop(card_key)
|
||||
@@ -645,11 +661,14 @@ class MainWindow(QMainWindow):
|
||||
del self.pending_images[card_key]
|
||||
layout_changed = True
|
||||
|
||||
# Add or update cards for current games
|
||||
# Добавляем новые карточки и обновляем существующие
|
||||
for game_data in games_list:
|
||||
game_name = game_data[0]
|
||||
search_text = self.searchEdit.text().strip().lower()
|
||||
should_be_visible = search_text in game_name.lower() or not search_text
|
||||
|
||||
if game_name not in self.game_card_cache:
|
||||
# Create new card
|
||||
# Создаем новую карточку
|
||||
card = GameCard(
|
||||
*game_data,
|
||||
select_callback=self.openGameDetailPage,
|
||||
@@ -657,7 +676,7 @@ class MainWindow(QMainWindow):
|
||||
card_width=self.card_width,
|
||||
context_menu_manager=self.context_menu_manager
|
||||
)
|
||||
# Connect context menu signals
|
||||
# Подключаем сигналы контекстного меню
|
||||
card.editShortcutRequested.connect(self.context_menu_manager.edit_game_shortcut)
|
||||
card.deleteGameRequested.connect(self.context_menu_manager.delete_game)
|
||||
card.addToMenuRequested.connect(self.context_menu_manager.add_to_menu)
|
||||
@@ -670,18 +689,18 @@ class MainWindow(QMainWindow):
|
||||
self.game_card_cache[game_name] = card
|
||||
self.gamesListLayout.addWidget(card)
|
||||
layout_changed = True
|
||||
elif self.card_width != getattr(self, '_last_card_width', None):
|
||||
# Update size only if card_width has changed
|
||||
else:
|
||||
# Обновляем видимость существующей карточки
|
||||
card = self.game_card_cache[game_name]
|
||||
card.setFixedWidth(self.card_width + 20) # Account for extra_margin in GameCard
|
||||
card.setVisible(should_be_visible)
|
||||
|
||||
# Store the current card_width
|
||||
# Сохраняем текущий card_width
|
||||
self._last_card_width = self.card_width
|
||||
|
||||
# Trigger lazy image loading for visible cards
|
||||
# Загружаем изображения для видимых карточек
|
||||
self.loadVisibleImages()
|
||||
|
||||
# Update layout geometry only if the layout has changed
|
||||
# Обновляем геометрию только при необходимости
|
||||
if layout_changed:
|
||||
self.gamesListWidget.updateGeometry()
|
||||
|
||||
@@ -953,7 +972,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# 5. Fullscreen setting for application
|
||||
self.fullscreenCheckBox = QCheckBox(_("Launch Application in Fullscreen"))
|
||||
#self.fullscreenCheckBox.setStyleSheet(self.theme.SETTINGS_CHECKBOX_STYLE)
|
||||
self.fullscreenCheckBox.setStyleSheet(self.theme.SETTINGS_CHECKBOX_STYLE)
|
||||
self.fullscreenCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
self.fullscreenTitle = QLabel(_("Application Fullscreen Mode:"))
|
||||
self.fullscreenTitle.setStyleSheet(self.theme.PARAMS_TITLE_STYLE)
|
||||
@@ -965,6 +984,7 @@ class MainWindow(QMainWindow):
|
||||
# 6. Automatic fullscreen on gamepad connection
|
||||
self.autoFullscreenGamepadCheckBox = QCheckBox(_("Auto Fullscreen on Gamepad connected"))
|
||||
self.autoFullscreenGamepadCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
self.autoFullscreenGamepadCheckBox.setStyleSheet(self.theme.SETTINGS_CHECKBOX_STYLE)
|
||||
self.autoFullscreenGamepadTitle = QLabel(_("Auto Fullscreen on Gamepad connected:"))
|
||||
self.autoFullscreenGamepadTitle.setStyleSheet(self.theme.PARAMS_TITLE_STYLE)
|
||||
self.autoFullscreenGamepadTitle.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
|
@@ -22,35 +22,35 @@ class SystemOverlay(QDialog):
|
||||
|
||||
# Reboot button
|
||||
reboot_button = QPushButton(_("Reboot"))
|
||||
#reboot_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
reboot_button.setStyleSheet(self.theme.OVERLAY_BUTTON_STYLE)
|
||||
reboot_button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
reboot_button.clicked.connect(self.reboot)
|
||||
layout.addWidget(reboot_button)
|
||||
|
||||
# Shutdown button
|
||||
shutdown_button = QPushButton(_("Shutdown"))
|
||||
#shutdown_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
shutdown_button.setStyleSheet(self.theme.OVERLAY_BUTTON_STYLE)
|
||||
shutdown_button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
shutdown_button.clicked.connect(self.shutdown)
|
||||
layout.addWidget(shutdown_button)
|
||||
|
||||
# Suspend button
|
||||
suspend_button = QPushButton(_("Suspend"))
|
||||
#suspend_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
suspend_button.setStyleSheet(self.theme.OVERLAY_BUTTON_STYLE)
|
||||
suspend_button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
suspend_button.clicked.connect(self.suspend)
|
||||
layout.addWidget(suspend_button)
|
||||
|
||||
# Exit application button
|
||||
exit_button = QPushButton(_("Exit Application"))
|
||||
#exit_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
exit_button.setStyleSheet(self.theme.OVERLAY_BUTTON_STYLE)
|
||||
exit_button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
exit_button.clicked.connect(self.exit_application)
|
||||
layout.addWidget(exit_button)
|
||||
|
||||
# Cancel button
|
||||
cancel_button = QPushButton(_("Cancel"))
|
||||
#cancel_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
cancel_button.setStyleSheet(self.theme.OVERLAY_BUTTON_STYLE)
|
||||
cancel_button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
cancel_button.clicked.connect(self.reject)
|
||||
layout.addWidget(cancel_button)
|
||||
|
@@ -90,6 +90,13 @@ SEARCH_EDIT_STYLE = """
|
||||
}
|
||||
"""
|
||||
|
||||
SETTINGS_CHECKBOX_STYLE = """
|
||||
QCheckBox:focus {
|
||||
border: 2px solid #409EFF;
|
||||
background: #404554;
|
||||
}
|
||||
"""
|
||||
|
||||
# ОТКЛЮЧАЕМ РАМКУ У QScrollArea
|
||||
SCROLL_AREA_STYLE = """
|
||||
QWidget {
|
||||
@@ -206,6 +213,28 @@ ACTION_BUTTON_STYLE = """
|
||||
}
|
||||
"""
|
||||
|
||||
# СТИЛЬ КНОПОК ОВЕРЛЕЯ
|
||||
OVERLAY_BUTTON_STYLE = """
|
||||
QPushButton {
|
||||
background: #3f424d;
|
||||
border: 1px solid rgba(255, 255, 255, 0.20);
|
||||
border-radius: 10px;
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
font-family: 'Play';
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #282a33;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #282a33;
|
||||
}
|
||||
QPushButton:focus {
|
||||
border: 2px solid #409EFF;
|
||||
background-color: #404554;
|
||||
}
|
||||
"""
|
||||
|
||||
# ТЕКСТОВЫЕ СТИЛИ: ЗАГОЛОВКИ И ОСНОВНОЙ КОНТЕНТ
|
||||
TAB_TITLE_STYLE = "font-family: 'Play'; font-size: 24px; color: #ffffff; background-color: none;"
|
||||
CONTENT_STYLE = """
|
||||
|
Reference in New Issue
Block a user