From baead4f54d23fc3642a5ccc9a1247cca0e4f9e15 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 15:37:46 -0800 Subject: [PATCH 1/2] StringSelect: keep the theme's text color for entries without a color The selected entry's text was always drawn in the entry's text_color, and an entry with no color has Color() == 0, which Qt draws as black. In dark mode the selected value was unreadable. Now the line edit keeps the default palette unless the entry sets a color, matching how the popup list already treats items without a color. --- .../Options/QtWidgets/StringSelectWidget.cpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp b/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp index f64b47e7a7..b49d85ed3a 100644 --- a/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp +++ b/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp @@ -24,6 +24,17 @@ template class RegisterUiStateQtWidget; template class RegisterUiStateQtWidget; +// Shows the selected entry's text in its own color. An entry with no color +// keeps the theme's text color: Color() is 0, which Qt draws as black. +static void set_selected_text_color(QLineEdit& line_edit, Color color){ + QPalette palette; + if (color){ + palette.setColor(QPalette::Text, QColor((uint32_t)color)); + } + line_edit.setPalette(palette); +} + + StringSelectCellWidget::~StringSelectCellWidget(){ @@ -49,9 +60,7 @@ StringSelectCellWidget::StringSelectCellWidget(QWidget& parent, StringSelectCell StringSelectCellWidget::update_value(); - QPalette palette; - palette.setColor(QPalette::Text, QColor((uint32_t)entry.text_color)); - this->lineEdit()->setPalette(palette); + set_selected_text_color(*this->lineEdit(), entry.text_color); connect( this, static_cast(&QComboBox::activated), @@ -85,10 +94,7 @@ void StringSelectCellWidget::load_options(){ size_t index = m_value.index(); this->setCurrentIndex((int)index); - QPalette palette; - palette.setColor(QPalette::Text, QColor((uint32_t)cases[index].text_color)); -// palette.setColor(QPalette::Text, Qt::red); - this->lineEdit()->setPalette(palette); + set_selected_text_color(*this->lineEdit(), cases[index].text_color); update_size_cache(); } @@ -122,10 +128,7 @@ void StringSelectCellWidget::hide_options(){ this->addItem(pixmap, QString::fromStdString(entry.display_name)); this->setCurrentIndex(0); - QPalette palette; - palette.setColor(QPalette::Text, QColor((uint32_t)entry.text_color)); -// palette.setColor(QPalette::Text, Qt::red); - this->lineEdit()->setPalette(palette); + set_selected_text_color(*this->lineEdit(), entry.text_color); } QSize StringSelectCellWidget::sizeHint() const{ From 3e86c5f3d067ad96b748b0d295a9bcd1e131f5fd Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 16:01:05 -0800 Subject: [PATCH 2/2] StringSelect: inputs before the output parameter in set_selected_text_color --- .../CommonTools/Options/QtWidgets/StringSelectWidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp b/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp index b49d85ed3a..8dea26e142 100644 --- a/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp +++ b/SerialPrograms/Source/CommonTools/Options/QtWidgets/StringSelectWidget.cpp @@ -26,7 +26,7 @@ template class RegisterUiStateQtWidget; // Shows the selected entry's text in its own color. An entry with no color // keeps the theme's text color: Color() is 0, which Qt draws as black. -static void set_selected_text_color(QLineEdit& line_edit, Color color){ +static void set_selected_text_color(Color color, QLineEdit& line_edit){ QPalette palette; if (color){ palette.setColor(QPalette::Text, QColor((uint32_t)color)); @@ -60,7 +60,7 @@ StringSelectCellWidget::StringSelectCellWidget(QWidget& parent, StringSelectCell StringSelectCellWidget::update_value(); - set_selected_text_color(*this->lineEdit(), entry.text_color); + set_selected_text_color(entry.text_color, *this->lineEdit()); connect( this, static_cast(&QComboBox::activated), @@ -94,7 +94,7 @@ void StringSelectCellWidget::load_options(){ size_t index = m_value.index(); this->setCurrentIndex((int)index); - set_selected_text_color(*this->lineEdit(), cases[index].text_color); + set_selected_text_color(cases[index].text_color, *this->lineEdit()); update_size_cache(); } @@ -128,7 +128,7 @@ void StringSelectCellWidget::hide_options(){ this->addItem(pixmap, QString::fromStdString(entry.display_name)); this->setCurrentIndex(0); - set_selected_text_color(*this->lineEdit(), entry.text_color); + set_selected_text_color(entry.text_color, *this->lineEdit()); } QSize StringSelectCellWidget::sizeHint() const{