修复左侧无法拉伸
This commit is contained in:
parent
621d752a8d
commit
d583e711f0
Binary file not shown.
7
app_info.py
Normal file
7
app_info.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
APP_NAME = "牛马软件柜"
|
||||||
|
__VERSION__ = "0.0.3"
|
||||||
|
|
||||||
|
|
||||||
|
def app_title() -> str:
|
||||||
|
return f"{APP_NAME} - Version:{__VERSION__}"
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
4
main.py
4
main.py
@ -9,7 +9,7 @@ from ui.ball import FloatBall, BALL_SIZE
|
|||||||
import ui.theme as theme
|
import ui.theme as theme
|
||||||
from db import database
|
from db import database
|
||||||
|
|
||||||
__VERSION__ = "0.0.3"
|
from app_info import __VERSION__, app_title
|
||||||
|
|
||||||
# ===================== 打包兼容核心函数 =====================
|
# ===================== 打包兼容核心函数 =====================
|
||||||
def get_resource_path(relative_path):
|
def get_resource_path(relative_path):
|
||||||
@ -34,7 +34,7 @@ def _wake_existing_or_exit() -> bool:
|
|||||||
import ctypes.wintypes
|
import ctypes.wintypes
|
||||||
|
|
||||||
mutex_name = r"Global\CleanDesktopOrganizerSingleton"
|
mutex_name = r"Global\CleanDesktopOrganizerSingleton"
|
||||||
title = "牛马软件柜 v" + __VERSION__
|
title = app_title()
|
||||||
|
|
||||||
kernel32 = ctypes.windll.kernel32
|
kernel32 = ctypes.windll.kernel32
|
||||||
user32 = ctypes.windll.user32
|
user32 = ctypes.windll.user32
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72
ui/dock.py
72
ui/dock.py
@ -39,6 +39,7 @@ from ui.group import GroupWidget
|
|||||||
import ui.theme as theme
|
import ui.theme as theme
|
||||||
import ui.dialog_style as dialog_style
|
import ui.dialog_style as dialog_style
|
||||||
from ui.updater import Updater
|
from ui.updater import Updater
|
||||||
|
from app_info import app_title
|
||||||
|
|
||||||
PANEL_W = 260
|
PANEL_W = 260
|
||||||
PANEL_H = 40
|
PANEL_H = 40
|
||||||
@ -314,7 +315,7 @@ class PanelWindow(QWidget):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowTitle("牛马软件柜")
|
self.setWindowTitle(app_title())
|
||||||
# 默认不置顶;仅图钉开启时与悬浮球一并置顶(见 _apply_pin_window_layer)
|
# 默认不置顶;仅图钉开启时与悬浮球一并置顶(见 _apply_pin_window_layer)
|
||||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
||||||
# 任务栏/开始菜单图标:使用项目 logo.png
|
# 任务栏/开始菜单图标:使用项目 logo.png
|
||||||
@ -530,6 +531,9 @@ class PanelWindow(QWidget):
|
|||||||
self._quick_bar = QWidget()
|
self._quick_bar = QWidget()
|
||||||
self._quick_bar.setObjectName("quick_bar")
|
self._quick_bar.setObjectName("quick_bar")
|
||||||
self._quick_bar.setFixedWidth(50)
|
self._quick_bar.setFixedWidth(50)
|
||||||
|
# 快捷栏上的按钮会吃掉鼠标事件;为保证边缘 resize 可用,快捷栏自身也追踪鼠标并接入事件过滤
|
||||||
|
self._quick_bar.setMouseTracking(True)
|
||||||
|
self._quick_bar.installEventFilter(self)
|
||||||
quick_layout = QVBoxLayout(self._quick_bar)
|
quick_layout = QVBoxLayout(self._quick_bar)
|
||||||
quick_layout.setContentsMargins(0, 10, 0, 10)
|
quick_layout.setContentsMargins(0, 10, 0, 10)
|
||||||
quick_layout.setSpacing(6)
|
quick_layout.setSpacing(6)
|
||||||
@ -541,6 +545,9 @@ class PanelWindow(QWidget):
|
|||||||
btn.setFixedSize(34, 34)
|
btn.setFixedSize(34, 34)
|
||||||
btn.setToolTip(tooltip)
|
btn.setToolTip(tooltip)
|
||||||
btn.setStyleSheet("border:none; background:transparent; border-radius:4px;")
|
btn.setStyleSheet("border:none; background:transparent; border-radius:4px;")
|
||||||
|
btn.setMouseTracking(True)
|
||||||
|
# 鼠标落在按钮上时,也要能触发边缘检测/resize
|
||||||
|
btn.installEventFilter(self)
|
||||||
try:
|
try:
|
||||||
btn.setIcon(qta.icon(icon_name, color="#888"))
|
btn.setIcon(qta.icon(icon_name, color="#888"))
|
||||||
btn.setIconSize(QSize(16, 16))
|
btn.setIconSize(QSize(16, 16))
|
||||||
@ -577,7 +584,7 @@ class PanelWindow(QWidget):
|
|||||||
self.pin_btn.clicked.connect(self._toggle_pin)
|
self.pin_btn.clicked.connect(self._toggle_pin)
|
||||||
|
|
||||||
# 程序名称
|
# 程序名称
|
||||||
self.app_title = QLabel("牛马软件柜")
|
self.app_title = QLabel(app_title())
|
||||||
self.app_title.setStyleSheet(
|
self.app_title.setStyleSheet(
|
||||||
"font-size:13px; font-weight:bold; background:transparent;"
|
"font-size:13px; font-weight:bold; background:transparent;"
|
||||||
)
|
)
|
||||||
@ -755,6 +762,8 @@ class PanelWindow(QWidget):
|
|||||||
is_dark = theme.name() == "dark"
|
is_dark = theme.name() == "dark"
|
||||||
ic = "#cccccc" if is_dark else "#555555"
|
ic = "#cccccc" if is_dark else "#555555"
|
||||||
|
|
||||||
|
self._apply_tooltip_theme(t, is_dark)
|
||||||
|
|
||||||
self.container.setStyleSheet(
|
self.container.setStyleSheet(
|
||||||
f"""
|
f"""
|
||||||
QWidget#container {{
|
QWidget#container {{
|
||||||
@ -842,8 +851,8 @@ class PanelWindow(QWidget):
|
|||||||
f"""
|
f"""
|
||||||
QWidget#quick_bar {{
|
QWidget#quick_bar {{
|
||||||
background: {bar_side_bg};
|
background: {bar_side_bg};
|
||||||
border-right: 1px solid {t['panel_border']};
|
border: 1px solid {t['panel_border']};
|
||||||
border-radius: 10px 0 0 10px;
|
border-radius: 10px;
|
||||||
}}
|
}}
|
||||||
QPushButton {{ border:none; background:transparent; border-radius:4px; }}
|
QPushButton {{ border:none; background:transparent; border-radius:4px; }}
|
||||||
QPushButton:hover {{ background:{t['header_hover']}; }}
|
QPushButton:hover {{ background:{t['header_hover']}; }}
|
||||||
@ -887,6 +896,41 @@ class PanelWindow(QWidget):
|
|||||||
if item and item.widget():
|
if item and item.widget():
|
||||||
item.widget()._apply_theme()
|
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):
|
def _quit_application(self):
|
||||||
ret = dialog_style.question(
|
ret = dialog_style.question(
|
||||||
self,
|
self,
|
||||||
@ -1354,7 +1398,11 @@ class PanelWindow(QWidget):
|
|||||||
|
|
||||||
# ── eventFilter:处理 container 上的 resize/drag ─────
|
# ── eventFilter:处理 container 上的 resize/drag ─────
|
||||||
def eventFilter(self, obj, event):
|
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()
|
et = event.type()
|
||||||
# drop 事件放行给子 widget
|
# drop 事件放行给子 widget
|
||||||
if et in (
|
if et in (
|
||||||
@ -1377,12 +1425,14 @@ class PanelWindow(QWidget):
|
|||||||
self._resize_start_global = event.globalPosition().toPoint()
|
self._resize_start_global = event.globalPosition().toPoint()
|
||||||
self._resize_start_geo = self.geometry()
|
self._resize_start_geo = self.geometry()
|
||||||
return True
|
return True
|
||||||
pos_c = self.container.mapFrom(self, local)
|
# 快捷栏/按钮区域不允许拖动窗口(只保留边缘 resize)
|
||||||
if not self._container_pos_is_title_bar(pos_c):
|
if obj is self.container:
|
||||||
return False
|
pos_c = self.container.mapFrom(self, local)
|
||||||
self._win_drag_pos = (
|
if not self._container_pos_is_title_bar(pos_c):
|
||||||
event.globalPosition().toPoint() - self.frameGeometry().topLeft()
|
return False
|
||||||
)
|
self._win_drag_pos = (
|
||||||
|
event.globalPosition().toPoint() - self.frameGeometry().topLeft()
|
||||||
|
)
|
||||||
|
|
||||||
elif et == QEvent.Type.MouseMove:
|
elif et == QEvent.Type.MouseMove:
|
||||||
gp = event.globalPosition().toPoint()
|
gp = event.globalPosition().toPoint()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user