Commit ee069c75 authored by Claudio Valerio's avatar Claudio Valerio

fixed with pixmap and svg not saved on disk when added from a capture

parent bddb4db2
...@@ -1104,21 +1104,6 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl ...@@ -1104,21 +1104,6 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
UBGraphicsPixmapItem* pixItem = mActiveScene->addPixmap(pix, NULL, pPos, 1.); UBGraphicsPixmapItem* pixItem = mActiveScene->addPixmap(pix, NULL, pPos, 1.);
pixItem->setSourceUrl(sourceUrl); 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) if (isBackground)
{ {
mActiveScene->setAsBackgroundObject(pixItem, true); mActiveScene->setAsBackgroundObject(pixItem, true);
...@@ -1138,28 +1123,6 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl ...@@ -1138,28 +1123,6 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData); 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 NULL;
}
file.write(svgItem->fileData());
file.close();
}
svgItem->setSourceUrl(sourceUrl); svgItem->setSourceUrl(sourceUrl);
if (isBackground) if (isBackground)
......
...@@ -1291,6 +1291,20 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi ...@@ -1291,6 +1291,20 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
pixmapItem->show(); pixmapItem->show();
setDocumentUpdated(); setDocumentUpdated();
QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png";
QString path = documentPath + "/" + fileName;
if (!QFile::exists(path))
{
QDir dir;
dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory);
pixmapItem->pixmap().toImage().save(path, "PNG");
}
return pixmapItem; return pixmapItem;
} }
...@@ -1537,6 +1551,28 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint ...@@ -1537,6 +1551,28 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
setDocumentUpdated(); setDocumentUpdated();
QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg";
QString completePath = documentPath + "/" + fileName;
if (!QFile::exists(completePath))
{
QDir dir;
dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory);
QFile file(completePath);
if (!file.open(QIODevice::WriteOnly))
{
qWarning() << "cannot open file for writing embeded svg content " << completePath;
return NULL;
}
file.write(svgItem->fileData());
file.close();
}
return svgItem; return svgItem;
} }
......
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