From 3506afa3b43ad8131eb974228d9823aeb9eff54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Tue, 5 Feb 2019 15:11:29 +0100 Subject: [PATCH] fixed a bug where flash widgets were not handled properly when set as tools --- src/board/UBBoardController.cpp | 32 ++++++++++++++++---------------- src/core/UBDownloadManager.cpp | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index bd88ba68..2e637d69 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -741,7 +741,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) return retItem; } - UBItem *createdItem = downloadFinished(true, sourceUrl, srcFile, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false); + UBItem *createdItem = downloadFinished(true, sourceUrl, QUrl::fromLocalFile(srcFile), contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false); if (createdItem) { createdItem->setSourceUrl(item->sourceUrl()); @@ -1375,11 +1375,8 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl)); qDebug() << widgetItem->getOwnFolder(); qDebug() << widgetItem->getSnapshotPath(); - QString ownFolder = selectedDocument()->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt"; - widgetItem->setOwnFolder(ownFolder); - QString adaptedUUid = widgetItem->uuid().toString().replace("{","").replace("}",""); - ownFolder = ownFolder.replace(widgetItem->uuid().toString() + ".wgt", adaptedUUid + ".png"); - widgetItem->setSnapshotPath(ownFolder); + + widgetItem->setSnapshotPath(widgetItem->getOwnFolder()); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); @@ -2500,22 +2497,25 @@ void UBBoardController::togglePodcast(bool checked) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) { mActiveScene->setURStackEnable(false); - UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast(graphicsWidget)); + UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast(graphicsWidget)); UBGraphicsWidgetItem *copyedGraphicsWidget = NULL; - if (UBGraphicsWidgetItem::Type == toolW3C->type()) - copyedGraphicsWidget = static_cast(toolW3C); + if (toolW3C) + { + if (UBGraphicsWidgetItem::Type == toolW3C->type()) + copyedGraphicsWidget = static_cast(toolW3C); - UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView); + UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView); - graphicsWidget->remove(false); - mActiveScene->addItemToDeletion(graphicsWidget); + graphicsWidget->remove(false); + mActiveScene->addItemToDeletion(graphicsWidget); - mActiveScene->setURStackEnable(true); + mActiveScene->setURStackEnable(true); - QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); - toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos)); - toolWidget->show(); + QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); + toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos)); + toolWidget->show(); + } } diff --git a/src/core/UBDownloadManager.cpp b/src/core/UBDownloadManager.cpp index 0c6e7ae2..a483e5fc 100644 --- a/src/core/UBDownloadManager.cpp +++ b/src/core/UBDownloadManager.cpp @@ -93,7 +93,7 @@ void UBAsyncLocalFileDownloader::run() QFile::remove(mTo); } else - emit signal_asyncCopyFinished(mDesc.id, !mTo.isEmpty(), QUrl::fromLocalFile(mTo), QUrl(mDesc.originalSrcUrl), "", NULL, mDesc.pos, mDesc.size, mDesc.isBackground); + emit signal_asyncCopyFinished(mDesc.id, !mTo.isEmpty(), QUrl::fromLocalFile(mTo), QUrl::fromLocalFile(mDesc.originalSrcUrl), "", NULL, mDesc.pos, mDesc.size, mDesc.isBackground); } void UBAsyncLocalFileDownloader::abort()