Fix for copy/paste issues

This fixes two related issues:
1) When taking a partial screenshot of the desktop, then copying it
(Ctrl-C) and pasting it in a new document, it was not saved
2) When a page of one document was copied into another (in document
mode, by dragging the page onto another document), media files
disappeared from the new page.
preferencesAboutTextFull
Craig Watson 8 years ago
parent 716314fe73
commit fc81e27b9f
  1. 2
      src/board/UBBoardController.cpp
  2. 7
      src/board/UBBoardPaletteManager.cpp
  3. 22
      src/domain/UBGraphicsScene.cpp
  4. 7
      src/gui/UBDocumentTreeWidget.cpp

@ -651,7 +651,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
{ {
QBuffer buffer(&pData); QBuffer buffer(&pData);
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
QString format = UBFileSystemUtils::extension(item->sourceUrl().toLocalFile()); QString format = UBFileSystemUtils::extension(item->sourceUrl().toString(QUrl::DecodeReserved));
pixitem->pixmap().save(&buffer, format.toLatin1()); pixitem->pixmap().save(&buffer, format.toLatin1());
} }
}break; }break;

@ -73,6 +73,7 @@
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController) UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController)
@ -846,7 +847,11 @@ void UBBoardPaletteManager::addItemToCurrentPage()
{ {
UBGraphicsPixmapItem* item = UBApplication::boardController->activeScene()->addPixmap(mPixmap, NULL, mPos, mScaleFactor); UBGraphicsPixmapItem* item = UBApplication::boardController->activeScene()->addPixmap(mPixmap, NULL, mPos, mScaleFactor);
item->setSourceUrl(mItemUrl); QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + item->uuid().toString() + ".png";
QString path = documentPath + "/" + fileName;
item->setSourceUrl(QUrl(path));
item->setSelected(true); item->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);

@ -2209,15 +2209,19 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
while (itItems.hasNext()) while (itItems.hasNext())
{ {
QGraphicsItem* item = itItems.next(); QGraphicsItem* item = itItems.next();
UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast<UBGraphicsMediaItem*> (item);
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item);
if (mediaItem){ if (videoItem){
QString completeFileName = QFileInfo(mediaItem->mediaFileUrl().toLocalFile()).fileName(); QString completeFileName = QFileInfo(videoItem->mediaFileUrl().toLocalFile()).fileName();
QString path; QString path = UBPersistenceManager::videoDirectory + "/";
if(mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video) relativePathes << QUrl(path + completeFileName);
path = UBPersistenceManager::videoDirectory + "/"; continue;
else }
path = UBPersistenceManager::audioDirectory + "/";
UBGraphicsAudioItem *audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item);
if (audioItem){
QString completeFileName = QFileInfo(audioItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::audioDirectory + "/";
relativePathes << QUrl(path + completeFileName); relativePathes << QUrl(path + completeFileName);
continue; continue;
} }

@ -285,13 +285,16 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
QString source = scene->document()->persistencePath() + "/" + relativeFile.toString(); QString source = scene->document()->persistencePath() + "/" + relativeFile.toString();
QString target = targetDocProxy->persistencePath() + "/" + relativeFile.toString(); QString target = targetDocProxy->persistencePath() + "/" + relativeFile.toString();
QString sourceDecoded = scene->document()->persistencePath() + "/" + relativeFile.toString(QUrl::DecodeReserved);
QString targetDecoded = targetDocProxy->persistencePath() + "/" + relativeFile.toString(QUrl::DecodeReserved);
if(QFileInfo(source).isDir()) if(QFileInfo(source).isDir())
UBFileSystemUtils::copyDir(source,target); UBFileSystemUtils::copyDir(source,target);
else{ else{
QFileInfo fi(target); QFileInfo fi(targetDecoded);
QDir d = fi.dir(); QDir d = fi.dir();
d.mkpath(d.absolutePath()); d.mkpath(d.absolutePath());
QFile::copy(source, target); QFile::copy(sourceDecoded, targetDecoded);
} }
} }

Loading…
Cancel
Save