diff --git a/src/ui/windows/export_transactions_dialog.cpp b/src/ui/windows/export_transactions_dialog.cpp index 761ce28..5f31c12 100644 --- a/src/ui/windows/export_transactions_dialog.cpp +++ b/src/ui/windows/export_transactions_dialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace dragonx { namespace ui { @@ -158,6 +159,15 @@ void ExportTransactionsDialog::render(App* app) ImGui::Spacing(); ImGui::Text(TR("export_tx_count"), scopeOk ? subsetIdx.size() : (size_t)0); + // Spell out why Export is unavailable, inline, instead of only reacting on click. (F034) + const bool canExport = scopeOk && !subsetIdx.empty(); + if (!canExport) { + const char* why = !scopeOk ? (s_scope == 1 ? TR("export_tx_scope_stale") : TR("export_tx_range_invalid")) + : TR("export_tx_none"); + ImGui::PushTextWrapPos(0.0f); + ImGui::TextColored(m::WarningVec4(), "%s", why); + ImGui::PopTextWrapPos(); + } ImGui::Spacing(); // Filename + save-location hint. @@ -166,6 +176,9 @@ void ExportTransactionsDialog::render(App* app) // Show the real, resolved config directory (the old hardcoded ~/.config path was wrong on Windows/macOS). ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceDisabled()), "%s %s", TR("file_save_location"), util::Platform::getConfigDir().c_str()); + // Persistent "Open folder" — reachable before an export too, not only on the success screen. (F073) + if (m::TactileButton(TR("export_tx_open_folder"), ImVec2(0, 0))) + util::Platform::openFolder(util::Platform::getConfigDir()); // Result — success shows the saved path as a copy field; failure shows a red line. if (!s_saved_path.empty()) { @@ -176,19 +189,17 @@ void ExportTransactionsDialog::render(App* app) ImGui::SameLine(0, 4.0f * Layout::dpiScale()); ImGui::TextColored(m::SuccessVec4(), "%s", TR("export_tx_success")); widgets::AddressCopyField("##exportedpath", s_saved_path); - if (m::TactileButton(TR("export_tx_open_folder"), ImVec2(0, 0))) - util::Platform::openFolder(util::Platform::getConfigDir()); } else if (!s_error.empty()) { ImGui::Spacing(); ImGui::PushTextWrapPos(0.0f); - ImGui::TextColored(ImVec4(0.8f, 0.3f, 0.3f, 1.0f), "%s", s_error.c_str()); + ImGui::TextColored(m::ErrorVec4(), "%s", s_error.c_str()); // follow the active skin (F085) ImGui::PopTextWrapPos(); } ImGui::Spacing(); bool doExport = false, doClose = false; - m::DialogActionFooter(TR("export"), true, TR("close"), doExport, doClose); + m::DialogActionFooter(TR("export"), canExport, TR("close"), doExport, doClose); if (doClose) s_open = false; if (doExport) { s_saved_path.clear(); @@ -203,8 +214,16 @@ void ExportTransactionsDialog::render(App* app) // Sanitize in-buffer so the user sees exactly what was written (and we can't be pointed outside // the config dir by a pasted path). std::string safeName = util::sanitizeExportFilename(s_filename, ".csv", "dragonx_transactions.csv"); - snprintf(s_filename, sizeof(s_filename), "%s", safeName.c_str()); std::string filepath = configDir + "/" + safeName; + // Don't silently overwrite an existing export — suffix the name (-2, -3, …). (F073) + if (std::filesystem::exists(filepath)) { + const std::string stem = safeName.substr(0, safeName.size() - 4); // strip ".csv" + for (int k = 2; k < 1000; ++k) { + std::string cand = stem + "-" + std::to_string(k) + ".csv"; + if (!std::filesystem::exists(configDir + "/" + cand)) { safeName = cand; filepath = configDir + "/" + cand; break; } + } + } + snprintf(s_filename, sizeof(s_filename), "%s", safeName.c_str()); // Build the chosen subset (scope 0 exports the whole list with no copy), then write atomically // (temp + fsync + rename) so a disk-full failure is reported instead of a truncated CSV. std::string csv;