first draft

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent f5931f0f05
commit 0045204c7a
  1. 103
      src/gui/UBTeacherBarWidget.cpp
  2. 12
      src/gui/UBTeacherBarWidget.h

@ -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";

@ -2,7 +2,6 @@
#define UBTEACHERBARWIDGET_H #define UBTEACHERBARWIDGET_H
class UBMediaPlayer; class UBMediaPlayer;
class UBVideoPlayer;
#include <QWidget> #include <QWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -14,6 +13,8 @@ class UBVideoPlayer;
#include <QTabWidget> #include <QTabWidget>
#include <QButtonGroup> #include <QButtonGroup>
#include "customWidgets/UBWidgetList.h"
#include "UBDockPaletteWidget.h" #include "UBDockPaletteWidget.h"
#define LABEL_MINWIDHT 80 #define LABEL_MINWIDHT 80
@ -45,7 +46,7 @@ private:
}; };
class UBTeacherBarDropMediaZone : public QWidget class UBTeacherBarDropMediaZone : public UBWidgetList
{ {
Q_OBJECT Q_OBJECT
@ -54,12 +55,7 @@ public:
~UBTeacherBarDropMediaZone(); ~UBTeacherBarDropMediaZone();
private: private:
QLabel* mpTitleLabel; QList<QWidget*>mWidgetList;
QLabel* mpImageTab;
UBMediaPlayer* mpVideoTab;
UBMediaPlayer* mpAudioTab;
QTabWidget* mpTabWidget;
QVBoxLayout* mpLayout;
protected: protected:
void dragEnterEvent(QDragEnterEvent* pEvent); void dragEnterEvent(QDragEnterEvent* pEvent);

Loading…
Cancel
Save