|
|
@ -1,7 +1,8 @@ |
|
|
|
#include "UBTeacherBarWidget.h" |
|
|
|
#include "UBTeacherBarWidget.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "core/UBApplication.h" |
|
|
|
#include "core/UBPersistenceManager.h" |
|
|
|
#include "core/UBPersistenceManager.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "UBMainWindow.h" |
|
|
|
#include "UBMainWindow.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "document/UBDocumentController.h" |
|
|
|
#include "document/UBDocumentController.h" |
|
|
@ -10,6 +11,10 @@ |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
#include "board/UBBoardController.h" |
|
|
|
#include "board/UBBoardPaletteManager.h" |
|
|
|
#include "board/UBBoardPaletteManager.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "gui/UBMediaPlayer.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
|
UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) |
|
|
|
UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) |
|
|
@ -326,110 +331,50 @@ QTextEdit* UBTeacherStudentAction::student() |
|
|
|
return mpStudent; |
|
|
|
return mpStudent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#include "gui/UBMediaPlayer.h" |
|
|
|
|
|
|
|
#include "gui/UBVideoPlayer.h" |
|
|
|
|
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent) |
|
|
|
UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):UBWidgetList(parent) |
|
|
|
, mpTitleLabel(NULL) |
|
|
|
|
|
|
|
, mpImageTab(NULL) |
|
|
|
|
|
|
|
, mpTabWidget(NULL) |
|
|
|
|
|
|
|
, mpLayout(NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
setAcceptDrops(true); |
|
|
|
setAcceptDrops(true); |
|
|
|
|
|
|
|
setEmptyText(tr("Drag media here ...")); |
|
|
|
setAttribute(Qt::WA_StyledBackground, true); |
|
|
|
|
|
|
|
setStyleSheet(UBApplication::globalStyleSheet()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the GUI
|
|
|
|
|
|
|
|
mpLayout = new QVBoxLayout(this); |
|
|
|
|
|
|
|
setLayout(mpLayout); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mpImageTab = new QLabel(); |
|
|
|
|
|
|
|
mpVideoTab = new UBMediaPlayer(); |
|
|
|
|
|
|
|
mpAudioTab = new UBMediaPlayer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mpTitleLabel = new QLabel(tr("Drop media here")); |
|
|
|
|
|
|
|
mpLayout->addWidget(mpTitleLabel); |
|
|
|
|
|
|
|
mpTabWidget = new QTabWidget(); |
|
|
|
|
|
|
|
mpTabWidget->setMinimumHeight(120); |
|
|
|
|
|
|
|
mpTabWidget->addTab(mpImageTab,QIcon(":images/toolbar/extraTool.png"),""); |
|
|
|
|
|
|
|
mpTabWidget->addTab(mpVideoTab,QIcon(":images/libpalette/movieIcon.svg"),""); |
|
|
|
|
|
|
|
mpTabWidget->addTab(mpAudioTab,QIcon(":images/libpalette/soundIcon.svg"),""); |
|
|
|
|
|
|
|
mpLayout->addWidget(mpTabWidget); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() |
|
|
|
UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(NULL != mpTitleLabel) |
|
|
|
qDeleteAll(mWidgetList); |
|
|
|
{ |
|
|
|
|
|
|
|
delete mpTitleLabel; |
|
|
|
|
|
|
|
mpTitleLabel = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(NULL != mpImageTab) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete mpImageTab; |
|
|
|
|
|
|
|
mpImageTab = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(NULL != mpVideoTab) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete mpVideoTab; |
|
|
|
|
|
|
|
mpVideoTab = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(NULL != mpAudioTab) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete mpAudioTab; |
|
|
|
|
|
|
|
mpAudioTab = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(NULL != mpTabWidget) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete mpTabWidget; |
|
|
|
|
|
|
|
mpTabWidget = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(NULL != mpLayout) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete mpLayout; |
|
|
|
|
|
|
|
mpLayout = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) |
|
|
|
void UBTeacherBarDropMediaZone::dragEnterEvent(QDragEnterEvent *pEvent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setBackgroundRole(QPalette::Highlight); |
|
|
|
|
|
|
|
pEvent->acceptProposedAction(); |
|
|
|
pEvent->acceptProposedAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) |
|
|
|
void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setBackgroundRole(QPalette::Dark); |
|
|
|
|
|
|
|
pEvent->accept(); |
|
|
|
pEvent->accept(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) |
|
|
|
void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setBackgroundRole(QPalette::Dark); |
|
|
|
|
|
|
|
if(pEvent->mimeData()->hasHtml()) qDebug() << pEvent->mimeData()->html(); |
|
|
|
|
|
|
|
if(pEvent->mimeData()->hasUrls()) qDebug() << pEvent->mimeData()->urls(); |
|
|
|
|
|
|
|
if(pEvent->mimeData()->hasText()) qDebug() << pEvent->mimeData()->text(); |
|
|
|
|
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
if(mimeType.contains("image")){ |
|
|
|
if(mimeType.contains("image")){ |
|
|
|
QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
mpImageTab->setPixmap(pix); |
|
|
|
float ratio = (float)width()/(float)pix.width(); |
|
|
|
mpTabWidget->setCurrentWidget(mpImageTab); |
|
|
|
pix.transformed(QTransform::scale((float)pix.width()/ratio,(float)pix.height()/ratio)); |
|
|
|
} |
|
|
|
QLabel* label = new QLabel(); |
|
|
|
else if(mimeType.contains("video")){ |
|
|
|
label->setPixmap(pix); |
|
|
|
mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
label->setScaledContents(true); |
|
|
|
mpVideoTab->playPause(); |
|
|
|
addWidget(label); |
|
|
|
|
|
|
|
mWidgetList << label; |
|
|
|
mpTabWidget->setCurrentWidget(mpVideoTab); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
|
|
|
else if(mimeType.contains("audio")){ |
|
|
|
UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); |
|
|
|
mpVideoTab->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
mediaPlayer->setFile(pEvent->mimeData()->urls().at(0).toLocalFile()); |
|
|
|
mpVideoTab->playPause(); |
|
|
|
mediaPlayer->playPause(); |
|
|
|
mpTabWidget->setCurrentWidget(mpAudioTab); |
|
|
|
addWidget(mediaPlayer); |
|
|
|
|
|
|
|
mWidgetList << mediaPlayer; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
qWarning() << "bad idea to come here"; |
|
|
|
qWarning() << "bad idea to come here"; |
|
|
|