12#include <QApplication>
14#include <QDomDocument>
100 QDomElement imageElement = doc.createElement(
"IMAGE");
131 const QString mode = [&]() {
140 Q_UNREACHABLE_RETURN(
"custom");
169 QDomElement animationElement = doc.createElement(
"animation");
173 imageElement.appendChild(animationElement);
178 if (beginIt != endIt) {
179 QDomElement annotationsElement = doc.createElement(
ANNOTATIONS);
181 while (it != endIt) {
182 if (!(*it) || (*it)->type().isEmpty()) {
186 QString type = (*it)->type();
190 QString description = (*it)->description();
191 QDomElement annotationElement = doc.createElement(
ANNOTATION);
192 annotationsElement.appendChild(annotationElement);
193 annotationElement.setAttribute(
"type", type);
194 annotationElement.setAttribute(
"description", description);
198 imageElement.appendChild(annotationsElement);
230 if (!store->
open(path +
'/' + fileName)) {
237 QByteArray ba = resource.
data();
241 nwritten = store->
write(ba);
248 if (nwritten != ba.size()) {
266 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save storyboards.");
271 QDomElement root = storyboardDocument.documentElement();
274 QByteArray ba = storyboardDocument.toByteArray();
277 nwritten = store->
write(ba);
280 qWarning() <<
"Could not save storyboard data to a byte array!";
283 bool r = store->
close();
284 success = success && r && (nwritten == ba.size());
288 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save storyboards.");
300 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save animation meta data.");
305 QDomElement root = animationDocument.documentElement();
310 QByteArray ba = animationDocument.toByteArray();
313 nwritten = store->
write(ba);
315 qWarning() <<
"Could not save animation meta data to a byte array!";
319 bool r = store->
close();
321 success = success && r && (nwritten == ba.size());
324 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save animation meta data.");
337 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save audio meta data.");
342 QDomElement root = audioDocument.documentElement();
346 QByteArray byteArray = audioDocument.toByteArray();
347 qint64 bytesWriteCount = 0;
348 if (!byteArray.isEmpty()) {
349 bytesWriteCount = store->
write(byteArray);
351 qWarning() <<
"Could not save audio data to a byte array!";
355 bool closeOK = store->
close();
357 success = success && closeOK && (bytesWriteCount == byteArray.size());
360 m_d->
errorMessages << i18nc(
"Error message when saving a .kra file",
"Could not save audio meta data.");
369 QDomElement ePalette = doc.createElement(
PALETTES);
370 QDomElement eResources = doc.createElement(
RESOURCES);
378 QDomElement eResource = doc.createElement(
"resource");
379 eResource.setAttribute(
"type", sig.
type);
380 eResource.setAttribute(
"name", sig.
name);
381 eResource.setAttribute(
"filename", sig.
filename);
382 eResource.setAttribute(
"md5sum", sig.
md5sum);
385 ePalette.appendChild(eResource);
388 eResources.appendChild(eResource);
392 element.appendChild(ePalette);
393 element.appendChild(eResources);
399 QDomElement eCommentList = doc.createElement(
"StoryboardCommentList");
401 QDomElement commentElement = doc.createElement(
"storyboardcomment");
402 commentElement.setAttribute(
"name", comment.name);
403 commentElement.setAttribute(
"visibility", comment.visibility);
404 eCommentList.appendChild(commentElement);
406 element.appendChild(eCommentList);
409 QDomElement eItemList = doc.createElement(
"StoryboardItemList");
411 QDomElement eItem = item->toXML(doc);
412 eItemList.appendChild(eItem);
414 element.appendChild(eItemList);
424 QDomElement exportItemElem = doc.createElement(
"export-settings");
428 element.appendChild(exportItemElem);
434 QMap<const KisNode*, QString>::iterator it;
437 const KisNode *node = it.key();
438 QString filename = it.value();
441 (external ? QString() : uri)
455 QDomElement root = doc.documentElement();
460 root.appendChild(element);
464 if (store->
open(location)) {
465 QByteArray xml = doc.toByteArray();
466 qint64 nwritten = store->
write(xml);
467 bool r = store->
close();
468 success = r && (nwritten == xml.size());
473 m_d->
errorMessages << i18nc(
"Error message on saving a .kra file",
"Could not save keyframes.");
502 bool savingAnnotationsSuccess =
true;
505 location = external ? QString() : uri;
507 if (store->
open(location)) {
508 nwritten = store->
write(annotation->annotation());
510 savingAnnotationsSuccess = savingAnnotationsSuccess && (nwritten == annotation->annotation().size()) && r;
512 savingAnnotationsSuccess =
false;
516 if (!savingAnnotationsSuccess) {
517 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save annotations."));
520 success = success && savingAnnotationsSuccess;
522 bool savingImageProfileSuccess =
true;
527 QByteArray profileRawData = profile->
rawData();
528 if (!profileRawData.isEmpty()) {
529 if (profile->
type() ==
"icc") {
538 location = external ? QString() : uri;
540 if (store->
open(location)) {
541 nwritten = store->
write(annotation->annotation());
543 savingImageProfileSuccess = savingImageProfileSuccess && (nwritten == annotation->annotation().size()) && r;
545 savingImageProfileSuccess =
false;
550 if (!savingImageProfileSuccess) {
551 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save image profile."));
553 success = success && savingImageProfileSuccess;
556 bool savingSoftproofingProfileSuccess =
true;
560 if (proofingProfile && proofingProfile->
valid()) {
561 QByteArray proofingProfileRaw = proofingProfile->
rawData();
562 if (!proofingProfileRaw.isEmpty()) {
567 location = external ? QString() : uri;
569 if (store->
open(location)) {
570 nwritten = store->
write(annotation->annotation());
572 savingSoftproofingProfileSuccess =
573 savingSoftproofingProfileSuccess && (nwritten == annotation->annotation().size()) && r;
575 savingSoftproofingProfileSuccess =
false;
580 if (!savingSoftproofingProfileSuccess) {
581 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save softproofing color profile."));
584 success = success && savingSoftproofingProfileSuccess;
590 bool savingRemainingAnnotationsSuccess =
true;
591 if (beginIt != endIt) {
593 while (it != endIt) {
594 if (!(*it) || (*it)->type().isEmpty()) {
598 QString type = (*it)->type();
601 location = external ? QString() : uri;
603 if (store->
open(location)) {
604 nwritten = store->
write((*it)->annotation());
606 savingRemainingAnnotationsSuccess = savingRemainingAnnotationsSuccess && (nwritten == (*it)->annotation().size()) && r;
608 savingRemainingAnnotationsSuccess =
false;
615 if (!savingRemainingAnnotationsSuccess) {
616 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save additional annotations."));
619 success = success && savingRemainingAnnotationsSuccess;
621 bool savingLayerStylesSuccess =
true;
625 if (stylesClones.size() > 0) {
626 location = external ? QString() : uri;
629 if (store->
open(location)) {
631 if (aslBuffer.open(QIODevice::WriteOnly)) {
635 nwritten = store->
write(aslBuffer.buffer());
636 savingLayerStylesSuccess = savingLayerStylesSuccess && (nwritten == aslBuffer.buffer().size());
638 savingLayerStylesSuccess =
false;
641 savingLayerStylesSuccess = savingLayerStylesSuccess && r;
643 savingLayerStylesSuccess =
false;
648 if (!savingLayerStylesSuccess) {
649 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save layer styles."));
652 success = success && savingLayerStylesSuccess;
654 bool savingMergedImageSuccess =
true;
655 if (addMergedImage) {
659 savingMergedImageSuccess = savingMergedImageSuccess && r;
663 if (!savingMergedImageSuccess) {
664 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save merged image."));
667 success = success && savingMergedImageSuccess;
670 success = success && r;
692 e.setAttribute(
COLORBYTEDATA, QString(colorData.toBase64()));
693 element.appendChild(e);
698 QDomElement colorsElement = doc.createElement(
COLORHISTORY);
701 element.appendChild(colorsElement);
709 element.appendChild(e);
718 element.appendChild(e);
725 QDomElement e = doc.createElement(
"compositions");
727 composition->save(doc, e);
729 element.appendChild(e);
736 QMap<QString, int> assistantcounters;
740 QMap<KisPaintingAssistantHandleSP, int> handlemap;
743 if (!assistants.isEmpty()) {
746 if (!assistantcounters.contains(assist->id())){
747 assistantcounters.insert(assist->id(),0);
749 location = external ? QString() : uri;
751 location += QString(assist->id()+
"%1.assistant").arg(assistantcounters[assist->id()]);
753 data = assist->saveXml(handlemap);
754 if (store->
open(location)) {
755 qint64 nwritten = store->
write(data);
756 bool r = store->
close();
757 success = success && r && (nwritten == data.size());
761 assistantcounters[assist->id()]++;
765 m_d->
errorMessages.append(i18nc(
"Saving .kra file error message",
"Could not save assistants."));
772 int count_ellipse = 0,
774 count_perspective = 0,
776 count_vanishingpoint = 0,
777 count_infiniteruler = 0,
778 count_parallelruler = 0,
779 count_concentricellipse = 0,
780 count_fisheyepoint = 0,
782 count_perspectiveellipse = 0,
783 count_curvilinearperspective = 0;
785 if (!assistants.isEmpty()) {
786 QDomElement assistantsElement = doc.createElement(
"assistants");
788 if (assist->id() ==
"ellipse"){
789 assist->saveXmlList(doc, assistantsElement, count_ellipse);
792 else if (assist->id() ==
"spline"){
793 assist->saveXmlList(doc, assistantsElement, count_spline);
796 else if (assist->id() ==
"perspective"){
797 assist->saveXmlList(doc, assistantsElement, count_perspective);
800 else if (assist->id() ==
"vanishing point"){
801 assist->saveXmlList(doc, assistantsElement, count_vanishingpoint);
802 count_vanishingpoint++;
804 else if (assist->id() ==
"infinite ruler"){
805 assist->saveXmlList(doc, assistantsElement, count_infiniteruler);
806 count_infiniteruler++;
808 else if (assist->id() ==
"parallel ruler"){
809 assist->saveXmlList(doc, assistantsElement, count_parallelruler);
810 count_parallelruler++;
812 else if (assist->id() ==
"concentric ellipse"){
813 assist->saveXmlList(doc, assistantsElement, count_concentricellipse);
814 count_concentricellipse++;
816 else if (assist->id() ==
"fisheye-point"){
817 assist->saveXmlList(doc, assistantsElement, count_fisheyepoint);
818 count_fisheyepoint++;
820 else if (assist->id() ==
"two point"){
821 assist->saveXmlList(doc, assistantsElement, count_twopoint);
824 else if (assist->id() ==
"ruler"){
825 assist->saveXmlList(doc, assistantsElement, count_ruler);
828 else if (assist->id() ==
"perspective ellipse"){
829 assist->saveXmlList(doc, assistantsElement, count_perspectiveellipse);
830 count_perspectiveellipse++;
832 else if (assist->id() ==
"curvilinear-perspective"){
833 assist->saveXmlList(doc, assistantsElement, count_curvilinearperspective);
834 count_curvilinearperspective++;
837 element.appendChild(assistantsElement);
848 element.appendChild(gridElement);
859 QDomElement guidesElement = guides.
saveToXml(doc,
"guides");
860 element.appendChild(guidesElement);
872 element.appendChild(mirrorAxisElement);
883 if (!clips.isEmpty()) {
884 QDomElement audioClips = doc.createElement(
"audioClips");
885 Q_FOREACH(
const QFileInfo& file, clips) {
886 QDomElement clip = doc.createElement(QString(
"Clip"));
887 clip.setAttribute(
"filePath", file.absoluteFilePath());
888 clip.setAttribute(
"volume", volume);
889 audioClips.appendChild(clip);
891 element.appendChild(audioClips);
901 Q_FOREACH(
const KoColor & color, colors) {
902 color.
toXML(doc, colorsElement);
const QString DESCRIPTION
A data extension mechanism for Krita.
static QVector< KisPSDLayerStyleSP > collectAllLayerStyles(KisNodeSP root)
void saveToDevice(QIODevice &device)
void setStyles(const QVector< KisPSDLayerStyleSP > &styles)
QList< KoColor > colorHistory
KisMirrorAxisConfig mirrorAxisConfig
KoDocumentInfo * documentInfo() const
QDomDocument createDomDocument(const QString &tagName, const QString &version) const
QColor assistantsGlobalColor()
StoryboardItemList getStoryboardItemList()
returns the list of pointers to storyboard Items for the document
KisNodeWSP preActivatedNode
QList< KisPaintingAssistantSP > assistants
QVector< StoryboardComment > getStoryboardCommentsList()
returns the list of comments for the storyboard docker in the document
QVector< QFileInfo > getAudioTracks() const
KisGuidesConfig guidesConfig
QDomElement saveDynamicDataToXml(QDomDocument &doc, const QString &tag) const
QDomElement saveToXml(QDomDocument &doc, const QString &tag) const
QString exportSequenceBaseName()
int currentUITime() const
const KisTimeSpan & documentPlaybackRange() const
documentPlaybackRange
QString exportSequenceFilePath()
int exportInitialFrameNumber()
vKisAnnotationSP_it endAnnotations()
KisGroupLayerSP rootLayer() const
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
KisAnnotationSP annotation(const QString &type)
KisPaintDeviceSP projection() const
QList< KisLayerCompositionSP > compositions()
QRect bounds() const override
KoColor defaultProjectionColor() const
const KoColorProfile * profile() const
vKisAnnotationSP_it beginAnnotations()
KisProofingConfigurationSP proofingConfiguration() const
proofingConfiguration
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
virtual QDomElement toXML(QDomDocument doc, const QString &layerFilename)
QStringList errorMessages() const
void setExternalUri(const QString &uri)
bool saveKeyframes(KoStore *store, const QString &uri, bool external)
void saveStoryboardToXML(QDomDocument &doc, QDomElement &element)
bool saveNodeKeyframes(KoStore *store, QString location, const KisNode *node)
bool saveMirrorAxis(QDomDocument &doc, QDomElement &element)
bool saveAssistants(KoStore *store, QString uri, bool external)
QStringList errorMessages() const
QDomElement saveXML(QDomDocument &doc, KisImageSP image)
bool saveAnimationMetadata(KoStore *store, KisImageSP image, const QString &uri)
void saveResourcesToXML(QDomDocument &doc, QDomElement &element)
bool saveAudioXML(QDomDocument &doc, QDomElement &element)
bool saveResources(KoStore *store, KisImageSP image, const QString &uri)
bool saveBinaryData(KoStore *store, KisImageSP image, const QString &uri, bool external, bool addMergedImage)
bool saveAudio(KoStore *store)
void saveWarningColor(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveKoColors(QDomDocument &doc, QDomElement &element, const QList< KoColor > &colors) const
void saveColorHistory(QDomDocument &doc, QDomElement &element)
bool saveGrid(QDomDocument &doc, QDomElement &element)
bool saveGuides(QDomDocument &doc, QDomElement &element)
KisKraSaver(KisDocument *document, const QString &filename, bool addMergedImage=true)
void saveBackgroundColor(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveStoryboard(KoStore *store, KisImageSP image, const QString &uri)
QStringList warningMessages() const
void saveCompositions(QDomDocument &doc, QDomElement &element, KisImageSP image)
bool saveAssistantsList(QDomDocument &doc, QDomElement &element)
void saveAssistantsGlobalColor(QDomDocument &doc, QDomElement &element)
void saveAnimationMetadataToXML(QDomDocument &doc, QDomElement &element, KisImageSP image)
The KisMirrorAxisConfig class stores configuration for the KisMirrorAxis canvas decoration....
QDomElement saveToXml(QDomDocument &doc, const QString &tag) const
saveToXml() function for KisKraSaver
bool isDefault() const
Check whether the config object was changed, or is the class default.
static bool saveDeviceToStore(const QString &filename, const QRect &imageRect, const qreal xRes, const qreal yRes, KisPaintDeviceSP dev, KoStore *store, KisMetaData::Store *metaData=0)
saveDeviceToStore saves the given paint device to the KoStore. If the device is not 8 bits sRGB,...
@ Custom
Let artists configure their own.
@ Paper
Whether to use Paper settings (absolute colorimetric, 0% adaptation.)
@ Monitor
Whether to use monitor rendering intent and flags for the second transform.
QMap< const KisNode *, QString > keyframeFileNames()
QMap< const KisNode *, QString > nodeFileNames()
QStringList errorMessages() const
void setSelectedNodes(vKisNodeSP selectedNodes)
virtual quint32 pixelSize() const =0
void toXML(QDomDocument &doc, QDomElement &colorElt) const
const KoColorSpace * colorSpace() const
return the current colorSpace
QString aboutInfo(const QString &info) const
const KoResourceSignature & signature() const
KoEmbeddedResource embeddedResource() const noexcept
KoResourceSignature signature() const
A simple wrapper object for the main information about the resource.
qint64 write(const QByteArray &data)
virtual void setCompressionEnabled(bool e)
bool open(const QString &name)
This file is part of the Krita application in calligra.
#define KIS_SAFE_ASSERT_RECOVER(cond)
vKisAnnotationSP::iterator vKisAnnotationSP_it
const QString PROOFINGPROFILENAME
const QString COLORHISTORY
const QString CANVASPROJECTIONCOLOR
const QString COLORBYTEDATA
const QString PROOFINGBLACKPOINTCOMPENSATION
const QString ICC_PROOFING_PATH
const QString Y_RESOLUTION
const QString ASSISTANTS_PATH
const QString PROOFINGDEPTH
const QString ANIMATION_METADATA_PATH
const QString NATIVE_MIMETYPE
const QString LAYER_STYLES_PATH
const QString X_RESOLUTION
const QString STORYBOARD_PATH
const QString ANNOTATIONS_PATH
const QString PROOFINGDISPLAYBLACKPOINTCOMPENSATION
const QString PROOFINGDISPLAYMODE
const QString PROOFINGWARNINGCOLOR
const QString PROOFINGDISPLAYINTENT
const QString GLOBALASSISTANTSCOLOR
const QString ANNOTATIONS
const QString RESOURCE_PATH
const QString PROOFINGMODEL
const QString PALETTE_PATH
const QString PROOFINGINTENT
const QString ICCPROOFINGPROFILE
const QString MIRROR_AXIS
const QString SIMPLECOLORDATA
const QString PROOFINGADAPTATIONSTATE
const QString COLORSPACE_NAME
void saveValue(QDomElement *parent, const QString &tag, const QSize &size)
QString qColorToQString(QColor color)
QString toString(const QString &value)
QMap< QString, KisKeyframeChannel * > keyframeChannels
bool accept(KisNodeVisitor &v) override
QMap< const KisNode *, QString > keyframeFilenames
QStringList warningMessages
QList< KoResourceLoadResult > linkedDocumentResources
QStringList errorMessages
QMap< const KisNode *, QString > nodeFileNames
QStringList specialAnnotations
virtual QByteArray rawData() const
virtual QString type() const
virtual bool valid() const =0
const KoColorProfile * profileByName(const QString &name) const
static KoColorSpaceRegistry * instance()