diff --git a/gui/style/json/global.json b/gui/style/json/global.json index 2eac1689d2..46ce419c19 100644 --- a/gui/style/json/global.json +++ b/gui/style/json/global.json @@ -31,5 +31,21 @@ "ch7": "#c7c10a", "white": "#FFFFFF", "black": "#000000", -"run_button_color": "&interactive_primary_idle&" +"run_button_color": "&interactive_primary_idle&", +"regmap_value_color_0": "#FF0000", +"regmap_value_color_1": "#00FF00", +"regmap_value_color_2": "#E76423", +"regmap_value_color_3": "#B16EE0", +"regmap_value_color_4": "#2E9E6F", +"regmap_value_color_5": "#3A8EE9", +"regmap_value_color_6": "#F64C5A", +"regmap_value_color_7": "#1694CA", +"regmap_value_color_8": "#E84DB4", +"regmap_value_color_9": "#0000FF", +"regmap_value_color_10": "#FFFF00", +"regmap_value_color_11": "#00FFFF", +"regmap_value_color_12": "#FF00FF", +"regmap_value_color_13": "#8B4513", +"regmap_value_color_14": "#8A2BE2", +"regmap_value_color_15": "#DEB887" } diff --git a/plugins/regmap/src/regmapplugin.cpp b/plugins/regmap/src/regmapplugin.cpp index 3a5a1d8862..5fea9eb52c 100644 --- a/plugins/regmap/src/regmapplugin.cpp +++ b/plugins/regmap/src/regmapplugin.cpp @@ -166,6 +166,35 @@ bool RegmapPlugin::loadPreferencesPage() "Register background and Bitfield text", "Register text and Bitfield background"}, generalSection)); + QWidget *colorWidget = new QWidget(m_preferencesPage); + QVBoxLayout *colorWidgetLayout = new QVBoxLayout(colorWidget); + colorWidgetLayout->setContentsMargins(0, 0, 0, 0); + + for(int i = 0; i < 16; i++) { + QString regmapValueColorString = "regmap_value_color_"; + QColor color = + Style::getAttribute(QString(regmapValueColorString + QString::number(i)).toStdString().c_str()); + + QWidget *hContainer = new QWidget; // Horizontal container + QHBoxLayout *hLayout = new QHBoxLayout(hContainer); + hLayout->setContentsMargins(0, 0, 0, 0); // Remove margins for tight layout + + // Create a color square + QFrame *colorSquare = new QFrame; + colorSquare->setFixedSize(40, 40); // Increased size of the square + colorSquare->setStyleSheet("background-color: " + color.name() + ";"); + + QLabel *label = new QLabel("Color for value : " + QString::number(i, 16)); + label->setMargin(0); // Remove default margins for the label + hLayout->addWidget(colorSquare); + hLayout->addWidget(label); + hLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); + + colorWidgetLayout->addWidget(hContainer); // Add the horizontal container to the main layout + } + + lay->addWidget(colorWidget); + return true; } @@ -337,3 +366,4 @@ void RegmapPlugin::InitApi() js->registerApi(api); } #include "moc_regmapplugin.cpp" +#include "regmapstylehelper.hpp" diff --git a/plugins/regmap/src/regmapstylehelper.cpp b/plugins/regmap/src/regmapstylehelper.cpp index 26d19e6b9e..64592d7d6d 100644 --- a/plugins/regmap/src/regmapstylehelper.cpp +++ b/plugins/regmap/src/regmapstylehelper.cpp @@ -204,5 +204,17 @@ void RegmapStyleHelper::smallBlueButton(QPushButton *button, QString objectName) QString RegmapStyleHelper::getColorBasedOnValue(QString value) { uint32_t colorIndex = Utils::convertQStringToUint32(value) % 16; - return StyleHelper::getChannelColor(colorIndex); + return RegmapStyleHelper::getRegmapValueColor(colorIndex); +} + +QString RegmapStyleHelper::getRegmapValueColor(int index) +{ + if(index <= 15) { + QString regmapValueColorString = "regmap_value_color_"; + QColor color = Style::getAttribute( + QString(regmapValueColorString + QString::number(index)).toStdString().c_str()); + return color.name(); + } else { + return ""; + } } diff --git a/plugins/regmap/src/regmapstylehelper.hpp b/plugins/regmap/src/regmapstylehelper.hpp index e10fcc6a65..acd3c2fb38 100644 --- a/plugins/regmap/src/regmapstylehelper.hpp +++ b/plugins/regmap/src/regmapstylehelper.hpp @@ -70,6 +70,7 @@ class RegmapStyleHelper private: QMap colorMap; static RegmapStyleHelper *pinstance_; + static QString getRegmapValueColor(int index); }; } // namespace scopy::regmap #endif // REGMAPSTYLEHELPER_HPP