修复左侧无法拉伸
This commit is contained in:
+61
-11
@@ -39,6 +39,7 @@ from ui.group import GroupWidget
|
||||
import ui.theme as theme
|
||||
import ui.dialog_style as dialog_style
|
||||
from ui.updater import Updater
|
||||
from app_info import app_title
|
||||
|
||||
PANEL_W = 260
|
||||
PANEL_H = 40
|
||||
@@ -314,7 +315,7 @@ class PanelWindow(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("牛马软件柜")
|
||||
self.setWindowTitle(app_title())
|
||||
# 默认不置顶;仅图钉开启时与悬浮球一并置顶(见 _apply_pin_window_layer)
|
||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
||||
# 任务栏/开始菜单图标:使用项目 logo.png
|
||||
@@ -530,6 +531,9 @@ class PanelWindow(QWidget):
|
||||
self._quick_bar = QWidget()
|
||||
self._quick_bar.setObjectName("quick_bar")
|
||||
self._quick_bar.setFixedWidth(50)
|
||||
# 快捷栏上的按钮会吃掉鼠标事件;为保证边缘 resize 可用,快捷栏自身也追踪鼠标并接入事件过滤
|
||||
self._quick_bar.setMouseTracking(True)
|
||||
self._quick_bar.installEventFilter(self)
|
||||
quick_layout = QVBoxLayout(self._quick_bar)
|
||||
quick_layout.setContentsMargins(0, 10, 0, 10)
|
||||
quick_layout.setSpacing(6)
|
||||
@@ -541,6 +545,9 @@ class PanelWindow(QWidget):
|
||||
btn.setFixedSize(34, 34)
|
||||
btn.setToolTip(tooltip)
|
||||
btn.setStyleSheet("border:none; background:transparent; border-radius:4px;")
|
||||
btn.setMouseTracking(True)
|
||||
# 鼠标落在按钮上时,也要能触发边缘检测/resize
|
||||
btn.installEventFilter(self)
|
||||
try:
|
||||
btn.setIcon(qta.icon(icon_name, color="#888"))
|
||||
btn.setIconSize(QSize(16, 16))
|
||||
@@ -577,7 +584,7 @@ class PanelWindow(QWidget):
|
||||
self.pin_btn.clicked.connect(self._toggle_pin)
|
||||
|
||||
# 程序名称
|
||||
self.app_title = QLabel("牛马软件柜")
|
||||
self.app_title = QLabel(app_title())
|
||||
self.app_title.setStyleSheet(
|
||||
"font-size:13px; font-weight:bold; background:transparent;"
|
||||
)
|
||||
@@ -755,6 +762,8 @@ class PanelWindow(QWidget):
|
||||
is_dark = theme.name() == "dark"
|
||||
ic = "#cccccc" if is_dark else "#555555"
|
||||
|
||||
self._apply_tooltip_theme(t, is_dark)
|
||||
|
||||
self.container.setStyleSheet(
|
||||
f"""
|
||||
QWidget#container {{
|
||||
@@ -842,8 +851,8 @@ class PanelWindow(QWidget):
|
||||
f"""
|
||||
QWidget#quick_bar {{
|
||||
background: {bar_side_bg};
|
||||
border-right: 1px solid {t['panel_border']};
|
||||
border-radius: 10px 0 0 10px;
|
||||
border: 1px solid {t['panel_border']};
|
||||
border-radius: 10px;
|
||||
}}
|
||||
QPushButton {{ border:none; background:transparent; border-radius:4px; }}
|
||||
QPushButton:hover {{ background:{t['header_hover']}; }}
|
||||
@@ -887,6 +896,41 @@ class PanelWindow(QWidget):
|
||||
if item and item.widget():
|
||||
item.widget()._apply_theme()
|
||||
|
||||
def _apply_tooltip_theme(self, t: dict, is_dark: bool):
|
||||
"""让所有控件 tooltip 跟随主题(含快捷栏按钮)。"""
|
||||
app = QApplication.instance()
|
||||
if app is None:
|
||||
return
|
||||
bg = "rgba(45,45,45,245)" if is_dark else "rgba(255,255,255,250)"
|
||||
fg = "#eeeeee" if is_dark else "#111111"
|
||||
bd = t.get("menu_border") or t.get("search_border") or t.get("panel_border") or "#666"
|
||||
|
||||
start = "/*TOOLTIP_THEME_START*/"
|
||||
end = "/*TOOLTIP_THEME_END*/"
|
||||
tooltip_css = (
|
||||
f"{start}\n"
|
||||
"QToolTip {\n"
|
||||
f" background-color: {bg};\n"
|
||||
f" color: {fg};\n"
|
||||
f" border: 1px solid {bd};\n"
|
||||
" border-radius: 6px;\n"
|
||||
" padding: 6px 8px;\n"
|
||||
" font-size: 12px;\n"
|
||||
"}\n"
|
||||
f"{end}\n"
|
||||
)
|
||||
|
||||
ss = app.styleSheet() or ""
|
||||
if start in ss and end in ss:
|
||||
pre = ss.split(start, 1)[0]
|
||||
post = ss.split(end, 1)[1]
|
||||
ss = pre + tooltip_css + post
|
||||
else:
|
||||
if ss and not ss.endswith("\n"):
|
||||
ss += "\n"
|
||||
ss += tooltip_css
|
||||
app.setStyleSheet(ss)
|
||||
|
||||
def _quit_application(self):
|
||||
ret = dialog_style.question(
|
||||
self,
|
||||
@@ -1354,7 +1398,11 @@ class PanelWindow(QWidget):
|
||||
|
||||
# ── eventFilter:处理 container 上的 resize/drag ─────
|
||||
def eventFilter(self, obj, event):
|
||||
if obj is self.container:
|
||||
is_quick = (
|
||||
obj is getattr(self, "_quick_bar", None)
|
||||
or (hasattr(self, "_quick_bar") and isinstance(obj, QPushButton) and obj.parentWidget() is self._quick_bar)
|
||||
)
|
||||
if obj is self.container or is_quick:
|
||||
et = event.type()
|
||||
# drop 事件放行给子 widget
|
||||
if et in (
|
||||
@@ -1377,12 +1425,14 @@ class PanelWindow(QWidget):
|
||||
self._resize_start_global = event.globalPosition().toPoint()
|
||||
self._resize_start_geo = self.geometry()
|
||||
return True
|
||||
pos_c = self.container.mapFrom(self, local)
|
||||
if not self._container_pos_is_title_bar(pos_c):
|
||||
return False
|
||||
self._win_drag_pos = (
|
||||
event.globalPosition().toPoint() - self.frameGeometry().topLeft()
|
||||
)
|
||||
# 快捷栏/按钮区域不允许拖动窗口(只保留边缘 resize)
|
||||
if obj is self.container:
|
||||
pos_c = self.container.mapFrom(self, local)
|
||||
if not self._container_pos_is_title_bar(pos_c):
|
||||
return False
|
||||
self._win_drag_pos = (
|
||||
event.globalPosition().toPoint() - self.frameGeometry().topLeft()
|
||||
)
|
||||
|
||||
elif et == QEvent.Type.MouseMove:
|
||||
gp = event.globalPosition().toPoint()
|
||||
|
||||
Reference in New Issue
Block a user