Skip to content

feat(profile-editor): 为时间表编辑器添加撤销/重做功能#1818

Merged
HelloWRC merged 8 commits into
ClassIsland:masterfrom
Akiyama-Mizuki-44:feature/undo-redo-v2
Jun 11, 2026
Merged

feat(profile-editor): 为时间表编辑器添加撤销/重做功能#1818
HelloWRC merged 8 commits into
ClassIsland:masterfrom
Akiyama-Mizuki-44:feature/undo-redo-v2

Conversation

@Akiyama-Mizuki-44

Copy link
Copy Markdown
Contributor

这个 Pull Request 做了什么?

为时间表编辑器添加撤销(Ctrl+Z)和重做(Ctrl+Y)功能:

  • 支持撤销/重做添加、删除时间点操作
  • 工具栏新增撤销/重做按钮,点击可展开历史记录列表,支持跳转到指定步骤
  • 切换时间表时自动清空历史记录

检查清单

  • 我已经在本地测试过这个 PR,确保欲实现的功能或修复的问题能正常工作。

@Akiyama-Mizuki-44 Akiyama-Mizuki-44 requested review from a team and HelloWRC as code owners May 29, 2026 17:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f60b6cd32

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ClassIsland/Views/ProfileSettingsWindow.axaml.cs
@Akiyama-Mizuki-44

Copy link
Copy Markdown
Contributor Author

涉及文件:

  • ClassIsland/ViewModels/ProfileSettingsViewModel.cs
  • ClassIsland/Views/ProfileSettingsWindow.axaml
  • ClassIsland/Views/ProfileSettingsWindow.axaml.cs

@Akiyama-Mizuki-44 Akiyama-Mizuki-44 force-pushed the feature/undo-redo-v2 branch 2 times, most recently from 6ed1df6 to b457db9 Compare May 29, 2026 17:46

@HelloWRC HelloWRC left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此外,目前还发现了以下问题:

  • 在刚刚创建完新时间点时,Ctrl + Z 键盘快捷键无法撤销,而只有在将选择移动到其它时间点后,才可以撤销。
  • 并且在通过键盘快捷键 Ctrl + Z 撤销删除了选中的时间点后,无法继续使用 Ctrl + Z 撤销,只有在选中了其他时间点后,才能继续使用此快捷键撤销。

private readonly Stack<UndoEntry> _undoStack = new();
private readonly Stack<UndoEntry> _redoStack = new();

private static string DescribeItem(TimeLayoutItem item) => item.TimeType switch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeLayoutItem 的 ToString 方法已经实现了将 TimeLayoutItem 转换为描述性的字符串,无需在此处进行额外的封装。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经删掉 DescribeItem,直接用 item.ToString() 了,感谢指出

ToolTip.Tip="添加行动时间点。"
Label="行动" />
<controls:CommandBarSeparator />
<controls:CommandBarButton IconSource="{ci:FluentIconSource &#xE10E;}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处添加的按钮导致命令栏溢出,进一步导致“删除时间表”按钮在默认窗口大小下无法使用。请考虑通过删减文本缩小此处的按钮宽度。

此外,此处按钮应该替换为符合“撤销”、“重做”语义的图标。

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经去掉按钮的文字标签改成纯图标,命令栏不会再溢出了,图标也换成了 arrow_undo / arrow_redo,符合撤销/重做语义

@Akiyama-Mizuki-44

Copy link
Copy Markdown
Contributor Author

这两个都修了,把 Ctrl+Z/Y 改成了窗口级快捷键,不再依赖时间点列表是否获得焦点,所以新建时间点或撤销删除后都能直接继续用,同时做了保护,焦点在文本框里时仍走文本框自己的撤销

@HelloWRC HelloWRC merged commit d2c32bf into ClassIsland:master Jun 11, 2026
2 checks passed
@HelloWRC

Copy link
Copy Markdown
Member

感谢您的贡献🤝

昔涟 爱

@all-contributors please add @Akiyama-Mizuki-44 for code

@allcontributors

Copy link
Copy Markdown
Contributor

@HelloWRC

I've put up a pull request to add @Akiyama-Mizuki-44! 🎉

Koharu-Mizuki added a commit to Koharu-Mizuki/ClassIsland-RB that referenced this pull request Jun 19, 2026
* feat(profile-editor): 添加时间点撤销功能 (Ctrl+Z)

* feat(profile-editor): 添加时间点重做功能 (Ctrl+Y)

* feat(profile-editor): 撤销/重做支持历史记录下拉列表

* fix(profile-editor): 修复时间表为空时 Ctrl+Z/Y 快捷键失效的问题

* fix(profile-editor): 撤销/重做后同步更新选中的时间点

* style: 移除重复的 break 语句与多余空行

* fix(profile-editor): 撤销/重做改用窗口级快捷键,修复新建或撤销后需重新选中才能触发的问题

* fix(profile-editor): 使用 item.ToString() 替代 DescribeItem,改用正确图标并移除按钮文字标签

---------

Co-authored-by: 曉山瑞希🍥🏳️‍⚧️ <w_mutsumi@hotmail.com>
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.

3 participants