Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions TeXmacs/misc/themes/liii-night.css
Original file line number Diff line number Diff line change
Expand Up @@ -1097,36 +1097,6 @@ QLabel#startup-tab-page-desc {
margin-bottom: 24px;
}

/* File页主按钮 - New Document */
QPushButton#startup-tab-primary-btn {
background-color: #2791ad;
color: #ffffff;
border: none;
border-radius: 6px;
padding: 12px 32px;
font-size: 14px;
font-weight: bold;
}

QPushButton#startup-tab-primary-btn:hover {
background-color: #1e7891;
}

/* File页次按钮 - Open Document */
QPushButton#startup-tab-secondary-btn {
background-color: transparent;
color: #ffffff;
border: 2px solid #2791ad;
border-radius: 6px;
padding: 12px 32px;
font-size: 14px;
font-weight: bold;
}

QPushButton#startup-tab-secondary-btn:hover {
background-color: rgba(39, 145, 173, 0.2);
}

/* 模板使用按钮 - Template Use Button */
QPushButton#template-use-btn {
background-color: #4CAF50;
Expand Down
30 changes: 0 additions & 30 deletions TeXmacs/misc/themes/liii.css
Original file line number Diff line number Diff line change
Expand Up @@ -1070,36 +1070,6 @@ QLabel#startup-tab-page-desc {
margin-bottom: 24px;
}

/* File页主按钮 - New Document */
QPushButton#startup-tab-primary-btn {
background-color: #2791ad;
color: #ffffff;
border: none;
border-radius: 6px;
padding: 12px 32px;
font-size: 14px;
font-weight: bold;
}

QPushButton#startup-tab-primary-btn:hover {
background-color: #215a6a;
}

/* File页次按钮 - Open Document */
QPushButton#startup-tab-secondary-btn {
background-color: #ffffff;
color: #215a6a;
border: 2px solid #2791ad;
border-radius: 6px;
padding: 12px 32px;
font-size: 14px;
font-weight: bold;
}

QPushButton#startup-tab-secondary-btn:hover {
background-color: #e8f4f6;
}

/* 模板使用按钮 - Template Use Button */
QPushButton#template-use-btn {
background-color: #4CAF50;
Expand Down
60 changes: 60 additions & 0 deletions TeXmacs/progs/startup-tab/startup-tab-file.scm
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))
3 changes: 2 additions & 1 deletion TeXmacs/progs/startup-tab/startup-tab.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (startup-tab startup-tab)
(:use (texmacs texmacs tm-files)))
(:use (texmacs texmacs tm-files))
(:use (startup-tab startup-tab-file)))

(tm-define (startup-tab-enabled?)
#t)
Expand Down
91 changes: 91 additions & 0 deletions devel/216_5.md
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)`,不切换页面
Loading
Loading