mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 02:09:46 +08:00
feat(ui): 统一管理IUP控件名称常量,增强可维护性
refactor(core): 移除未使用的get_app_context函数 refactor(os_env): 修改backup_registry函数以返回错误码并备份到指定目录 refactor(path_manager): 增强路径管理函数的错误处理
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#define APP_CONTEXT_H
|
||||
|
||||
#include "utils/string_ext.h"
|
||||
#include <iup.h>
|
||||
|
||||
// 应用上下文结构体,用于存储应用运行时的状态
|
||||
typedef struct {
|
||||
@@ -16,7 +15,4 @@ AppContext* create_app_context(void);
|
||||
// 销毁应用上下文
|
||||
void destroy_app_context(AppContext* ctx);
|
||||
|
||||
// 获取应用上下文
|
||||
AppContext* get_app_context(Ihandle *ih);
|
||||
|
||||
#endif // APP_CONTEXT_H
|
||||
|
||||
@@ -5,9 +5,16 @@
|
||||
#include "utils/string_ext.h"
|
||||
|
||||
// 刷新单个列表框样式
|
||||
// 功能说明:
|
||||
// 1. 路径有效性检查:无效路径显示红色前景色 (255 0 0)
|
||||
// 2. 重复检查:重复路径显示橙色前景色 (255 128 0),只检查当前项之前的项
|
||||
// 3. 斑马纹背景:奇偶行交替显示不同背景色 (白/灰)
|
||||
// 注意: 该函数需要IUP控件已设置NAME属性
|
||||
void refresh_single_list_style(Ihandle *list);
|
||||
|
||||
// 同步字符串列表到 UI 列表框
|
||||
// 将StringList中的所有项同步到IUP FlatList控件中
|
||||
// 会先清空列表然后重新添加所有项,最后刷新样式
|
||||
void sync_string_list_to_ui(Ihandle *list_ui, const StringList *str_list);
|
||||
|
||||
#endif // UI_UTILS_H
|
||||
|
||||
@@ -11,7 +11,8 @@ typedef enum {
|
||||
ERR_INVALID_FORMAT = -6, // 无效格式
|
||||
ERR_REGISTRY_FAILED = -7, // 注册表操作失败
|
||||
ERR_NOT_FOUND = -8, // 未找到
|
||||
ERR_EXISTS = -9 // 已存在
|
||||
ERR_EXISTS = -9, // 已存在
|
||||
ERR_INVALID_INDEX = -10 // 无效索引
|
||||
} ErrorCode;
|
||||
|
||||
const char* error_code_to_string(ErrorCode code);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef OS_ENV_H
|
||||
#define OS_ENV_H
|
||||
|
||||
#include "utils/error_code.h"
|
||||
|
||||
// 检查是否以管理员权限运行
|
||||
int check_admin(void);
|
||||
|
||||
@@ -8,6 +10,6 @@ int check_admin(void);
|
||||
int is_path_valid(const char *path);
|
||||
|
||||
// 备份注册表
|
||||
void backup_registry(void);
|
||||
ErrorCode backup_registry(void);
|
||||
|
||||
#endif // OS_ENV_H
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef UI_CONSTANTS_H
|
||||
#define UI_CONSTANTS_H
|
||||
|
||||
// 缓冲区大小常量
|
||||
#define PATH_BUFFER_SIZE 4096
|
||||
|
||||
// 控件名称常量 - 统一管理所有IUP控件名称字符串
|
||||
// 使用这些常量替代硬编码字符串,便于维护和减少拼写错误
|
||||
|
||||
// 列表控件
|
||||
#define CTRL_LIST_SYS "LIST_SYS"
|
||||
#define CTRL_LIST_USER "LIST_USER"
|
||||
|
||||
// 选项卡
|
||||
#define CTRL_TABS_MAIN "TABS_MAIN"
|
||||
|
||||
// 搜索框
|
||||
#define CTRL_TXT_SEARCH "TXT_SEARCH"
|
||||
|
||||
// 状态标签
|
||||
#define CTRL_LBL_STATUS "LBL_STATUS"
|
||||
|
||||
// 操作按钮
|
||||
#define CTRL_BTN_NEW "BTN_NEW"
|
||||
#define CTRL_BTN_EDIT "BTN_EDIT"
|
||||
#define CTRL_BTN_BROWSE "BTN_BROWSE"
|
||||
#define CTRL_BTN_DEL "BTN_DEL"
|
||||
#define CTRL_BTN_UP "BTN_UP"
|
||||
#define CTRL_BTN_DOWN "BTN_DOWN"
|
||||
#define CTRL_BTN_CLEAN "BTN_CLEAN"
|
||||
#define CTRL_BTN_IMPORT "BTN_IMPORT"
|
||||
#define CTRL_BTN_EXPORT "BTN_EXPORT"
|
||||
#define CTRL_BTN_OK "BTN_OK"
|
||||
#define CTRL_BTN_CANCEL "BTN_CANCEL"
|
||||
#define CTRL_BTN_HELP "BTN_HELP"
|
||||
#define CTRL_BTN_LANG "BTN_LANG"
|
||||
|
||||
#endif // UI_CONSTANTS_H
|
||||
Reference in New Issue
Block a user