namespace lyx {
namespace{
-// FIXME (later): Qt >= 4.4 has a proper QPalette::NoRole value.
-QPalette::ColorRole const NoRole = static_cast<QPalette::ColorRole>(-1);
QPalette::ColorRole role(ColorCode col)
{
case Color_mathcorners:
return QPalette::Base;
break;
-
+
case Color_foreground:
case Color_cursor:
case Color_preview:
case Color_previewframe:
return QPalette::Text;
break;
-
+
case Color_selection:
return QPalette::Highlight;
break;
case Color_selectiontext:
return QPalette::HighlightedText;
break;
+ case Color_urllabel:
+ case Color_urltext:
+ return QPalette::Link;
default:
- return NoRole;
+ return QPalette::NoRole;
}
}
if (!initialized_)
const_cast<ColorCache *>(this)->init();
if (color <= Color_ignore && color.mergeColor == Color_ignore) {
- QPalette::ColorRole cr = role(color.baseColor);
- if (syscolors && cr != NoRole) {
- static QColor white = Qt::white;
- QColor c = pal_.brush(QPalette::Active, cr).color();
+ QPalette::ColorRole const cr = role(color.baseColor);
+ if (syscolors && cr != QPalette::NoRole) {
+ static QColor const white = Qt::white;
+ QColor const c = pal_.brush(QPalette::Active, cr).color();
if (cr == QPalette::Base && c == white)
return lcolors_[color.baseColor];
else
(base_color.blue() + merge_color.blue()) / 2);
}
// used by branches
- return QColor(lcolor.getX11Name(color.baseColor).c_str());
+ return QColor(lcolor.getX11Name(color.baseColor).c_str());
}
bool ColorCache::isSystem(ColorCode const color) const
{
- return role(color) != NoRole;
+ QPalette::ColorRole const cr = role(color);
+ if (cr == QPalette::Base) {
+ static QColor const white = Qt::white;
+ return pal_.brush(QPalette::Active, cr).color() != white;
+ } else
+ return cr != QPalette::NoRole;
}