From fea07e19fe9c09fe09d3c9af182d63d5be5518d9 Mon Sep 17 00:00:00 2001 From: dervart Date: Sat, 21 Jun 2025 22:33:03 +0700 Subject: [PATCH] reworked styles to look the same in normal use and gamescope session --- portprotonqt/main_window.py | 69 +++++++++++++------------- portprotonqt/themes/standart/styles.py | 65 +++++++++++++++++++----- 2 files changed, 88 insertions(+), 46 deletions(-) diff --git a/portprotonqt/main_window.py b/portprotonqt/main_window.py index 6120de2..5e39059 100644 --- a/portprotonqt/main_window.py +++ b/portprotonqt/main_window.py @@ -53,7 +53,40 @@ class MainWindow(QMainWindow): def __init__(self): super().__init__() + # Создаём менеджер тем и читаем, какая тема выбрана + self.theme_manager = ThemeManager() + selected_theme = read_theme_from_config() + self.current_theme_name = selected_theme + try: + self.theme = self.theme_manager.apply_theme(selected_theme) + except FileNotFoundError: + logger.warning(f"Тема '{selected_theme}' не найдена, применяется стандартная тема 'standart'") + self.theme = self.theme_manager.apply_theme("standart") + self.current_theme_name = "standart" + save_theme_to_config("standart") + if not self.theme: + self.theme = default_styles + self.card_width = read_card_size() + self.setWindowTitle("PortProtonQt") + self.setMinimumSize(800, 600) + + self.games = [] + self.filtered_games = self.games + self.game_processes = [] + self.target_exe = None + self.current_running_button = None + self.portproton_location = get_portproton_location() + + self.context_menu_manager = ContextMenuManager( + self, + self.portproton_location, + self.theme, + self.loadGames, + self.updateGameGrid + ) + QApplication.setStyle("Fusion") + self.setStyleSheet(self.theme.MAIN_WINDOW_STYLE) self.setAcceptDrops(True) self.current_exec_line = None self.currentDetailPage = None @@ -88,41 +121,11 @@ class MainWindow(QMainWindow): self.legendary_path = os.path.join(self.legendary_config_path, "legendary") self.downloader = Downloader(max_workers=4) - # Создаём менеджер тем и читаем, какая тема выбрана - self.theme_manager = ThemeManager() - selected_theme = read_theme_from_config() - self.current_theme_name = selected_theme - try: - self.theme = self.theme_manager.apply_theme(selected_theme) - except FileNotFoundError: - logger.warning(f"Тема '{selected_theme}' не найдена, применяется стандартная тема 'standart'") - self.theme = self.theme_manager.apply_theme("standart") - self.current_theme_name = "standart" - save_theme_to_config("standart") - if not self.theme: - self.theme = default_styles - self.card_width = read_card_size() - self.setWindowTitle("PortProtonQt") - self.setMinimumSize(800, 600) - - self.games = [] - self.filtered_games = self.games - self.game_processes = [] - self.target_exe = None - self.current_running_button = None - self.portproton_location = get_portproton_location() - - self.context_menu_manager = ContextMenuManager( - self, - self.portproton_location, - self.theme, - self.loadGames, - self.updateGameGrid - ) - # Статус-бар self.setStatusBar(QStatusBar(self)) + self.statusBar().setStyleSheet(self.theme.STATUS_BAR_STYLE) self.progress_bar = QProgressBar() + self.progress_bar.setStyleSheet(self.theme.PROGRESS_BAR_STYLE) self.progress_bar.setMaximumWidth(200) self.progress_bar.setTextVisible(True) self.progress_bar.setVisible(False) @@ -203,8 +206,6 @@ class MainWindow(QMainWindow): self.restore_state() - self.setStyleSheet(self.theme.MAIN_WINDOW_STYLE) - self.setStyleSheet(self.theme.MESSAGE_BOX_STYLE) self.input_manager = InputManager(self) QTimer.singleShot(0, self.loadGames) diff --git a/portprotonqt/themes/standart/styles.py b/portprotonqt/themes/standart/styles.py index 0c01cba..daf4861 100644 --- a/portprotonqt/themes/standart/styles.py +++ b/portprotonqt/themes/standart/styles.py @@ -108,6 +108,55 @@ CONTEXT_MENU_STYLE = """ } """ +# ГЛОБАЛЬНЫЙ СТИЛЬ ДЛЯ ОКНА (ФОН), ЛЭЙБЛОВ, КНОПОК +MAIN_WINDOW_STYLE = """ + QWidget { + background: #282a33; + } + QLabel { + color: #ffffff; + } + QPushButton { + background: #3f424d; + border: 2px solid rgba(255, 255, 255, 0.01); + border-radius: 10px; + color: #ffffff; + font-size: 16px; + font-family: 'Play'; + padding: 8px 16px; + } + QPushButton:hover { + background: #409EFF; + border: 2px solid #409EFF; + } + QPushButton:pressed { + background: #282a33; + } + QPushButton:focus { + border: 2px solid #409EFF; + background-color: #409EFF; + } +""" + +# СТИЛЬ ПРОГРЕСС-БАРА +PROGRESS_BAR_STYLE = """ + QProgressBar { + color: #ffffff; + background-color: #3f424d; + text-align: center; + } + QProgressBar::chunk { + background-color: #409EFF; + } +""" + +# СТИЛЬ СТАТУС-БАРА +STATUS_BAR_STYLE = """ + QStatusBar { + color: #ffffff; + } +""" + # СТИЛЬ ШАПКИ ГЛАВНОГО ОКНА MAIN_WINDOW_HEADER_STYLE = """ QFrame { @@ -133,7 +182,7 @@ TITLE_LABEL_STYLE = """ # СТИЛЬ ОБЛАСТИ НАВИГАЦИИ (КНОПКИ ВКЛАДОК) NAV_WIDGET_STYLE = """ QWidget { - background: #282a33; + background: transparent; border: 0px solid; } """ @@ -164,16 +213,6 @@ NAV_BUTTON_STYLE = """ } """ -# ГЛОБАЛЬНЫЙ СТИЛЬ ДЛЯ ОКНА (ФОН) И QLabel -MAIN_WINDOW_STYLE = """ - QMainWindow { - background: none; - } - QLabel { - color: #232627; - } -""" - # СТИЛЬ ПОЛЯ ПОИСКА SEARCH_EDIT_STYLE = """ QLineEdit { @@ -767,8 +806,10 @@ SETTINGS_COMBO_STYLE = f""" SETTINGS_CHECKBOX_STYLE = f""" QCheckBox {{ height: 34px; + color: #ffffff; + font-family: 'Play'; + font-size: 16px; }} - QCheckBox::indicator {{ width: 24px; height: 24px;