-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfolder_picker.hpp
More file actions
40 lines (33 loc) · 1.78 KB
/
Copy pathfolder_picker.hpp
File metadata and controls
40 lines (33 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
// 跨平台目录选择器,用于"+ 添加项目" 入口。Windows 走 IFileOpenDialog,POSIX
// 在 MVP 阶段返回 nullopt(后续 PR 接 GTK / Cocoa)。
#include <optional>
#include <string>
namespace acecode::desktop {
// parent_hwnd: Windows 上传 HWND 当 dialog 的 owner 让 modal 关系正确;
// nullptr 也合法,Windows 下会尝试使用当前前台窗口作为 owner。
// 返回:用户选定的绝对路径(正斜杠 normalize 由调用方做);取消 / 失败 → nullopt。
std::optional<std::string> pick_folder(void* parent_hwnd);
// 可区分结果的版本:"用户取消"与"环境缺失选择器工具"是两种必须区别对待的
// 失败 —— 前者静默合理,后者必须把原因透传到 UI,否则用户点"添加项目"看到的
// 就是毫无反应(Linux 上 zenity/kdialog 双缺失时的真实事故)。
struct FolderPickOutcome {
std::optional<std::string> path; // 有值 = 用户选中
std::string error; // 非空 = 环境问题(如缺 zenity/kdialog)
// path 为空且 error 为空 = 用户取消
};
FolderPickOutcome pick_folder_outcome(void* parent_hwnd);
// 原生“另存为”对话框。suggested_filename 只包含建议文件名(例如
// "会话标题.md"),用户可在系统对话框里修改文件名和保存位置。
struct SaveFilePickOutcome {
std::optional<std::string> path; // 有值 = 用户确认的完整文件路径
std::string error; // 非空 = 对话框环境/系统错误
// path 为空且 error 为空 = 用户取消
};
SaveFilePickOutcome pick_save_file_outcome(
void* parent_hwnd,
const std::string& suggested_filename);
std::optional<std::string> pick_save_file(
void* parent_hwnd,
const std::string& suggested_filename);
} // namespace acecode::desktop