fix white theme
This commit is contained in:
		
							parent
							
								
									730262fe3a
								
							
						
					
					
						commit
						136c6e9fad
					
				
							
								
								
									
										72
									
								
								app/core/dialogs.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								app/core/dialogs.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					from PySide6.QtWidgets import QMessageBox
 | 
				
			||||||
 | 
					from .theme import theme_manager, set_dark_title_bar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def show_themed_messagebox(parent, icon, title, text, buttons=QMessageBox.Ok):
 | 
				
			||||||
 | 
					    msg = QMessageBox(parent)
 | 
				
			||||||
 | 
					    msg.setIcon(icon)
 | 
				
			||||||
 | 
					    msg.setWindowTitle(title)
 | 
				
			||||||
 | 
					    msg.setText(text)
 | 
				
			||||||
 | 
					    msg.setStandardButtons(buttons)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if theme_manager.is_dark():
 | 
				
			||||||
 | 
					        msg.setStyleSheet("""
 | 
				
			||||||
 | 
					            QMessageBox {
 | 
				
			||||||
 | 
					                background-color: #2e2e2e;
 | 
				
			||||||
 | 
					                color: white;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QLabel {
 | 
				
			||||||
 | 
					                color: white;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QPushButton {
 | 
				
			||||||
 | 
					                background-color: #444;
 | 
				
			||||||
 | 
					                color: white;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					                border-radius: 6px;
 | 
				
			||||||
 | 
					                padding: 6px 12px;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QPushButton:hover {
 | 
				
			||||||
 | 
					                background-color: #666;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        """)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        msg.setStyleSheet("""
 | 
				
			||||||
 | 
					            QMessageBox {
 | 
				
			||||||
 | 
					                background-color: white;
 | 
				
			||||||
 | 
					                color: black;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QLabel {
 | 
				
			||||||
 | 
					                color: black;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					                background: transparent;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QPushButton {
 | 
				
			||||||
 | 
					                background-color: #e0e0e0;
 | 
				
			||||||
 | 
					                color: black;
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					                border-radius: 6px;
 | 
				
			||||||
 | 
					                padding: 6px 12px;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QPushButton:focus,
 | 
				
			||||||
 | 
					            QMessageBox QPushButton:pressed {
 | 
				
			||||||
 | 
					                border: none;
 | 
				
			||||||
 | 
					                outline: none;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            QMessageBox QPushButton:hover {
 | 
				
			||||||
 | 
					                background-color: #d0d0d0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        """)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    hwnd = int(msg.winId())
 | 
				
			||||||
 | 
					    set_dark_title_bar(hwnd, theme_manager.is_dark())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return msg.exec()
 | 
				
			||||||
@ -1,4 +1,17 @@
 | 
				
			|||||||
 | 
					import ctypes
 | 
				
			||||||
