X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FColorCache.cpp;h=5b7a416afcc38d7bd5d8a3ebd53718da16bb9060;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=4ae3d065bb7304a8a85a419f818df425861e4f47;hpb=2e968d06610325ad5b69cee0e93f99b8435d5542;p=lyx.git diff --git a/src/frontends/qt4/ColorCache.cpp b/src/frontends/qt4/ColorCache.cpp index 4ae3d065bb..5b7a416afc 100644 --- a/src/frontends/qt4/ColorCache.cpp +++ b/src/frontends/qt4/ColorCache.cpp @@ -11,10 +11,7 @@ #include #include "ColorCache.h" - -#include "Color.h" - -#include +#include "ColorSet.h" namespace lyx { @@ -27,11 +24,24 @@ void ColorCache::init() /// get the given color -QColor const & ColorCache::get(ColorCode color) const +QColor ColorCache::get(Color color) const { if (!initialized_) const_cast(this)->init(); - return lcolors_[color]; + if (color <= Color_ignore && color.mergeColor == Color_ignore) + return lcolors_[color.baseColor]; + if (color.mergeColor != Color_ignore) { + // FIXME: This would ideally be done in the Color class, but + // that means that we'd have to use the Qt code in the core. + QColor base_color = get(color.baseColor).toRgb(); + QColor merge_color = get(color.mergeColor).toRgb(); + return QColor( + (base_color.red() + merge_color.red()) / 2, + (base_color.green() + merge_color.green()) / 2, + (base_color.blue() + merge_color.blue()) / 2); + } + // used by branches + return QColor(lcolor.getX11Name(color.baseColor).c_str()); }