chore(virtual_keyboard): move styles to style.py
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Code check / Check code (pull_request) Successful in 1m12s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Code check / Check code (pull_request) Successful in 1m12s
				
			Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
		| @@ -210,8 +210,7 @@ class MainWindow(QMainWindow): | |||||||
|  |  | ||||||
|         self.restore_state() |         self.restore_state() | ||||||
|  |  | ||||||
|         self.keyboard = VirtualKeyboard(self) |         self.keyboard = VirtualKeyboard(self, self.theme) | ||||||
|         mainLayout.addWidget(self.keyboard) |  | ||||||
|  |  | ||||||
|         self.detail_animations = DetailPageAnimations(self, self.theme) |         self.detail_animations = DetailPageAnimations(self, self.theme) | ||||||
|         QTimer.singleShot(0, self.loadGames) |         QTimer.singleShot(0, self.loadGames) | ||||||
|   | |||||||
| @@ -217,6 +217,56 @@ CONTEXT_MENU_STYLE = f""" | |||||||
|     }} |     }} | ||||||
| """ | """ | ||||||
|  |  | ||||||
|  | VIRTUAL_KEYBOARD_STYLE = """ | ||||||
|  | VirtualKeyboard { | ||||||
|  |     background-color: rgba(30, 30, 30, 200); | ||||||
|  |     border-radius: 0px; | ||||||
|  |     border: none; | ||||||
|  | } | ||||||
|  | QPushButton { | ||||||
|  |     font-size: 14px; | ||||||
|  |     border: 1px solid #555; | ||||||
|  |     border-top-color: #666; | ||||||
|  |     border-left-color: #666; | ||||||
|  |     border-radius: 3px; | ||||||
|  |     min-width: 30px; | ||||||
|  |     min-height: 30px; | ||||||
|  |     padding: 4px; | ||||||
|  |     background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop:1 #404040); | ||||||
|  |     color: #e0e0e0; | ||||||
|  | } | ||||||
|  | QPushButton:hover { | ||||||
|  |     background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #606060, stop:1 #505050); | ||||||
|  |     border: 1px solid #666; | ||||||
|  |     border-top-color: #777; | ||||||
|  |     border-left-color: #777; | ||||||
|  | } | ||||||
|  | QPushButton:focus { | ||||||
|  |     border: 2px solid #4a90e2; | ||||||
|  |     background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #5a5a5a, stop:1 #454545); | ||||||
|  | } | ||||||
|  | QPushButton:pressed { | ||||||
|  |     background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #3a3a3a, stop:1 #303030); | ||||||
|  |     border: 1px solid #444; | ||||||
|  |     border-bottom-color: #555; | ||||||
|  |     border-right-color: #555; | ||||||
|  |     padding-top: 5px; | ||||||
|  |     padding-bottom: 3px; | ||||||
|  |     padding-left: 5px; | ||||||
|  |     padding-right: 3px; | ||||||
|  | } | ||||||
|  | QPushButton[checked="true"] { | ||||||
|  |     background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4a90e2, stop:1 #3a7ad2); | ||||||
|  |     color: white; | ||||||
|  |     border: 1px solid #2a6ac2; | ||||||
|  |     border-top-color: #5aa0f2; | ||||||
|  |     border-left-color: #5aa0f2; | ||||||
|  | } | ||||||
|  | QPushButton[checked="true"]:focus { | ||||||
|  |     border: 2px solid #6aa3f5; | ||||||
|  | } | ||||||
|  | """ | ||||||
|  |  | ||||||
| # ГЛОБАЛЬНЫЙ СТИЛЬ ДЛЯ ОКНА (ФОН), ЛЭЙБЛОВ, КНОПОК | # ГЛОБАЛЬНЫЙ СТИЛЬ ДЛЯ ОКНА (ФОН), ЛЭЙБЛОВ, КНОПОК | ||||||
| MAIN_WINDOW_STYLE = f""" | MAIN_WINDOW_STYLE = f""" | ||||||
|     QWidget {{ |     QWidget {{ | ||||||
|   | |||||||
| @@ -2,15 +2,20 @@ from typing import cast | |||||||
| from PySide6.QtWidgets import (QFrame, QVBoxLayout, QPushButton, QGridLayout, | from PySide6.QtWidgets import (QFrame, QVBoxLayout, QPushButton, QGridLayout, | ||||||
|                                QSizePolicy, QWidget, QLineEdit) |                                QSizePolicy, QWidget, QLineEdit) | ||||||
| from PySide6.QtCore import Qt, Signal, QProcess | from PySide6.QtCore import Qt, Signal, QProcess | ||||||
| from portprotonqt.keyboard_layouts import keyboard_layouts  # Импортируем раскладки | from portprotonqt.keyboard_layouts import keyboard_layouts | ||||||
|  | from portprotonqt.theme_manager import ThemeManager | ||||||
|  | from portprotonqt.config_utils import read_theme_from_config | ||||||
|  |  | ||||||
|  | theme_manager = ThemeManager() | ||||||
|  |  | ||||||
| class VirtualKeyboard(QFrame): | class VirtualKeyboard(QFrame): | ||||||
|     keyPressed = Signal(str) |     keyPressed = Signal(str) | ||||||
|  |  | ||||||
|     def __init__(self, parent: QWidget | None = None): |     def __init__(self, parent: QWidget | None = None, theme=None): | ||||||
|         super().__init__(parent) |         super().__init__(parent) | ||||||
|         self._parent: QWidget | None = parent |         self._parent: QWidget | None = parent | ||||||
|         self.available_layouts: list[str] = self.get_layouts_setxkbmap() |         self.available_layouts: list[str] = self.get_layouts_setxkbmap() | ||||||
|  |         self.theme = theme if theme else theme_manager.apply_theme(read_theme_from_config()) | ||||||
|         if not self.available_layouts: |         if not self.available_layouts: | ||||||
|             self.available_layouts.append('en') |             self.available_layouts.append('en') | ||||||
|         self.current_layout: str = self.available_layouts[0] |         self.current_layout: str = self.available_layouts[0] | ||||||
| @@ -32,33 +37,7 @@ class VirtualKeyboard(QFrame): | |||||||
|         self.initUI() |         self.initUI() | ||||||
|         self.hide() |         self.hide() | ||||||
|  |  | ||||||
|         self.setStyleSheet(""" |         self.setStyleSheet(self.theme.VIRTUAL_KEYBOARD_STYLE) | ||||||
|             VirtualKeyboard { |  | ||||||
|                 background-color: rgba(0, 0, 0, 200);  /* Полупрозрачный серый */ |  | ||||||
|                 border-radius: 5px; |  | ||||||
|                 border: 1px solid #ccc; |  | ||||||
|             } |  | ||||||
|             QPushButton { |  | ||||||
|                 font-size: 14px; |  | ||||||
|                 border: 1px solid #888; |  | ||||||
|                 border-radius: 3px; |  | ||||||
|                 min-width: 30px; |  | ||||||
|                 min-height: 30px; |  | ||||||
|                 padding: 0px; |  | ||||||
|             } |  | ||||||
|             QPushButton:pressed { |  | ||||||
|                 background-color: #d0d0d0; |  | ||||||
|             } |  | ||||||
|             QPushButton[checked="true"] { |  | ||||||
|                 background-color: #a0c4ff; |  | ||||||
|                 border: 1px solid #4a90e2; |  | ||||||
|             } |  | ||||||
|             QPushButton[checked="true"] { |  | ||||||
|                 background-color: #4a90e2; |  | ||||||
|                 color: white; |  | ||||||
|                 border: 2px solid #1a73e8; |  | ||||||
|             } |  | ||||||
|         """) |  | ||||||
|  |  | ||||||
|     def highlight_cursor_position(self): |     def highlight_cursor_position(self): | ||||||
|         """Подсвечиваем текущую позицию курсора""" |         """Подсвечиваем текущую позицию курсора""" | ||||||
| @@ -74,20 +53,18 @@ class VirtualKeyboard(QFrame): | |||||||
|         layout.setSpacing(0) |         layout.setSpacing(0) | ||||||
|  |  | ||||||
|         self.keyboard_layout = QGridLayout() |         self.keyboard_layout = QGridLayout() | ||||||
|         self.keyboard_layout.setSpacing(1) |         self.keyboard_layout.setSpacing(4) | ||||||
|         self.keyboard_layout.setContentsMargins(0, 0, 0, 0) |         self.keyboard_layout.setContentsMargins(5, 5, 5, 5) | ||||||
|         self.create_keyboard() |         self.create_keyboard() | ||||||
|  |  | ||||||
|         keyboard_container = QWidget() |         keyboard_container = QWidget() | ||||||
|         keyboard_container.setLayout(self.keyboard_layout) |         keyboard_container.setLayout(self.keyboard_layout) | ||||||
|         # keyboard_container.setFixedSize(660, 220) |  | ||||||
|         keyboard_container.setMinimumWidth(574) |         keyboard_container.setMinimumWidth(574) | ||||||
|         keyboard_container.setMinimumHeight(220) |         keyboard_container.setMinimumHeight(220) | ||||||
|         keyboard_container.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) |         keyboard_container.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) | ||||||
|  |  | ||||||
|         layout.addWidget(keyboard_container, 0, Qt.AlignmentFlag.AlignHCenter) |         layout.addWidget(keyboard_container, 0, Qt.AlignmentFlag.AlignHCenter) | ||||||
|         self.setLayout(layout) |         self.setLayout(layout) | ||||||
|         # self.setMinimumHeight(240) |  | ||||||
|         self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) |         self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) | ||||||
|  |  | ||||||
|     def run_shell_command(self, cmd: str) -> str | None: |     def run_shell_command(self, cmd: str) -> str | None: | ||||||
| @@ -471,7 +448,7 @@ class VirtualKeyboard(QFrame): | |||||||
|         """Активирует текущую выделенную кнопку на клавиатуре""" |         """Активирует текущую выделенную кнопку на клавиатуре""" | ||||||
|         focused = self.focusWidget() |         focused = self.focusWidget() | ||||||
|         if isinstance(focused, QPushButton): |         if isinstance(focused, QPushButton): | ||||||
|             focused.click() |             focused.animateClick() | ||||||
|  |  | ||||||
|     def focusNextKey(self, direction: str): |     def focusNextKey(self, direction: str): | ||||||
|         """Перемещает фокус на следующую кнопку в указанном направлении""" |         """Перемещает фокус на следующую кнопку в указанном направлении""" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user