from PySide6.QtCore import QSettings, Signal, QObject
 | 
					from PySide6.QtCore import QSettings, Signal, QObject
 | 
				
			||||||
 | 
					from PySide6.QtWidgets import QMessageBox
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def set_dark_title_bar(hwnd, enable=True):
 | 
				
			||||||
 | 
					    """Включает тёмный заголовок окна в Windows 10+."""
 | 
				
			||||||
 | 
					    DWMWA_USE_IMMERSIVE_DARK_MODE = 20
 | 
				
			||||||
 | 
					    value = ctypes.c_int(1 if enable else 0)
 | 
				
			||||||
 | 
					    ctypes.windll.dwmapi.DwmSetWindowAttribute(
 | 
				
			||||||
 | 
					        hwnd,
 | 
				
			||||||
 | 
					        DWMWA_USE_IMMERSIVE_DARK_MODE,
 | 
				
			||||||
 | 
					        ctypes.byref(value),
 | 
				
			||||||
 | 
					        ctypes.sizeof(value)
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ThemeManager(QObject):
 | 
					class ThemeManager(QObject):
 | 
				
			||||||
    theme_changed = Signal(str)
 | 
					    theme_changed = Signal(str)
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,7 @@ from app.core.theme import theme_manager
 | 
				
			|||||||
import app.core.config as config
 | 
					import app.core.config as config
 | 
				
			||||||
import asyncio
 | 
					import asyncio
 | 
				
			||||||
from app.core.services import auth_service
 | 
					from app.core.services import auth_service
 | 
				
			||||||
 | 
					from app.core.dialogs import show_themed_messagebox
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def validate_username(username, is_login=False):
 | 
					def validate_username(username, is_login=False):
 | 
				
			||||||
@ -259,7 +260,7 @@ class LoginView(QWidget):
 | 
				
			|||||||
        if not is_login_valid or not is_password_valid:
 | 
					        if not is_login_valid or not is_password_valid:
 | 
				
			||||||
            # Показываем первую попавшуюся ошибку, они должны быть общими
 | 
					            # Показываем первую попавшуюся ошибку, они должны быть общими
 | 
				
			||||||
            error_msg = login_msg if not is_login_valid else password_msg
 | 
					            error_msg = login_msg if not is_login_valid else password_msg
 | 
				
			||||||
            QMessageBox.warning(self, localizer.translate("Ошибка"), error_msg)
 | 
					            show_themed_messagebox(self, QMessageBox.Warning, localizer.translate("Ошибка"), error_msg)
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Отключаем кнопку на время запроса
 | 
					        # Отключаем кнопку на время запроса
 | 
				
			||||||
@ -273,7 +274,7 @@ class LoginView(QWidget):
 | 
				
			|||||||
            if success:
 | 
					            if success:
 | 
				
			||||||
                self.on_login(login)
 | 
					                self.on_login(login)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                QMessageBox.warning(self, localizer.translate("Ошибка"), message)
 | 
					                show_themed_messagebox(self, QMessageBox.Warning, localizer.translate("Ошибка"), message)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            # Включаем кнопку обратно в любом случае
 | 
					            # Включаем кнопку обратно в любом случае
 | 
				
			||||||
@ -304,7 +305,7 @@ class LoginView(QWidget):
 | 
				
			|||||||
            self.confirm_password_input.is_valid,
 | 
					            self.confirm_password_input.is_valid,
 | 
				
			||||||
            self.invite_code_input.is_valid
 | 
					            self.invite_code_input.is_valid
 | 
				
			||||||
        ]):
 | 
					        ]):
 | 
				
			||||||
            QMessageBox.warning(self, localizer.translate("Ошибка"), localizer.translate("Пожалуйста, исправьте ошибки в форме"))
 | 
					            show_themed_messagebox(self, QMessageBox.Warning, localizer.translate("Ошибка"), "Пожалуйста, исправьте ошибки в форме")
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        login = self.reg_login_input.text()
 | 
					        login = self.reg_login_input.text()
 | 
				
			||||||
@ -319,10 +320,10 @@ class LoginView(QWidget):
 | 
				
			|||||||
            success, message = await auth_service.register(login, password, invite)
 | 
					            success, message = await auth_service.register(login, password, invite)
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if success:
 | 
					            if success:
 | 
				
			||||||
                QMessageBox.information(self, localizer.translate("Успех"), message)
 | 
					                show_themed_messagebox(self, QMessageBox.Information, localizer.translate("Успех"), message)
 | 
				
			||||||
                self.show_login_form()
 | 
					                self.show_login_form()
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                QMessageBox.warning(self, localizer.translate("Ошибка"), message)
 | 
					                show_themed_messagebox(self, QMessageBox.Warning, localizer.translate("Ошибка"), message)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            # Возвращаем кнопку в исходное состояние
 | 
					            # Возвращаем кнопку в исходное состояние
 | 
				
			||||||
 | 
				
			|||||||
@ -1,13 +1,14 @@
 | 
				
			|||||||
import asyncio
 | 
					import asyncio
 | 
				
			||||||
