fix tab bar hover
This commit is contained in:
		
							parent
							
								
									136c6e9fad
								
							
						
					
					
						commit
						35ad95b8f7
					
				@ -208,7 +208,11 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
        button.setObjectName("TabButton")
 | 
					        button.setObjectName("TabButton")
 | 
				
			||||||
        button.setCursor(Qt.PointingHandCursor)
 | 
					        button.setCursor(Qt.PointingHandCursor)
 | 
				
			||||||
        button.setFocusPolicy(Qt.NoFocus)
 | 
					        button.setFocusPolicy(Qt.NoFocus)
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
 | 
					        # важно для стабильного hover
 | 
				
			||||||
 | 
					        button.setAttribute(Qt.WA_Hover, True)
 | 
				
			||||||
 | 
					        button.setMouseTracking(True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        layout = QVBoxLayout(button)
 | 
					        layout = QVBoxLayout(button)
 | 
				
			||||||
        layout.setContentsMargins(0, 5, 0, 5)
 | 
					        layout.setContentsMargins(0, 5, 0, 5)
 | 
				
			||||||
        layout.setSpacing(4)
 | 
					        layout.setSpacing(4)
 | 
				
			||||||
@ -221,6 +225,10 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
        text_label.setAlignment(Qt.AlignCenter)
 | 
					        text_label.setAlignment(Qt.AlignCenter)
 | 
				
			||||||
        text_label.setObjectName("TabText")
 | 
					        text_label.setObjectName("TabText")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # ключ: делаем детей «прозрачными» для мыши
 | 
				
			||||||
 | 
					        icon_label.setAttribute(Qt.WA_TransparentForMouseEvents, True)
 | 
				
			||||||
 | 
					        text_label.setAttribute(Qt.WA_TransparentForMouseEvents, True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        layout.addWidget(icon_label)
 | 
					        layout.addWidget(icon_label)
 | 
				
			||||||
        layout.addWidget(text_label)
 | 
					        layout.addWidget(text_label)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -465,9 +473,16 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
                background-color: {hover_color};
 | 
					                background-color: {hover_color};
 | 
				
			||||||
                border-radius: 6px;
 | 
					                border-radius: 6px;
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
 | 
					            #TabButton:pressed {{
 | 
				
			||||||
 | 
					                background-color: {active_color}22; /* активный цвет с прозрачностью */
 | 
				
			||||||
 | 
					                border-radius: 6px;
 | 
				
			||||||
 | 
					            }}
 | 
				
			||||||
            #TabButton #TabIcon {{ color: {text_color}; }}
 | 
					            #TabButton #TabIcon {{ color: {text_color}; }}
 | 
				
			||||||
            #TabButton #TabText {{ color: {text_color}; }}
 | 
					            #TabButton #TabText {{ color: {text_color}; }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #TabButton[selected="true"] {{
 | 
				
			||||||
 | 
					                background-color: {active_color}22;
 | 
				
			||||||
 | 
					            }}
 | 
				
			||||||
            #TabButton[selected="true"] #TabIcon,
 | 
					            #TabButton[selected="true"] #TabIcon,
 | 
				
			||||||
            #TabButton[selected="true"] #TabText {{
 | 
					            #TabButton[selected="true"] #TabText {{
 | 
				
			||||||
                color: {active_color};
 | 
					                color: {active_color};
 | 
				
			||||||
