commit 2654e2bbb4b082ea38893196e49e00946b1a83cf
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Sat Feb 22 08:20:12 2025 +0100

    Option to flag default color in ColorsCombo
---
 src/frontends/qt/ColorsCombo.cpp | 11 ++++++++---
 src/frontends/qt/ColorsCombo.h   |  6 +++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/frontends/qt/ColorsCombo.cpp b/src/frontends/qt/ColorsCombo.cpp
index 2fb0798a76..9086f797c2 100644
--- a/src/frontends/qt/ColorsCombo.cpp
+++ b/src/frontends/qt/ColorsCombo.cpp
@@ -14,6 +14,7 @@
 #include "LaTeXColors.h"
 
 #include "support/gettext.h"
+#include "support/lstrings.h"
 #include "qt_helpers.h"
 
 #include "support/qstring_helpers.h"
@@ -59,7 +60,10 @@ void ColorsCombo::setColorIcon(int const i, QString const 
color)
 void ColorsCombo::addItemSort(QString const & item, QString const & guiname,
                              QString const & category, QString const color)
 {
-       QString titem = guiname;
+       QString titem = (item != default_color_)
+                       ? guiname
+                       : toqstr(bformat(_("%1$s (= Default[[color]])"),
+                                        qstring_to_ucs4(guiname)));;
 
        QList<QStandardItem *> row;
        QStandardItem * gui = new QStandardItem(titem);
@@ -112,8 +116,9 @@ void ColorsCombo::fillComboColor()
        if (has_ignore_)
                addItemSort(QString("ignore"), qt_("No change"),
                            QString());
-       addItemSort(QString("none"), qt_("Default"),
-                   QString());
+       if (default_color_.isEmpty())
+               addItemSort(QString("none"), qt_("Default"),
+                           QString());
        if (has_inherit_)
                addItemSort(QString("inherit"), qt_("(Without)[[color]]"),
                            QString());
diff --git a/src/frontends/qt/ColorsCombo.h b/src/frontends/qt/ColorsCombo.h
index 085fcfa922..e4345b6329 100644
--- a/src/frontends/qt/ColorsCombo.h
+++ b/src/frontends/qt/ColorsCombo.h
@@ -13,7 +13,7 @@
 #define LYX_COLORSCOMBO_H
 
 #include "CategorizedCombo.h"
-#include "BufferParams.h"
+#include "support/qstring_helpers.h"
 
 #include <QComboBox>
 
@@ -44,6 +44,8 @@ public:
        void hasIgnore(bool const b) { has_ignore_ = b; }
        /// Add "inherit" color entry?
        void hasInherit(bool const b) { has_inherit_ = b; }
+       /// Flag a color as default. This will also omit the "none" entry
+       void setDefaultColor(std::string const & col) { default_color_ = 
toqstr(col); }
 
 private:
        ///
@@ -56,6 +58,8 @@ private:
        bool has_ignore_;
        ///
        bool has_inherit_;
+       ///
+       QString default_color_;
 };
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to