FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
fix(markets): responsive panels, theme font system, column distribution
tilakpatel22c8148e9bb39e
diff --git a/fincept-qt/src/screens/markets/MarketPanel.cpp b/fincept-qt/src/screens/markets/MarketPanel.cppindex 588842491..b99fe5a8b 100644--- a/fincept-qt/src/screens/markets/MarketPanel.cpp+++ b/fincept-qt/src/screens/markets/MarketPanel.cpp@@ -17,6 +17,7 @@ MarketPanel::MarketPanel(const MarketPanelConfig& config, QWidget* parent)if (config_.column_order.isEmpty())config_.column_order = default_market_columns();setMinimumWidth(180);+ setMinimumHeight(kHeaderH + kColHeaderH + kRowH * 4); // always room for at least 4 rowssetSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);build_ui();connect(&ui::ThemeManager::instance(), &ui::ThemeManager::theme_changed, this,@@ -210,7 +211,11 @@ void MarketPanel::refresh() {void MarketPanel::show_data() {error_widget_->setVisible(false);table_->setVisible(true);- populate(cached_quotes_);+ // Defer populate until after the splitter has performed layout so body_->height() is valid+ QPointer<MarketPanel> self = this;+ QMetaObject::invokeMethod(this, [self]() {+ if (self) self->populate(self->cached_quotes_);+ }, Qt::QueuedConnection);}void MarketPanel::show_error(const QString& msg) {@@ -221,7 +226,10 @@ void MarketPanel::show_error(const QString& msg) {void MarketPanel::populate(const QVector<services::QuoteData>& quotes) {const int body_h = body_->height();- const int visible = (body_h - kColHeaderH) / kRowH;+ // Use actual visible rows if laid out, otherwise show all quotes (resizeEvent will trim)+ const int visible = (body_h > kColHeaderH + kRowH)+ ? (body_h - kColHeaderH) / kRowH+ : quotes.size();const int count = qMin(quotes.size(), qMax(visible, 0));table_->setRowCount(count);@@ -281,6 +289,12 @@ void MarketPanel::resizeEvent(QResizeEvent* event) {// ---------------------------------------------------------------------------void MarketPanel::refresh_theme() {+ const QString ff = ui::fonts::DATA_FAMILY;+ const int fdata = ui::fonts::font_px(-2); // table cell font size (base-2, e.g. 12px at base 14)+ const int fhdr = ui::fonts::font_px(-2); // column header font size+ const int fbtn = ui::fonts::font_px(-3); // button font size (base-3, e.g. 11px)+ const int ftitle = ui::fonts::font_px(-1); // panel title font size (base-1, e.g. 13px)+setStyleSheet(QString("background:%1;border:1px solid %2;").arg(ui::colors::BG_SURFACE(), ui::colors::BORDER_DIM()));@@ -293,41 +307,42 @@ void MarketPanel::refresh_theme() {const QString btn_ss =QString("QPushButton{background:transparent;color:%1;border:none;"- "font-size:11px;font-family:monospace;padding:0 4px;}"- "QPushButton:hover{color:%2;}")- .arg(ui::colors::TEXT_DIM(), ui::colors::TEXT_PRIMARY());+ "font-size:%2px;font-family:'%3';padding:0 4px;}"+ "QPushButton:hover{color:%4;}")+ .arg(ui::colors::TEXT_DIM()).arg(fbtn).arg(ff).arg(ui::colors::TEXT_PRIMARY());if (cols_btn_) cols_btn_->setStyleSheet(btn_ss);if (edit_btn_) edit_btn_->setStyleSheet(btn_ss);if (delete_btn_) delete_btn_->setStyleSheet(btn_ss);if (title_label_)title_label_->setStyleSheet(- QString("color:%1;font-size:12px;font-weight:700;font-family:monospace;background:transparent;")- .arg(ui::colors::TEXT_PRIMARY()));+ QString("color:%1;font-size:%2px;font-weight:700;font-family:'%3';background:transparent;")+ .arg(ui::colors::TEXT_PRIMARY()).arg(ftitle).arg(ff));if (error_label_)error_label_->setStyleSheet(- QString("color:%1;font-size:11px;font-family:monospace;background:transparent;")- .arg(ui::colors::NEGATIVE()));+ QString("color:%1;font-size:%2px;font-family:'%3';background:transparent;")+ .arg(ui::colors::NEGATIVE()).arg(fdata).arg(ff));if (retry_btn_)retry_btn_->setStyleSheet(QString("QPushButton{background:transparent;color:%1;border:none;"- "font-size:11px;font-family:monospace;padding:0 4px;}"- "QPushButton:hover{color:%2;}")- .arg(ui::colors::TEXT_DIM(), ui::colors::TEXT_PRIMARY()));+ "font-size:%2px;font-family:'%3';padding:0 4px;}"+ "QPushButton:hover{color:%4;}")+ .arg(ui::colors::TEXT_DIM()).arg(fbtn).arg(ff).arg(ui::colors::TEXT_PRIMARY()));if (table_) {table_->setStyleSheet(QString("QTableWidget{background:%1;alternate-background-color:%2;border:none;"- "font-size:11px;font-family:monospace;}"+ "font-size:%6px;font-family:'%7';}""QTableWidget::item{padding:0 4px;}""QTableWidget::item:selected{background:transparent;}""QHeaderView::section{background:%3;color:%4;border:none;"- "border-bottom:1px solid %5;font-size:11px;font-weight:600;"- "font-family:monospace;padding:0 4px;}")+ "border-bottom:1px solid %5;font-size:%6px;font-weight:600;"+ "font-family:'%7';padding:0 4px;}").arg(ui::colors::BG_BASE(), ui::colors::BG_SURFACE(), ui::colors::BG_BASE(),- ui::colors::TEXT_DIM(), ui::colors::BORDER_DIM()));+ ui::colors::TEXT_DIM(), ui::colors::BORDER_DIM())+ .arg(fhdr).arg(ff));}}diff --git a/fincept-qt/src/screens/markets/MarketPanelStore.cpp b/fincept-qt/src/screens/markets/MarketPanelStore.cppindex 6b63dd2fc..3c4bf0644 100644--- a/fincept-qt/src/screens/markets/MarketPanelStore.cpp+++ b/fincept-qt/src/screens/markets/MarketPanelStore.cpp@@ -46,7 +46,20 @@ QVector<MarketPanelConfig> MarketPanelStore::load() {if (!cfg.id.isEmpty() && !cfg.title.isEmpty())panels.append(cfg);}- return panels.isEmpty() ? build_defaults() : panels;+ if (panels.isEmpty())+ return build_defaults();++ // Migration: if all panels have column_index==0 (old save format), redistribute evenly+ bool all_zero = true;+ for (const auto& p : panels) {+ if (p.column_index != 0) { all_zero = false; break; }+ }+ if (all_zero && panels.size() > 1) {+ for (int i = 0; i < panels.size(); ++i)+ panels[i].column_index = i % 3;+ }++ return panels;}void MarketPanelStore::save(const QVector<MarketPanelConfig>& panels) {@@ -92,6 +105,10 @@ QVector<MarketPanelConfig> MarketPanelStore::build_defaults() {panels.append(MarketPanelConfig::make(reg.region, syms, true));}+ // Distribute panels evenly across 3 columns+ for (int i = 0; i < panels.size(); ++i)+ panels[i].column_index = i % 3;+return panels;}diff --git a/fincept-qt/src/screens/markets/MarketsScreen.cpp b/fincept-qt/src/screens/markets/MarketsScreen.cppindex cbbf31de4..f5020814b 100644--- a/fincept-qt/src/screens/markets/MarketsScreen.cpp+++ b/fincept-qt/src/screens/markets/MarketsScreen.cpp@@ -27,9 +27,10 @@ namespace fincept::screens {// Helper// ----------------------------------------------------------------------------static QString lbl_ss(const QString& color, bool bold = false, int px = 12) {- return QString("color:%1;background:transparent;font-size:%2px;font-family:monospace;%3")- .arg(color).arg(px).arg(bold ? "font-weight:bold;" : "");+static QString lbl_ss(const QString& color, bool bold = false, int px = -1) {+ const int sz = (px > 0) ? px : ui::fonts::font_px(-2);+ return QString("color:%1;background:transparent;font-size:%2px;font-family:'%3';%4")+ .arg(color).arg(sz).arg(ui::fonts::DATA_FAMILY()).arg(bold ? "font-weight:bold;" : "");}// ---------------------------------------------------------------------------@@ -325,9 +326,10 @@ QWidget* MarketsScreen::build_header_bar() {b->setFlat(true);b->setStyleSheet(QString("QPushButton{background:transparent;color:%1;border:none;"- "font-size:11px;font-family:monospace;padding:0 6px;}"- "QPushButton:hover{color:%2;}")- .arg(ui::colors::TEXT_DIM(), ui::colors::TEXT_PRIMARY()));+ "font-size:%2px;font-family:'%3';padding:0 6px;}"+ "QPushButton:hover{color:%4;}")+ .arg(ui::colors::TEXT_DIM()).arg(ui::fonts::font_px(-3))+ .arg(ui::fonts::DATA_FAMILY()).arg(ui::colors::TEXT_PRIMARY()));return b;};@@ -341,10 +343,12 @@ QWidget* MarketsScreen::build_header_bar() {auto_btn->setText(auto_update_ ? "[F9] AUTO: ON" : "[F9] AUTO: OFF");auto_btn->setStyleSheet(QString("QPushButton{background:transparent;color:%1;border:none;"- "font-size:11px;font-family:monospace;padding:0 6px;}"+ "font-size:%3px;font-family:'%4';padding:0 6px;}""QPushButton:hover{color:%2;}").arg(auto_update_ ? ui::colors::AMBER() : ui::colors::TEXT_DIM(),- ui::colors::TEXT_PRIMARY()));+ ui::colors::TEXT_PRIMARY())+ .arg(ui::fonts::font_px(-3))+ .arg(ui::fonts::DATA_FAMILY()));};update_auto_style();connect(auto_btn, &QPushButton::clicked, this, [this, update_auto_style]() {@@ -370,12 +374,14 @@ QWidget* MarketsScreen::build_header_bar() {iv->setCurrentIndex(1);iv->setStyleSheet(QString("QComboBox{background:transparent;color:%1;border:none;"- "font-size:11px;font-family:monospace;padding:0 4px;}"+ "font-size:%6px;font-family:'%7';padding:0 4px;}""QComboBox::drop-down{border:none;width:12px;}""QComboBox QAbstractItemView{background:%2;color:%3;border:1px solid %4;"- "selection-background-color:%5;font-size:11px;font-family:monospace;}")+ "selection-background-color:%5;font-size:%6px;font-family:'%7';}").arg(ui::colors::TEXT_DIM(), ui::colors::BG_RAISED(),- ui::colors::TEXT_PRIMARY(), ui::colors::BORDER_MED(), ui::colors::BG_HOVER()));+ ui::colors::TEXT_PRIMARY(), ui::colors::BORDER_MED(), ui::colors::BG_HOVER())+ .arg(ui::fonts::font_px(-3))+ .arg(ui::fonts::DATA_FAMILY()));connect(iv, &QComboBox::currentIndexChanged, this, [this, iv](int i) {update_interval_ms_ = iv->itemData(i).toInt();auto_refresh_timer_->setInterval(update_interval_ms_);@@ -388,11 +394,13 @@ QWidget* MarketsScreen::build_header_bar() {auto* menu = new QMenu(this);menu->setStyleSheet(QString("QMenu{background:%1;border:1px solid %2;color:%3;"- "font-size:11px;font-family:monospace;}"+ "font-size:%5px;font-family:'%6';}""QMenu::item{padding:4px 16px;}""QMenu::item:selected{background:%4;}").arg(ui::colors::BG_RAISED(), ui::colors::BORDER_MED(),- ui::colors::TEXT_PRIMARY(), ui::colors::BG_HOVER()));+ ui::colors::TEXT_PRIMARY(), ui::colors::BG_HOVER())+ .arg(ui::fonts::font_px(-3))+ .arg(ui::fonts::DATA_FAMILY()));for (int i = 0; i < kNumColumns; ++i) {auto* act = menu->addAction(QString("ADD TO COL %1").arg(i + 1));connect(act, &QAction::triggered, this, [this, i]() {