Changeset View
Changeset View
Standalone View
Standalone View
plugins/impex/libkra/kis_kra_loader.cpp
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | 197 | { | |||
---|---|---|---|---|---|
201 | qint32 width; | 201 | qint32 width; | ||
202 | qint32 height; | 202 | qint32 height; | ||
203 | QString profileProductName; | 203 | QString profileProductName; | ||
204 | double xres; | 204 | double xres; | ||
205 | double yres; | 205 | double yres; | ||
206 | QString colorspacename; | 206 | QString colorspacename; | ||
207 | const KoColorSpace * cs; | 207 | const KoColorSpace * cs; | ||
208 | 208 | | |||
209 | | ||||
209 | if ((attr = element.attribute(MIME)) == NATIVE_MIMETYPE) { | 210 | if ((attr = element.attribute(MIME)) == NATIVE_MIMETYPE) { | ||
210 | 211 | | |||
211 | if ((m_d->imageName = element.attribute(NAME)).isNull()) { | 212 | if ((m_d->imageName = element.attribute(NAME)).isNull()) { | ||
212 | m_d->errorMessages << i18n("Image does not have a name."); | 213 | m_d->errorMessages << i18n("Image does not have a name."); | ||
213 | return KisImageSP(0); | 214 | return KisImageSP(0); | ||
214 | } | 215 | } | ||
215 | 216 | | |||
216 | if ((attr = element.attribute(WIDTH)).isNull()) { | 217 | if ((attr = element.attribute(WIDTH)).isNull()) { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
301 | } | 302 | } | ||
302 | image->setResolution(xres, yres); | 303 | image->setResolution(xres, yres); | ||
303 | loadNodes(element, image, const_cast<KisGroupLayer*>(image->rootLayer().data())); | 304 | loadNodes(element, image, const_cast<KisGroupLayer*>(image->rootLayer().data())); | ||
304 | 305 | | |||
305 | 306 | | |||
306 | KoXmlNode child; | 307 | KoXmlNode child; | ||
307 | for (child = element.lastChild(); !child.isNull(); child = child.previousSibling()) { | 308 | for (child = element.lastChild(); !child.isNull(); child = child.previousSibling()) { | ||
308 | KoXmlElement e = child.toElement(); | 309 | KoXmlElement e = child.toElement(); | ||
310 | | ||||
309 | if(e.tagName() == CANVASPROJECTIONCOLOR) { | 311 | if(e.tagName() == CANVASPROJECTIONCOLOR) { | ||
310 | if (e.hasAttribute(COLORBYTEDATA)) { | 312 | if (e.hasAttribute(COLORBYTEDATA)) { | ||
311 | QByteArray colorData = QByteArray::fromBase64(e.attribute(COLORBYTEDATA).toLatin1()); | 313 | QByteArray colorData = QByteArray::fromBase64(e.attribute(COLORBYTEDATA).toLatin1()); | ||
312 | KoColor color((const quint8*)colorData.data(), image->colorSpace()); | 314 | KoColor color((const quint8*)colorData.data(), image->colorSpace()); | ||
313 | image->setDefaultProjectionColor(color); | 315 | image->setDefaultProjectionColor(color); | ||
314 | } | 316 | } | ||
315 | } | 317 | } | ||
316 | 318 | | |||
319 | | ||||
320 | if(e.tagName() == GLOBALASSISTANTSCOLOR) { | ||||
321 | if (e.hasAttribute(SIMPLECOLORDATA)) { | ||||
322 | QString colorData = e.attribute(SIMPLECOLORDATA); | ||||
323 | m_d->document->setAssistantsGlobalColor(KisDomUtils::qStringToQColor(colorData)); | ||||
dkazakov: Why do you use two different saving methods for saving global color and local color? Please use… | |||||
I was originally following the pattern for the saving/loading for the global assistant color. That was using the byte array KoColor method. The assistant data can also be in XML when saving the assistants, so I just made all assistant saving/loading use the new conversion function that translates them to and from QStrings. 8 bit color information is fine for this storage scottpetrovic: I was originally following the pattern for the saving/loading for the global assistant color. | |||||
324 | } | ||||
325 | } | ||||
326 | | ||||
327 | | ||||
317 | if(e.tagName()== PROOFINGWARNINGCOLOR) { | 328 | if(e.tagName()== PROOFINGWARNINGCOLOR) { | ||
318 | QDomDocument dom; | 329 | QDomDocument dom; | ||
319 | KoXml::asQDomElement(dom, e); | 330 | KoXml::asQDomElement(dom, e); | ||
320 | QDomElement eq = dom.firstChildElement(); | 331 | QDomElement eq = dom.firstChildElement(); | ||
321 | proofingConfig->warningColor = KoColor::fromXML(eq.firstChildElement(), Integer8BitsColorDepthID.id()); | 332 | proofingConfig->warningColor = KoColor::fromXML(eq.firstChildElement(), Integer8BitsColorDepthID.id()); | ||
322 | } | 333 | } | ||
323 | 334 | | |||
324 | if (e.tagName().toLower() == "animation") { | 335 | if (e.tagName().toLower() == "animation") { | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | |||||
498 | 509 | | |||
499 | 510 | | |||
500 | void KisKraLoader::loadAssistants(KoStore *store, const QString &uri, bool external) | 511 | void KisKraLoader::loadAssistants(KoStore *store, const QString &uri, bool external) | ||
501 | { | 512 | { | ||
502 | QString file_path; | 513 | QString file_path; | ||
503 | QString location; | 514 | QString location; | ||
504 | QMap<int ,KisPaintingAssistantHandleSP> handleMap; | 515 | QMap<int ,KisPaintingAssistantHandleSP> handleMap; | ||
505 | KisPaintingAssistant* assistant = 0; | 516 | KisPaintingAssistant* assistant = 0; | ||
517 | QColor globalColor = m_d->document->assistantsGlobalColor(); | ||||
518 | | ||||
506 | QMap<QString,QString>::const_iterator loadedAssistant = m_d->assistantsFilenames.constBegin(); | 519 | QMap<QString,QString>::const_iterator loadedAssistant = m_d->assistantsFilenames.constBegin(); | ||
507 | while (loadedAssistant != m_d->assistantsFilenames.constEnd()){ | 520 | while (loadedAssistant != m_d->assistantsFilenames.constEnd()){ | ||
508 | const KisPaintingAssistantFactory* factory = KisPaintingAssistantFactoryRegistry::instance()->get(loadedAssistant.value()); | 521 | const KisPaintingAssistantFactory* factory = KisPaintingAssistantFactoryRegistry::instance()->get(loadedAssistant.value()); | ||
509 | if (factory) { | 522 | if (factory) { | ||
510 | assistant = factory->createPaintingAssistant(); | 523 | assistant = factory->createPaintingAssistant(); | ||
511 | location = external ? QString() : uri; | 524 | location = external ? QString() : uri; | ||
512 | location += m_d->imageName + ASSISTANTS_PATH; | 525 | location += m_d->imageName + ASSISTANTS_PATH; | ||
513 | file_path = location + loadedAssistant.key(); | 526 | file_path = location + loadedAssistant.key(); | ||
514 | assistant->loadXml(store, handleMap, file_path); | 527 | assistant->loadXml(store, handleMap, file_path); | ||
528 | assistant->setAssistantGlobalColor(globalColor); | ||||
515 | 529 | | |||
516 | //If an assistant has too few handles than it should according to it's own setup, just don't load it// | 530 | //If an assistant has too few handles than it should according to it's own setup, just don't load it// | ||
517 | if (assistant->handles().size()==assistant->numHandles()){ | 531 | if (assistant->handles().size()==assistant->numHandles()){ | ||
518 | m_d->assistants.append(toQShared(assistant)); | 532 | m_d->assistants.append(toQShared(assistant)); | ||
519 | } | 533 | } | ||
520 | } | 534 | } | ||
521 | loadedAssistant++; | 535 | loadedAssistant++; | ||
522 | } | 536 | } | ||
▲ Show 20 Lines • Show All 675 Lines • Show Last 20 Lines |
Why do you use two different saving methods for saving global color and local color? Please use one method for both cases, either KoColor or QColor::name() or your own method, but extracted into some common class (e.g. KisDomUtils) and tested.