feat(console): persist accent toggle + add monochrome-text toggle
Persist the two console output display preferences and add a second toolbar toggle for monochrome text. - Persistence: new Settings fields console_line_accents / console_text_color (both default true, matching the ConsoleTab statics so an upgrade re-save can't flip visible behavior). Restored into the statics at startup in the App constructor, and saved from a diff-and-save after the console renders (only when a value actually changed — save() is disk I/O). The startup restore also fixes a pre-existing bug: scanline was only synced from settings when the Settings page or first-run wizard ran, so an existing wallet ignored a saved scanline preference on launch. - Monochrome text: a new toolbar toggle (FORMAT_COLOR_TEXT, dimmed when off) next to the accent toggle. channelTextColor() early-returns the neutral COLOR_RESULT for every channel (and JSON syntax role) when off, leaving the left accent bars independent. COLOR_RESULT is contrast-floored per theme, so text stays readable on light and dark terminals. Adds console_toggle_text_color to the English source + all 8 translations. Verified: both toggles independent, persistence round-trips across restart, monochrome readable on light + dark skins. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "Unbekannt",
|
||||
"console_tab_completion": "Tab zur Vervollständigung",
|
||||
"console_toggle_accents": "Farbakzente der Zeilen umschalten",
|
||||
"console_toggle_text_color": "Textfarben der Zeilen umschalten",
|
||||
"console_type_help": "Geben Sie 'help' ein für verfügbare Befehle",
|
||||
"console_welcome": "Willkommen bei ObsidianDragon Konsole",
|
||||
"console_zoom_in": "Vergrößern",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "Desconocido",
|
||||
"console_tab_completion": "Tab para completar",
|
||||
"console_toggle_accents": "Alternar acentos de color de línea",
|
||||
"console_toggle_text_color": "Alternar colores de texto de línea",
|
||||
"console_type_help": "Escribe 'help' para ver los comandos disponibles",
|
||||
"console_welcome": "Bienvenido a la Consola de ObsidianDragon",
|
||||
"console_zoom_in": "Acercar",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "Inconnu",
|
||||
"console_tab_completion": "Tab pour compléter",
|
||||
"console_toggle_accents": "Basculer les accents de couleur des lignes",
|
||||
"console_toggle_text_color": "Basculer les couleurs du texte des lignes",
|
||||
"console_type_help": "Tapez 'help' pour les commandes disponibles",
|
||||
"console_welcome": "Bienvenue dans la console ObsidianDragon",
|
||||
"console_zoom_in": "Agrandir",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "不明",
|
||||
"console_tab_completion": "Tabで補完",
|
||||
"console_toggle_accents": "行のカラーアクセントを切り替え",
|
||||
"console_toggle_text_color": "行のテキスト色を切り替え",
|
||||
"console_type_help": "'help'と入力して利用可能なコマンドを表示",
|
||||
"console_welcome": "ObsidianDragonコンソールへようこそ",
|
||||
"console_zoom_in": "拡大",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "알 수 없음",
|
||||
"console_tab_completion": "Tab으로 자동 완성",
|
||||
"console_toggle_accents": "줄 색상 강조 전환",
|
||||
"console_toggle_text_color": "줄 텍스트 색상 전환",
|
||||
"console_type_help": "'help'를 입력하여 사용 가능한 명령어 보기",
|
||||
"console_welcome": "ObsidianDragon 콘솔에 오신 것을 환영합니다",
|
||||
"console_zoom_in": "확대",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "Desconhecido",
|
||||
"console_tab_completion": "Tab para completar",
|
||||
"console_toggle_accents": "Alternar destaques de cor das linhas",
|
||||
"console_toggle_text_color": "Alternar cores do texto das linhas",
|
||||
"console_type_help": "Digite 'help' para comandos disponíveis",
|
||||
"console_welcome": "Bem-vindo ao Console ObsidianDragon",
|
||||
"console_zoom_in": "Aumentar zoom",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "Неизвестно",
|
||||
"console_tab_completion": "Tab для дополнения",
|
||||
"console_toggle_accents": "Переключить цветовые акценты строк",
|
||||
"console_toggle_text_color": "Переключить цвета текста строк",
|
||||
"console_type_help": "Введите 'help' для списка команд",
|
||||
"console_welcome": "Добро пожаловать в консоль ObsidianDragon",
|
||||
"console_zoom_in": "Увеличить",
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"console_status_unknown": "未知",
|
||||
"console_tab_completion": "Tab 补全",
|
||||
"console_toggle_accents": "切换行颜色强调",
|
||||
"console_toggle_text_color": "切换行文本颜色",
|
||||
"console_type_help": "输入 'help' 查看可用命令",
|
||||
"console_welcome": "欢迎使用 ObsidianDragon 控制台",
|
||||
"console_zoom_in": "放大",
|
||||
|
||||
18
src/app.cpp
18
src/app.cpp
@@ -307,6 +307,13 @@ bool App::init()
|
||||
// Apply verbose logging preference from saved settings
|
||||
util::Logger::instance().setVerbose(settings_->getVerboseLogging());
|
||||
|
||||
// Restore console display preferences into the ConsoleTab statics at startup. These are the only
|
||||
// startup restore for these toggles — the Settings page / first-run wizard also sync scanline, but
|
||||
// only when visited, so without this an existing wallet would ignore a saved preference on launch.
|
||||
ui::ConsoleTab::s_scanline_enabled = settings_->getScanlineEnabled();
|
||||
ui::ConsoleTab::s_line_accents_enabled = settings_->getConsoleLineAccents();
|
||||
ui::ConsoleTab::s_line_text_color_enabled = settings_->getConsoleTextColor();
|
||||
|
||||
// Apply saved user font scale so fonts are correct on first reload
|
||||
{
|
||||
float fs = settings_->getFontScale();
|
||||
@@ -1786,6 +1793,17 @@ void App::render()
|
||||
console_exec_ = std::make_unique<ui::FullNodeConsoleExecutor>(this);
|
||||
}
|
||||
console_tab_.render(*console_exec_);
|
||||
// Persist the console toolbar toggles (ConsoleTab has no settings pointer). Save only when
|
||||
// a value actually changed — this runs every frame the console is visible and save() is
|
||||
// disk I/O — and only here in the Console case where these statics can change.
|
||||
if (settings_) {
|
||||
if (ui::ConsoleTab::s_line_accents_enabled != settings_->getConsoleLineAccents() ||
|
||||
ui::ConsoleTab::s_line_text_color_enabled != settings_->getConsoleTextColor()) {
|
||||
settings_->setConsoleLineAccents(ui::ConsoleTab::s_line_accents_enabled);
|
||||
settings_->setConsoleTextColor(ui::ConsoleTab::s_line_text_color_enabled);
|
||||
settings_->save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ui::NavPage::Settings:
|
||||
ui::RenderSettingsPage(this);
|
||||
|
||||
@@ -175,6 +175,8 @@ bool Settings::load(const std::string& path)
|
||||
loadScalar(j, "portfolio_style", portfolio_style_);
|
||||
if (portfolio_style_ < 0 || portfolio_style_ > 2) portfolio_style_ = 0;
|
||||
loadScalar(j, "scanline_enabled", scanline_enabled_);
|
||||
loadScalar(j, "console_line_accents", console_line_accents_);
|
||||
loadScalar(j, "console_text_color", console_text_color_);
|
||||
if (j.contains("hidden_addresses") && j["hidden_addresses"].is_array()) {
|
||||
hidden_addresses_.clear();
|
||||
for (const auto& a : j["hidden_addresses"])
|
||||
@@ -425,6 +427,8 @@ bool Settings::save(const std::string& path)
|
||||
j["balance_layout"] = balance_layout_; // saved as string ID
|
||||
j["portfolio_style"] = portfolio_style_;
|
||||
j["scanline_enabled"] = scanline_enabled_;
|
||||
j["console_line_accents"] = console_line_accents_;
|
||||
j["console_text_color"] = console_text_color_;
|
||||
j["hidden_addresses"] = json::array();
|
||||
for (const auto& addr : hidden_addresses_)
|
||||
j["hidden_addresses"].push_back(addr);
|
||||
|
||||
@@ -189,6 +189,13 @@ public:
|
||||
bool getScanlineEnabled() const { return scanline_enabled_; }
|
||||
void setScanlineEnabled(bool v) { scanline_enabled_ = v; }
|
||||
|
||||
// Console output appearance: per-line left color accent bars, and per-channel text coloring.
|
||||
// (Defaults match the ConsoleTab statics so an upgrade re-save doesn't flip visible behavior.)
|
||||
bool getConsoleLineAccents() const { return console_line_accents_; }
|
||||
void setConsoleLineAccents(bool v) { console_line_accents_ = v; }
|
||||
bool getConsoleTextColor() const { return console_text_color_; }
|
||||
void setConsoleTextColor(bool v) { console_text_color_ = v; }
|
||||
|
||||
// Hidden addresses (addresses hidden from the UI by the user)
|
||||
const std::set<std::string>& getHiddenAddresses() const { return hidden_addresses_; }
|
||||
bool isAddressHidden(const std::string& addr) const { return hidden_addresses_.count(addr) > 0; }
|
||||
@@ -482,6 +489,8 @@ private:
|
||||
std::string balance_layout_ = "classic";
|
||||
int portfolio_style_ = 0; // Market portfolio row style (0 single / 1 two-line / 2 hero)
|
||||
bool scanline_enabled_ = true;
|
||||
bool console_line_accents_ = true; // left color accent bars in console output
|
||||
bool console_text_color_ = true; // per-channel text coloring in console output
|
||||
std::set<std::string> hidden_addresses_;
|
||||
std::set<std::string> favorite_addresses_;
|
||||
std::map<std::string, AddressMeta> address_meta_;
|
||||
|
||||
@@ -45,6 +45,7 @@ ImU32 ConsoleTab::COLOR_INFO = IM_COL32(191, 209, 229, 255);
|
||||
ImU32 ConsoleTab::COLOR_RPC = IM_COL32(120, 180, 255, 210);
|
||||
bool ConsoleTab::s_scanline_enabled = true;
|
||||
bool ConsoleTab::s_line_accents_enabled = true;
|
||||
bool ConsoleTab::s_line_text_color_enabled = true;
|
||||
float ConsoleTab::s_console_zoom = 1.0f;
|
||||
bool ConsoleTab::s_daemon_messages_enabled = true;
|
||||
bool ConsoleTab::s_errors_only_enabled = false;
|
||||
@@ -189,6 +190,10 @@ void ConsoleTab::refreshColors()
|
||||
ImU32 ConsoleTab::channelTextColor(ConsoleChannel channel) const
|
||||
{
|
||||
using namespace material;
|
||||
// Monochrome mode: collapse every channel (and JSON syntax role) to the neutral result-body
|
||||
// color. COLOR_RESULT is theme-correct (contrast-floored on light terminals in refreshColors),
|
||||
// so text stays readable. The left accent bars are gated separately and stay independent.
|
||||
if (!s_line_text_color_enabled) return COLOR_RESULT;
|
||||
switch (channel) {
|
||||
// COLOR_* channels are already palette-derived + contrast-floored in refreshColors(). The
|
||||
// roles below are computed live from the theme palette, so floor them to a readable contrast on
|
||||
@@ -560,6 +565,18 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec)
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_accents"));
|
||||
}
|
||||
|
||||
// Text-color toggle: colored per-channel text vs. monochrome (grouped with the accent toggle).
|
||||
ImGui::SameLine();
|
||||
{
|
||||
float btnSz = ImGui::GetFrameHeight();
|
||||
if (!s_line_text_color_enabled)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled()));
|
||||
if (TactileButton(ICON_MD_FORMAT_COLOR_TEXT, ImVec2(btnSz, btnSz), Type().iconMed()))
|
||||
s_line_text_color_enabled = !s_line_text_color_enabled;
|
||||
if (!s_line_text_color_enabled) ImGui::PopStyleColor();
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_text_color"));
|
||||
}
|
||||
|
||||
// Zoom +/- buttons (right side of toolbar)
|
||||
ImGui::SameLine();
|
||||
ImGui::Spacing();
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
// Draw the per-line left color accent bars (channel-colored). Toggled from the toolbar.
|
||||
static bool s_line_accents_enabled;
|
||||
|
||||
// Color output text per channel. When false the console is monochrome text. Toolbar-toggled.
|
||||
static bool s_line_text_color_enabled;
|
||||
|
||||
// Show/hide daemon output messages
|
||||
static bool s_daemon_messages_enabled;
|
||||
|
||||
|
||||
@@ -1291,6 +1291,7 @@ void I18n::loadBuiltinEnglish()
|
||||
strings_["console_zoom_in"] = "Zoom in";
|
||||
strings_["console_zoom_out"] = "Zoom out";
|
||||
strings_["console_toggle_accents"] = "Toggle line color accents";
|
||||
strings_["console_toggle_text_color"] = "Toggle line text colors";
|
||||
|
||||
// --- Export All Keys Dialog ---
|
||||
strings_["export_keys_btn"] = "Export Keys";
|
||||
|
||||
Reference in New Issue
Block a user