from PySide6.QtWidgets import (
 | 
					from PySide6.QtWidgets import (
 | 
				
			||||||
    QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFrame, 
 | 
					    QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFrame, 
 | 
				
			||||||
    QStackedWidget, QSpacerItem, QSizePolicy, QGraphicsDropShadowEffect,
 | 
					    QStackedWidget, QSizePolicy, QGraphicsDropShadowEffect,
 | 
				
			||||||
    QGraphicsOpacityEffect, QMessageBox
 | 
					    QGraphicsOpacityEffect, QMessageBox
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
from PySide6.QtCore import Qt, QSize, QPropertyAnimation, QEasingCurve, Property
 | 
					from PySide6.QtCore import Qt, QPropertyAnimation, QEasingCurve
 | 
				
			||||||
from PySide6.QtGui import QIcon, QColor
 | 
					from PySide6.QtGui import QColor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from app.core.theme import theme_manager
 | 
					from app.core.theme import theme_manager
 | 
				
			||||||
 | 
					from app.core.dialogs import show_themed_messagebox
 | 
				
			||||||
from app.ui.views.side_menu_view import SideMenuView
 | 
					from app.ui.views.side_menu_view import SideMenuView
 | 
				
			||||||
from app.core.services.auth_service import get_user_role
 | 
					from app.core.services.auth_service import get_user_role
 | 
				
			||||||
from app.core.database import get_current_access_token
 | 
					from app.core.database import get_current_access_token
 | 
				
			||||||
@ -161,12 +162,14 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
        self.search_button.setFocusPolicy(Qt.NoFocus)
 | 
					        self.search_button.setFocusPolicy(Qt.NoFocus)
 | 
				
			||||||
        self.search_button.setCursor(Qt.PointingHandCursor)
 | 
					        self.search_button.setCursor(Qt.PointingHandCursor)
 | 
				
			||||||
        top_bar_layout.addWidget(self.search_button)
 | 
					        top_bar_layout.addWidget(self.search_button)
 | 
				
			||||||
 | 
					        self.search_button.clicked.connect(self.handle_search_click)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.notification_button = QPushButton("🔔")
 | 
					        self.notification_button = QPushButton("🔔")
 | 
				
			||||||
        self.notification_button.setObjectName("NotificationButton")
 | 
					        self.notification_button.setObjectName("NotificationButton")
 | 
				
			||||||
        self.notification_button.setFocusPolicy(Qt.NoFocus)
 | 
					        self.notification_button.setFocusPolicy(Qt.NoFocus)
 | 
				
			||||||
        self.notification_button.setCursor(Qt.PointingHandCursor)
 | 
					        self.notification_button.setCursor(Qt.PointingHandCursor)
 | 
				
			||||||
        top_bar_layout.addWidget(self.notification_button)
 | 
					        top_bar_layout.addWidget(self.notification_button)
 | 
				
			||||||
 | 
					        self.notification_button.clicked.connect(self.handle_notification_click)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return top_bar_widget
 | 
					        return top_bar_widget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -328,12 +331,12 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def show_error_message(self, message):
 | 
					    def show_error_message(self, message):
 | 
				
			||||||
        """Показывает диалоговое окно с сообщением об ошибке."""
 | 
					        """Показывает диалоговое окно с сообщением об ошибке."""
 | 
				
			||||||
        msg_box = QMessageBox(self)
 | 
					        show_themed_messagebox(
 | 
				
			||||||
        msg_box.setIcon(QMessageBox.Warning)
 | 
					            self,
 | 
				
			||||||
        msg_box.setText(message)
 | 
					            QMessageBox.Warning,
 | 
				
			||||||
        msg_box.setWindowTitle(localizer.translate("Ошибка доступа"))
 | 
					            localizer.translate("Ошибка доступа"),
 | 
				
			||||||
        msg_box.setStandardButtons(QMessageBox.Ok)
 | 
					            message
 | 
				
			||||||
        msg_box.exec()
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def update_tab_selection(self, selected_index):
 | 
					    def update_tab_selection(self, selected_index):
 | 
				
			||||||
        if not hasattr(self, 'bottom_bar'):
 | 
					        if not hasattr(self, 'bottom_bar'):
 | 
				
			||||||
@ -366,6 +369,24 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
            self.music_label = denied
 | 
					            self.music_label = denied
 | 
				
			||||||
            self.content_stack.insertWidget(1, denied)
 | 
					            self.content_stack.insertWidget(1, denied)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def handle_search_click(self):
 | 
				
			||||||
 | 
					        """Пустышка для кнопки поиска."""
 | 
				
			||||||
 | 
					        show_themed_messagebox(
 | 
				
			||||||
 | 
					            self,
 | 
				
			||||||
 | 
					            QMessageBox.Information,
 | 
				
			||||||
 | 
					            "Поиск",
 | 
				
			||||||
 | 
					            "🔍 Функция поиска пока в разработке."
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def handle_notification_click(self):
 | 
				
			||||||
 | 
					        """Пустышка для кнопки уведомлений."""
 | 
				
			||||||
 | 
					        show_themed_messagebox(
 | 
				
			||||||
 | 
					            self,
 | 
				
			||||||
 | 
					            QMessageBox.Information,
 | 
				
			||||||
 | 
					            "Уведомления",
 | 
				
			||||||
 | 
					            "🔔 Центр уведомлений пока в разработке."
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_stylesheet(self):
 | 
					    def get_stylesheet(self):
 | 
				
			||||||
        """Возвращает QSS стили для компонента в зависимости от темы."""
 | 
					        """Возвращает QSS стили для компонента в зависимости от темы."""
 | 
				
			||||||
        is_dark = theme_manager.is_dark()
 | 
					        is_dark = theme_manager.is_dark()
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										63
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								main.py
									
									
									
									
									
								
							@ -1,11 +1,11 @@
 | 
				
			|||||||
import asyncio
 | 
					import asyncio
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					import qasync
 | 
				
			||||||
from PySide6.QtWidgets import QApplication, QMainWindow
 | 
					from PySide6.QtWidgets import QApplication, QMainWindow
 | 
				
			||||||
from PySide6.QtGui import QIcon
 | 
					from PySide6.QtGui import QIcon
 | 
				
			||||||
from app.controllers.main_controller import MainController
 | 
					from app.controllers.main_controller import MainController
 | 
				
			||||||
from app.core.theme import theme_manager
 | 
					from app.core.theme import theme_manager, set_dark_title_bar
 | 
				
			||||||
import app.core.config as config
 | 
					import app.core.config as config
 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
import qasync
 | 
					 | 
				
			||||||
from app.core.database import init_db
 | 
					from app.core.database import init_db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MainWindow(QMainWindow):
 | 
					class MainWindow(QMainWindow):
 | 
				
			||||||
@ -21,11 +21,66 @@ class MainWindow(QMainWindow):
 | 
				
			|||||||
        self.apply_theme(theme_manager.get_theme())
 | 
					        self.apply_theme(theme_manager.get_theme())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def apply_theme(self, theme):
 | 
					    def apply_theme(self, theme):
 | 
				
			||||||
        if theme == "dark":
 | 
					        is_dark = theme == "dark"
 | 
				
			||||||
 | 
					        if is_dark:
 | 
				
			||||||
            self.setStyleSheet("background-color: #2e2e2e;")
 | 
					            self.setStyleSheet("background-color: #2e2e2e;")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.setStyleSheet("background-color: #f0f0f0;")
 | 
					            self.setStyleSheet("background-color: #f0f0f0;")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # if is_dark:
 | 
				
			||||||
 | 
					        #     self.setStyleSheet("""
 | 
				
			||||||
 | 
					        #         QMainWindow {
 | 
				
			||||||
 | 
					        #             background-color: #2e2e2e;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox {
 | 
				
			||||||
 | 
					        #             background-color: #2e2e2e;
 | 
				
			||||||
 | 
					        #             color: white;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QLabel {
 | 
				
			||||||
 | 
					        #             color: white;
 | 
				
			||||||
 | 
					        #             font-size: 14px;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QPushButton {
 | 
				
			||||||
 | 
					        #             background-color: #3c3c3c;
 | 
				
			||||||
 | 
					        #             color: white;
 | 
				
			||||||
 | 
					        #             border-radius: 6px;
 | 
				
			||||||
 | 
					        #             padding: 5px 12px;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QPushButton:hover {
 | 
				
			||||||
 | 
					        #             background-color: #505050;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #     """)
 | 
				
			||||||
 | 
					        # else:
 | 
				
			||||||
 | 
					        #     self.setStyleSheet("""
 | 
				
			||||||
 | 
					        #         QMainWindow {
 | 
				
			||||||
 | 
					        #             background-color: #f0f0f0;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox {
 | 
				
			||||||
 | 
					        #             background-color: #ffffff;
 | 
				
			||||||
 | 
					        #             color: black;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QLabel {
 | 
				
			||||||
 | 
					        #             color: black;
 | 
				
			||||||
 | 
					        #             font-size: 14px;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QPushButton {
 | 
				
			||||||
 | 
					        #             background-color: #e0e0e0;
 | 
				
			||||||
 | 
					        #             color: black;
 | 
				
			||||||
 | 
					        #             border-radius: 6px;
 | 
				
			||||||
 | 
					        #             padding: 5px 12px;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #         QMessageBox QPushButton:hover {
 | 
				
			||||||
 | 
					        #             background-color: #d0d0d0;
 | 
				
			||||||
 | 
					        #         }
 | 
				
			||||||
 | 
					        #     """)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # получаем HWND и красим системный бар
 | 
				
			||||||
 | 
					        hwnd = int(self.winId())
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            set_dark_title_bar(hwnd, is_dark)
 | 
				
			||||||
 | 
					        except Exception as e:
 | 
				
			||||||
 | 
					            print("Не удалось поменять цвет системного бара:", e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def main():
 | 
					async def main():
 | 
				
			||||||
    init_db()
 | 
					    init_db()
 | 
				
			||||||
    app = QApplication(sys.argv)
 | 
					    app = QApplication(sys.argv)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user