]> git.lyx.org Git - features.git/commitdiff
fix my color cache "improvements"
authorAndré Pönitz <poenitz@gmx.net>
Sat, 31 May 2008 22:39:52 +0000 (22:39 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 31 May 2008 22:39:52 +0000 (22:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25029 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/ColorCache.cpp
src/frontends/qt4/ColorCache.h
src/insets/InsetBranch.cpp

index 4ae3d065bb7304a8a85a419f818df425861e4f47..69520fc7384ab3de81d6d820e77fa78022752d3d 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <string>
 
+
 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<ColorCache *>(this)->init();
-       return lcolors_[color];
+       if (color <= Color_ignore)
+               return lcolors_[color];
+       // used by branches
+       return QColor(lcolor.getX11Name(color).c_str()); 
 }
 
 
index b667f911971e0b14c43764627df808edf0198fb5..1716d5c04448bf6f5f1e6baad898706989ef747f 100644 (file)
@@ -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; }
index 948a8d638842a38ff2e92df34bed37bb9e9ab042..d8b2fd7cbc76aadd6e19441f7829da2f3b01c606 100644 (file)
@@ -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;
 }