From fd3b72676b24d8e04058698a5aabb8f1f816bd6c Mon Sep 17 00:00:00 2001 From: Ziao Huang <71763696+amazing-fish@users.noreply.github.com> Date: Sat, 10 Jan 2026 14:29:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E6=8E=92=E5=BA=8F=E4=B8=8B=E6=8B=89=E6=A1=86=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E9=97=AE=E9=A2=98=EF=BC=8C=E7=89=88=E6=9C=AC=20v1.7.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- anchor.md | 3 ++- todo_app/constants.py | 2 +- todo_app/main_window.py | 24 ++++++++++++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/anchor.md b/anchor.md index a9cd7ae..c86bd2d 100644 --- a/anchor.md +++ b/anchor.md @@ -34,7 +34,7 @@ - `feature` → 提升次版本号。 - `bugfix` → 提升修订号。 - 仅文档与注释变更默认不触发版本号递增,除非影响发布说明或行为约定。 -- 当前约定版本:`v1.7.3`。 +- 当前约定版本:`v1.7.4`。 ## 数据约束 - 所有待办保存在项目根目录下的 `todos.json`,结构为列表,元素为字典;打包版运行时会改存至用户数据目录(Windows `%APPDATA%\TODOList`,其他平台 `~/.todolist/`)。 @@ -66,6 +66,7 @@ - 若确认无变更,提交说明需写明“锚点已复盘,无需更新”。 ## 最近约定变更 +- 2026-01-11:bugfix,修复筛选/排序下拉框宽度计算导致文字截断与空白区问题,版本更新至 `v1.7.4`。 - 2026-01-10:bugfix,Windows 打包流程改用 Runner 临时目录缓存 pip,修复缓存路径不存在告警(不触发版本号)。 - 2026-01-09:refactor,GitHub Actions 打包流程增加 pip 缓存以提升构建速度(不触发版本号)。 - 2026-01-08:bugfix,调整新增任务按钮位置避免窄屏与排序选项重叠,版本更新至 `v1.7.3`。 diff --git a/todo_app/constants.py b/todo_app/constants.py index 7094e64..98eac95 100644 --- a/todo_app/constants.py +++ b/todo_app/constants.py @@ -38,7 +38,7 @@ class ThemeColors: # --- 基本信息 --- APP_NAME = "桌面待办事项 v1" -APP_VERSION = "1.7.3" +APP_VERSION = "1.7.4" # --- 文件资源 --- APP_ICON_PATH = "assets/icons/app_icon.svg" diff --git a/todo_app/main_window.py b/todo_app/main_window.py index 08e3630..8c5160b 100644 --- a/todo_app/main_window.py +++ b/todo_app/main_window.py @@ -22,6 +22,8 @@ QMessageBox, QPushButton, QSizePolicy, + QStyle, + QStyleOptionComboBox, QSystemTrayIcon, QVBoxLayout, QWidget, @@ -274,21 +276,23 @@ def _apply_combo_palette(self, combo: Optional[QComboBox], palette: ThemeColors) self._update_combo_compact_width(combo) def _update_combo_compact_width(self, combo: Optional[QComboBox]) -> None: - """根据内容长度压缩组合框宽度,避免在布局中被拉伸。""" + """根据内容与样式计算组合框宽度,避免文本被截断或出现空白区。""" if combo is None: return + if combo.count() == 0: + return + metrics = combo.fontMetrics() - max_text_width = 0 - for index in range(combo.count()): - text_width = metrics.horizontalAdvance(combo.itemText(index)) - if text_width > max_text_width: - max_text_width = text_width - - # 样式中左右内边距分别为 6px 与 14px,箭头宽度约 9px,额外保留 8px 防止文字贴边。 - extra_spacing = 6 + 14 + 9 + 8 - combo.setFixedWidth(max_text_width + extra_spacing) + max_text = max(combo.itemText(index) for index in range(combo.count())) + text_width = metrics.horizontalAdvance(max_text) + option = QStyleOptionComboBox() + option.initFrom(combo) + option.currentText = max_text + option.fontMetrics = metrics + size = combo.style().sizeFromContents(QStyle.CT_ComboBox, option, QSize(text_width, 0), combo) + combo.setFixedWidth(size.width() + 2) def _refresh_item_widgets_palette(self, palette: ThemeColors) -> None: From e93466caa5dd1124afe6960fe0c79d689b7c1cb6 Mon Sep 17 00:00:00 2001 From: Ziao Huang <71763696+amazing-fish@users.noreply.github.com> Date: Sat, 10 Jan 2026 15:17:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bugfix:=20=E4=BF=AE=E6=AD=A3=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=E6=9C=80=E9=95=BF=E6=96=87=E6=9C=AC=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E8=AE=A1=E7=AE=97=EF=BC=8C=E7=89=88=E6=9C=AC=20v1.7.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- anchor.md | 3 ++- todo_app/constants.py | 2 +- todo_app/main_window.py | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/anchor.md b/anchor.md index c86bd2d..455dca9 100644 --- a/anchor.md +++ b/anchor.md @@ -34,7 +34,7 @@ - `feature` → 提升次版本号。 - `bugfix` → 提升修订号。 - 仅文档与注释变更默认不触发版本号递增,除非影响发布说明或行为约定。 -- 当前约定版本:`v1.7.4`。 +- 当前约定版本:`v1.7.5`。 ## 数据约束 - 所有待办保存在项目根目录下的 `todos.json`,结构为列表,元素为字典;打包版运行时会改存至用户数据目录(Windows `%APPDATA%\TODOList`,其他平台 `~/.todolist/`)。 @@ -66,6 +66,7 @@ - 若确认无变更,提交说明需写明“锚点已复盘,无需更新”。 ## 最近约定变更 +- 2026-01-11:bugfix,修正筛选/排序下拉框最长文本宽度计算逻辑,版本更新至 `v1.7.5`。 - 2026-01-11:bugfix,修复筛选/排序下拉框宽度计算导致文字截断与空白区问题,版本更新至 `v1.7.4`。 - 2026-01-10:bugfix,Windows 打包流程改用 Runner 临时目录缓存 pip,修复缓存路径不存在告警(不触发版本号)。 - 2026-01-09:refactor,GitHub Actions 打包流程增加 pip 缓存以提升构建速度(不触发版本号)。 diff --git a/todo_app/constants.py b/todo_app/constants.py index 98eac95..9b5cb66 100644 --- a/todo_app/constants.py +++ b/todo_app/constants.py @@ -38,7 +38,7 @@ class ThemeColors: # --- 基本信息 --- APP_NAME = "桌面待办事项 v1" -APP_VERSION = "1.7.4" +APP_VERSION = "1.7.5" # --- 文件资源 --- APP_ICON_PATH = "assets/icons/app_icon.svg" diff --git a/todo_app/main_window.py b/todo_app/main_window.py index 8c5160b..08cb7c2 100644 --- a/todo_app/main_window.py +++ b/todo_app/main_window.py @@ -285,7 +285,10 @@ def _update_combo_compact_width(self, combo: Optional[QComboBox]) -> None: return metrics = combo.fontMetrics() - max_text = max(combo.itemText(index) for index in range(combo.count())) + max_text = max( + (combo.itemText(index) for index in range(combo.count())), + key=metrics.horizontalAdvance, + ) text_width = metrics.horizontalAdvance(max_text) option = QStyleOptionComboBox() option.initFrom(combo)