Fix theme import font colours

This commit is contained in:
Jon Tibble 2010-02-22 16:42:10 +00:00
parent 0337127985
commit 61c7b6479f

View File

@ -30,7 +30,7 @@ from PyQt4 import QtGui
DelphiColors={"clRed":0xFF0000, DelphiColors={"clRed":0xFF0000,
"clBlue":0x0000FF, "clBlue":0x0000FF,
"clYellow":0x0FFFF00, "clYellow":0xFFFF00,
"clBlack":0x000000, "clBlack":0x000000,
"clWhite":0xFFFFFF} "clWhite":0xFFFFFF}
@ -113,6 +113,7 @@ class Theme(object):
root = ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter = root.getiterator() iter = root.getiterator()
for element in iter: for element in iter:
delphiColorChange = False
if element.tag != u'Theme': if element.tag != u'Theme':
t = element.text t = element.text
val = 0 val = 0
@ -128,6 +129,7 @@ class Theme(object):
pass pass
elif DelphiColors.has_key(t): elif DelphiColors.has_key(t):
val = DelphiColors[t] val = DelphiColors[t]
delphiColorChange = True
else: else:
try: try:
val = int(t) val = int(t)
@ -136,7 +138,10 @@ class Theme(object):
if (element.tag.find(u'Color') > 0 or if (element.tag.find(u'Color') > 0 or
(element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))):
# convert to a wx.Colour # convert to a wx.Colour
if not delphiColorChange:
val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF)
else:
val = QtGui.QColor((val>>16)&0xFF, (val>>8)&0xFF, val&0xFF)
setattr(self, element.tag, val) setattr(self, element.tag, val)
def __str__(self): def __str__(self):