mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
Made QColor wrapper class so that Servatrice will compile without QtGui
This commit is contained in:
parent
ee0a010add
commit
b1d8c7bda0
19 changed files with 226 additions and 184 deletions
|
|
@ -116,29 +116,19 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml)
|
|||
xml->writeCharacters(data ? "1" : "0");
|
||||
}
|
||||
|
||||
int SerializableItem_Color::colorToInt(const QColor &color) const
|
||||
{
|
||||
return color.red() * 65536 + color.green() * 256 + color.blue();
|
||||
}
|
||||
|
||||
QColor SerializableItem_Color::colorFromInt(int colorValue) const
|
||||
{
|
||||
return QColor(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
||||
}
|
||||
|
||||
bool SerializableItem_Color::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isCharacters() && !xml->isWhitespace()) {
|
||||
bool ok;
|
||||
int colorValue = xml->text().toString().toInt(&ok);
|
||||
data = ok ? colorFromInt(colorValue) : Qt::black;
|
||||
data = ok ? Color(colorValue) : Color();
|
||||
}
|
||||
return SerializableItem::readElement(xml);
|
||||
}
|
||||
|
||||
void SerializableItem_Color::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeCharacters(QString::number(colorToInt(data)));
|
||||
xml->writeCharacters(QString::number(data.getValue()));
|
||||
}
|
||||
|
||||
bool SerializableItem_DateTime::readElement(QXmlStreamReader *xml)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue