dnd try and first media viewer widget

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent f2948758c6
commit afab4879e1
  1. 4
      src/board/UBBoardView.cpp
  2. 8
      src/gui/UBMediaPlayer.cpp
  3. 79
      src/gui/UBTeacherBarWidget.cpp
  4. 25
      src/gui/UBTeacherBarWidget.h

@ -33,6 +33,8 @@
#include "gui/UBToolWidget.h" #include "gui/UBToolWidget.h"
#include "gui/UBResources.h" #include "gui/UBResources.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBTeacherBarWidget.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
@ -725,7 +727,7 @@ void
UBBoardView::dropEvent (QDropEvent *event) UBBoardView::dropEvent (QDropEvent *event)
{ {
qDebug() << event->source(); qDebug() << event->source();
if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source())) if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBTeacherBarPreviewMedia *>(event->source()))
{ {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction (); event->acceptProposedAction ();

@ -39,7 +39,7 @@ UBMediaPlayer::UBMediaPlayer() :
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu);
QSize buttonSize(34, 28); QSize buttonSize(26, 20);
// QPushButton *openButton = new QPushButton(this); // QPushButton *openButton = new QPushButton(this);
@ -67,7 +67,7 @@ UBMediaPlayer::UBMediaPlayer() :
slider->setMediaObject(&m_MediaObject); slider->setMediaObject(&m_MediaObject);
QVBoxLayout *vLayout = new QVBoxLayout(this); QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setContentsMargins(8, 8, 8, 8); vLayout->setContentsMargins(1, 1, 1, 1);
// QHBoxLayout *layout = new QHBoxLayout(); // QHBoxLayout *layout = new QHBoxLayout();
@ -101,7 +101,7 @@ UBMediaPlayer::UBMediaPlayer() :
initVideoWindow(); initVideoWindow();
vLayout->addWidget(&m_videoWindow); vLayout->addWidget(&m_videoWindow);
QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); QVBoxLayout *buttonPanelLayout = new QVBoxLayout();
m_videoWindow.hide(); // m_videoWindow.hide();
// buttonPanelLayout->addLayout(layout); // buttonPanelLayout->addLayout(layout);
// timeLabel = new QLabel(this); // timeLabel = new QLabel(this);
@ -224,7 +224,7 @@ void UBMediaPlayer::initVideoWindow()
videoLayout->addWidget(m_videoWidget); videoLayout->addWidget(m_videoWidget);
videoLayout->setContentsMargins(0, 0, 0, 0); videoLayout->setContentsMargins(0, 0, 0, 0);
m_videoWindow.setLayout(videoLayout); m_videoWindow.setLayout(videoLayout);
m_videoWindow.setMinimumSize(70, 70); m_videoWindow.setMinimumSize(100, 100);
} }
void UBMediaPlayer::playPause() void UBMediaPlayer::playPause()

@ -333,7 +333,6 @@ void UBTeacherBarWidget::loadContent()
} }
} }
// Media // Media
// TODO : Add the media items here
mpDropMediaZone->reloadMedia(nextInfos.medias); mpDropMediaZone->reloadMedia(nextInfos.medias);
// Links // Links
@ -352,6 +351,7 @@ void UBTeacherBarWidget::loadContent()
} }
if(!isEmpty()){ if(!isEmpty()){
mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
mpStackWidget->setCurrentWidget(mpPreview); mpStackWidget->setCurrentWidget(mpPreview);
} }
} }
@ -685,12 +685,14 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
setLayout(mpLayout); setLayout(mpLayout);
mpEditButton = new QPushButton(tr("Edit infos"), this); mpEditButton = new QPushButton(tr("Edit infos"), this);
mpEditLayout = new QHBoxLayout(); mpEditLayout = new QVBoxLayout();
mpEditLayout->addStretch(1); mpEditLayout->addStretch(1);
mpEditLayout->addWidget(mpEditButton, 0); mpEditLayout->addWidget(mpEditButton, 0);
mpEditLayout->addStretch(1); mpEditLayout->addStretch(1);
mpEditLayout->addWidget(&mMediaViewer);
mpLayout->addLayout(mpEditLayout); mpLayout->addLayout(mpEditLayout);
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
} }
@ -714,3 +716,76 @@ void UBTeacherBarPreviewWidget::onEdit()
{ {
emit showEditMode(); emit showEditMode();
} }
// ------------------------------------------------------------------------------------
UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent)
{
setObjectName(name);
setAcceptDrops(true);
mWidget = new UBWidgetList(parent);
mWidget->setEmptyText(tr("No media found"));
mLayout.addWidget(mWidget);
setLayout(&mLayout);
//TO TEST only
// QStringList mediaPathList;
// mediaPathList << "/home/claudio/Desktop/PIPPO.jpg";
// loadMedia(mediaPathList);
}
UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
{
if(mWidget){
delete mWidget;
mWidget = NULL;
}
}
// for test only
QString tempString;
void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
{
foreach(QString eachString, pMedias){
if(!eachString.isEmpty()){
tempString = eachString;
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
if(mimeType.contains("image")){
QPixmap pix = QPixmap(eachString);
QLabel* label = new QLabel();
label->setPixmap(pix);
label->setScaledContents(true);
mWidget->addWidget(label);
// mWidgetList << label;
}
else if(mimeType.contains("video") || mimeType.contains("audio")){
UBMediaPlayer* mediaPlayer = new UBMediaPlayer();
mediaPlayer->setFile(eachString);
mWidget->addWidget(mediaPlayer);
// mWidgetList << mediaPlayer;
}
else{
qWarning() << "pMediaPath" << eachString;
qWarning() << "bad idea to come here";
}
}
}
}
void UBTeacherBarPreviewMedia::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl::fromLocalFile(tempString);
mimeData->setUrls(urls);
mimeData->setText(tempString);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}

@ -68,6 +68,27 @@ protected:
void dragLeaveEvent(QDragLeaveEvent* pEvent); void dragLeaveEvent(QDragLeaveEvent* pEvent);
}; };
class UBTeacherBarPreviewMedia : public QWidget
{
Q_OBJECT
public:
UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia");
~UBTeacherBarPreviewMedia();
void loadMedia(QStringList pMedias);
private:
UBWidgetList* mWidget;
QVBoxLayout mLayout;
protected:
void mousePressEvent(QMouseEvent *event);
public slots:
};
class UBUrlWidget : public QWidget class UBUrlWidget : public QWidget
{ {
public: public:
@ -89,6 +110,7 @@ class UBTeacherBarPreviewWidget : public QWidget
public: public:
UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget");
~UBTeacherBarPreviewWidget(); ~UBTeacherBarPreviewWidget();
UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;}
signals: signals:
void showEditMode(); void showEditMode();
@ -99,7 +121,8 @@ private slots:
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QPushButton* mpEditButton; QPushButton* mpEditButton;
QHBoxLayout* mpEditLayout; QVBoxLayout* mpEditLayout;
UBTeacherBarPreviewMedia mMediaViewer;
}; };
class UBTeacherBarWidget : public UBDockPaletteWidget class UBTeacherBarWidget : public UBDockPaletteWidget

Loading…
Cancel
Save