|
|
@ -304,7 +304,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const |
|
|
|
setMinimumHeight(250); |
|
|
|
setMinimumHeight(250); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) |
|
|
|
UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWidget* parent,bool forceFlashMediaType,const char* name): QStackedWidget(parent) |
|
|
|
, mpTreeWidgetItem(widget) |
|
|
|
, mpTreeWidgetItem(widget) |
|
|
|
, mpDropMeWidget(NULL) |
|
|
|
, mpDropMeWidget(NULL) |
|
|
|
, mpWorkWidget(NULL) |
|
|
|
, mpWorkWidget(NULL) |
|
|
@ -320,7 +320,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + mediaPath; |
|
|
|
mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + mediaPath; |
|
|
|
setAcceptDrops(false); |
|
|
|
setAcceptDrops(false); |
|
|
|
createWorkWidget(); |
|
|
|
createWorkWidget(forceFlashMediaType); |
|
|
|
setFixedHeight(200); |
|
|
|
setFixedHeight(200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -343,8 +343,7 @@ void UBTGMediaWidget::initializeWithDom(QDomElement element) |
|
|
|
mIsInitializationMode = true; |
|
|
|
mIsInitializationMode = true; |
|
|
|
setAcceptDrops(false); |
|
|
|
setAcceptDrops(false); |
|
|
|
mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element.attribute("relativePath"); |
|
|
|
mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element.attribute("relativePath"); |
|
|
|
qDebug() << mMediaPath; |
|
|
|
createWorkWidget(element.attribute("mediaType").contains("flash")); |
|
|
|
createWorkWidget(); |
|
|
|
|
|
|
|
setFixedHeight(200); |
|
|
|
setFixedHeight(200); |
|
|
|
mpTitle->setInitialText(element.attribute("title")); |
|
|
|
mpTitle->setInitialText(element.attribute("title")); |
|
|
|
mIsInitializationMode = false; |
|
|
|
mIsInitializationMode = false; |
|
|
@ -369,8 +368,12 @@ 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){ |
|
|
|
mpWebView->load(QUrl(mMediaPath + "/index.htm")); |
|
|
|
QString indexPath = mMediaPath+"/index.htm"; |
|
|
|
|
|
|
|
if(!QFile::exists(indexPath)) |
|
|
|
|
|
|
|
indexPath += "l"; |
|
|
|
|
|
|
|
mpWebView->load(QUrl::fromLocalFile(indexPath)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tUBGEElementNode* UBTGMediaWidget::saveData() |
|
|
|
tUBGEElementNode* UBTGMediaWidget::saveData() |
|
|
@ -392,7 +395,7 @@ void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event) |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGMediaWidget::createWorkWidget() |
|
|
|
void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); |
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); |
|
|
|
bool setMedia = true; |
|
|
|
bool setMedia = true; |
|
|
@ -419,12 +422,32 @@ void UBTGMediaWidget::createWorkWidget() |
|
|
|
mpMediaLabelWidget->setPixmap(pixmap); |
|
|
|
mpMediaLabelWidget->setPixmap(pixmap); |
|
|
|
mpMediaLabelWidget->setScaledContents(true); |
|
|
|
mpMediaLabelWidget->setScaledContents(true); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(mimeType.contains("application")){ |
|
|
|
else if(mimeType.contains("widget") && !forceFlashMediaType){ |
|
|
|
mMediaType = "w3c"; |
|
|
|
mMediaType = "w3c"; |
|
|
|
|
|
|
|
if(!(mIsPresentationMode || mIsInitializationMode)){ |
|
|
|
|
|
|
|
mMediaPath = UBPersistenceManager::persistenceManager()->addWidgetToTeacherGuideDirectory(proxyDocument, mMediaPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mpWebView = new UBDraggableWeb(mMediaPath); |
|
|
|
|
|
|
|
mpWebView->setAcceptDrops(false); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
|
|
|
|
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
|
|
|
|
|
|
QString indexPath = mMediaPath+"/index.htm"; |
|
|
|
|
|
|
|
if(!QFile::exists(indexPath)) |
|
|
|
|
|
|
|
indexPath += "l"; |
|
|
|
|
|
|
|
mpWebView->load(QUrl::fromLocalFile(indexPath)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(mimeType.contains("x-shockwave-flash") || forceFlashMediaType){ |
|
|
|
|
|
|
|
mMediaType = "flash"; |
|
|
|
if(!(mIsPresentationMode || mIsInitializationMode)){ |
|
|
|
if(!(mIsPresentationMode || mIsInitializationMode)){ |
|
|
|
QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument)); |
|
|
|
QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument)); |
|
|
|
mMediaPath = UBGraphicsW3CWidgetItem::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid()); |
|
|
|
mMediaPath = UBGraphicsW3CWidgetItem::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
qDebug() << mMediaPath; |
|
|
|
mpWebView = new UBDraggableWeb(mMediaPath); |
|
|
|
mpWebView = new UBDraggableWeb(mMediaPath); |
|
|
|
mpWebView->setAcceptDrops(false); |
|
|
|
mpWebView->setAcceptDrops(false); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
|
|
@ -434,8 +457,10 @@ void UBTGMediaWidget::createWorkWidget() |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
|
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
|
|
|
|
|
|
QString indexPath = mMediaPath+"/index.htm"; |
|
|
|
mpWebView->load(QUrl(mMediaPath+"/index.htm")); |
|
|
|
if(!QFile::exists(indexPath)) |
|
|
|
|
|
|
|
indexPath += "l"; |
|
|
|
|
|
|
|
mpWebView->load(QUrl::fromLocalFile(indexPath)); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
qDebug() << "createWorkWidget mime type not handled" << mimeType; |
|
|
|
qDebug() << "createWorkWidget mime type not handled" << mimeType; |
|
|
|