Batch of safe, isolated fixes from the 10-surface UX audit: - settings: Auto-shield / Save-z-transactions toggles now persist on change (they discarded CB()'s return and relied on a Save button that only renders on the About tab, so the choice was silently lost on relaunch). - exports: show the resolved Platform::getConfigDir() instead of a hardcoded ~/.config path (wrong on Windows/macOS) in both the all-keys and CSV dialogs; all-keys also reveals the file path on a partial export. - notifications: error/warning toasts last 9s/7s (were 4s/3.5s) so failures are readable. - qr popup / tx-details: copy-to-clipboard now confirms with a toast. - about: Escape-to-close + readable heading contrast via OnSurfaceMedium(). - sidebar: suppress single-key nav (J/K/arrows/[) while an overlay dialog or ImGui popup is open, so it no longer switches the tab behind a modal. - i18n: strip the stale hardcoded path out of file_save_location in i18n.cpp and all eight res/lang/*.json locales (additive, one key each). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
163 lines
5.6 KiB
C++
163 lines
5.6 KiB
C++
// DragonX Wallet - ImGui Edition
|
|
// Copyright 2024-2026 The Hush Developers
|
|
// Released under the GPLv3
|
|
|
|
#include "about_dialog.h"
|
|
#include "../../app.h"
|
|
#include "../../config/version.h"
|
|
#include "../../util/i18n.h"
|
|
#include "../../util/platform.h"
|
|
#include "../schema/ui_schema.h"
|
|
#include "../material/type.h"
|
|
#include "../material/draw_helpers.h"
|
|
#include "imgui.h"
|
|
|
|
namespace dragonx {
|
|
namespace ui {
|
|
|
|
void RenderAboutDialog(App* app, bool* p_open)
|
|
{
|
|
(void)app;
|
|
auto& S = schema::UI();
|
|
auto win = S.window("dialogs.about");
|
|
auto linkBtn = S.button("dialogs.about", "link-button");
|
|
auto closeBtn = S.button("dialogs.about", "close-button");
|
|
auto versionLbl = S.label("dialogs.about", "version-label");
|
|
auto editionLbl = S.label("dialogs.about", "edition-label");
|
|
|
|
// Schema positions/widths are logical px. BeginOverlayDialog scales the card by dpiScale(), so
|
|
// scale the value-column x, the edition inset, and the button widths to match — raw values left
|
|
// the value column jammed against the labels and the buttons left-packed at higher DPI.
|
|
const float dp = Layout::dpiScale();
|
|
const float valX = versionLbl.position * dp;
|
|
const float edX = editionLbl.position * dp;
|
|
const float linkW = linkBtn.width * dp;
|
|
const float closeW = closeBtn.width * dp;
|
|
|
|
if (!material::BeginOverlayDialog(TR("about_title"), p_open, win.width, 0.94f)) {
|
|
return;
|
|
}
|
|
|
|
// Escape closes the dialog (click-outside and the Close button already work; this matches the FAQ
|
|
// dialog's affordance so Escape behaves consistently across modal dialogs).
|
|
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
|
*p_open = false;
|
|
}
|
|
|
|
// Use Body2 font for all dialog text
|
|
ImGui::PushFont(Type().body2());
|
|
|
|
// Logo/Title area
|
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.3f, 0.69f, 0.31f, 1.0f)); // Green
|
|
ImGui::PushFont(Type().h4());
|
|
ImGui::Text("ObsidianDragon");
|
|
ImGui::PopFont();
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::SameLine(ImGui::GetWindowWidth() - edX);
|
|
ImGui::TextDisabled("%s", TR("about_edition"));
|
|
|
|
ImGui::Spacing();
|
|
ImGui::Separator();
|
|
ImGui::Spacing();
|
|
|
|
// Version info
|
|
ImGui::Text("%s", TR("about_version"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("%s", DRAGONX_VERSION);
|
|
|
|
ImGui::Text("%s", TR("about_imgui"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("%s", IMGUI_VERSION);
|
|
|
|
ImGui::Text("%s", TR("about_build_date"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("%s %s", __DATE__, __TIME__);
|
|
|
|
#ifdef DRAGONX_DEBUG
|
|
ImGui::Text("%s", TR("about_build_type"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::TextColored(ImVec4(1.0f, 0.6f, 0.0f, 1.0f), "%s", TR("about_debug"));
|
|
#else
|
|
ImGui::Text("%s", TR("about_build_type"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("%s", TR("about_release"));
|
|
#endif
|
|
|
|
// Daemon info
|
|
if (app && app->isConnected()) {
|
|
ImGui::Spacing();
|
|
ImGui::Separator();
|
|
ImGui::Spacing();
|
|
|
|
ImGui::Text("%s", TR("about_daemon"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::TextColored(ImVec4(0.3f, 0.8f, 0.3f, 1.0f), "%s", TR("connected"));
|
|
|
|
const auto& state = app->getWalletState();
|
|
ImGui::Text("%s", TR("about_chain"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("ObsidianDragon");
|
|
|
|
ImGui::Text("%s", TR("about_block_height"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text("%d", state.sync.blocks);
|
|
|
|
ImGui::Text("%s", TR("about_connections"));
|
|
ImGui::SameLine(valX);
|
|
ImGui::Text(TR("about_peers_count"), state.peers.size());
|
|
}
|
|
|
|
ImGui::Spacing();
|
|
ImGui::Separator();
|
|
ImGui::Spacing();
|
|
|
|
// Credits
|
|
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(material::OnSurfaceMedium()), "%s", TR("about_credits"));
|
|
ImGui::Spacing();
|
|
|
|
ImGui::BulletText("The Hush Developers");
|
|
ImGui::BulletText("ObsidianDragon Community");
|
|
ImGui::BulletText("Dear ImGui by Omar Cornut");
|
|
ImGui::BulletText("ImPlot by Evan Pezent");
|
|
ImGui::BulletText("SDL3 by Sam Lantinga");
|
|
|
|
ImGui::Spacing();
|
|
ImGui::Separator();
|
|
ImGui::Spacing();
|
|
|
|
// License
|
|
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(material::OnSurfaceMedium()), "%s", TR("about_license"));
|
|
ImGui::Spacing();
|
|
ImGui::TextWrapped("%s", TR("about_license_text"));
|
|
|
|
// Links — 3-button action row, centered via the shared footer helper (draws its own
|
|
// Spacing/Separator/Spacing above the row, replacing the hand-rolled divider block).
|
|
const float linksTotalW = linkW * 3.0f + ImGui::GetStyle().ItemSpacing.x * 2.0f;
|
|
material::BeginOverlayDialogFooter(linksTotalW);
|
|
if (material::TactileButton(TR("about_website"), ImVec2(linkW, 0), S.resolveFont(linkBtn.font))) {
|
|
util::Platform::openUrl("https://dragonx.is");
|
|
}
|
|
ImGui::SameLine();
|
|
if (material::TactileButton(TR("about_github"), ImVec2(linkW, 0), S.resolveFont(linkBtn.font))) {
|
|
util::Platform::openUrl("https://git.dragonx.is/dragonx/ObsidianDragon");
|
|
}
|
|
ImGui::SameLine();
|
|
if (material::TactileButton(TR("about_block_explorer"), ImVec2(linkW, 0), S.resolveFont(linkBtn.font))) {
|
|
util::Platform::openUrl("https://explorer.dragonx.is");
|
|
}
|
|
|
|
// Close button — lone dismiss action, centered via the shared footer helper (no extra
|
|
// divider above it, so it sits directly under the links row).
|
|
material::BeginOverlayDialogFooter(closeW, false);
|
|
if (material::TactileButton(TR("close"), ImVec2(closeW, 0), S.resolveFont(closeBtn.font))) {
|
|
*p_open = false;
|
|
}
|
|
|
|
ImGui::PopFont(); // Body2
|
|
material::EndOverlayDialog();
|
|
}
|
|
|
|
} // namespace ui
|
|
} // namespace dragonx
|