diff --git a/__pycache__/shortcut_target.cpython-314.pyc b/__pycache__/shortcut_target.cpython-314.pyc index e1f461b..ee1076c 100644 Binary files a/__pycache__/shortcut_target.cpython-314.pyc and b/__pycache__/shortcut_target.cpython-314.pyc differ diff --git a/app_info.py b/app_info.py new file mode 100644 index 0000000..b66c1e7 --- /dev/null +++ b/app_info.py @@ -0,0 +1,7 @@ +APP_NAME = "牛马软件柜" +__VERSION__ = "0.0.3" + + +def app_title() -> str: + return f"{APP_NAME} - Version:{__VERSION__}" + diff --git a/db/__pycache__/__init__.cpython-314.pyc b/db/__pycache__/__init__.cpython-314.pyc index a96bb38..788c4ac 100644 Binary files a/db/__pycache__/__init__.cpython-314.pyc and b/db/__pycache__/__init__.cpython-314.pyc differ diff --git a/db/__pycache__/database.cpython-314.pyc b/db/__pycache__/database.cpython-314.pyc index d476d44..d9d0367 100644 Binary files a/db/__pycache__/database.cpython-314.pyc and b/db/__pycache__/database.cpython-314.pyc differ diff --git a/main.py b/main.py index d8145ce..0169df0 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from ui.ball import FloatBall, BALL_SIZE import ui.theme as theme from db import database -__VERSION__ = "0.0.3" +from app_info import __VERSION__, app_title # ===================== 打包兼容核心函数 ===================== def get_resource_path(relative_path): @@ -34,7 +34,7 @@ def _wake_existing_or_exit() -> bool: import ctypes.wintypes mutex_name = r"Global\CleanDesktopOrganizerSingleton" - title = "牛马软件柜 v" + __VERSION__ + title = app_title() kernel32 = ctypes.windll.kernel32 user32 = ctypes.windll.user32 diff --git a/ui/__pycache__/__init__.cpython-314.pyc b/ui/__pycache__/__init__.cpython-314.pyc index 3d14df1..efb2ce1 100644 Binary files a/ui/__pycache__/__init__.cpython-314.pyc and b/ui/__pycache__/__init__.cpython-314.pyc differ diff --git a/ui/__pycache__/ball.cpython-314.pyc b/ui/__pycache__/ball.cpython-314.pyc index 52cea95..a5e1fee 100644 Binary files a/ui/__pycache__/ball.cpython-314.pyc and b/ui/__pycache__/ball.cpython-314.pyc differ diff --git a/ui/__pycache__/dialog_style.cpython-314.pyc b/ui/__pycache__/dialog_style.cpython-314.pyc index 030c621..6a397a0 100644 Binary files a/ui/__pycache__/dialog_style.cpython-314.pyc and b/ui/__pycache__/dialog_style.cpython-314.pyc differ diff --git a/ui/__pycache__/dock.cpython-314.pyc b/ui/__pycache__/dock.cpython-314.pyc index 1b6abc9..5640f6b 100644 Binary files a/ui/__pycache__/dock.cpython-314.pyc and b/ui/__pycache__/dock.cpython-314.pyc differ diff --git a/ui/__pycache__/flow_layout.cpython-314.pyc b/ui/__pycache__/flow_layout.cpython-314.pyc index 4271dd3..342c24f 100644 Binary files a/ui/__pycache__/flow_layout.cpython-314.pyc and b/ui/__pycache__/flow_layout.cpython-314.pyc differ diff --git a/ui/__pycache__/group.cpython-314.pyc b/ui/__pycache__/group.cpython-314.pyc index 70c0541..cedb468 100644 Binary files a/ui/__pycache__/group.cpython-314.pyc and b/ui/__pycache__/group.cpython-314.pyc differ diff --git a/ui/__pycache__/item.cpython-314.pyc b/ui/__pycache__/item.cpython-314.pyc index af74f4e..67ac674 100644 Binary files a/ui/__pycache__/item.cpython-314.pyc and b/ui/__pycache__/item.cpython-314.pyc differ diff --git a/ui/__pycache__/settings_window.cpython-314.pyc b/ui/__pycache__/settings_window.cpython-314.pyc index a8e5032..e7889bb 100644 Binary files a/ui/__pycache__/settings_window.cpython-314.pyc and b/ui/__pycache__/settings_window.cpython-314.pyc differ diff --git a/ui/__pycache__/theme.cpython-314.pyc b/ui/__pycache__/theme.cpython-314.pyc index e9d538f..6e096e4 100644 Binary files a/ui/__pycache__/theme.cpython-314.pyc and b/ui/__pycache__/theme.cpython-314.pyc differ diff --git a/ui/dock.py b/ui/dock.py index e866c57..9efc5b0 100644 --- a/ui/dock.py +++ b/ui/dock.py @@ -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()