Sankore dnd copying widgets on placing w3cwidget on the scene cleaning needed

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent fd9fc41990
commit 28d04e54ff
  1. 1
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/api/UBWidgetUniboardAPI.cpp
  3. 34
      src/board/UBBoardController.cpp
  4. 2
      src/board/UBBoardController.h
  5. 22
      src/core/UBPersistenceManager.cpp
  6. 1
      src/core/UBPersistenceManager.h
  7. 4
      src/domain/UBGraphicsWidgetItem.h

@ -2105,7 +2105,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
startFileUrl = widgetRootUrl.toString() + "/" + item->widgetWebView()->mainHtmlFileName(); startFileUrl = widgetRootUrl.toString() + "/" + item->widgetWebView()->mainHtmlFileName();
mXmlWriter.writeAttribute("src", startFileUrl); mXmlWriter.writeAttribute("src", startFileUrl);
mXmlWriter.writeEndElement(); //iFrame mXmlWriter.writeEndElement(); //iFrame
//persists widget state //persists widget state

@ -439,7 +439,7 @@ void UBWidgetUniboardAPI::enableDropOnWidget()
QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const QString &extention) QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const QString &extention)
{ {
QString result; QString result;
QUrl widgetUrl = mGraphicsWidget->widgetWebView()->widgetUrl(); QUrl widgetUrl = mGraphicsWidget->getOwnFolder();
QString destFileName =widgetUrl.toLocalFile() + "/objects/" + QUuid::createUuid().toString() + extention; QString destFileName =widgetUrl.toLocalFile() + "/objects/" + QUuid::createUuid().toString() + extention;
if (UBFileSystemUtils::copyFile(objectUrl, destFileName)) { if (UBFileSystemUtils::copyFile(objectUrl, destFileName)) {

@ -871,9 +871,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetUrl = expandWidgetToTempDir(pData); widgetUrl = expandWidgetToTempDir(pData);
} }
UBGraphicsWidgetItem* w3cWidgetItem = mActiveScene->addW3CWidget(widgetUrl, pPos); UBGraphicsWidgetItem *w3cWidgetItem = addW3cWidget(widgetUrl, pPos);
w3cWidgetItem->setSourceUrl(sourceUrl);
if (isBackground) if (isBackground)
{ {
@ -1647,10 +1645,8 @@ void UBBoardController::updateBackgroundState()
{ {
newBackgroundStyle ="QWidget {background-color: #F1F1F1}"; newBackgroundStyle ="QWidget {background-color: #F1F1F1}";
} }
} }
void UBBoardController::stylusToolChanged(int tool) void UBBoardController::stylusToolChanged(int tool)
{ {
if (UBPlatformUtils::hasVirtualKeyboard() && mPaletteManager->mKeyboardPalette) if (UBPlatformUtils::hasVirtualKeyboard() && mPaletteManager->mKeyboardPalette)
@ -1784,6 +1780,34 @@ UBGraphicsAudioItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool st
} }
UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QPointF &pos)
{
UBGraphicsWidgetItem* w3cWidgetItem = 0;
QUuid uuid = QUuid::createUuid();
QUrl newUrl = pUrl;
newUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(mActiveDocument, pUrl.toLocalFile(), uuid));
w3cWidgetItem = mActiveScene->addW3CWidget(pUrl, pos);
if (w3cWidgetItem) {
w3cWidgetItem->setUuid(uuid);
w3cWidgetItem->setOwnFolder(newUrl);
w3cWidgetItem->setSourceUrl(pUrl);
QString struuid = UBStringUtils::toCanonicalUuid(uuid);
QString snapshotPath = mActiveDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + struuid + ".png";
UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem);
if (tmpItem)
tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG");
}
return 0;
}
void UBBoardController::cut() void UBBoardController::cut()
{ {

@ -200,6 +200,8 @@ class UBBoardController : public QObject
void controlViewShown(); void controlViewShown();
UBGraphicsVideoItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos); UBGraphicsVideoItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsAudioItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos); UBGraphicsAudioItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos);
void cut(); void cut();
void copy(); void copy();
void paste(); void paste();

@ -987,7 +987,29 @@ QString UBPersistenceManager::addPdfFileToDocument(UBDocumentProxy* pDocumentPro
return fileName; return fileName;
} }
QString UBPersistenceManager::addGraphicsWidgteToDocument(UBDocumentProxy *pDocumentProxy, QString path, QUuid objectUuid)
{
QFileInfo fi(path);
if (!fi.exists() || !pDocumentProxy || objectUuid.isNull())
return "";
QString widgetRootDir = path;
QString extension = QFileInfo(widgetRootDir).suffix();
QString widgetTargetDir = pDocumentProxy->persistencePath() + "/" + widgetDirectory + "/" + objectUuid.toString() + "." + extension;
if (!QFile::exists(widgetTargetDir)) {
QDir dir;
dir.mkpath(widgetTargetDir);
UBFileSystemUtils::copyDir(widgetRootDir, widgetTargetDir);
}
if (!QFile::exists(widgetTargetDir))
widgetTargetDir = QString();
return widgetTargetDir;
}
void UBPersistenceManager::documentRepositoryChanged(const QString& path) void UBPersistenceManager::documentRepositoryChanged(const QString& path)

@ -120,6 +120,7 @@ class UBPersistenceManager : public QObject
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid);
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid); virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid);
virtual QString addPdfFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); virtual QString addPdfFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid);
virtual QString addGraphicsWidgteToDocument(UBDocumentProxy *mDocumentProxy, QString path, QUuid objectUuid);
bool mayHaveVideo(UBDocumentProxy* pDocumentProxy); bool mayHaveVideo(UBDocumentProxy* pDocumentProxy);
bool mayHaveAudio(UBDocumentProxy* pDocumentProxy); bool mayHaveAudio(UBDocumentProxy* pDocumentProxy);

@ -68,6 +68,9 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
void removeScript(); void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention); QString downloadUrl(const QString &fileUrl, const QString &extention);
virtual void setOwnFolder(const QUrl &newFolder) {ownFolder = newFolder;}
virtual QUrl getOwnFolder() const {return ownFolder;}
virtual void clearSource(){;} virtual void clearSource(){;}
@ -91,6 +94,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
QPointF mLastMousePos; QPointF mLastMousePos;
bool mShouldMoveWidget; bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI; UBWidgetUniboardAPI* mUniboardAPI;
QUrl ownFolder;
}; };
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem

Loading…
Cancel
Save