summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-11-30 10:25:06 +0100
committerDanny Baumann <dannybaumann@web.de>2008-11-30 10:25:06 +0100
commitd8a0eb774c030632b85bc689d0f38d09d47eabc2 (patch)
tree196687fe4223eba1d633e3a7d470742ccefc148a
parent02432d69ee607434844ee26b7e63766f777266f8 (diff)
downloadcompizconfig-backend-kconfig4-d8a0eb774c030632b85bc689d0f38d09d47eabc2.tar.gz
compizconfig-backend-kconfig4-d8a0eb774c030632b85bc689d0f38d09d47eabc2.tar.bz2
- KConfigGroup::convertToQVariant doesn't know about float, give it a
double instead - QColor doesn't know about RGBA (it parses only #RRGGBB strings), so do the color parsing ourselves.
-rw-r--r--src/kconfig_backend.cpp52
1 files changed, 21 insertions, 31 deletions
diff --git a/src/kconfig_backend.cpp b/src/kconfig_backend.cpp
index 35c7938..d1ea904 100644
--- a/src/kconfig_backend.cpp
+++ b/src/kconfig_backend.cpp
@@ -648,7 +648,7 @@ readSetting (CCSContext *c,
break;
case TypeFloat:
- ccsSetFloat (setting, cfg.readEntry (key, 0.0f));
+ ccsSetFloat (setting, cfg.readEntry (key, double(0.0)));
break;
case TypeInt:
@@ -664,15 +664,11 @@ readSetting (CCSContext *c,
case TypeColor:
{
- QColor col = cfg.readEntry (key, QColor(Qt::black));
CCSSettingColorValue color;
+ QString value = cfg.readEntry (key, "");
- color.color.red = col.red () << 8 | col.red ();
- color.color.green = col.green () << 8 | col.green ();
- color.color.blue = col.blue () << 8 | col.blue ();
- color.color.alpha = col.alpha () << 8 | col.alpha ();
-
- ccsSetColor (setting, color);
+ if (ccsStringToColor (value.toAscii ().constData (), &color))
+ ccsSetColor (setting, color);
}
break;
@@ -814,18 +810,13 @@ readSetting (CCSContext *c,
foreach (QString val, list)
{
- int c[4];
-
- if (sscanf (val.toAscii ().constData (),
- "#%2x%2x%2x%2x",
- &c[0], &c[1], &c[2], &c[3]) == 4)
+ if (!ccsStringToColor (val.toAscii ().constData (),
+ &array[i]))
{
- array[i].color.red = c[0] << 8 | c[0];
- array[i].color.green = c[1] << 8 | c[1];
- array[i].color.blue = c[2] << 8 | c[2];
- array[i].color.alpha = c[3] << 8 | c[3];
+ memset (&array[i], 0,
+ sizeof (CCSSettingColorValue));
+ array[i].color.alpha = 0xffff;
}
-
i++;
}
@@ -1427,14 +1418,15 @@ writeSetting (CCSContext *c,
case TypeColor:
{
CCSSettingColorValue color;
+ char *value;
- if (!ccsGetColor (setting, &color) )
+ if (!ccsGetColor (setting, &color))
break;
- cfg.writeEntry (key, QColor (color.color.red >> 8,
- color.color.green >> 8,
- color.color.blue >> 8,
- color.color.alpha >> 8));
+ value = ccsColorToString (&color);
+ if (value)
+ cfg.writeEntry (key, QString (value));
+ free (value);
}
break;
@@ -1543,15 +1535,13 @@ writeSetting (CCSContext *c,
while (l)
{
- char tmp[256];
-
- snprintf (tmp, 256, "#%.2x%.2x%.2x%.2x",
- l->data->value.asColor.array.array[0] / 256,
- l->data->value.asColor.array.array[1] / 256,
- l->data->value.asColor.array.array[2] / 256,
- l->data->value.asColor.array.array[3] / 256);
+ char *value;
+
+ value = ccsColorToString (&l->data->value.asColor);
+ if (value)
+ list.append (QString (value));
+ free (value);
- list.append (QString (tmp));
l = l->next;
}