feat(portfolio): Overview right-click to add/remove an address to a portfolio
Add a "Portfolio" submenu to the Overview address-list context menu: it lists each Market-tab portfolio entry with a checkmark showing whether this address is in it, and clicking toggles membership (add/remove), persisting immediately. If no entries exist yet, a disabled hint points to creating one. Full-node + lite build clean; ctest green; source hygiene clean. Completes the Market configurable-portfolio item (last of the todo.md batch). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "../../app.h"
|
||||
#include "../../config/settings.h"
|
||||
#include "../../data/portfolio.h"
|
||||
#include "../../config/version.h"
|
||||
#include "../../util/i18n.h"
|
||||
#include "../../util/text_format.h"
|
||||
@@ -677,6 +678,25 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
if (ImGui::MenuItem(TR("favorite_address")))
|
||||
app->favoriteAddress(addr.address);
|
||||
}
|
||||
// Portfolio membership — toggle this address in each Market-tab portfolio entry.
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu(TR("portfolio_add_to"))) {
|
||||
const auto& pf = app->settings()->getPortfolioEntries();
|
||||
if (pf.empty()) {
|
||||
ImGui::MenuItem(TR("portfolio_no_entries"), nullptr, false, false);
|
||||
}
|
||||
for (int pi = 0; pi < (int)pf.size(); pi++) {
|
||||
bool inSet = dragonx::data::PortfolioEntryContains(pf[pi].addresses, addr.address);
|
||||
if (ImGui::MenuItem(pf[pi].label.c_str(), nullptr, inSet)) {
|
||||
auto entries = pf; // copy, mutate, persist
|
||||
if (inSet) dragonx::data::PortfolioEntryRemove(entries[pi].addresses, addr.address);
|
||||
else dragonx::data::PortfolioEntryAdd(entries[pi].addresses, addr.address);
|
||||
app->settings()->setPortfolioEntries(entries);
|
||||
app->settings()->save();
|
||||
}
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
effects::ImGuiAcrylic::EndAcrylicPopup();
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
Reference in New Issue
Block a user