@ -506,3 +521,130 @@ class YobbleHomeView(QWidget):
 | 
				
			|||||||
                );
 | 
					                );
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # def get_stylesheet(self):
 | 
				
			||||||
 | 
					    #     """Возвращает QSS стили для компонента в зависимости от темы."""
 | 
				
			||||||
 | 
					    #     is_dark = theme_manager.is_dark()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #     # Цветовая палитра
 | 
				
			||||||
 | 
					    #     bg_color = "#1c1c1e" if is_dark else "white"
 | 
				
			||||||
 | 
					    #     bar_bg_color = "#2c2c2e" if is_dark else "#f8f8f8"
 | 
				
			||||||
 | 
					    #     bar_border_color = "#3c3c3c" if is_dark else "#e7e7e7"
 | 
				
			||||||
 | 
					    #     text_color = "#8e8e93" if is_dark else "#888888"
 | 
				
			||||||
 | 
					    #     title_color = "white" if is_dark else "black"
 | 
				
			||||||
 | 
					    #     active_color = "#0A84FF"
 | 
				
			||||||
 | 
					    #     top_bar_bg = "#2c2c2e" if is_dark else "#f5f5f5"
 | 
				
			||||||
 | 
					    #     top_bar_border = "#3c3c3c" if is_dark else "#e0e0e0"
 | 
				
			||||||
 | 
					    #     hover_color = "#3a3a3c" if is_dark else "#e0e0e0"
 | 
				
			||||||
 | 
					    #     overlay_color = "rgba(0, 0, 0, 0.5)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #     return f"""
 | 
				
			||||||
 | 
					    #         #content_widget {{
 | 
				
			||||||
 | 
					    #             background-color: {bg_color};
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #Overlay {{
 | 
				
			||||||
 | 
					    #             background-color: {overlay_color};
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         /* Глобальные стили для кнопок */
 | 
				
			||||||
 | 
					    #         QPushButton {{
 | 
				
			||||||
 | 
					    #             background: transparent;
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             outline: none;
 | 
				
			||||||
 | 
					    #             transition: background-color 200ms ease, transform 150ms ease;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         QPushButton:focus,
 | 
				
			||||||
 | 
					    #         QPushButton:checked {{
 | 
				
			||||||
 | 
					    #             background: transparent;
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             outline: none;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         /* Верхняя панель */
 | 
				
			||||||
 | 
					    #         #TopBar {{
 | 
				
			||||||
 | 
					    #             background-color: {top_bar_bg};
 | 
				
			||||||
 | 
					    #             border-bottom: 1px solid {top_bar_border};
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #TopBar QPushButton {{
 | 
				
			||||||
 | 
					    #             font-size: 22px;
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             padding: 5px;
 | 
				
			||||||
 | 
					    #             color: {title_color};
 | 
				
			||||||
 | 
					    #             background: transparent;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #TitleLabel {{
 | 
				
			||||||
 | 
					    #             font-size: 18px;
 | 
				
			||||||
 | 
					    #             font-weight: bold;
 | 
				
			||||||
 | 
					    #             color: {title_color};
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             outline: none;
 | 
				
			||||||
 | 
					    #             background-color: transparent;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         /* Нижняя панель */
 | 
				
			||||||
 | 
					    #         #BottomBar {{
 | 
				
			||||||
 | 
					    #             background-color: {bar_bg_color};
 | 
				
			||||||
 | 
					    #             border-top: 1px solid {bar_border_color};
 | 
				
			||||||
 | 
					    #             padding-top: 5px;
 | 
				
			||||||
 | 
					    #             padding-bottom: 15px;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         /* Кнопки вкладок */
 | 
				
			||||||
 | 
					    #         #TabButton {{
 | 
				
			||||||
 | 
					    #             border-radius: 6px;
 | 
				
			||||||
 | 
					    #             padding: 6px;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         /* Hover (не выбранная вкладка) */
 | 
				
			||||||
 | 
					    #         #TabButton:hover[selected="false"] {{
 | 
				
			||||||
 | 
					    #             background-color: {hover_color};
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         /* Pressed (удержание) */
 | 
				
			||||||
 | 
					    #         #TabButton:pressed {{
 | 
				
			||||||
 | 
					    #             background-color: {active_color}44;
 | 
				
			||||||
 | 
					    #             transform: scale(0.95);
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         /* Selected */
 | 
				
			||||||
 | 
					    #         #TabButton[selected="true"] {{
 | 
				
			||||||
 | 
					    #             background-color: {active_color}22;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #TabButton[selected="true"] #TabIcon,
 | 
				
			||||||
 | 
					    #         #TabButton[selected="true"] #TabText {{
 | 
				
			||||||
 | 
					    #             color: {active_color};
 | 
				
			||||||
 | 
					    #             font-weight: 600;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         #TabIcon, #TabText {{
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             outline: none;
 | 
				
			||||||
 | 
					    #             background-color: transparent;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #TabIcon {{ font-size: 22px; color: {text_color}; }}
 | 
				
			||||||
 | 
					    #         #TabText {{ font-size: 12px; color: {text_color}; }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #         /* Центральная кнопка "Создать" */
 | 
				
			||||||
 | 
					    #         #CreateButton {{
 | 
				
			||||||
 | 
					    #             color: white;
 | 
				
			||||||
 | 
					    #             font-size: 30px;
 | 
				
			||||||
 | 
					    #             font-weight: 300;
 | 
				
			||||||
 | 
					    #             border: none;
 | 
				
			||||||
 | 
					    #             border-radius: 28px;
 | 
				
			||||||
 | 
					    #             background-color: qlineargradient(
 | 
				
			||||||
 | 
					    #                 x1: 0, y1: 0, x2: 0, y2: 1,
 | 
				
			||||||
 | 
					    #                 stop: 0 #007AFF, stop: 1 #0056b3
 | 
				
			||||||
 | 
					    #             );
 | 
				
			||||||
 | 
					    #             margin-bottom: 20px;
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #CreateButton:hover {{
 | 
				
			||||||
 | 
					    #             background-color: qlineargradient(
 | 
				
			||||||
 | 
					    #                 x1: 0, y1: 0, x2: 0, y2: 1,
 | 
				
			||||||
 | 
					    #                 stop: 0 #0088FF, stop: 1 #0066c3
 | 
				
			||||||
 | 
					    #             );
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #         #CreateButton:pressed {{
 | 
				
			||||||
 | 
					    #             background-color: qlineargradient(
 | 
				
			||||||
 | 
					    #                 x1: 0, y1: 0, x2: 0, y2: 1,
 | 
				
			||||||
 | 
					    #                 stop: 0 #0056b3, stop: 1 #004493
 | 
				
			||||||
 | 
					    #             );
 | 
				
			||||||
 | 
					    #             transform: scale(0.95);
 | 
				
			||||||
 | 
					    #         }}
 | 
				
			||||||
 | 
					    #     """
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user