From bf434e330ec405b9cbaff4dcb21f5005cfa20c5b Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 20 Nov 2026 13:18:14 -0600 Subject: [PATCH] feat(chat): translate export header, safer delete-dialog layout (F075/F041) UX audit, Chat surface (batch 2): - F075: the chat-export file's human-readable title is translated (chat_export_header); the machine-readable "cid:" line stays stable English. The success toast already shows the saved path. Choice a. - F041: the delete-conversation dialog no longer shows two identical red buttons. Cancel comes first with primary emphasis (safe default), the plain local delete is low-emphasis, and only "Delete & Block" keeps the destructive red. The conversation name is in the title. Choice a. New string (English). Build + tests green. Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/chat_tab.cpp | 24 +++++++++++++++++------- src/util/i18n.cpp | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ui/windows/chat_tab.cpp b/src/ui/windows/chat_tab.cpp index a2ff96f..0a14d36 100644 --- a/src/ui/windows/chat_tab.cpp +++ b/src/ui/windows/chat_tab.cpp @@ -2370,8 +2370,8 @@ void RenderChatTab(App* app) float wCan = std::max(90.0f * edp, ImGui::CalcTextSize(TR("chat_cancel")).x + 24.0f * edp); material::BeginOverlayDialogFooter(wExp + wCan + egap, false); if (material::TactileButton(TR("chat_export_confirm_btn"), ImVec2(wExp, 0))) { - // Build + write exactly as the old inline export did (format byte-identical). - std::string content = "DragonX chat export\n"; + // Human-readable title is translated; the machine-readable cid: line stays English. (F075) + std::string content = std::string(TR("chat_export_header")) + "\n"; content += ex->peerName + " <" + ex->peerZaddr + ">\n"; content += "cid: " + ex->cid + "\n\n"; for (const auto& m : store.conversation(ex->cid)) { @@ -2447,7 +2447,9 @@ void RenderChatTab(App* app) if (s_show_delete_confirm) { const float dp = Layout::dpiScale(); material::OverlayDialogSpec ov; - ov.title = TR("chat_delete_title"); + // Conversation name in the title, not only the body. (F041) + std::string delTitle = std::string(TR("chat_delete_title")) + " \xE2\x80\x94 " + s_delete_name; + ov.title = delTitle.c_str(); ov.p_open = &s_show_delete_confirm; // X / backdrop closes it (no-op) ov.style = material::OverlayStyle::BlurFloat; ov.cardWidth = 500.0f; ov.idSuffix = "chatdelete"; @@ -2548,16 +2550,24 @@ void RenderChatTab(App* app) const float wCan = std::max(90.0f * dp, textW(TR("chat_cancel"))); material::BeginOverlayDialogFooter(wDel + wBlk + wCan + gap2 * 2.0f, /*drawSeparator=*/false); + // Cancel first with primary emphasis — the safe default no longer looks like a delete button. (F041) + ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(material::WithAlpha(material::Primary(), 205))); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::ColorConvertU32ToFloat4(material::Primary())); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::ColorConvertU32ToFloat4(material::WithAlpha(material::Primary(), 235))); + ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(material::OnPrimary())); + const bool doCancel = material::TactileButton(TR("chat_cancel"), ImVec2(wCan, 0)); + ImGui::PopStyleColor(4); + ImGui::SameLine(0, gap2); + // Plain local delete — low emphasis; red is reserved for the irreversible block. + const bool doDel = material::TactileButton(TR("chat_delete_confirm"), ImVec2(wDel, 0)); + ImGui::SameLine(0, gap2); + // Delete & block — the only destructive-red action in this footer. ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(material::WithAlpha(material::Error(), 205))); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::ColorConvertU32ToFloat4(material::Error())); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::ColorConvertU32ToFloat4(material::WithAlpha(material::Error(), 235))); ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(material::OnError())); - const bool doDel = material::TactileButton(TR("chat_delete_confirm"), ImVec2(wDel, 0)); - ImGui::SameLine(0, gap2); const bool doBlk = material::TactileButton(TR("chat_delete_block"), ImVec2(wBlk, 0)); ImGui::PopStyleColor(4); - ImGui::SameLine(0, gap2); - const bool doCancel = material::TactileButton(TR("chat_cancel"), ImVec2(wCan, 0)); if (doDel) doDelete(false); if (doBlk) doDelete(true); diff --git a/src/util/i18n.cpp b/src/util/i18n.cpp index bf459a5..80bb50a 100644 --- a/src/util/i18n.cpp +++ b/src/util/i18n.cpp @@ -287,6 +287,7 @@ void I18n::loadBuiltinEnglish() strings_["chat_export"] = "Export chat\xE2\x80\xA6"; strings_["chat_export_warn"] = "Saves the decrypted messages as plain text. Store the file securely."; strings_["chat_export_done"] = "Conversation exported"; + strings_["chat_export_header"] = "DragonX chat export"; strings_["chat_export_failed"] = "Could not write the export file."; strings_["chat_export_confirm_title"] = "Export chat as plain text?"; strings_["chat_export_confirm_body"] = "This saves the decrypted messages as an UNENCRYPTED plain-text file. Anyone who can open the file can read the whole conversation. Store it securely and delete it when you no longer need it.";