+QPalette::ColorRole role(ColorCode col)
+{
+ switch (ColorCode(col)) {
+ case Color_background:
+ case Color_commentbg:
+ case Color_greyedoutbg:
+ case Color_mathbg:
+ case Color_graphicsbg:
+ case Color_mathmacrobg:
+ case Color_mathcorners:
+ return QPalette::Base;
+ break;
+
+ case Color_foreground:
+ case Color_cursor:
+ case Color_preview:
+ case Color_tabularline:
+ 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 QPalette::NoRole;
+ }
+}
+
+} // namespace