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);
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());
}
}break;

@ -73,6 +73,7 @@
#include "document/UBDocumentController.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h"
UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController)
@ -846,7 +847,11 @@ void UBBoardPaletteManager::addItemToCurrentPage()
{
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);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);

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

@ -285,13 +285,16 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
QString source = scene->document()->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())
UBFileSystemUtils::copyDir(source,target);
else{
QFileInfo fi(target);
QFileInfo fi(targetDecoded);
QDir d = fi.dir();
d.mkpath(d.absolutePath());
QFile::copy(source, target);
QFile::copy(sourceDecoded, targetDecoded);
}
}

Loading…
Cancel
Save