Merge branch 'Bett-2012' of github.com:Sankore/Sankore-3.1 into Bett-2012

preferencesAboutTextFull
shibakaneki 13 years ago
commit 86f30482d7
  1. 10
      src/board/UBBoardView.cpp
  2. 39
      src/customWidgets/UBDraggableLabel.cpp
  3. 23
      src/customWidgets/UBDraggableLabel.h
  4. 8
      src/customWidgets/customWidgets.pri
  5. 28
      src/gui/UBMediaPlayer.cpp
  6. 12
      src/gui/UBMediaPlayer.h
  7. 44
      src/gui/UBTeacherBarWidget.cpp
  8. 7
      src/gui/UBTeacherBarWidget.h

@ -19,6 +19,7 @@
#include "UBDrawingController.h" #include "UBDrawingController.h"
#include "frameworks/UBGeometryUtils.h" #include "frameworks/UBGeometryUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/UBMimeData.h" #include "core/UBMimeData.h"
@ -33,8 +34,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 "gui/UBMediaPlayer.h"
#include "gui/UBThumbnailWidget.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
@ -44,9 +45,8 @@
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "../gui/UBThumbnailWidget.h"
#include "frameworks/UBPlatformUtils.h" #include "customWidgets/UBDraggableLabel.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -727,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()) || dynamic_cast<UBTeacherBarPreviewMedia *>(event->source())) if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source()) || dynamic_cast<UBDraggableLabel *>(event->source()))
{ {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction (); event->acceptProposedAction ();

@ -0,0 +1,39 @@
#include <QMimeData>
#include <QDrag>
#include <QUrl>
#include "UBDraggableLabel.h"
UBDraggableLabel::UBDraggableLabel(QWidget *parent) :
QLabel(parent)
{
}
UBDraggableLabel::~UBDraggableLabel()
{
//NOOP
}
void UBDraggableLabel::loadImage(QString imagePath)
{
mSourcePath = imagePath;
QPixmap pix = QPixmap(mSourcePath);
setPixmap(pix);
setScaledContents(true);
}
void UBDraggableLabel::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl::fromLocalFile(mSourcePath);
mimeData->setUrls(urls);
mimeData->setText(mSourcePath);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}

@ -0,0 +1,23 @@
#ifndef UBDRAGGABLELABEL_H
#define UBDRAGGABLELABEL_H
#include <QLabel>
class UBDraggableLabel : public QLabel
{
Q_OBJECT
public:
UBDraggableLabel(QWidget *parent = 0);
~UBDraggableLabel();
void loadImage(QString imagePath);
signals:
public slots:
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBDRAGGABLELABEL_H

@ -1,5 +1,9 @@
HEADERS += src/customWidgets/UBWidgetList.h HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h
SOURCES += src/customWidgets/UBWidgetList.cpp SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp

@ -343,3 +343,31 @@ void UBMediaPlayer::hasVideoChanged(bool bHasVideo)
// info->setVisible(!bHasVideo); // info->setVisible(!bHasVideo);
m_videoWindow.setVisible(bHasVideo); m_videoWindow.setVisible(bHasVideo);
} }
//*************************************************************************
UBDraggableMediaPlayer::UBDraggableMediaPlayer():UBMediaPlayer()
{
// setAcceptDrops(true);
}
void UBDraggableMediaPlayer::setFile(const QString &text)
{
mSourcePath = text;
UBMediaPlayer::setFile(text);
}
void UBDraggableMediaPlayer::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl::fromLocalFile(mSourcePath);
mimeData->setUrls(urls);
mimeData->setText(mSourcePath);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}

@ -89,4 +89,16 @@ private:
Phonon::Path m_audioOutputPath; Phonon::Path m_audioOutputPath;
}; };
class UBDraggableMediaPlayer : public UBMediaPlayer
{
Q_OBJECT
public:
UBDraggableMediaPlayer();
void setFile(const QString &text);
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBUBMediaPlayer_H #endif // UBUBMediaPlayer_H

@ -15,6 +15,8 @@
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "customWidgets/UBDraggableLabel.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)
@ -593,7 +595,6 @@ void UBTeacherBarDropMediaZone::reloadMedia(QStringList pList)
foreach(QString eachString, pList){ foreach(QString eachString, pList){
addMedia(eachString); addMedia(eachString);
} }
} }
void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent) void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent)
@ -809,15 +810,11 @@ void UBTeacherBarPreviewWidget::setDuration(eDuration duration)
UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent)
{ {
setObjectName(name); setObjectName(name);
setAcceptDrops(true);
mWidget = new UBWidgetList(parent); mWidget = new UBWidgetList(parent);
mWidget->setEmptyText(tr("No media found")); mWidget->setEmptyText(tr("No media found"));
mLayout.addWidget(mWidget); mLayout.addWidget(mWidget);
setLayout(&mLayout); setLayout(&mLayout);
//TO TEST only mWidgetList.clear();
// QStringList mediaPathList;
// mediaPathList << "/home/claudio/Desktop/PIPPO.jpg";
// loadMedia(mediaPathList);
} }
UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
@ -830,28 +827,25 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
} }
// for test only
QString tempString;
void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
{ {
foreach(QWidget* eachWidget, mWidgetList.keys())
delete eachWidget;
mWidgetList.clear();
foreach(QString eachString, pMedias){ foreach(QString eachString, pMedias){
if(!eachString.isEmpty()){ if(!eachString.isEmpty()){
tempString = eachString;
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString); QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
if(mimeType.contains("image")){ if(mimeType.contains("image")){
QPixmap pix = QPixmap(eachString); UBDraggableLabel* label = new UBDraggableLabel();
QLabel* label = new QLabel(); label->loadImage(eachString);
label->setPixmap(pix);
label->setScaledContents(true);
mWidget->addWidget(label); mWidget->addWidget(label);
// mWidgetList << label; mWidgetList[label]=eachString;
} }
else if(mimeType.contains("video") || mimeType.contains("audio")){ else if(mimeType.contains("video") || mimeType.contains("audio")){
UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer();
mediaPlayer->setFile(eachString); mediaPlayer->setFile(eachString);
mWidget->addWidget(mediaPlayer); mWidget->addWidget(mediaPlayer);
// mWidgetList << mediaPlayer; mWidgetList[mediaPlayer] = eachString;
} }
else{ else{
qWarning() << "pMediaPath" << eachString; qWarning() << "pMediaPath" << eachString;
@ -860,19 +854,3 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
} }
} }
} }
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();
}

@ -87,12 +87,7 @@ public:
private: private:
UBWidgetList* mWidget; UBWidgetList* mWidget;
QVBoxLayout mLayout; QVBoxLayout mLayout;
QMap<QWidget*,QString>mWidgetList;
protected:
void mousePressEvent(QMouseEvent *event);
public slots:
}; };
class UBUrlWidget : public QWidget class UBUrlWidget : public QWidget

Loading…
Cancel
Save