Skip to content

feat(gui): add category-switch keyboard shortcuts (Alt+arrows / Alt+F)#136

Open
StudentWeis wants to merge 1 commit into
mainfrom
feat/category-hotkeys
Open

feat(gui): add category-switch keyboard shortcuts (Alt+arrows / Alt+F)#136
StudentWeis wants to merge 1 commit into
mainfrom
feat/category-hotkeys

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

Summary

为分类筛选条加上键盘快捷键,避免用户用全局快捷键唤起后还要切到鼠标点筛选按钮(响应 discussion #134)。

Linked Issue

Closes #135

Changes

  • Alt + → / Alt + ←:在 All → Text → Image → Files → All 之间循环切换内容分类过滤
  • Alt + F:切换"仅收藏"过滤;与内容分类正交,可组合(如"收藏的图片"),且搜索框聚焦时也生效
  • 新增三个 GPUI action(CycleFilterNext / CycleFilterPrev / ToggleFavoritesFilter),在 src/app.rs 通过 bind_keys 注册
  • 新增纯函数 next_content_filter(current, forward) -> ContentFilter,覆盖单元测试(正向 / 反向循环)
  • 帮助面板 src/gui/panel/help.rs 新增两行,i18n 键 help_cycle_filter / help_toggle_favorites_filter 三种语言齐备

设计说明

  • 选 Alt+方向键而非 Tab:Input 组件在自己 context 里把 tab / shift-tab 绑成了 IndentInline / OutdentInlinegpui-component-0.5.1/src/input/state.rs:127-128),用 Tab 会让搜索框里行为不一致。Alt+方向键有同类问题(Input 也绑了 MoveToPreviousWord / MoveToNextWord),但只影响"搜索框聚焦时的循环切换"——和现有 j/k/h/l 在搜索框中失效的语义一致。
  • Alt+F 之所以在搜索框也可用:Input 没有绑定 alt-f,所以全局 bind_keys 优先级足够。
  • 循环到 All 等价于"无过滤",再按一次 Alt+F 关闭收藏过滤——和现有点击行为一致(点已激活的过滤按钮会重置)。

Testing

  • scripts/precheck.sh passes locally(cargo check / clippy / test 442 passed / i18n / icons / themes / machete 全部 OK)
  • New / updated tests cover the change(next_content_filter_cycles_forward / next_content_filter_cycles_backward
  • 手动验证 Alt+→/← 在主列表聚焦时循环切换 Text/Image/Files/All
  • 手动验证 Alt+F 在主列表与搜索框聚焦下都能切换收藏过滤
  • 手动验证 Alt+F + Alt+→ 组合可达到"收藏的图片"

Self-Check

  • PR title follows Conventional Commits
  • No hardcoded user-facing strings — i18n keys added to all locale files
  • Errors defined with thiserror (no manual impl Display/Error) — N/A,本次无新错误类型
  • No unrelated changes mixed in

Alt+Right / Alt+Left cycle the content filter (All → Text → Image →
Files → All), and Alt+F toggles the favorites-only filter. The two
dimensions remain orthogonal, so users can scope to e.g. "favorited
images" entirely from the keyboard.

Implemented as proper GPUI actions registered via bind_keys so the
favorites toggle also fires while the search input is focused (Tab and
Alt+arrow are intercepted by the Input context, so cycling is
list-focused — consistent with existing j/k/h/l).

Refs #135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 增加分类切换快捷键 (Alt+方向键 / Alt+F)

1 participant