Added clearing sources of any UBGraphicsWidget.

Added new system util method: deleteFile.
preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 93e08950bc
commit 70e3b539ec
  1. 1
      src/board/UBBoardController.cpp
  2. 8
      src/domain/UBGraphicsMediaItem.cpp
  3. 8
      src/domain/UBGraphicsWidgetItem.cpp
  4. 6
      src/domain/UBGraphicsWidgetItem.h
  5. 4
      src/frameworks/UBCoreGraphicsScene.cpp
  6. 7
      src/frameworks/UBFileSystemUtils.cpp
  7. 3
      src/frameworks/UBFileSystemUtils.h

@ -1802,6 +1802,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
QString struuid = UBStringUtils::toCanonicalUuid(uuid);
QString snapshotPath = mActiveDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + struuid + ".png";
w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath));
UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem);
if (tmpItem)
tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG");

@ -25,6 +25,8 @@
#include "core/memcheck.h"
#include "frameworks/UBFileSystemUtils.h"
bool UBGraphicsMediaItem::sIsMutedByDefault = false;
UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent)
@ -85,15 +87,11 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
void UBGraphicsMediaItem::clearSource()
{
QString path = mediaFileUrl().path();
//if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path;
QFile f(path);
f.setPermissions(path, QFile::ReadOwner | QFile::WriteOwner);
f.remove();
UBFileSystemUtils::deleteFile(path);
}
void UBGraphicsMediaItem::toggleMute()

@ -25,6 +25,7 @@
#include "UBW3CWidget.h"
#include "UBGraphicsScene.h"
#include "UBAppleWidget.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
@ -246,6 +247,13 @@ void UBGraphicsWidgetItem::removeScript()
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}");
}
}
void UBGraphicsWidgetItem::clearSource()
{
UBFileSystemUtils::deleteDir(getOwnFolder().toLocalFile());
UBFileSystemUtils::deleteFile(getSnapshotPath().toLocalFile());
}
QString UBGraphicsWidgetItem::downloadUrl(const QString &fileUrl, const QString &extention)
{
return mUniboardAPI->downloadUrl(fileUrl, extention);

@ -70,9 +70,10 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void setOwnFolder(const QUrl &newFolder) {ownFolder = newFolder;}
virtual QUrl getOwnFolder() const {return ownFolder;}
virtual void setSnapshotPath(const QUrl &newFilePath){SnapshotFile = newFilePath;}
virtual QUrl getSnapshotPath(){return SnapshotFile;}
virtual void clearSource(){;}
virtual void clearSource();
protected:
@ -95,6 +96,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI;
QUrl ownFolder;
QUrl SnapshotFile;
};
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem

@ -19,6 +19,7 @@
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h"
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent )
@ -70,6 +71,9 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
case UBGraphicsVideoItem::Type:
item_casted = dynamic_cast<UBGraphicsVideoItem*>(item);
break;
case UBGraphicsW3CWidgetItem::Type:
item_casted = dynamic_cast<UBGraphicsWidgetItem*>(item);
break;
}
if (0 != item_casted)

@ -79,6 +79,13 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
return QFile::copy(source, normalizedDestination);
}
bool UBFileSystemUtils::deleteFile(const QString &path)
{
QFile f(path);
f.setPermissions(path, QFile::ReadOwner | QFile::WriteOwner);
return f.remove();
}
QString UBFileSystemUtils::defaultTempDirPath()
{
return QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/" + defaultTempDirName();

@ -66,7 +66,8 @@ class UBFileSystemUtils
static bool isAZipFile(QString &filePath);
static bool copyFile(const QString &source, const QString &Destination, bool overwrite = false);
static bool deleteFile(const QString &path);
/**
* Compress a source directory in a zip file.
* @arg pDir the directory to add in zip

Loading…
Cancel
Save