Commit dbc0f592 authored by Claudio Valerio's avatar Claudio Valerio

images are stored on disk when downloaded on the board

parent cf9d3850
......@@ -1863,14 +1863,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::pixmapItemToLinkedImage(UBGraphicsPi
QString path = mDocumentPath + "/" + fileName;
if (!QFile::exists(path))
{
QDir dir;
dir.mkdir(mDocumentPath + "/" + UBPersistenceManager::imageDirectory);
pixmapItem->pixmap().toImage().save(path, "PNG");
}
mXmlWriter.writeAttribute(nsXLink, "href", fileName);
graphicsItemToSvg(pixmapItem);
......@@ -1910,25 +1902,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::svgItemToLinkedSvg(UBGraphicsSvgItem
mXmlWriter.writeStartElement("image");
QString fileName = UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg";
QString path = mDocumentPath + "/" + fileName;
if (!QFile::exists(path))
{
QDir dir;
dir.mkdir(mDocumentPath + "/" + UBPersistenceManager::imageDirectory);
QFile file(path);
if (!file.open(QIODevice::WriteOnly))
{
qWarning() << "cannot open file for writing embeded svg content " << path;
return;
}
file.write(svgItem->fileData());
}
mXmlWriter.writeAttribute(nsXLink, "href", fileName);
graphicsItemToSvg(svgItem);
......@@ -1984,6 +1957,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::pdfItemToLinkedPDF(UBGraphicsPDFItem
}
file.write(pdfItem->fileData());
file.close();
}
mXmlWriter.writeAttribute(nsXLink, "href", fileName + "#page=" + QString::number(pdfItem->pageNumber()));
......@@ -2344,11 +2318,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "frozen", xmlTrue);
}
// QString snapshotPath = mDocumentPath + "/" + UBPersistenceManager::widgetDirectory + "/" + uuid + ".png";
// item->takeSnapshot().save(snapshotPath, "PNG");
mXmlWriter.writeStartElement(nsXHtml, "iframe");
mXmlWriter.writeAttribute("style", "border: none");
......
......@@ -1105,6 +1105,21 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
UBGraphicsPixmapItem* pixItem = mActiveScene->addPixmap(pix, NULL, pPos, 1.);
pixItem->setSourceUrl(sourceUrl);
QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + pixItem->uuid().toString() + ".png";
QString path = documentPath + "/" + fileName;
if (!QFile::exists(path))
{
QDir dir;
dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory);
pixItem->pixmap().toImage().save(path, "PNG");
}
if (isBackground)
{
mActiveScene->setAsBackgroundObject(pixItem, true);
......@@ -1123,6 +1138,29 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
qDebug() << "accepting mime type" << mimeType << "as vecto image";
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData);
QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg";
QString path = documentPath + "/" + fileName;
if (!QFile::exists(path))
{
QDir dir;
dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory);
QFile file(path);
if (!file.open(QIODevice::WriteOnly))
{
qWarning() << "cannot open file for writing embeded svg content " << path;
return;
}
file.write(svgItem->fileData());
file.close();
}
svgItem->setSourceUrl(sourceUrl);
if (isBackground)
......
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