-
Notifications
You must be signed in to change notification settings - Fork 92
[216_5] 实现文档页面创建不同样式文档 #3121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+743
−163
Merged
[216_5] 实现文档页面创建不同样式文档 #3121
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
|
|
||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; MODULE : startup-tab-file.scm | ||
| ;; DESCRIPTION: Scheme bindings for startup tab file operations | ||
| ;; COPYRIGHT : (C) 2026 Yuki Lu | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; This software falls under the GNU general public license version 3 or later. | ||
| ;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE | ||
| ;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (texmacs-module (startup-tab startup-tab-file) | ||
| (:use (texmacs texmacs tm-server)) | ||
| (:use (texmacs texmacs tm-files)) | ||
| (:use (utils library cursor))) | ||
|
|
||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; Document creation with specific style | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (tm-define (new-document-with-style style-id) | ||
| ;; Create a new document with the specified style | ||
| ;; style-id: "generic", "beamer", "book", "exam", "letter", "article" | ||
| ;; Use with-buffer to ensure we're working in the correct buffer context | ||
| (with-default-view | ||
| (let ((buf (if (window-per-buffer?) (open-window) (new-buffer)))) | ||
| ;; Schedule style initialization after buffer is fully set up | ||
| (delayed | ||
| (:idle 100) | ||
| (with-buffer buf | ||
| (init-style style-id)))))) | ||
|
|
||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; File operations wrappers | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (tm-define (startup-tab-file-open) | ||
| ;; Open file dialog wrapper | ||
| (open-document)) | ||
|
|
||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; Recent documents management | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (tm-define (startup-tab-get-recent-docs) | ||
| ;; Get list of recent documents | ||
| ;; Returns: list of (filename path timestamp) tuples | ||
| '()) | ||
|
|
||
| (tm-define (startup-tab-add-recent-doc path) | ||
| ;; Add a document to recent list | ||
| (noop)) | ||
|
|
||
| (tm-define (startup-tab-clear-recent-doc path) | ||
| ;; Remove a specific document from recent list | ||
| (noop)) | ||
|
|
||
| (tm-define (startup-tab-clear-all-recent) | ||
| ;; Clear all recent documents | ||
| (noop)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # 216_5 启动标签页文件页完整实现 | ||
|
|
||
| ## 如何测试 | ||
| 1. 编译时先输入 `xmake config -vD --startup_tab=true` | ||
| 2. 启动 Mogan STEM,点击 "Mogan STEM" 标签页 | ||
| 3. 测试左侧导航栏: | ||
| - **File**: 切换到文件页 | ||
| - **Template**: 切换到模板页(占位) | ||
| - **Open Folder**: 点击弹出文件选择对话框 | ||
| - **Settings**: 切换到设置页(占位) | ||
| - **Quit**: 退出程序 | ||
| 4. File 页测试: | ||
| - **样式卡片区**: | ||
| - 鼠标悬停卡片:高亮选中(蓝色边框) | ||
| - 单击卡片:创建对应样式的新文档 | ||
| - Generic 卡片有 "Default" 标签 | ||
| - **最近文档列表**(当前为占位实现): | ||
| - UI 已就绪,可展示最近文档列表 | ||
| - 点击/右键菜单功能待与文件打开历史集成后启用 | ||
|
|
||
| ## 2026/04/09 启动标签页文件页完整实现 | ||
|
|
||
| ### What | ||
| 实现启动标签页「文件」页的完整功能,包括文档样式选择、最近文档管理和文件打开功能。 | ||
|
|
||
| #### 新增文件: | ||
|
|
||
| **src/Plugins/Qt/qt_file_page.hpp** (新增) | ||
| - `StyleCard` 类:样式卡片控件,支持悬停选中、单击创建 | ||
| - `QtFilePage` 类:文件页面主类 | ||
| - 样式卡片区(Generic/Beamer/Book/Exam/Letter/Article) | ||
| - 最近文档列表(QListWidget) | ||
| - 样式卡片与最近文档的分隔线 | ||
|
|
||
| **src/Plugins/Qt/qt_file_page.cpp** (新增) | ||
| - 样式卡片实现:100x120px 固定大小,首字母图标,名称标签 | ||
| - 最近文档列表(占位实现):UI 框架已就绪,待与文件打开历史集成 | ||
| - 文档创建:通过 Scheme 函数 `(new-document-with-style style-id)` | ||
|
|
||
| **TeXmacs/progs/startup-tab/startup-tab-file.scm** (新增) | ||
| - `(new-document-with-style style-id)`: 创建指定样式的新文档 | ||
| - `(startup-tab-file-open)`: 打开文件对话框包装 | ||
|
|
||
| #### 修改文件: | ||
|
|
||
| **src/Plugins/Qt/qt_startup_tab_widget.hpp** (修改) | ||
| - 替换 `navRecentBtn_` 为 `navOpenFolderBtn_` | ||
| - 添加 `filePage_` 成员指针 | ||
| - 移除旧的新建/打开文件槽函数 | ||
|
|
||
| **src/Plugins/Qt/qt_startup_tab_widget.cpp** (修改) | ||
| - File 页面使用 `QtFilePage` 替代简单占位 | ||
| - 左侧导航栏顺序:File | Template | Open Folder | Settings | ||
| - "Open Folder" 不在互斥按钮组,点击直接触发 `(open-document)` | ||
| - 移除旧的 `create_recent_page()` 实现 | ||
|
|
||
| **TeXmacs/progs/startup-tab/startup-tab.scm** (修改) | ||
| - 添加模块依赖:`(startup-tab startup-tab-file)` | ||
|
|
||
| **TeXmacs/misc/themes/liii.css(liii-night.css)** (修改) | ||
| - 删除不再使用的按钮样式:`startup-tab-primary-btn`, `startup-tab-secondary-btn` | ||
|
|
||
| ### Why | ||
| 之前只实现了简单的 New/Open 按钮,需要在当前PR中: | ||
| 1. 提供文档样式选择(Generic/Beamer/Book/Exam/Letter/Article) | ||
| 2. 最近文档 UI 框架(数据集成待后续实现) | ||
| 3. 将打开文件功能移到更合理的导航栏位置 | ||
| 4. 优化文档创建流程(悬停预览、单击创建) | ||
|
|
||
| ### How | ||
|
|
||
| **核心逻辑**: | ||
|
|
||
| 1. **样式选择**: | ||
| - `StyleCard` 继承 `QWidget`,自定义绘制选中边框 | ||
| - 悬停:`hovered()` 信号 → 更新选中状态 | ||
| - 单击:`clicked()` 信号 → 创建文档 | ||
|
|
||
| 2. **文档创建**: | ||
| - C++: `createDocumentWithStyle(styleId)` → Scheme: `(new-document-with-style styleId)` | ||
| - Scheme: 使用 `with-default-view` + `new-buffer` 创建缓冲区 | ||
| - 通过 `delayed` + `init-style` 异步应用样式,避免初始化时序问题 | ||
|
|
||
| 3. **最近文档(占位实现)**: | ||
| - UI 框架:`QListWidget` 展示列表,`QJsonDocument` 存储格式 | ||
| - 数据结构预留:`[{"path": "...", "name": "...", "opened_at": "..."}, ...]` | ||
| - 待集成:与 `buffer-notify-recent` 等 Scheme 函数对接,实现真正的文件历史记录 | ||
|
|
||
| 4. **导航栏**: | ||
| - "Open Folder" 使用 `setCheckable(false)`,不加入 `QButtonGroup` | ||
| - 点击直接执行 `(open-document)`,不切换页面 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.