diff --git a/src/frontends/controllers/frontend_helpers.cpp b/src/frontends/controllers/frontend_helpers.cpp index 22d1048a80..25c1434641 100644 --- a/src/frontends/controllers/frontend_helpers.cpp +++ b/src/frontends/controllers/frontend_helpers.cpp @@ -1113,6 +1113,16 @@ public: } }; + +class ColorSorter +{ +public: + bool operator()(Color::color const & lhs, + Color::color const & rhs) const { + return lcolor.getGUIName(lhs) < lcolor.getGUIName(rhs); + } +}; + } // namespace anon @@ -1147,6 +1157,14 @@ vector const getLanguageData(bool character_dlg) return langs; } + +vector const getSortedColors(vector colors) +{ + // sort the colors + std::sort(colors.begin(), colors.end(), ColorSorter()); + return colors; +} + } // namespace frontend using support::addName; diff --git a/src/frontends/controllers/frontend_helpers.h b/src/frontends/controllers/frontend_helpers.h index ae3ce48de9..2d71a2668b 100644 --- a/src/frontends/controllers/frontend_helpers.h +++ b/src/frontends/controllers/frontend_helpers.h @@ -229,6 +229,8 @@ typedef std::pair LanguagePair; * to the vector. */ std::vector const getLanguageData(bool character_dlg); +/// sort colors for the gui +std::vector const getSortedColors(std::vector colors); } // namespace frontend diff --git a/src/frontends/qt4/QPrefs.cpp b/src/frontends/qt4/QPrefs.cpp index 3840f7e249..b7b446b1cb 100644 --- a/src/frontends/qt4/QPrefs.cpp +++ b/src/frontends/qt4/QPrefs.cpp @@ -534,9 +534,15 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent) || lc == Color::ignore) continue; lcolors_.push_back(lc); + } + lcolors_ = frontend::getSortedColors(lcolors_); + vector::const_iterator cit = lcolors_.begin(); + vector::const_iterator const end = lcolors_.end(); + for (; cit != end; ++cit) + { // This is not a memory leak: /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(icon), - toqstr(lcolor.getGUIName(lc)), lyxObjectsLW); + toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW); } curcolors_.resize(lcolors_.size()); newcolors_.resize(lcolors_.size()); diff --git a/status.15x b/status.15x index fb5db1ca20..9c885db5e5 100644 --- a/status.15x +++ b/status.15x @@ -47,6 +47,9 @@ What's new - Fix bug with math-matrix dialog always producing 1x1 matrices on platforms lacking proper support for wide characters (bug 4076). +- Sort colors in the Preferences dialog (bug 2571). + + * DOCUMENTATION