From: André Pönitz Date: Sat, 31 May 2008 22:39:52 +0000 (+0000) Subject: fix my color cache "improvements" X-Git-Tag: 1.6.10~4597 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7f678a39cd0a4516c5cba1068ec89a2c36405c91;p=features.git fix my color cache "improvements" git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25029 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/ColorCache.cpp b/src/frontends/qt4/ColorCache.cpp index 4ae3d065bb..69520fc738 100644 --- a/src/frontends/qt4/ColorCache.cpp +++ b/src/frontends/qt4/ColorCache.cpp @@ -16,6 +16,7 @@ #include + namespace lyx { void ColorCache::init() @@ -27,11 +28,14 @@ void ColorCache::init() /// get the given color -QColor const & ColorCache::get(ColorCode color) const +QColor ColorCache::get(ColorCode color) const { if (!initialized_) const_cast(this)->init(); - return lcolors_[color]; + if (color <= Color_ignore) + return lcolors_[color]; + // used by branches + return QColor(lcolor.getX11Name(color).c_str()); } diff --git a/src/frontends/qt4/ColorCache.h b/src/frontends/qt4/ColorCache.h index b667f91197..1716d5c044 100644 --- a/src/frontends/qt4/ColorCache.h +++ b/src/frontends/qt4/ColorCache.h @@ -29,7 +29,7 @@ public: ColorCache() : initialized_(false) {} /// get the given color - QColor const & get(ColorCode color) const; + QColor get(ColorCode color) const; /// clear all colors void clear() { initialized_ = false; } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 948a8d6388..d8b2fd7cbc 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -82,9 +82,8 @@ void InsetBranch::setButtonLabel() if (!params_.branch.empty()) { // FIXME UNICODE ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch)); - if (c == Color_none) { + if (c == Color_none) s = _("Undef: ") + s; - } } if (decoration() == InsetLayout::Classic) setLabel(isOpen() ? s : getNewLabel(s) ); @@ -95,15 +94,13 @@ void InsetBranch::setButtonLabel() ColorCode InsetBranch::backgroundColor() const { - if (!params_.branch.empty()) { - // FIXME UNICODE - ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch)); - if (c == Color_none) { - c = Color_error; - } - return c; - } else + if (params_.branch.empty()) return Inset::backgroundColor(); + // FIXME UNICODE + ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch)); + if (c == Color_none) + c = Color_error; + return c; }