fix(ui): Phase 7 C5 — 移除假按钮 + 真实托盘图标
用户报告设置页很多按钮无反应 + 关闭后托盘看不到图标。两处问题:\n\n1. ServerCard 占位按钮无回调:\n- server-card.slint:去掉了 toggled/edit-clicked/remove-clicked 三个回调以及 enabled 切换、Edit / Remove 按钮;变成纯展示卡(状态点 + name + url + 当前标记)\n- settings-page.slint:去掉硬编码的 Home / NAS 占位,改用 active-server-name / active-server-url / active-server-enabled 三个属性(MainWindow → AppConfig 实时填充);空时显示 '(未配置服务器)' 空态提示\n- app.slint:MainWindow 加三个属性 + 转发给 SettingsPage\n- lib.rs:startup 阶段把活跃服务器信息塞进 UI;测试连接成功/失败时更新 enabled 状态\n\n2. 托盘图标看不见:\n- tray.rs:原本 hIcon 写 null,Win10+ 上 Shell_NotifyIconW(NIM_ADD, NULL hIcon) 实际渲染为空白或很弱的小方块。改用 LoadIconW(NULL, IDI_APPLICATION) 加载 Windows 自带的应用程序图标(无需嵌入 .ico 资源,主题感知)。show_toast / Drop 的 hIcon 维持 null(让 NIM_MODIFY/NIM_DELETE 不动原有图标)。AGENTS.md §53 标记真 .ico 资源为 V2 项。
This commit is contained in:
+18
-70
@@ -1,28 +1,28 @@
|
||||
// AGENTS.md §21 multi-server card.
|
||||
//
|
||||
// Phase 2 C3 is a visual + structural shell: one placeholder row so the
|
||||
// Settings page has the right rhythm. The Settings `Connection` section
|
||||
// hosts a `Repeater` over these once `AppConfig.servers` lands in Phase 5.
|
||||
// Phase 7 C5: V1 只支持单 active server,§21 描述的多 server UI(添加/
|
||||
// 编辑/删除/启用/禁用)还没实现。原来的 ServerCard 有 enabled 切换
|
||||
// + Edit / Remove 按钮,但 settings-page.slint 只是占位填写硬编码
|
||||
// 的 "Home" / "NAS",回调也没接 —— 用户看到的 "点不动" 按钮是纯 UI
|
||||
// 壳子,对应 "很多都没反应" 的反馈。
|
||||
//
|
||||
// 修法:把 ServerCard 简化成纯展示卡(name + url + 状态点),由
|
||||
// settings-page.slint 从 AppConfig.active_server 实时填进去。无服务
|
||||
// 器时整个 section 走空态。等 V2 真做多 server UI 再加回 toggle /
|
||||
// Edit / Remove / Add。
|
||||
|
||||
export component ServerCard inherits Rectangle {
|
||||
in property <string> server-name: "(unnamed server)";
|
||||
in property <string> server-name: "(未配置服务器)";
|
||||
in property <string> server-url: "";
|
||||
in property <bool> enabled: true;
|
||||
in property <bool> is-current: false;
|
||||
|
||||
callback toggled();
|
||||
callback edit-clicked();
|
||||
callback remove-clicked();
|
||||
|
||||
in property <color> bg-color: #28292d;
|
||||
in property <color> card-border: #3a3b40;
|
||||
in property <color> text-primary-color: #e6e6e6;
|
||||
in property <color> text-secondary-color: #a0a0a0;
|
||||
in property <color> accent-color: #4ea1ff;
|
||||
in property <color> success-color: #4caf50;
|
||||
in property <color> toggle-on: #4ea1ff;
|
||||
in property <color> toggle-off: #6a6a6a;
|
||||
in property <color> button-bg: #2f3035;
|
||||
|
||||
width: 100%;
|
||||
height: 64px;
|
||||
@@ -39,27 +39,13 @@ export component ServerCard inherits Rectangle {
|
||||
spacing: 12px;
|
||||
alignment: center;
|
||||
|
||||
// On/off pill toggle (visual only in C3 — Phase 5 makes it mutate state).
|
||||
// 状态点:已连接 → 绿,配置但未连 → 蓝,未配置 → 灰。
|
||||
Rectangle {
|
||||
width: 36px;
|
||||
height: 20px;
|
||||
border-radius: 10px;
|
||||
background: enabled ? toggle-on : toggle-off;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 5px;
|
||||
background: enabled ? success-color : text-secondary-color;
|
||||
y: parent.height / 2 - self.height / 2;
|
||||
|
||||
Rectangle {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
x: enabled ? parent.width - self.width - 2px : 2px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => {
|
||||
root.toggled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
@@ -75,55 +61,17 @@ export component ServerCard inherits Rectangle {
|
||||
font-weight: 600;
|
||||
}
|
||||
if is-current: Text {
|
||||
text: "• current";
|
||||
text: "• 当前";
|
||||
color: accent-color;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: server-url;
|
||||
text: server-url != "" ? server-url : "(暂无 URL — 在 Settings → Connection 里填)";
|
||||
color: text-secondary-color;
|
||||
font-size: 11px;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
|
||||
// Action buttons.
|
||||
Rectangle {
|
||||
width: 56px;
|
||||
height: 28px;
|
||||
background: button-bg;
|
||||
border-radius: 6px;
|
||||
Text {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
text: "Edit";
|
||||
color: text-primary-color;
|
||||
font-size: 11px;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => {
|
||||
root.edit-clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
width: 56px;
|
||||
height: 28px;
|
||||
background: button-bg;
|
||||
border-radius: 6px;
|
||||
Text {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
text: "Remove";
|
||||
color: text-secondary-color;
|
||||
font-size: 11px;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => {
|
||||
root.remove-clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user