Commit 3bbf025b authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Intitial saving/loading of config.[unstable]

Works, but might change later.
parent 1f733e28
......@@ -75,6 +75,7 @@
#include "kis_time_range.h"
#include "kis_grid_config.h"
#include "kis_guides_config.h"
#include "KisProofingConfiguration.h"
/*
......@@ -263,6 +264,21 @@ KisImageWSP KisKraLoader::loadXML(const KoXmlElement& element)
return KisImageWSP(0);
}
}
qDebug()<<"start loading proofing data";
KisProofingConfiguration *proofingConfig = new KisProofingConfiguration();
qDebug()<<"start loading the name";
if (!(attr = element.attribute(PROOFINGPROFILENAME)).isNull()) {
proofingConfig->proofingProfile = attr;
}
if (!(attr = element.attribute(PROOFINGMODEL)).isNull()) {
proofingConfig->proofingModel = attr;
}
if (!(attr = element.attribute(PROOFINGDEPTH)).isNull()) {
proofingConfig->proofingDepth = attr;
}
if (!(attr = element.attribute(PROOFINGINTENT)).isNull()) {
proofingConfig->intent = (KoColorConversionTransformation::Intent) KisDomUtils::toInt(attr);
}
if (m_d->document) {
image = new KisImage(m_d->document->createUndoStore(), width, height, cs, name);
......@@ -273,6 +289,7 @@ KisImageWSP KisKraLoader::loadXML(const KoXmlElement& element)
image->setResolution(xres, yres);
loadNodes(element, image, const_cast<KisGroupLayer*>(image->rootLayer().data()));
KoXmlNode child;
for (child = element.lastChild(); !child.isNull(); child = child.previousSibling()) {
KoXmlElement e = child.toElement();
......@@ -284,11 +301,21 @@ KisImageWSP KisKraLoader::loadXML(const KoXmlElement& element)
}
}
if(e.tagName()== PROOFINGWARNINGCOLOR) {
if (e.hasAttribute("ColorData")) {
QByteArray colorData = QByteArray::fromBase64(e.attribute("ColorData").toLatin1());
KoColor color((const quint8*)colorData.data(), image->colorSpace());
proofingConfig->warningColor = color;
}
}
if (e.tagName().toLower() == "animation") {
loadAnimationMetadata(e, image);
}
}
image->setProofingConfiguration(proofingConfig);
for (child = element.lastChild(); !child.isNull(); child = child.previousSibling()) {
KoXmlElement e = child.toElement();
if(e.tagName() == "compositions") {
......
......@@ -55,6 +55,7 @@
#include "kis_dom_utils.h"
#include "kis_grid_config.h"
#include "kis_guides_config.h"
#include "KisProofingConfiguration.h"
using namespace KRA;
......@@ -102,6 +103,11 @@ QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageWSP image)
}
imageElement.setAttribute(X_RESOLUTION, KisDomUtils::toString(image->xRes()*72.0));
imageElement.setAttribute(Y_RESOLUTION, KisDomUtils::toString(image->yRes()*72.0));
//now the proofing options:
imageElement.setAttribute(PROOFINGPROFILENAME, KisDomUtils::toString(image->proofingConfiguration()->proofingProfile));
imageElement.setAttribute(PROOFINGMODEL, KisDomUtils::toString(image->proofingConfiguration()->proofingModel));
imageElement.setAttribute(PROOFINGDEPTH, KisDomUtils::toString(image->proofingConfiguration()->proofingDepth));
imageElement.setAttribute(PROOFINGINTENT, KisDomUtils::toString(image->proofingConfiguration()->intent));
quint32 count = 1; // We don't save the root layer, but it does count
KisSaveXmlVisitor visitor(doc, imageElement, count, m_d->doc->url().toLocalFile(), true);
......@@ -114,6 +120,7 @@ QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageWSP image)
m_d->keyframeFilenames = visitor.keyframeFileNames();
saveBackgroundColor(doc, imageElement, image);
saveWarningColor(doc, imageElement, image);
saveCompositions(doc, imageElement, image);
saveAssistantsList(doc,imageElement);
saveGrid(doc,imageElement);
......@@ -225,6 +232,16 @@ bool KisKraSaver::saveBinaryData(KoStore* store, KisImageWSP image, const QStrin
}
}
if (image->proofingConfiguration()) {
const KoColorProfile *proofingProfile = KoColorSpaceRegistry::instance()->profileByName(image->proofingConfiguration()->proofingProfile);
if (proofingProfile && proofingProfile->valid()) {
QByteArray proofingProfileRaw = proofingProfile->rawData();
if (!proofingProfileRaw.isEmpty()) {
annotation = new KisAnnotation(ICCPROOFINGPROFILE, proofingProfile->name(), proofingProfile->rawData());
}
}
}
{
KisPSDLayerStyleCollectionResource collection("not-nexists.asl");
KIS_ASSERT_RECOVER_NOOP(!collection.valid());
......@@ -274,6 +291,17 @@ void KisKraSaver::saveBackgroundColor(QDomDocument& doc, QDomElement& element, K
element.appendChild(e);
}
void KisKraSaver::saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageWSP image)
{
if (image->proofingConfiguration()) {
QDomElement e = doc.createElement(PROOFINGWARNINGCOLOR);
KoColor color = image->proofingConfiguration()->warningColor;
QByteArray colorData = QByteArray::fromRawData((const char*)color.data(), color.colorSpace()->pixelSize());
e.setAttribute("ColorData", QString(colorData.toBase64()));
element.appendChild(e);
}
}
void KisKraSaver::saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image)
{
if (!image->compositions().isEmpty()) {
......
......@@ -47,6 +47,7 @@ public:
private:
void saveBackgroundColor(QDomDocument& doc, QDomElement& element, KisImageWSP image);
void saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageWSP image);
void saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image);
bool saveAssistants(KoStore *store,QString uri, bool external);
bool saveAssistantsList(QDomDocument& doc, QDomElement& element);
......
......@@ -109,6 +109,12 @@ const QString ACTIVE = "active";
const QString LAYER_STYLE_UUID = "layerstyle";
const QString PASS_THROUGH_MODE = "passthrough";
const QString KEYFRAME_FILE = "keyframes";
const QString PROOFINGPROFILENAME = "proofing-profile-name";
const QString PROOFINGMODEL = "proofing-model";
const QString PROOFINGDEPTH = "proofing-depth";
const QString PROOFINGINTENT = "proofing-intent";
const QString PROOFINGWARNINGCOLOR ="ProofingWarningColor";
const QString ICCPROOFINGPROFILE ="icc-proofing-profile";
}
......
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