mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 02:09:46 +08:00
feat(merge): 添加合并预览 Tab 页
- 新增第三个 Tab「合并预览」,只读展示系统+用户 PATH 完整列表 - 选项卡切换时自动刷新合并列表 - 支持无效/重复路径高亮 - 新增中英文翻译 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -23,4 +23,7 @@ Ihandle *get_current_list(Ihandle *dlg);
|
||||
// 刷新撤销/重做按钮的启用状态
|
||||
void refresh_undo_redo_buttons(Ihandle *dlg);
|
||||
|
||||
// 同步合并预览列表
|
||||
void sync_merged_list(Ihandle *dlg);
|
||||
|
||||
#endif // CALLBACKS_INTERNAL_H
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// 列表控件
|
||||
#define CTRL_LIST_SYS "LIST_SYS"
|
||||
#define CTRL_LIST_USER "LIST_USER"
|
||||
#define CTRL_LIST_MERGED "LIST_MERGED"
|
||||
|
||||
// 选项卡
|
||||
#define CTRL_TABS_MAIN "TABS_MAIN"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -51,6 +51,7 @@ local config = {
|
||||
search_placeholder = "Search...",
|
||||
tab_sys = "System Variables",
|
||||
tab_user = "User Variables",
|
||||
tab_merged = "Merged Preview",
|
||||
export_title = "Export PATH",
|
||||
import_title = "Import PATH"
|
||||
},
|
||||
|
||||
@@ -28,6 +28,10 @@ msgstr "System Variables"
|
||||
msgid "User Variables"
|
||||
msgstr "User Variables"
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "Merged Preview"
|
||||
msgstr "Merged Preview"
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "New"
|
||||
msgstr "New"
|
||||
|
||||
@@ -29,6 +29,10 @@ msgstr ""
|
||||
msgid "User Variables"
|
||||
msgstr ""
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "Merged Preview"
|
||||
msgstr ""
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "New"
|
||||
msgstr ""
|
||||
|
||||
@@ -28,6 +28,10 @@ msgstr "系统变量"
|
||||
msgid "User Variables"
|
||||
msgstr "用户变量"
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "Merged Preview"
|
||||
msgstr "合并预览"
|
||||
|
||||
#: src/ui/main_window.c
|
||||
msgid "New"
|
||||
msgstr "新建"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "core/app_context.h"
|
||||
#include "core/undo_redo.h"
|
||||
#include "utils/ui_constants.h"
|
||||
#include "ui/ui_utils.h"
|
||||
#include <iup.h>
|
||||
|
||||
// 辅助函数:获取主对话框
|
||||
@@ -62,3 +63,24 @@ void refresh_undo_redo_buttons(Ihandle *dlg)
|
||||
if (btn_redo)
|
||||
IupSetAttribute(btn_redo, "ACTIVE", can_redo(ctx->undo_redo_mgr) ? "YES" : "NO");
|
||||
}
|
||||
|
||||
// 同步合并预览列表(sys + user)
|
||||
void sync_merged_list(Ihandle *dlg)
|
||||
{
|
||||
AppContext *ctx = get_app_context_from_dlg(dlg);
|
||||
Ihandle *list_merged = IupGetDialogChild(dlg, CTRL_LIST_MERGED);
|
||||
if (!ctx || !list_merged)
|
||||
return;
|
||||
|
||||
IupSetAttribute(list_merged, "REMOVEITEM", "ALL");
|
||||
|
||||
int pos = 1;
|
||||
for (int i = 0; i < ctx->sys_paths.count; i++)
|
||||
IupSetAttributeId(list_merged, "", pos++, string_list_get(&ctx->sys_paths, i));
|
||||
for (int i = 0; i < ctx->user_paths.count; i++)
|
||||
IupSetAttributeId(list_merged, "", pos++, string_list_get(&ctx->user_paths, i));
|
||||
|
||||
int total = ctx->sys_paths.count + ctx->user_paths.count;
|
||||
IupSetInt(list_merged, "COUNT", total);
|
||||
refresh_single_list_style(list_merged);
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@ void load_all_paths(void)
|
||||
|
||||
sync_string_list_to_ui(list_sys, &ctx->sys_paths);
|
||||
sync_string_list_to_ui(list_user, &ctx->user_paths);
|
||||
sync_merged_list(dlg);
|
||||
|
||||
Ihandle *lbl_status = IupGetDialogChild(dlg, CTRL_LBL_STATUS);
|
||||
if (lbl_status)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ui/main_window.h"
|
||||
#include "controller/callbacks.h"
|
||||
#include "controller/callbacks_internal.h"
|
||||
#include "core/lua_config.h"
|
||||
#include "utils/i18n.h"
|
||||
#include "utils/ui_constants.h"
|
||||
@@ -24,6 +25,16 @@ static Ihandle *create_path_list(const char *name)
|
||||
return list;
|
||||
}
|
||||
|
||||
// 选项卡切换回调:切换到合并预览时刷新列表
|
||||
static int tab_change_cb(Ihandle *self, Ihandle *new_tab, Ihandle *old_tab)
|
||||
{
|
||||
(void)old_tab;
|
||||
(void)new_tab;
|
||||
Ihandle *dlg = IupGetDialog(self);
|
||||
sync_merged_list(dlg);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
// 创建主窗口
|
||||
Ihandle *create_main_window(void)
|
||||
{
|
||||
@@ -31,6 +42,15 @@ Ihandle *create_main_window(void)
|
||||
Ihandle *list_sys = create_path_list(CTRL_LIST_SYS);
|
||||
// 创建用户路径列表
|
||||
Ihandle *list_user = create_path_list(CTRL_LIST_USER);
|
||||
// 创建合并预览列表(只读)
|
||||
Ihandle *list_merged = IupFlatList();
|
||||
IupSetAttribute(list_merged, "NAME", CTRL_LIST_MERGED);
|
||||
IupSetAttribute(list_merged, "EXPAND", "YES");
|
||||
IupSetAttribute(list_merged, "ITEMPADDING", lua_config_get_string("list", "item_padding"));
|
||||
IupSetAttribute(list_merged, "BACKCOLOR", lua_config_get_string("list", "backcolor"));
|
||||
IupSetAttribute(list_merged, "BORDER", "YES");
|
||||
IupSetAttribute(list_merged, "HLINE", "NO");
|
||||
IupSetAttribute(list_merged, "ACTIVE", "NO"); // 只读
|
||||
|
||||
// 创建搜索框
|
||||
Ihandle *txt_search = IupText(NULL);
|
||||
@@ -43,11 +63,14 @@ Ihandle *create_main_window(void)
|
||||
Ihandle *tabs_main = IupTabs(
|
||||
IupVbox(list_sys, NULL),
|
||||
IupVbox(list_user, NULL),
|
||||
IupVbox(list_merged, NULL),
|
||||
NULL);
|
||||
IupSetAttribute(tabs_main, "NAME", CTRL_TABS_MAIN);
|
||||
IupSetAttribute(tabs_main, "TABTITLE0", _(lua_config_get_string("label", "tab_sys")));
|
||||
IupSetAttribute(tabs_main, "TABTITLE1", _(lua_config_get_string("label", "tab_user")));
|
||||
IupSetAttribute(tabs_main, "TABTITLE2", _(lua_config_get_string("label", "tab_merged")));
|
||||
IupSetAttribute(tabs_main, "TABTYPE", "TOP");
|
||||
IupSetCallback(tabs_main, "TABCHANGE_CB", (Icallback)tab_change_cb);
|
||||
|
||||
// 创建操作按钮
|
||||
Ihandle *btn_new = IupButton(_(lua_config_get_string("button", "new")), NULL);
|
||||
@@ -201,6 +224,7 @@ void refresh_main_window_ui(Ihandle *main_dlg)
|
||||
{
|
||||
IupSetAttribute(tabs, "TABTITLE0", _(lua_config_get_string("label", "tab_sys")));
|
||||
IupSetAttribute(tabs, "TABTITLE1", _(lua_config_get_string("label", "tab_user")));
|
||||
IupSetAttribute(tabs, "TABTITLE2", _(lua_config_get_string("label", "tab_merged")));
|
||||
}
|
||||
|
||||
// 辅助函数:设置子控件标题
|
||||
|
||||
Reference in New Issue
Block a user