Commit 2e6e5d1a authored by Sven Langkamp's avatar Sven Langkamp

save segmented gradients

parent ffb16af1
......@@ -179,7 +179,31 @@ bool KoSegmentGradient::loadFromDevice(QIODevice *dev)
bool KoSegmentGradient::save()
{
return false;
QFile file(filename());
if (!file.open(QIODevice::WriteOnly)) {
return false;
}
QTextStream fileContent(&file);
fileContent << "GIMP Gradient\n";
fileContent << "Name: " << name() << "\n";
fileContent << m_segments.count() << "\n";
foreach(KoGradientSegment* segment, m_segments) {
fileContent << QString::number(segment->startOffset(), 'f') << " " << QString::number(segment->middleOffset(), 'f') << " "
<< QString::number(segment->endOffset(), 'f') << " ";
QColor startColor = segment->startColor().toQColor();
QColor endColor = segment->endColor().toQColor();
fileContent << QString::number(startColor.redF(), 'f') << " " << QString::number(startColor.greenF(), 'f') << " "
<< QString::number(startColor.blueF(), 'f') << " " << QString::number(startColor.alphaF(), 'f') << " ";
fileContent << QString::number(endColor.redF(), 'f') << " " << QString::number(endColor.greenF(), 'f') << " "
<< QString::number(endColor.blueF(), 'f') << " " << QString::number(endColor.alphaF(), 'f') << " ";
fileContent << (int)segment->interpolation() << " " << (int)segment->colorInterpolation() << "\n";
}
return true;
}
bool KoSegmentGradient::saveToDevice(QIODevice *) const
......
......@@ -220,7 +220,7 @@ public:
}
}
if (resource->save()) {
if (!resource->save()) {
kWarning(30009) << "Could not save resource!";
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment