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/UBResources.h"
#include "gui/UBMainWindow.h"
#include "gui/UBTeacherBarWidget.h"
#include "board/UBBoardController.h"
@ -725,7 +727,7 @@ void
UBBoardView::dropEvent (QDropEvent *event)
{
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 ()));
event->acceptProposedAction ();

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

@ -333,7 +333,6 @@ void UBTeacherBarWidget::loadContent()
}
}
// Media
// TODO : Add the media items here
mpDropMediaZone->reloadMedia(nextInfos.medias);
// Links
@ -352,6 +351,7 @@ void UBTeacherBarWidget::loadContent()
}
if(!isEmpty()){
mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
mpStackWidget->setCurrentWidget(mpPreview);
}
}
@ -685,12 +685,14 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
setLayout(mpLayout);
mpEditButton = new QPushButton(tr("Edit infos"), this);
mpEditLayout = new QHBoxLayout();
mpEditLayout = new QVBoxLayout();
mpEditLayout->addStretch(1);
mpEditLayout->addWidget(mpEditButton, 0);
mpEditLayout->addStretch(1);
mpEditLayout->addWidget(&mMediaViewer);
mpLayout->addLayout(mpEditLayout);
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
}
@ -714,3 +716,76 @@ void UBTeacherBarPreviewWidget::onEdit()
{
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);
};
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
{
public:
@ -89,6 +110,7 @@ class UBTeacherBarPreviewWidget : public QWidget
public:
UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget");
~UBTeacherBarPreviewWidget();
UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;}
signals:
void showEditMode();
@ -99,7 +121,8 @@ private slots:
private:
QVBoxLayout* mpLayout;
QPushButton* mpEditButton;
QHBoxLayout* mpEditLayout;
QVBoxLayout* mpEditLayout;
UBTeacherBarPreviewMedia mMediaViewer;
};
class UBTeacherBarWidget : public UBDockPaletteWidget

Loading…
Cancel
Save