|
|
@ -26,6 +26,9 @@ |
|
|
|
#include "UBTeacherGuideWidgetsTools.h" |
|
|
|
#include "UBTeacherGuideWidgetsTools.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/UBPersistenceManager.h" |
|
|
|
#include "core/UBPersistenceManager.h" |
|
|
|
|
|
|
|
#include "core/UBApplication.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "board/UBBoardController.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "domain/UBW3CWidget.h" |
|
|
|
#include "domain/UBW3CWidget.h" |
|
|
|
|
|
|
|
|
|
|
@ -87,6 +90,11 @@ UBTGActionWidget::~UBTGActionWidget() |
|
|
|
DELETEPTR(mpLayout); |
|
|
|
DELETEPTR(mpLayout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGActionWidget::initializeWithDom(QDomElement element) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mpOwner->setCurrentIndex(element.attribute("owner").toInt()); |
|
|
|
|
|
|
|
mpTask->setInitialText(element.attribute("task")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tUBGEElementNode* UBTGActionWidget::saveData() |
|
|
|
tUBGEElementNode* UBTGActionWidget::saveData() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -195,6 +203,12 @@ void UBTGAdaptableText::onTextChanged() |
|
|
|
} |
|
|
|
} |
|
|
|
mIsUpdatingSize = false; |
|
|
|
mIsUpdatingSize = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UBTGAdaptableText::setInitialText(const QString& text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setText(text); |
|
|
|
|
|
|
|
setReadOnly(false); |
|
|
|
|
|
|
|
onTextChanged(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::showText(const QString & text) |
|
|
|
void UBTGAdaptableText::showText(const QString & text) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -266,8 +280,9 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const |
|
|
|
, mpMediaLabelWidget(NULL) |
|
|
|
, mpMediaLabelWidget(NULL) |
|
|
|
, mpMediaWidget(NULL) |
|
|
|
, mpMediaWidget(NULL) |
|
|
|
, mpWebView(NULL) |
|
|
|
, mpWebView(NULL) |
|
|
|
, mRelativePath(QString("")) |
|
|
|
, mMediaPath(QString("")) |
|
|
|
, mIsPresentationMode(false) |
|
|
|
, mIsPresentationMode(false) |
|
|
|
|
|
|
|
, mIsInitializationMode(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
mpDropMeWidget = new QLabel(); |
|
|
|
mpDropMeWidget = new QLabel(); |
|
|
@ -280,7 +295,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const |
|
|
|
setMinimumHeight(250); |
|
|
|
setMinimumHeight(250); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) |
|
|
|
UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) |
|
|
|
, mpTreeWidgetItem(widget) |
|
|
|
, mpTreeWidgetItem(widget) |
|
|
|
, mpDropMeWidget(NULL) |
|
|
|
, mpDropMeWidget(NULL) |
|
|
|
, mpWorkWidget(NULL) |
|
|
|
, mpWorkWidget(NULL) |
|
|
@ -289,13 +304,14 @@ UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, |
|
|
|
, mpMediaLabelWidget(NULL) |
|
|
|
, mpMediaLabelWidget(NULL) |
|
|
|
, mpMediaWidget(NULL) |
|
|
|
, mpMediaWidget(NULL) |
|
|
|
, mpWebView(NULL) |
|
|
|
, mpWebView(NULL) |
|
|
|
, mRelativePath(relativePath) |
|
|
|
, mMediaPath(mediaPath) |
|
|
|
, mIsPresentationMode(true) |
|
|
|
, mIsPresentationMode(true) |
|
|
|
, mMediaType("") |
|
|
|
, mMediaType("") |
|
|
|
|
|
|
|
, mIsInitializationMode(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
setAcceptDrops(false); |
|
|
|
setAcceptDrops(false); |
|
|
|
createWorkWidget(mRelativePath); |
|
|
|
createWorkWidget(); |
|
|
|
setFixedHeight(200); |
|
|
|
setFixedHeight(200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -313,6 +329,17 @@ UBTGMediaWidget::~UBTGMediaWidget() |
|
|
|
DELETEPTR(mpWorkWidget); |
|
|
|
DELETEPTR(mpWorkWidget); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::initializeWithDom(QDomElement element) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mIsInitializationMode = true; |
|
|
|
|
|
|
|
setAcceptDrops(false); |
|
|
|
|
|
|
|
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath() + "/" + element.attribute("relativePath"); |
|
|
|
|
|
|
|
createWorkWidget(); |
|
|
|
|
|
|
|
setFixedHeight(200); |
|
|
|
|
|
|
|
mpTitle->setInitialText(element.attribute("title")); |
|
|
|
|
|
|
|
mIsInitializationMode = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::hideEvent(QHideEvent* event) |
|
|
|
void UBTGMediaWidget::hideEvent(QHideEvent* event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(mpWebView) |
|
|
|
if(mpWebView) |
|
|
@ -323,10 +350,8 @@ void UBTGMediaWidget::hideEvent(QHideEvent* event) |
|
|
|
void UBTGMediaWidget::showEvent(QShowEvent* event) |
|
|
|
void UBTGMediaWidget::showEvent(QShowEvent* event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QWidget::showEvent(event); |
|
|
|
QWidget::showEvent(event); |
|
|
|
if(mpWebView){ |
|
|
|
if(mpWebView) |
|
|
|
qDebug() << mRelativePath; |
|
|
|
mpWebView->load(QUrl(mMediaPath + "/index.htm")); |
|
|
|
mpWebView->load(QUrl(mRelativePath + "/index.htm")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tUBGEElementNode* UBTGMediaWidget::saveData() |
|
|
|
tUBGEElementNode* UBTGMediaWidget::saveData() |
|
|
@ -336,7 +361,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData() |
|
|
|
tUBGEElementNode* result = new tUBGEElementNode(); |
|
|
|
tUBGEElementNode* result = new tUBGEElementNode(); |
|
|
|
result->type = "media"; |
|
|
|
result->type = "media"; |
|
|
|
result->attributes.insert("title",mpTitle->text()); |
|
|
|
result->attributes.insert("title",mpTitle->text()); |
|
|
|
result->attributes.insert("relativePath",mRelativePath); |
|
|
|
result->attributes.insert("relativePath",mMediaPath); |
|
|
|
result->attributes.insert("mediaType",mMediaType); |
|
|
|
result->attributes.insert("mediaType",mMediaType); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -346,31 +371,40 @@ void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event) |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::createWorkWidget(QString& path) |
|
|
|
void UBTGMediaWidget::createWorkWidget() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); |
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); |
|
|
|
bool setMedia = true; |
|
|
|
bool setMedia = true; |
|
|
|
mRelativePath = path; |
|
|
|
UBDocumentProxy* proxyDocument = UBApplication::boardController->activeDocument(); |
|
|
|
if(mimeType.contains("audio") || mimeType.contains("video")){ |
|
|
|
if(mimeType.contains("audio") || mimeType.contains("video")){ |
|
|
|
mMediaType = mimeType.contains("audio")? "audio":"movie"; |
|
|
|
mMediaType = mimeType.contains("audio")? "audio":"movie"; |
|
|
|
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
|
|
|
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
|
|
|
mpMediaWidget->setFile(path); |
|
|
|
if(mIsPresentationMode || mIsInitializationMode){ |
|
|
|
|
|
|
|
mpMediaWidget->setFile(mMediaPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath); |
|
|
|
|
|
|
|
mpMediaWidget->setFile(mMediaPath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(mimeType.contains("image")){ |
|
|
|
else if(mimeType.contains("image")){ |
|
|
|
mMediaType = "image"; |
|
|
|
mMediaType = "image"; |
|
|
|
|
|
|
|
if(!(mIsPresentationMode || mIsInitializationMode)) |
|
|
|
|
|
|
|
mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath); |
|
|
|
|
|
|
|
|
|
|
|
mpMediaLabelWidget = new QLabel(); |
|
|
|
mpMediaLabelWidget = new QLabel(); |
|
|
|
QPixmap pixmap = QPixmap(QUrl(path).toLocalFile()); |
|
|
|
QPixmap pixmap = QPixmap(mMediaPath); |
|
|
|
pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width()); |
|
|
|
pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width()); |
|
|
|
mpMediaLabelWidget->setPixmap(pixmap); |
|
|
|
mpMediaLabelWidget->setPixmap(pixmap); |
|
|
|
mpMediaLabelWidget->setScaledContents(true); |
|
|
|
mpMediaLabelWidget->setScaledContents(true); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(mimeType.contains("application")){ |
|
|
|
else if(mimeType.contains("application")){ |
|
|
|
mMediaType = "w3c"; |
|
|
|
mMediaType = "w3c"; |
|
|
|
if(!mIsPresentationMode){ |
|
|
|
if(!(mIsPresentationMode || mIsInitializationMode)){ |
|
|
|
QDir baseW3CDirectory("/home/claudio"); |
|
|
|
QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument)); |
|
|
|
mRelativePath = UBW3CWidget::createNPAPIWrapperInDir(path,baseW3CDirectory,mimeType,QSize(100,100),"flashahaha"); |
|
|
|
mMediaPath = UBW3CWidget::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid()); |
|
|
|
} |
|
|
|
} |
|
|
|
mpWebView = new UBDraggableWeb(mRelativePath); |
|
|
|
mpWebView = new UBDraggableWeb(mMediaPath); |
|
|
|
mpWebView->setAcceptDrops(false); |
|
|
|
mpWebView->setAcceptDrops(false); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); |
|
|
@ -380,7 +414,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
|
|
|
|
|
|
|
|
|
|
mpWebView->load(QUrl(mRelativePath+"/index.htm")); |
|
|
|
mpWebView->load(QUrl(mMediaPath+"/index.htm")); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
qDebug() << "createWorkWidget mime type not handled" << mimeType; |
|
|
|
qDebug() << "createWorkWidget mime type not handled" << mimeType; |
|
|
@ -420,13 +454,12 @@ void UBTGMediaWidget::createWorkWidget(QString& path) |
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) |
|
|
|
void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString path; |
|
|
|
|
|
|
|
if(pMimeData){ |
|
|
|
if(pMimeData){ |
|
|
|
if(pMimeData->hasText()){ |
|
|
|
if(pMimeData->hasText()){ |
|
|
|
path = QUrl::fromLocalFile(pMimeData->text()).toString(); |
|
|
|
mMediaPath = QUrl::fromLocalFile(pMimeData->text()).toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(pMimeData->hasUrls()){ |
|
|
|
else if(pMimeData->hasUrls()){ |
|
|
|
path = pMimeData->urls().at(0).toString(); |
|
|
|
mMediaPath = pMimeData->urls().at(0).toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(pMimeData->hasImage()){ |
|
|
|
else if(pMimeData->hasImage()){ |
|
|
|
qDebug() << "Not yet implemented"; |
|
|
|
qDebug() << "Not yet implemented"; |
|
|
@ -435,7 +468,7 @@ void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) |
|
|
|
else |
|
|
|
else |
|
|
|
qDebug() << "No mime data present"; |
|
|
|
qDebug() << "No mime data present"; |
|
|
|
|
|
|
|
|
|
|
|
createWorkWidget(path); |
|
|
|
createWorkWidget(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::dropEvent(QDropEvent* event) |
|
|
|
void UBTGMediaWidget::dropEvent(QDropEvent* event) |
|
|
@ -451,9 +484,9 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
|
|
|
|
|
|
|
|
QDrag *drag = new QDrag(this); |
|
|
|
QDrag *drag = new QDrag(this); |
|
|
|
QMimeData *mimeData = new QMimeData; |
|
|
|
QMimeData *mimeData = new QMimeData(); |
|
|
|
QList<QUrl> urlList; |
|
|
|
QList<QUrl> urlList; |
|
|
|
urlList << QUrl(mRelativePath); |
|
|
|
urlList << QUrl(mMediaPath); |
|
|
|
mimeData->setUrls(urlList); |
|
|
|
mimeData->setUrls(urlList); |
|
|
|
drag->setMimeData(mimeData); |
|
|
|
drag->setMimeData(mimeData); |
|
|
|
|
|
|
|
|
|
|
@ -490,6 +523,12 @@ UBTGUrlWidget::~UBTGUrlWidget() |
|
|
|
DELETEPTR(mpLayout); |
|
|
|
DELETEPTR(mpLayout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGUrlWidget::initializeWithDom(QDomElement element) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mpTitle->setText(element.attribute("title")); |
|
|
|
|
|
|
|
mpUrl->setText(element.attribute("url")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tUBGEElementNode* UBTGUrlWidget::saveData() |
|
|
|
tUBGEElementNode* UBTGUrlWidget::saveData() |
|
|
|
{ |
|
|
|
{ |
|
|
|
tUBGEElementNode* result = new tUBGEElementNode(); |
|
|
|
tUBGEElementNode* result = new tUBGEElementNode(); |
|
|
|