Conflicts: Sankore_3.1.pro src/board/UBBoardPaletteManager.cpp src/board/UBBoardView.cpp src/document/UBDocumentProxy.cpp src/gui/UBDockPaletteWidget.cpp src/gui/UBTeacherBarWidget.h src/web/UBWebController.hpreferencesAboutTextFull
After Width: | Height: | Size: 795 B |
After Width: | Height: | Size: 909 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.0 KiB |
@ -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
|
@ -0,0 +1,42 @@ |
||||
#include <QApplication> |
||||
#include <QUrl> |
||||
|
||||
#include "UBDraggableMedia.h" |
||||
|
||||
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) |
||||
{ |
||||
|
||||
} |
||||
|
||||
UBDraggableMedia::~UBDraggableMedia() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) |
||||
{ |
||||
if(Qt::LeftButton == ev->button()){ |
||||
mDragStartPos = ev->pos(); |
||||
} |
||||
} |
||||
|
||||
void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) |
||||
{ |
||||
if(!(ev->buttons() & Qt::LeftButton)){ |
||||
return; |
||||
} |
||||
if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ |
||||
return; |
||||
} |
||||
QDrag *drag = new QDrag(this); |
||||
QMimeData *mimeData = new QMimeData; |
||||
|
||||
QList<QUrl> urls; |
||||
urls << QUrl(mFilePath); |
||||
mimeData->setText(mFilePath); |
||||
mimeData->setUrls(urls); |
||||
|
||||
drag->setMimeData(mimeData); |
||||
|
||||
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); |
||||
} |
@ -0,0 +1,19 @@ |
||||
#ifndef UBDRAGGABLEMEDIA_H |
||||
#define UBDRAGGABLEMEDIA_H |
||||
|
||||
#include "UBMediaWidget.h" |
||||
|
||||
class UBDraggableMedia : public UBMediaWidget |
||||
{ |
||||
public: |
||||
UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); |
||||
~UBDraggableMedia(); |
||||
protected: |
||||
void mousePressEvent(QMouseEvent* ev); |
||||
void mouseMoveEvent(QMouseEvent* ev); |
||||
|
||||
private: |
||||
QPoint mDragStartPos; |
||||
}; |
||||
|
||||
#endif // UBDRAGGABLEMEDIA_H
|
@ -0,0 +1,9 @@ |
||||
#ifndef UBGLOBALS_H |
||||
#define UBGLOBALS_H |
||||
|
||||
#define DELETEPTR(ptr) if(NULL != ptr){ \ |
||||
delete ptr; \
|
||||
ptr = NULL; \
|
||||
} |
||||
|
||||
#endif // UBGLOBALS_H
|
@ -0,0 +1,334 @@ |
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
#include "core/UBApplication.h" |
||||
#include "UBGlobals.h" |
||||
#include "UBMediaWidget.h" |
||||
|
||||
/**
|
||||
* \brief Constructor |
||||
* @param type as the media type |
||||
* @param parent as the parent widget |
||||
* @param name as the object name |
||||
*/ |
||||
UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpMediaObject(NULL) |
||||
, mpVideoWidget(NULL) |
||||
, mpAudioOutput(NULL) |
||||
, mpPlayStopButton(NULL) |
||||
, mpPauseButton(NULL) |
||||
, mpSlider(NULL) |
||||
, mAutoUpdate(false) |
||||
, mGeneratingThumbnail(false) |
||||
, mBorder(5) |
||||
, mpMediaContainer(NULL) |
||||
, mpCover(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
|
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
mType = type; |
||||
setLayout(&mLayout); |
||||
|
||||
mpPlayStopButton = new UBMediaButton(this); |
||||
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); |
||||
mpPauseButton = new UBMediaButton(this); |
||||
mpPauseButton->setPixmap(QPixmap(":images/pause.svg")); |
||||
mpPauseButton->setEnabled(false); |
||||
mpSlider = new QSlider(this); |
||||
mpSlider->setOrientation(Qt::Horizontal); |
||||
mpSlider->setMinimum(0); |
||||
mpSlider->setMaximum(0); |
||||
|
||||
mSeekerLayout.addWidget(mpPlayStopButton, 0); |
||||
mSeekerLayout.addWidget(mpPauseButton, 0); |
||||
mSeekerLayout.addWidget(mpSlider, 1); |
||||
mSeekerLayout.setContentsMargins(0, 0, 0, 0); |
||||
|
||||
connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); |
||||
connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); |
||||
connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Destructor |
||||
*/ |
||||
UBMediaWidget::~UBMediaWidget() |
||||
{ |
||||
DELETEPTR(mpSlider); |
||||
DELETEPTR(mpPauseButton); |
||||
DELETEPTR(mpPlayStopButton); |
||||
DELETEPTR(mpAudioOutput); |
||||
DELETEPTR(mpVideoWidget); |
||||
DELETEPTR(mpMediaObject); |
||||
DELETEPTR(mpCover); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Set the media file |
||||
* @param filePath as the media file path |
||||
*/ |
||||
void UBMediaWidget::setFile(const QString &filePath) |
||||
{ |
||||
Q_ASSERT("" != filePath); |
||||
mFilePath = filePath; |
||||
mpMediaObject = new Phonon::MediaObject(this); |
||||
mpMediaObject->setTickInterval(TICK_INTERVAL); |
||||
connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); |
||||
connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); |
||||
connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); |
||||
mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); |
||||
createMediaPlayer(); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Get the media type |
||||
* @returns the media type |
||||
*/ |
||||
eMediaType UBMediaWidget::mediaType() |
||||
{ |
||||
return mType; |
||||
} |
||||
|
||||
void UBMediaWidget::showEvent(QShowEvent* event) |
||||
{ |
||||
if(!mpVideoWidget){ |
||||
mpVideoWidget = new Phonon::VideoWidget(this); |
||||
mMediaLayout.addStretch(1); |
||||
mMediaLayout.addWidget(mpVideoWidget, 0); |
||||
mMediaLayout.addStretch(1); |
||||
Phonon::createPath(mpMediaObject, mpVideoWidget); |
||||
adaptSizeToVideo(); |
||||
mpMediaObject->play(); |
||||
mpMediaObject->stop(); |
||||
} |
||||
QWidget::showEvent(event); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Create the media player |
||||
*/ |
||||
void UBMediaWidget::createMediaPlayer() |
||||
{ |
||||
mpMediaContainer = new QWidget(this); |
||||
mpMediaContainer->setObjectName("UBMediaVideoContainer"); |
||||
mpMediaContainer->setLayout(&mMediaLayout); |
||||
|
||||
if(eMediaType_Video == mType){ |
||||
mMediaLayout.setContentsMargins(10, 10, 25, 10); |
||||
if(isVisible()){ |
||||
mpVideoWidget = new Phonon::VideoWidget(this); |
||||
mMediaLayout.addStretch(1); |
||||
mMediaLayout.addWidget(mpVideoWidget, 0); |
||||
mMediaLayout.addStretch(1); |
||||
Phonon::createPath(mpMediaObject, mpVideoWidget); |
||||
adaptSizeToVideo(); |
||||
} |
||||
mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); |
||||
Phonon::createPath(mpMediaObject, mpAudioOutput); |
||||
}else if(eMediaType_Audio == mType){ |
||||
mMediaLayout.setContentsMargins(10, 10, 10, 10); |
||||
mpCover = new QLabel(mpMediaContainer); |
||||
mpMediaContainer->setStyleSheet(QString("background: none;")); |
||||
setAudioCover(":images/libpalette/soundIcon.svg"); |
||||
mpCover->setScaledContents(true); |
||||
mMediaLayout.addStretch(1); |
||||
mMediaLayout.addWidget(mpCover, 0); |
||||
mMediaLayout.addStretch(1); |
||||
mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); |
||||
Phonon::createPath(mpMediaObject, mpAudioOutput); |
||||
} |
||||
mLayout.addWidget(mpMediaContainer, 1); |
||||
mLayout.addLayout(&mSeekerLayout, 0); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Adapt the widget size to the video in order to keep the good aspect ratio |
||||
*/ |
||||
void UBMediaWidget::adaptSizeToVideo() |
||||
{ |
||||
if(NULL != mpMediaContainer){ |
||||
int origW = mpMediaContainer->width(); |
||||
int origH = mpMediaContainer->height(); |
||||
int newW = width(); |
||||
float scaleFactor = (float)origW/(float)newW; |
||||
int newH = origH/scaleFactor; |
||||
resize(newW, height() + newH); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handle the media state change notification |
||||
* @param newState as the new state |
||||
* @param oldState as the old state |
||||
*/ |
||||
void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) |
||||
{ |
||||
if(!mGeneratingThumbnail){ |
||||
if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){ |
||||
if(eMediaType_Video == mType){ |
||||
// We do that here to generate the thumbnail of the video
|
||||
mGeneratingThumbnail = true; |
||||
mpMediaObject->play(); |
||||
mpMediaObject->pause(); |
||||
mGeneratingThumbnail = false; |
||||
} |
||||
}else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){ |
||||
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); |
||||
mpPauseButton->setEnabled(false); |
||||
}else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) || |
||||
(Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){ |
||||
mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg")); |
||||
mpPauseButton->setEnabled(true); |
||||
}else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){ |
||||
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); |
||||
mpPauseButton->setEnabled(false); |
||||
mpSlider->setValue(0); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the total time change notification |
||||
* @param total as the new total time |
||||
*/ |
||||
void UBMediaWidget::onTotalTimeChanged(qint64 total) |
||||
{ |
||||
mpSlider->setMaximum(total); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the tick notification |
||||
* @param currentTime as the current time |
||||
*/ |
||||
void UBMediaWidget::onTick(qint64 currentTime) |
||||
{ |
||||
mAutoUpdate = true; |
||||
mpSlider->setValue((int)currentTime); |
||||
mAutoUpdate = false; |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the seeker value change notification |
||||
* @param value as the new seeker value |
||||
*/ |
||||
void UBMediaWidget::onSliderChanged(int value) |
||||
{ |
||||
if(!mAutoUpdate){ |
||||
mpMediaObject->seek(value); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* \brief Toggle Play-Stop |
||||
*/ |
||||
void UBMediaWidget::onPlayStopClicked() |
||||
{ |
||||
switch(mpMediaObject->state()){ |
||||
case Phonon::PlayingState: |
||||
mpMediaObject->stop(); |
||||
break; |
||||
|
||||
case Phonon::StoppedState: |
||||
case Phonon::PausedState: |
||||
mpMediaObject->play(); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* \brief Pause the media |
||||
*/ |
||||
void UBMediaWidget::onPauseClicked() |
||||
{ |
||||
mpMediaObject->pause(); |
||||
} |
||||
|
||||
/**
|
||||
* Get the border |
||||
* @returns the actual border |
||||
*/ |
||||
int UBMediaWidget::border() |
||||
{ |
||||
return mBorder; |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the resize event |
||||
* @param ev as the resize event |
||||
*/ |
||||
void UBMediaWidget::resizeEvent(QResizeEvent* ev) |
||||
{ |
||||
Q_UNUSED(ev); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Set the audio cover |
||||
* @param coverPath as the cover image file path |
||||
*/ |
||||
void UBMediaWidget::setAudioCover(const QString &coverPath) |
||||
{ |
||||
if(NULL != mpCover){ |
||||
mpCover->setPixmap(QPixmap(coverPath)); |
||||
} |
||||
} |
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief Constructor |
||||
* @param parent as the parent widget |
||||
* @param name as the object name |
||||
*/ |
||||
UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) |
||||
, mPressed(false) |
||||
{ |
||||
setObjectName(name); |
||||
resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); |
||||
setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); |
||||
} |
||||
|
||||
/**
|
||||
* \brief Destructor |
||||
*/ |
||||
UBMediaButton::~UBMediaButton() |
||||
{ |
||||
|
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the mouse press notification |
||||
* @param ev as the mouse press event |
||||
*/ |
||||
void UBMediaButton::mousePressEvent(QMouseEvent* ev) |
||||
{ |
||||
Q_UNUSED(ev); |
||||
mPressed = true; |
||||
} |
||||
|
||||
/**
|
||||
* \brief Handles the mouse release notification |
||||
* @param ev as the mouse release event |
||||
*/ |
||||
void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) |
||||
{ |
||||
Q_UNUSED(ev); |
||||
if(mPressed){ |
||||
mPressed = false; |
||||
emit clicked(); |
||||
} |
||||
} |
@ -0,0 +1,122 @@ |
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
#ifndef UBMEDIAWIDGET_H |
||||
#define UBMEDIAWIDGET_H |
||||
|
||||
#include <QWidget> |
||||
#include <QVBoxLayout> |
||||
#include <QHBoxLayout> |
||||
#include <QLabel> |
||||
#include <QSlider> |
||||
#include <QMouseEvent> |
||||
|
||||
#include <phonon/MediaObject> |
||||
#include <phonon/VideoWidget> |
||||
#include <phonon/AudioOutput> |
||||
|
||||
#include "interfaces/IResizeable.h" |
||||
|
||||
#define UBMEDIABUTTON_SIZE 32 |
||||
#define TICK_INTERVAL 1000 |
||||
|
||||
/**
|
||||
* \brief The media type |
||||
*/ |
||||
typedef enum{ |
||||
eMediaType_Video, |
||||
eMediaType_Audio |
||||
}eMediaType; |
||||
|
||||
class UBMediaButton : public QLabel |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton"); |
||||
~UBMediaButton(); |
||||
|
||||
signals: |
||||
void clicked(); |
||||
|
||||
protected: |
||||
void mousePressEvent(QMouseEvent* ev); |
||||
void mouseReleaseEvent(QMouseEvent* ev); |
||||
|
||||
private: |
||||
/** And indicator of the press event in progress */ |
||||
bool mPressed; |
||||
}; |
||||
|
||||
class UBMediaWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget"); |
||||
~UBMediaWidget(); |
||||
void setFile(const QString& filePath); |
||||
eMediaType mediaType(); |
||||
int border(); |
||||
void setAudioCover(const QString& coverPath); |
||||
|
||||
protected: |
||||
void resizeEvent(QResizeEvent* ev); |
||||
void showEvent(QShowEvent* event); |
||||
/** The current media file path */ |
||||
QString mFilePath; |
||||
|
||||
private slots: |
||||
void onPlayStopClicked(); |
||||
void onPauseClicked(); |
||||
void onStateChanged(Phonon::State newState, Phonon::State oldState); |
||||
void onTotalTimeChanged(qint64 total); |
||||
void onTick(qint64 currentTime); |
||||
void onSliderChanged(int value); |
||||
|
||||
private: |
||||
void createMediaPlayer(); |
||||
void adaptSizeToVideo(); |
||||
|
||||
/** The current media type */ |
||||
eMediaType mType; |
||||
/** The media object */ |
||||
Phonon::MediaObject* mpMediaObject; |
||||
/** The video renderer */ |
||||
Phonon::VideoWidget* mpVideoWidget; |
||||
/** The audio renderer */ |
||||
Phonon::AudioOutput* mpAudioOutput; |
||||
/** The principal layout of this widget */ |
||||
QVBoxLayout mLayout; |
||||
/** The seeker layout */ |
||||
QHBoxLayout mSeekerLayout; |
||||
/** The play-stop button */ |
||||
UBMediaButton* mpPlayStopButton; |
||||
/** The pause button */ |
||||
UBMediaButton* mpPauseButton; |
||||
/** The seeker slider */ |
||||
QSlider* mpSlider; |
||||
/** An indicator of the seeker auto update in progress */ |
||||
bool mAutoUpdate; |
||||
/** An indicator of the thumbnail generation in progress */ |
||||
bool mGeneratingThumbnail; |
||||
/** The border */ |
||||
int mBorder; |
||||
/** A widget that will contain the media */ |
||||
QWidget* mpMediaContainer; |
||||
/** The media layout */ |
||||
QHBoxLayout mMediaLayout; |
||||
/** The audio cover */ |
||||
QLabel* mpCover; |
||||
}; |
||||
|
||||
#endif // UBMEDIAWIDGET_H
|
@ -0,0 +1,185 @@ |
||||
#include <QDebug> |
||||
#include <QScrollBar> |
||||
|
||||
#include "UBGlobals.h" |
||||
#include "UBWidgetList.h" |
||||
|
||||
UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) |
||||
, mpLayout(NULL) |
||||
, mpContainer(NULL) |
||||
, mMargin(5) |
||||
, mListElementsSpacing(10) |
||||
, mpEmptyLabel(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
mOrientation = orientation; |
||||
mpContainer = new QWidget(this); |
||||
mpEmptyLabel = new QLabel(this); |
||||
mpEmptyLabel->setObjectName("emptyString"); |
||||
mpEmptyLabel->setWordWrap(true); |
||||
mpEmptyLabel->setAlignment(Qt::AlignCenter); |
||||
|
||||
if(eWidgetListOrientation_Vertical == orientation){ |
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
mpLayout = new QVBoxLayout(mpContainer); |
||||
} |
||||
else{ |
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
mpLayout = new QHBoxLayout(mpContainer); |
||||
} |
||||
mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); |
||||
mpContainer->setLayout(mpLayout); |
||||
setWidget(mpContainer); |
||||
} |
||||
|
||||
UBWidgetList::~UBWidgetList() |
||||
{ |
||||
DELETEPTR(mpEmptyLabel); |
||||
DELETEPTR(mpLayout); |
||||
DELETEPTR(mpContainer); |
||||
} |
||||
|
||||
void UBWidgetList::addWidget(QWidget *widget) |
||||
{ |
||||
if(NULL != mpLayout && NULL != widget){ |
||||
widget->setParent(mpContainer); |
||||
mpEmptyLabel->setVisible(false); |
||||
mWidgetInfo[widget] = widget->size(); |
||||
updateView(size()); |
||||
mpLayout->addWidget(widget); |
||||
|
||||
// This call is used only to refresh the size of the widgets
|
||||
updateSizes(); |
||||
} |
||||
} |
||||
|
||||
void UBWidgetList::removeWidget(QWidget *widget) |
||||
{ |
||||
if(NULL != mpLayout && NULL != widget){ |
||||
mpLayout->removeWidget(widget); |
||||
mWidgetInfo.remove(widget); |
||||
widget->setVisible(false); |
||||
updateView(size()); |
||||
if(0 == mpLayout->count()){ |
||||
mpEmptyLabel->setVisible(true); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
int UBWidgetList::scaleWidgets(QSize pSize) |
||||
{ |
||||
// to remove the first spacing that shouldn't be there.
|
||||
int result = -mListElementsSpacing; |
||||
foreach(QWidget* eachWidget, mWidgetInfo.keys()){ |
||||
qreal scaleFactor = 0; |
||||
int newWidgetWidth = pSize.width(); |
||||
int newWidgetHeight = pSize.height(); |
||||
if(eWidgetListOrientation_Vertical == mOrientation){ |
||||
scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); |
||||
newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; |
||||
result += newWidgetHeight; |
||||
eachWidget->setMinimumHeight(newWidgetHeight- 1); |
||||
eachWidget->setMaximumHeight(newWidgetHeight); |
||||
} |
||||
else{ |
||||
scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); |
||||
newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; |
||||
result += newWidgetWidth; |
||||
eachWidget->setMinimumWidth(newWidgetWidth - 1); |
||||
eachWidget->setMaximumWidth(newWidgetWidth); |
||||
} |
||||
//Adding a vertical/horizontal space between each element of the list
|
||||
result += mListElementsSpacing; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
void UBWidgetList::scaleContainer(QSize pSize, int updateValue) |
||||
{ |
||||
if(eWidgetListOrientation_Vertical == mOrientation) |
||||
mpContainer->resize(pSize.width(), updateValue); |
||||
else |
||||
mpContainer->resize(updateValue, pSize.height()); |
||||
} |
||||
|
||||
|
||||
void UBWidgetList::updateView(QSize pSize) |
||||
{ |
||||
// Widgets on list are resized automatically to fit the mpcontainer.
|
||||
// so if you want to keep the aspect ratio you have to calculate
|
||||
// the sum of the new widget height and give it to the mpContainer.
|
||||
// The container resize will trig the widgets resize and the good
|
||||
// height permits to respect the aspect ratio.
|
||||
int updatedValue = scaleWidgets(pSize); |
||||
scaleContainer(pSize,updatedValue); |
||||
} |
||||
|
||||
|
||||
|
||||
void UBWidgetList::resizeEvent(QResizeEvent *ev) |
||||
{ |
||||
Q_UNUSED(ev); |
||||
mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, |
||||
(height() - mpEmptyLabel->height()) /2, |
||||
mpEmptyLabel->width(), |
||||
mpEmptyLabel->height()); |
||||
updateView(size()); |
||||
updateSizes(); |
||||
} |
||||
|
||||
void UBWidgetList::updateSizes() |
||||
{ |
||||
// Resize all the widgets
|
||||
foreach(QWidget* eachWidget, mWidgetInfo.keys()){ |
||||
if(NULL != eachWidget){ |
||||
QSize originalSize = mWidgetInfo[eachWidget]; |
||||
int currentWidth = mpContainer->width(); |
||||
int currentHeight = mpContainer->height(); |
||||
if(eWidgetListOrientation_Vertical == mOrientation){ |
||||
if(verticalScrollBar()->isVisible()){ |
||||
currentWidth -= verticalScrollBar()->width(); |
||||
eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width())); |
||||
} |
||||
float scaleFactor = (float)currentWidth/(float)originalSize.width(); |
||||
currentHeight = originalSize.height()*scaleFactor; |
||||
}else{ |
||||
if(horizontalScrollBar()->isVisible()){ |
||||
currentHeight -= horizontalScrollBar()->height(); |
||||
eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height())); |
||||
} |
||||
float scaleFactor = (float)currentHeight/(float)originalSize.height(); |
||||
currentWidth = originalSize.width()*scaleFactor; |
||||
} |
||||
|
||||
eachWidget->resize(currentWidth, currentHeight); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBWidgetList::setMargin(int margin) |
||||
{ |
||||
mMargin = margin; |
||||
} |
||||
|
||||
int UBWidgetList::margin() |
||||
{ |
||||
return mMargin; |
||||
} |
||||
|
||||
void UBWidgetList::setEmptyText(const QString &text) |
||||
{ |
||||
if(NULL != mpEmptyLabel){ |
||||
mpEmptyLabel->setText(text); |
||||
} |
||||
} |
||||
|
||||
bool UBWidgetList::empty() |
||||
{ |
||||
return mWidgetInfo.empty(); |
||||
} |
||||
|
||||
// TODO : - add onHover 'delete' button
|
||||
|
@ -0,0 +1,60 @@ |
||||
#ifndef UBWIDGETLIST_H |
||||
#define UBWIDGETLIST_H |
||||
|
||||
#include <QWidget> |
||||
#include <QScrollArea> |
||||
#include <QBoxLayout> |
||||
#include <QVBoxLayout> |
||||
#include <QHBoxLayout> |
||||
#include <QResizeEvent> |
||||
#include <QVector> |
||||
#include <QLabel> |
||||
|
||||
#include "interfaces/IResizeable.h" |
||||
|
||||
typedef enum{ |
||||
eWidgetListOrientation_Vertical, |
||||
eWidgetListOrientation_Horizontal |
||||
}eWidgetListOrientation; |
||||
|
||||
|
||||
class UBWidgetList : public QScrollArea |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
typedef struct |
||||
{ |
||||
QSize size; |
||||
bool isResizable; |
||||
} sWidgetProperties; |
||||
|
||||
public: |
||||
UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); |
||||
~UBWidgetList(); |
||||
void addWidget(QWidget* widget); |
||||
void removeWidget(QWidget* widget); |
||||
void setMargin(int margin); |
||||
void setEmptyText(const QString& text); |
||||
int margin(); |
||||
bool empty(); |
||||
void setListElementSpacing(int margin) { mListElementsSpacing = margin; } |
||||
int listElementsSpacing() {return mListElementsSpacing; } |
||||
|
||||
protected: |
||||
void resizeEvent(QResizeEvent* ev); |
||||
|
||||
private: |
||||
int scaleWidgets(QSize pSize); |
||||
void scaleContainer(QSize pSize, int updateValue); |
||||
void updateView(QSize pSize); |
||||
void updateSizes(); |
||||
QBoxLayout* mpLayout; |
||||
QWidget* mpContainer; |
||||
eWidgetListOrientation mOrientation; |
||||
int mMargin; |
||||
int mListElementsSpacing; |
||||
QMap<QWidget*, QSize> mWidgetInfo; |
||||
QLabel* mpEmptyLabel; |
||||
}; |
||||
|
||||
#endif // UBWIDGETLIST_H
|
@ -0,0 +1,11 @@ |
||||
|
||||
HEADERS += src/customWidgets/UBWidgetList.h \ |
||||
src/customWidgets/UBDraggableLabel.h \ |
||||
src/customWidgets/UBMediaWidget.h \ |
||||
src/customWidgets/UBGlobals.h \ |
||||
src/customWidgets/UBDraggableMedia.h |
||||
|
||||
SOURCES += src/customWidgets/UBWidgetList.cpp \ |
||||
src/customWidgets/UBDraggableLabel.cpp \ |
||||
src/customWidgets/UBMediaWidget.cpp \ |
||||
src/customWidgets/UBDraggableMedia.cpp |
@ -0,0 +1,389 @@ |
||||
#include "UBMediaPlayer.h" |
||||
|
||||
|
||||
|
||||
#include <QtGui> |
||||
|
||||
#define SLIDER_RANGE 8 |
||||
|
||||
|
||||
MediaVideoWidget::MediaVideoWidget(UBMediaPlayer *player, QWidget *parent) : |
||||
Phonon::VideoWidget(parent), m_player(player)/*, m_action(this)*/ |
||||
{ |
||||
// m_action.setCheckable(true);
|
||||
// m_action.setChecked(false);
|
||||
// m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return));
|
||||
// m_action.setShortcutContext(Qt::WindowShortcut);
|
||||
// connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool)));
|
||||
// addAction(&m_action);
|
||||
// setAcceptDrops(true);
|
||||
} |
||||
|
||||
void MediaVideoWidget::timerEvent(QTimerEvent *e) |
||||
{ |
||||
if (e->timerId() == m_timer.timerId()) { |
||||
//let's store the cursor shape
|
||||
#ifndef QT_NO_CURSOR |
||||
setCursor(Qt::BlankCursor); |
||||
#endif |
||||
} |
||||
Phonon::VideoWidget::timerEvent(e); |
||||
} |
||||
|
||||
|
||||
UBMediaPlayer::UBMediaPlayer() : |
||||
playButton(0), |
||||
m_AudioOutput(Phonon::VideoCategory), |
||||
m_videoWidget(new MediaVideoWidget(this)) |
||||
{ |
||||
setContextMenuPolicy(Qt::CustomContextMenu); |
||||
m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); |
||||
|
||||
QSize buttonSize(26, 20); |
||||
|
||||
// QPushButton *openButton = new QPushButton(this);
|
||||
|
||||
//// openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
|
||||
//// QPalette bpal;
|
||||
//// QColor arrowcolor = bpal.buttonText().color();
|
||||
//// if (arrowcolor == Qt::black)
|
||||
//// arrowcolor = QColor(80, 80, 80);
|
||||
//// bpal.setBrush(QPalette::ButtonText, arrowcolor);
|
||||
//// openButton->setPalette(bpal);
|
||||
|
||||
// rewindButton = new QPushButton(this);
|
||||
// rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
|
||||
|
||||
// forwardButton = new QPushButton(this);
|
||||
// forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
|
||||
// forwardButton->setEnabled(false);
|
||||
|
||||
playButton = new QPushButton(this); |
||||
playIcon = style()->standardIcon(QStyle::SP_MediaPlay); |
||||
pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); |
||||
playButton->setIcon(playIcon); |
||||
|
||||
slider = new Phonon::SeekSlider(this); |
||||
slider->setMediaObject(&m_MediaObject); |
||||
|
||||
QVBoxLayout *vLayout = new QVBoxLayout(this); |
||||
vLayout->setContentsMargins(1, 1, 1, 1); |
||||
|
||||
// QHBoxLayout *layout = new QHBoxLayout();
|
||||
|
||||
// info = new QLabel(this);
|
||||
// info->setMinimumHeight(70);
|
||||
// info->setAcceptDrops(false);
|
||||
// info->setMargin(2);
|
||||
// info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||
// info->setLineWidth(2);
|
||||
// info->setAutoFillBackground(true);
|
||||
|
||||
// QPalette palette;
|
||||
// palette.setBrush(QPalette::WindowText, Qt::white);
|
||||
#ifndef Q_WS_MAC |
||||
// rewindButton->setMinimumSize(buttonSize);
|
||||
// forwardButton->setMinimumSize(buttonSize);
|
||||
playButton->setMinimumSize(buttonSize); |
||||
#endif |
||||
// info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px");
|
||||
// info->setPalette(palette);
|
||||
// info->setText(tr("<center>No media</center>"));
|
||||
|
||||
|
||||
// layout->addWidget(rewindButton);
|
||||
// layout->addWidget(playButton);
|
||||
// layout->addWidget(forwardButton);
|
||||
|
||||
// layout->addStretch();
|
||||
|
||||
// vLayout->addWidget(info);
|
||||
initVideoWindow(); |
||||
vLayout->addWidget(&m_videoWindow); |
||||
// m_videoWidget->setStyleSheet(QString("background:red;"));
|
||||
QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); |
||||
#ifndef Q_WS_WIN |
||||
m_videoWindow.hide(); |
||||
#endif |
||||
// buttonPanelLayout->addLayout(layout);
|
||||
|
||||
// timeLabel = new QLabel(this);
|
||||
progressLabel = new QLabel(this); |
||||
QWidget *sliderPanel = new QWidget(this); |
||||
// sliderPanel->setStyleSheet(QString("background:green;"));
|
||||
QHBoxLayout *sliderLayout = new QHBoxLayout(); |
||||
// playButton->setStyleSheet(QString("background:yellow;"));
|
||||
sliderLayout->addWidget(playButton); |
||||
sliderLayout->addWidget(slider); |
||||
// sliderLayout->addWidget(timeLabel);
|
||||
sliderLayout->addWidget(progressLabel); |
||||
sliderLayout->setContentsMargins(0, 0, 0, 0); |
||||
sliderPanel->setLayout(sliderLayout); |
||||
|
||||
buttonPanelLayout->addWidget(sliderPanel); |
||||
buttonPanelLayout->setContentsMargins(0, 0, 0, 0); |
||||
#ifdef Q_OS_MAC |
||||
// layout->setSpacing(4);
|
||||
buttonPanelLayout->setSpacing(0); |
||||
// info->setMinimumHeight(100);
|
||||
// info->setFont(QFont("verdana", 15));
|
||||
// openButton->setFocusPolicy(Qt::NoFocus);
|
||||
#endif |
||||
QWidget *buttonPanelWidget = new QWidget(this); |
||||
buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); |
||||
buttonPanelWidget->setLayout(buttonPanelLayout); |
||||
vLayout->addWidget(buttonPanelWidget); |
||||
|
||||
QHBoxLayout *labelLayout = new QHBoxLayout(); |
||||
vLayout->addLayout(labelLayout); |
||||
setLayout(vLayout); |
||||
|
||||
|
||||
// Setup signal connections:
|
||||
// connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind()));
|
||||
|
||||
connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); |
||||
// connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward()));
|
||||
|
||||
// connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime()));
|
||||
// connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime()));
|
||||
connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); |
||||
connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); |
||||
connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); |
||||
connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); |
||||
|
||||
// rewindButton->setEnabled(false);
|
||||
playButton->setEnabled(false); |
||||
// setAcceptDrops(true);
|
||||
|
||||
m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); |
||||
Phonon::createPath(&m_MediaObject, m_videoWidget); |
||||
|
||||
resize(minimumSizeHint()); |
||||
} |
||||
|
||||
void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) |
||||
{ |
||||
if (oldstate == Phonon::LoadingState) { |
||||
QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); |
||||
QApplication::desktop()->screenGeometry().intersected(videoHintRect); |
||||
|
||||
if (m_MediaObject.hasVideo()) { |
||||
qApp->processEvents(); |
||||
resize(sizeHint()); |
||||
} else |
||||
resize(minimumSize()); |
||||
|
||||
} |
||||
|
||||
switch (newstate) { |
||||
case Phonon::ErrorState: |
||||
if (m_MediaObject.errorType() == Phonon::FatalError) { |
||||
playButton->setEnabled(false); |
||||
// rewindButton->setEnabled(false);
|
||||
} else { |
||||
m_MediaObject.pause(); |
||||
} |
||||
QMessageBox::warning(this, "Phonon UBMediaPlayer", m_MediaObject.errorString(), QMessageBox::Close); |
||||
break; |
||||
|
||||
case Phonon::StoppedState: |
||||
// m_videoWidget-> (false);
|
||||
// Fall through
|
||||
case Phonon::PausedState: |
||||
playButton->setIcon(playIcon); |
||||
if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ |
||||
playButton->setEnabled(true); |
||||
// rewindButton->setEnabled(true);
|
||||
} else { |
||||
playButton->setEnabled(false); |
||||
// rewindButton->setEnabled(false);
|
||||
} |
||||
break; |
||||
case Phonon::PlayingState: |
||||
playButton->setEnabled(true); |
||||
playButton->setIcon(pauseIcon); |
||||
if (m_MediaObject.hasVideo()) |
||||
m_videoWindow.show(); |
||||
// Fall through
|
||||
case Phonon::BufferingState: |
||||
// rewindButton->setEnabled(true);
|
||||
break; |
||||
case Phonon::LoadingState: |
||||
// rewindButton->setEnabled(false);
|
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
void UBMediaPlayer::setVolume(qreal volume) |
||||
{ |
||||
m_AudioOutput.setVolume(volume); |
||||
} |
||||
|
||||
|
||||
void UBMediaPlayer::initVideoWindow() |
||||
{ |
||||
QVBoxLayout *videoLayout = new QVBoxLayout(); |
||||
videoLayout->addWidget(m_videoWidget); |
||||
videoLayout->setContentsMargins(0, 0, 0, 0); |
||||
m_videoWindow.setLayout(videoLayout); |
||||
m_videoWindow.setMinimumSize(60, 40); |
||||
} |
||||
|
||||
void UBMediaPlayer::playPause() |
||||
{ |
||||
if (m_MediaObject.state() == Phonon::PlayingState) |
||||
m_MediaObject.pause(); |
||||
else { |
||||
if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) |
||||
m_MediaObject.seek(0); |
||||
m_MediaObject.play(); |
||||
} |
||||
} |
||||
|
||||
void UBMediaPlayer::setFile(const QString &fileName) |
||||
{ |
||||
setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); |
||||
m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); |
||||
} |
||||
|
||||
void UBMediaPlayer::setLocation(const QString& location) |
||||
{ |
||||
setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); |
||||
m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); |
||||
m_MediaObject.play(); |
||||
} |
||||
|
||||
|
||||
void UBMediaPlayer::openFile() |
||||
{ |
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); |
||||
|
||||
|
||||
m_MediaObject.clearQueue(); |
||||
if (fileNames.size() > 0) { |
||||
QString fileName = fileNames[0]; |
||||
setFile(fileName); |
||||
for (int i=1; i<fileNames.size(); i++) |
||||
m_MediaObject.enqueue(Phonon::MediaSource(fileNames[i])); |
||||
} |
||||
// forwardButton->setEnabled(m_MediaObject.queue().size() > 0);
|
||||
} |
||||
|
||||
void UBMediaPlayer::bufferStatus(int percent) |
||||
{ |
||||
if (percent == 100) |
||||
progressLabel->setText(QString()); |
||||
else { |
||||
QString str = QString::fromLatin1("(%1%)").arg(percent); |
||||
progressLabel->setText(str); |
||||
} |
||||
} |
||||
|
||||
//void UBMediaPlayer::updateTime()
|
||||
//{
|
||||
// long len = m_MediaObject.totalTime();
|
||||
// long pos = m_MediaObject.currentTime();
|
||||
// QString timeString;
|
||||
// if (pos || len)
|
||||
// {
|
||||
// int sec = pos/1000;
|
||||
// int min = sec/60;
|
||||
// int hour = min/60;
|
||||
// int msec = pos;
|
||||
|
||||
// QTime playTime(hour%60, min%60, sec%60, msec%1000);
|
||||
// sec = len / 1000;
|
||||
// min = sec / 60;
|
||||
// hour = min / 60;
|
||||
// msec = len;
|
||||
|
||||
// QTime stopTime(hour%60, min%60, sec%60, msec%1000);
|
||||
// QString timeFormat = "m:ss";
|
||||
// if (hour > 0)
|
||||
// timeFormat = "h:mm:ss";
|
||||
// timeString = playTime.toString(timeFormat);
|
||||
// if (len)
|
||||
// timeString += " / " + stopTime.toString(timeFormat);
|
||||
// }
|
||||
// timeLabel->setText(timeString);
|
||||
//}
|
||||
|
||||
void UBMediaPlayer::rewind() |
||||
{ |
||||
m_MediaObject.seek(0); |
||||
} |
||||
|
||||
void UBMediaPlayer::forward() |
||||
{ |
||||
QList<Phonon::MediaSource> queue = m_MediaObject.queue(); |
||||
if (queue.size() > 0) { |
||||
m_MediaObject.setCurrentSource(queue[0]); |
||||
// forwardButton->setEnabled(queue.size() > 1);
|
||||
m_MediaObject.play(); |
||||
} |
||||
} |
||||
|
||||
void UBMediaPlayer::openUrl() |
||||
{ |
||||
QSettings settings; |
||||
settings.beginGroup(QLatin1String("BrowserMainWindow")); |
||||
QString sourceURL = settings.value("location").toString(); |
||||
bool ok = false; |
||||
sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); |
||||
if (ok && !sourceURL.isEmpty()) { |
||||
setLocation(sourceURL); |
||||
settings.setValue("location", sourceURL); |
||||
} |
||||
} |
||||
|
||||
void UBMediaPlayer::finished() |
||||
{ |
||||
} |
||||
|
||||
void UBMediaPlayer::hasVideoChanged(bool bHasVideo) |
||||
{ |
||||
// info->setVisible(!bHasVideo);
|
||||
m_videoWindow.setVisible(bHasVideo); |
||||
} |
||||
|
||||
void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent) |
||||
{ |
||||
// int origWidth = m_videoWindow.width();
|
||||
// int origHeight = m_videoWindow.height();
|
||||
|
||||
// float scaleFactor = (float)origWidth / (float)width();
|
||||
// int newWidth = width();
|
||||
// int newHeigth = origHeight/scaleFactor;
|
||||
|
||||
// m_videoWindow.resize(newWidth, newHeigth);
|
||||
} |
||||
|
||||
//*************************************************************************
|
||||
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(); |
||||
} |
||||
|
@ -0,0 +1,107 @@ |
||||
#ifndef UBUBMediaPlayer_H |
||||
#define UBUBMediaPlayer_H |
||||
|
||||
#include <QtGui/QWidget> |
||||
#include <QtGui/QApplication> |
||||
#include <QtCore/QTimerEvent> |
||||
#include <QtGui/QShowEvent> |
||||
#include <QtGui/QIcon> |
||||
#include <QtCore/QBasicTimer> |
||||
#include <QtGui/QAction> |
||||
|
||||
#include <phonon/audiooutput.h> |
||||
#include <phonon/backendcapabilities.h> |
||||
#include <phonon/effect.h> |
||||
#include <phonon/effectparameter.h> |
||||
#include <phonon/effectwidget.h> |
||||
#include <phonon/mediaobject.h> |
||||
#include <phonon/seekslider.h> |
||||
#include <phonon/videowidget.h> |
||||
#include <phonon/volumeslider.h> |
||||
|
||||
QT_BEGIN_NAMESPACE |
||||
class QPushButton; |
||||
class QLabel; |
||||
class QSlider; |
||||
class QTextEdit; |
||||
QT_END_NAMESPACE |
||||
|
||||
class UBMediaPlayer; |
||||
|
||||
class MediaVideoWidget : public Phonon::VideoWidget |
||||
{ |
||||
Q_OBJECT; |
||||
|
||||
public: |
||||
MediaVideoWidget(UBMediaPlayer *player, QWidget *parent = 0); |
||||
|
||||
protected: |
||||
void timerEvent(QTimerEvent *e); |
||||
|
||||
private: |
||||
UBMediaPlayer* m_player; |
||||
QBasicTimer m_timer; |
||||
// QAction m_action;
|
||||
}; |
||||
|
||||
class UBMediaPlayer : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBMediaPlayer(); |
||||
|
||||
void setFile(const QString &text); |
||||
void setLocation(const QString &location); |
||||
void setVolume(qreal volume); |
||||
|
||||
public slots: |
||||
void openFile(); |
||||
void rewind(); |
||||
void forward(); |
||||
// void updateTime();
|
||||
void finished(); |
||||
void playPause(); |
||||
|
||||
protected: |
||||
void resizeEvent(QResizeEvent* pEvent); |
||||
|
||||
private slots: |
||||
void stateChanged(Phonon::State newstate, Phonon::State oldstate); |
||||
void bufferStatus(int percent); |
||||
void openUrl(); |
||||
|
||||
void hasVideoChanged(bool); |
||||
|
||||
private: |
||||
void initVideoWindow(); |
||||
|
||||
QIcon playIcon; |
||||
QIcon pauseIcon; |
||||
QPushButton *playButton; |
||||
// QPushButton *rewindButton;
|
||||
// QPushButton *forwardButton;
|
||||
Phonon::SeekSlider *slider; |
||||
// QLabel *timeLabel;
|
||||
QLabel *progressLabel; |
||||
// QLabel *info;
|
||||
|
||||
QWidget m_videoWindow; |
||||
Phonon::MediaObject m_MediaObject; |
||||
Phonon::AudioOutput m_AudioOutput; |
||||
MediaVideoWidget *m_videoWidget; |
||||
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
|
@ -0,0 +1,212 @@ |
||||
#include "UBTBDocumentEditWidget.h" |
||||
#include "customWidgets/UBGlobals.h" |
||||
|
||||
UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpPageViewButton(NULL) |
||||
, mpPreviewButton(NULL) |
||||
, mpTitleLabel(NULL) |
||||
, mpTitle(NULL) |
||||
, mpTargetLabel(NULL) |
||||
, mpTarget(NULL) |
||||
, mpMetadataLabel(NULL) |
||||
, mpLicenseLabel(NULL) |
||||
, mpLicenseCombox(NULL) |
||||
, mpKeywords(NULL) |
||||
, mpLevel(NULL) |
||||
, mpTopic(NULL) |
||||
, mpAuthor(NULL) |
||||
, mpKeywordLabel(NULL) |
||||
, mpLevelLabel(NULL) |
||||
, mpTopicLabel(NULL) |
||||
, mpAuthorLabel(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
|
||||
mpDataMgr = pDataMgr; |
||||
|
||||
setLayout(&mLayout); |
||||
mLayout.setContentsMargins(0, 0, 0, 0); |
||||
|
||||
mpContainer = new QWidget(this); |
||||
mpContainer->setObjectName("DockPaletteWidgetBox"); |
||||
mLayout.addWidget(mpContainer, 1); |
||||
mpContainer->setLayout(&mContainerLayout); |
||||
|
||||
// Title
|
||||
mpTitleLabel = new QLabel(tr("Session Title"), mpContainer); |
||||
mpTitleLabel->setAlignment(Qt::AlignLeft); |
||||
mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mContainerLayout.addWidget(mpTitleLabel, 0); |
||||
mpTitle = new QLineEdit(mpContainer); |
||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mContainerLayout.addWidget(mpTitle, 0); |
||||
mContainerLayout.addWidget(&mTitleSeparator); |
||||
|
||||
// Target
|
||||
mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); |
||||
mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mContainerLayout.addWidget(mpTargetLabel, 0); |
||||
mpTarget = new QTextEdit(mpContainer); |
||||
mpTarget->setObjectName("UBTeacherBarTargetBox"); |
||||
mContainerLayout.addWidget(mpTarget, 1); |
||||
mContainerLayout.addWidget(&mTargetSeparator); |
||||
|
||||
// Metadata
|
||||
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); |
||||
mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mpMetadataLabel->setAlignment(Qt::AlignLeft); |
||||
mContainerLayout.addWidget(mpMetadataLabel, 0); |
||||
mpKeywords = new QLineEdit(this); |
||||
mpKeywords->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mpLevel = new QComboBox(this); |
||||
mpLevel->setObjectName("DockPaletteWidgetComboBox"); |
||||
mpTopic = new QComboBox(this); |
||||
mpTopic->setObjectName("DockPaletteWidgetComboBox"); |
||||
mpAuthor = new QLineEdit(this); |
||||
mpAuthor->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mpKeywordLabel = new QLabel(tr("Keywords:"), this); |
||||
mpLevelLabel = new QLabel(tr("Level:"), this); |
||||
mpTopicLabel = new QLabel(tr("Topic:"), this); |
||||
mpAuthorLabel = new QLabel(tr("Author"), this); |
||||
|
||||
mKeywordLayout.addWidget(mpKeywordLabel, 0); |
||||
mKeywordLayout.addWidget(mpKeywords, 1); |
||||
mLevelLayout.addWidget(mpLevelLabel, 0); |
||||
mLevelLayout.addWidget(mpLevel, 1); |
||||
mTopicLayout.addWidget(mpTopicLabel, 0); |
||||
mTopicLayout.addWidget(mpTopic, 1); |
||||
mAuthorLayout.addWidget(mpAuthorLabel, 0); |
||||
mAuthorLayout.addWidget(mpAuthor, 1); |
||||
|
||||
mContainerLayout.addLayout(&mKeywordLayout, 0); |
||||
mContainerLayout.addLayout(&mLevelLayout, 0); |
||||
mContainerLayout.addLayout(&mTopicLayout, 0); |
||||
mContainerLayout.addLayout(&mAuthorLayout, 0); |
||||
|
||||
mContainerLayout.addWidget(&mLicenseSeparator); |
||||
|
||||
// License
|
||||
mpLicenseLabel = new QLabel(tr("License"), mpContainer); |
||||
mpLicenseLabel->setAlignment(Qt::AlignLeft); |
||||
mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mContainerLayout.addWidget(mpLicenseLabel, 0); |
||||
mpLicenseCombox = new QComboBox(this); |
||||
mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox"); |
||||
QStringList qslLicenses; |
||||
qslLicenses << "CC BY"; |
||||
qslLicenses << "CC BY-ND"; |
||||
qslLicenses << "CC BY-NC-SA"; |
||||
qslLicenses << "CC BY-SA"; |
||||
qslLicenses << "CC BY-NC"; |
||||
qslLicenses << "CC BY-NC-ND"; |
||||
mpLicenseCombox->addItems(qslLicenses); |
||||
mContainerLayout.addWidget(mpLicenseCombox); |
||||
|
||||
mpPageViewButton = new QPushButton(tr("Page View"), this); |
||||
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPreviewLayout.addWidget(mpPageViewButton, 0); |
||||
mpPreviewButton = new QPushButton(tr("Preview"), this); |
||||
mpPreviewButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPreviewLayout.addWidget(mpPreviewButton, 0); |
||||
mPreviewLayout.addStretch(1); |
||||
mLayout.addLayout(&mPreviewLayout, 0); |
||||
|
||||
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); |
||||
connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); |
||||
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged())); |
||||
connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged())); |
||||
connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); |
||||
connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString))); |
||||
connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString))); |
||||
connect(mpTopic, SIGNAL(currentIndexChanged(QString)), this, SLOT(onTopicChanged(QString))); |
||||
connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString))); |
||||
} |
||||
|
||||
UBTBDocumentEditWidget::~UBTBDocumentEditWidget() |
||||
{ |
||||
DELETEPTR(mpTitleLabel); |
||||
DELETEPTR(mpTitle); |
||||
DELETEPTR(mpTargetLabel); |
||||
DELETEPTR(mpTarget); |
||||
DELETEPTR(mpMetadataLabel); |
||||
DELETEPTR(mpKeywordLabel); |
||||
DELETEPTR(mpLevelLabel); |
||||
DELETEPTR(mpTopicLabel); |
||||
DELETEPTR(mpAuthorLabel); |
||||
DELETEPTR(mpKeywords); |
||||
DELETEPTR(mpLevel); |
||||
DELETEPTR(mpTopic); |
||||
DELETEPTR(mpAuthor); |
||||
DELETEPTR(mpLicenseLabel); |
||||
DELETEPTR(mpLicenseCombox); |
||||
DELETEPTR(mpPageViewButton); |
||||
DELETEPTR(mpPreviewButton); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onPageView() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PageEdit); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onPreview() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentPreview); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onSessionTitleChanged() |
||||
{ |
||||
mpDataMgr->setSessionTitle(mpTitle->text()); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onSessionTargetChanged() |
||||
{ |
||||
mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText()); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection) |
||||
{ |
||||
mpDataMgr->setSessionLicence((eLicense)selection); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::updateFields() |
||||
{ |
||||
mpTitle->setText(mpDataMgr->sessionTitle()); |
||||
mpTarget->setPlainText(mpDataMgr->sessionTarget()); |
||||
mpKeywords->setText(mpDataMgr->keywords()); |
||||
// TODO: retrieve the level
|
||||
// TODO retrieve the topic
|
||||
mpAuthor->setText(mpDataMgr->authors()); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::clearFields() |
||||
{ |
||||
mpTitle->setText(""); |
||||
mpTarget->setPlainText(""); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw) |
||||
{ |
||||
mpDataMgr->setKeywords(kw); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onLevelChanged(const QString &level) |
||||
{ |
||||
mpDataMgr->setLevel(level); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onTopicChanged(const QString &topic) |
||||
{ |
||||
mpDataMgr->setTopic(topic); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onAuthorChanged(const QString &authors) |
||||
{ |
||||
mpDataMgr->setAuthors(authors); |
||||
emit valueChanged(); |
||||
} |
@ -0,0 +1,73 @@ |
||||
#ifndef UBTBDOCUMENTEDITWIDGET_H |
||||
#define UBTBDOCUMENTEDITWIDGET_H |
||||
|
||||
#include <QVBoxLayout> |
||||
#include <QPushButton> |
||||
#include <QLabel> |
||||
#include <QLineEdit> |
||||
#include <QTextEdit> |
||||
#include <QComboBox> |
||||
|
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
class UBTBDocumentEditWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); |
||||
~UBTBDocumentEditWidget(); |
||||
void updateFields(); |
||||
void clearFields(); |
||||
|
||||
signals: |
||||
void changeTBState(eTeacherBarState state); |
||||
void valueChanged(); |
||||
|
||||
private slots: |
||||
void onPageView(); |
||||
void onPreview(); |
||||
void onSessionTitleChanged(); |
||||
void onSessionTargetChanged(); |
||||
void onLicenseCurrentIndexChanged(int selection); |
||||
void onKeywordChanged(const QString& kw); |
||||
void onLevelChanged(const QString& level); |
||||
void onTopicChanged(const QString& topic); |
||||
void onAuthorChanged(const QString& authors); |
||||
|
||||
private: |
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mPageLayout; |
||||
QHBoxLayout mPreviewLayout; |
||||
QVBoxLayout mContainerLayout; |
||||
QPushButton* mpPageViewButton; |
||||
QPushButton* mpPreviewButton; |
||||
UBTBSeparator mTitleSeparator; |
||||
UBTBSeparator mTargetSeparator; |
||||
UBTBSeparator mLicenseSeparator; |
||||
|
||||
QHBoxLayout mKeywordLayout; |
||||
QHBoxLayout mLevelLayout; |
||||
QHBoxLayout mTopicLayout; |
||||
QHBoxLayout mAuthorLayout; |
||||
|
||||
QWidget* mpContainer; |
||||
QLabel* mpTitleLabel; |
||||
QLineEdit* mpTitle; |
||||
QLabel* mpTargetLabel; |
||||
QTextEdit* mpTarget; |
||||
QLabel* mpMetadataLabel; |
||||
QLabel* mpLicenseLabel; |
||||
QComboBox* mpLicenseCombox; |
||||
QLineEdit* mpKeywords; |
||||
QComboBox* mpLevel; |
||||
QComboBox* mpTopic; |
||||
QLineEdit* mpAuthor; |
||||
QLabel* mpKeywordLabel; |
||||
QLabel* mpLevelLabel; |
||||
QLabel* mpTopicLabel; |
||||
QLabel* mpAuthorLabel; |
||||
|
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
}; |
||||
|
||||
#endif // UBTBDOCUMENTEDITWIDGET_H
|
@ -0,0 +1,57 @@ |
||||
#include "customWidgets/UBGlobals.h" |
||||
#include "UBTBDocumentPreviewWidget.h" |
||||
|
||||
UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpPageViewButton(NULL) |
||||
, mpEditButton(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
mpDataMgr = pDataMgr; |
||||
|
||||
setLayout(&mLayout); |
||||
|
||||
mpPageViewButton = new QPushButton(tr("Page View"), this); |
||||
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPageLayout.addStretch(1); |
||||
mPageLayout.addWidget(mpPageViewButton, 0); |
||||
mPageLayout.addStretch(1); |
||||
mLayout.addLayout(&mPageLayout); |
||||
|
||||
// TODO : Add the elements here
|
||||
|
||||
mpEditButton = new QPushButton(tr("Edit"), this); |
||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPreviewLayout.addStretch(1); |
||||
mPreviewLayout.addWidget(mpEditButton, 0); |
||||
mPreviewLayout.addStretch(1); |
||||
mLayout.addLayout(&mPreviewLayout); |
||||
|
||||
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); |
||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
||||
} |
||||
|
||||
UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() |
||||
{ |
||||
DELETEPTR(mpPageViewButton); |
||||
DELETEPTR(mpEditButton); |
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::onEdit() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::onPageView() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PagePreview); |
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::updateFields() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::clearFields() |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
#ifndef UBTBDOCUMENTPREVIEWWIDGET_H |
||||
#define UBTBDOCUMENTPREVIEWWIDGET_H |
||||
|
||||
#include <QVBoxLayout> |
||||
#include <QPushButton> |
||||
|
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
class UBTBDocumentPreviewWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); |
||||
~UBTBDocumentPreviewWidget(); |
||||
void updateFields(); |
||||
void clearFields(); |
||||
|
||||
signals: |
||||
void changeTBState(eTeacherBarState state); |
||||
|
||||
private slots: |
||||
void onPageView(); |
||||
void onEdit(); |
||||
|
||||
private: |
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mPageLayout; |
||||
QHBoxLayout mPreviewLayout; |
||||
QPushButton* mpPageViewButton; |
||||
QPushButton* mpEditButton; |
||||
|
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
}; |
||||
|
||||
#endif // UBTBDOCUMENTPREVIEWWIDGET_H
|
@ -0,0 +1,534 @@ |
||||
#include "customWidgets/UBGlobals.h" |
||||
#include "core/UBApplication.h" |
||||
#include "frameworks/UBFileSystemUtils.h" |
||||
#include "gui/UBMediaPlayer.h" |
||||
#include "customWidgets/UBMediaWidget.h" |
||||
|
||||
#include "UBTBPageEditWidget.h" |
||||
|
||||
UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpDataMgr(NULL) |
||||
, mpTitleLabel(NULL) |
||||
, mpTitle(NULL) |
||||
, mpMediaLabel(NULL) |
||||
, mpActionLabel(NULL) |
||||
, mpActions(NULL) |
||||
, mpActionButton(NULL) |
||||
, mpLinkLabel(NULL) |
||||
, mpLinks(NULL) |
||||
, mpLinkButton(NULL) |
||||
, mpCommentLabel(NULL) |
||||
, mpComments(NULL) |
||||
, mpDocumentEditbutton(NULL) |
||||
, mpPagePreviewButton(NULL) |
||||
, mpContainer(NULL) |
||||
{ |
||||
Q_UNUSED(name); |
||||
mpDataMgr = pDataMgr; |
||||
mActions.clear(); |
||||
mUrls.clear(); |
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
mClearingFields = false; |
||||
mLayout.setContentsMargins(0, 0, 0, 0); |
||||
setLayout(&mLayout); |
||||
|
||||
mpContainer = new QWidget(this); |
||||
mpContainer->setObjectName("DockPaletteWidgetBox"); |
||||
mpContainer->setLayout(&mContainerLayout); |
||||
mLayout.addWidget(mpContainer, 1); |
||||
|
||||
// Title
|
||||
mpTitleLabel = new QLabel(tr("Title"), mpContainer); |
||||
mpTitle = new QLineEdit(mpContainer); |
||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mContainerLayout.addWidget(mpTitleLabel, 0); |
||||
mContainerLayout.addWidget(mpTitle, 0); |
||||
|
||||
// Actions
|
||||
mpActionLabel = new QLabel(tr("Actions"), mpContainer); |
||||
mContainerLayout.addWidget(mpActionLabel, 0); |
||||
mpActions = new UBWidgetList(mpContainer); |
||||
mpActions->setEmptyText(tr("Add actions")); |
||||
mContainerLayout.addWidget(mpActions, 1); |
||||
mpActionButton = new QPushButton(mpContainer); |
||||
mpActionButton->setObjectName("DockPaletteWidgetButton"); |
||||
mpActionButton->setText(tr("Add action")); |
||||
mActionLayout.addWidget(mpActionButton, 0); |
||||
mActionLayout.addStretch(1); |
||||
mContainerLayout.addLayout(&mActionLayout, 0); |
||||
|
||||
// Media
|
||||
mpMediaLabel = new QLabel(tr("Medias"), mpContainer); |
||||
mContainerLayout.addWidget(mpMediaLabel, 0); |
||||
mpMediaContainer = new UBTBMediaContainer(mpContainer); |
||||
mpMediaContainer->setEmptyText(tr("Drop media here")); |
||||
mContainerLayout.addWidget(mpMediaContainer, 1); |
||||
|
||||
// Links
|
||||
mpLinkLabel = new QLabel(tr("Links"), mpContainer); |
||||
mContainerLayout.addWidget(mpLinkLabel, 0); |
||||
mpLinks = new UBWidgetList(mpContainer); |
||||
mContainerLayout.addWidget(mpLinks, 1); |
||||
mpLinkButton = new QPushButton(tr("Add link"), mpContainer); |
||||
mpLinkButton->setObjectName("DockPaletteWidgetButton"); |
||||
mLinkLayout.addWidget(mpLinkButton, 0); |
||||
mLinkLayout.addStretch(1); |
||||
mContainerLayout.addLayout(&mLinkLayout, 0); |
||||
|
||||
// Comments
|
||||
mpCommentLabel = new QLabel(tr("Comments"), mpContainer); |
||||
mContainerLayout.addWidget(mpCommentLabel, 0); |
||||
mpComments = new QTextEdit(mpContainer); |
||||
mpComments->setObjectName("DockPaletteWidgetBox"); |
||||
mpComments->setStyleSheet("background:white;"); |
||||
mContainerLayout.addWidget(mpComments, 1); |
||||
|
||||
mpPagePreviewButton = new QPushButton(tr("Preview"), this); |
||||
mpPagePreviewButton->setObjectName("DockPaletteWidgetButton"); |
||||
mpDocumentEditbutton = new QPushButton(tr("Document View"), this); |
||||
mpDocumentEditbutton->setObjectName("DockPaletteWidgetButton"); |
||||
mPagePreviewLayout.addWidget(mpDocumentEditbutton, 0); |
||||
mPagePreviewLayout.addWidget(mpPagePreviewButton, 0); |
||||
mPagePreviewLayout.addStretch(1); |
||||
mLayout.addLayout(&mPagePreviewLayout, 0); |
||||
|
||||
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged())); |
||||
connect(mpComments, SIGNAL(textChanged()), this, SLOT(onCommentsChanged())); |
||||
connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); |
||||
connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); |
||||
connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); |
||||
connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked())); |
||||
connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); |
||||
} |
||||
|
||||
UBTBPageEditWidget::~UBTBPageEditWidget() |
||||
{ |
||||
DELETEPTR(mpDocumentEditbutton); |
||||
DELETEPTR(mpPagePreviewButton); |
||||
DELETEPTR(mpComments); |
||||
DELETEPTR(mpCommentLabel); |
||||
DELETEPTR(mpLinks); |
||||
DELETEPTR(mpLinkLabel); |
||||
DELETEPTR(mpLinkButton); |
||||
DELETEPTR(mpMediaLabel); |
||||
DELETEPTR(mpActionButton); |
||||
DELETEPTR(mpActionLabel); |
||||
DELETEPTR(mpTitleLabel); |
||||
DELETEPTR(mpTitle); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onTitleChanged() |
||||
{ |
||||
if(!mClearingFields){ |
||||
mpDataMgr->setPageTitle(mpTitle->text()); |
||||
emit valueChanged(); |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onCommentsChanged() |
||||
{ |
||||
if(!mClearingFields){ |
||||
mpDataMgr->setComments(mpComments->document()->toPlainText()); |
||||
emit valueChanged(); |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onActionButton() |
||||
{ |
||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
||||
mActions << pAction; |
||||
mpActions->addWidget(pAction); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onLinkButton() |
||||
{ |
||||
UBUrlWidget* pUrl = new UBUrlWidget(this); |
||||
mUrls << pUrl; |
||||
mpLinks->addWidget(pUrl); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onMediaDropped(const QString &url) |
||||
{ |
||||
if("" != url){ |
||||
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); |
||||
if(NULL != pMedia){ |
||||
mMedias << pMedia; |
||||
mMediaUrls << url; |
||||
//mpDataMgr->medias()->append(pMedia);
|
||||
//mpDataMgr->addMediaUrl(url);
|
||||
mpMediaContainer->addWidget(pMedia); |
||||
emit valueChanged(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onDocumentEditClicked() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onPagePreviewClicked() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PagePreview); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::saveFields() |
||||
{ |
||||
mpDataMgr->actions()->clear(); |
||||
mpDataMgr->urls()->clear(); |
||||
mpDataMgr->mediaUrls()->clear(); |
||||
mpDataMgr->medias()->clear(); |
||||
|
||||
foreach(UBTeacherStudentAction* pAct, mActions){ |
||||
sAction action; |
||||
action.type = pAct->comboValue().toInt(); |
||||
action.content = pAct->text(); |
||||
mpDataMgr->actions()->append(action); |
||||
} |
||||
foreach(UBUrlWidget* pUrl, mUrls){ |
||||
sLink link; |
||||
link.title = pUrl->title(); |
||||
link.link = pUrl->url(); |
||||
mpDataMgr->urls()->append(link); |
||||
} |
||||
foreach(QString url, mMediaUrls){ |
||||
qDebug() << "saving media :" << url; |
||||
mpDataMgr->mediaUrls()->append(url); |
||||
} |
||||
foreach(QWidget* pMedia, mMedias){ |
||||
mpDataMgr->medias()->append(pMedia); |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::updateFields() |
||||
{ |
||||
// Title
|
||||
mpTitle->setText(mpDataMgr->pageTitle()); |
||||
// Actions
|
||||
foreach(sAction action, *mpDataMgr->actions()){ |
||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
||||
pAction->setComboValue(action.type); |
||||
pAction->setText(action.content); |
||||
mActions << pAction; |
||||
mpActions->addWidget(pAction); |
||||
} |
||||
// Medias
|
||||
foreach(QString url, *mpDataMgr->mediaUrls()){ |
||||
if(!url.isEmpty()){ |
||||
mMediaUrls << url; |
||||
QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); |
||||
if(pWidget != NULL){ |
||||
mMedias << pWidget; |
||||
mpMediaContainer->addWidget(pWidget); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Links
|
||||
foreach(sLink link, *mpDataMgr->urls()){ |
||||
UBUrlWidget* urlWidget = new UBUrlWidget(this); |
||||
urlWidget->setTitle(link.title); |
||||
urlWidget->setUrl(link.link); |
||||
mUrls << urlWidget; |
||||
mpLinks->addWidget(urlWidget); |
||||
} |
||||
// Comments
|
||||
mpComments->document()->setPlainText(mpDataMgr->comments()); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::clearFields() |
||||
{ |
||||
mClearingFields = true; |
||||
// Title
|
||||
mpTitle->setText(""); |
||||
// Actions
|
||||
foreach(UBTeacherStudentAction* pAction, mActions){ |
||||
mpActions->removeWidget(pAction); |
||||
DELETEPTR(pAction); |
||||
} |
||||
mActions.clear(); |
||||
// Medias
|
||||
foreach(QWidget* pMedia, mMedias){ |
||||
if(NULL != pMedia){ |
||||
mpMediaContainer->removeWidget(pMedia); |
||||
DELETEPTR(pMedia); |
||||
} |
||||
} |
||||
mMedias.clear(); |
||||
mMediaUrls.clear(); |
||||
// Links
|
||||
foreach(UBUrlWidget* pLink, mUrls){ |
||||
mpLinks->removeWidget(pLink); |
||||
DELETEPTR(pLink); |
||||
} |
||||
mUrls.clear(); |
||||
// Comments
|
||||
mpComments->setText(""); |
||||
|
||||
mClearingFields = false; |
||||
} |
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) |
||||
, mpLayout(NULL) |
||||
, mpUrlLabel(NULL) |
||||
, mpUrl(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
mpLayout = new QVBoxLayout(this); |
||||
setLayout(mpLayout); |
||||
|
||||
mpLabelLayout = new QHBoxLayout(0); |
||||
mpUrlLabel = new QLabel(tr("Url"), this); |
||||
mpLabelLayout->addWidget(mpUrlLabel, 0); |
||||
mpUrl = new QLineEdit(this); |
||||
mpUrl->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mpUrl->setMinimumHeight(20); |
||||
mpLabelLayout->addWidget(mpUrl, 1); |
||||
|
||||
mpTitleLayout = new QHBoxLayout(0); |
||||
mpTitleLabel = new QLabel(tr("Title"),this); |
||||
mpTitleLayout->addWidget(mpTitleLabel,0); |
||||
mpTitle = new QLineEdit(this); |
||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
||||
mpTitle->setMinimumHeight(20); |
||||
mpTitleLayout->addWidget(mpTitle,1); |
||||
|
||||
mpLayout->addLayout(mpTitleLayout); |
||||
mpLayout->addLayout(mpLabelLayout); |
||||
} |
||||
|
||||
UBUrlWidget::~UBUrlWidget() |
||||
{ |
||||
DELETEPTR(mpTitle); |
||||
DELETEPTR(mpTitleLabel); |
||||
DELETEPTR(mpUrlLabel); |
||||
DELETEPTR(mpUrl); |
||||
DELETEPTR(mpTitleLayout); |
||||
DELETEPTR(mpLabelLayout); |
||||
DELETEPTR(mpLayout); |
||||
} |
||||
|
||||
QString UBUrlWidget::url() |
||||
{ |
||||
QString str; |
||||
|
||||
if(NULL != mpUrl){ |
||||
str = mpUrl->text() + ";" + mpTitle->text(); |
||||
} |
||||
|
||||
return str; |
||||
} |
||||
|
||||
void UBUrlWidget::setUrl(const QString &url) |
||||
{ |
||||
if(NULL != mpUrl){ |
||||
mpUrl->setText(url); |
||||
} |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------
|
||||
UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent) |
||||
{ |
||||
setObjectName(name); |
||||
setAcceptDrops(true); |
||||
} |
||||
|
||||
UBTBMediaContainer::~UBTBMediaContainer() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) |
||||
{ |
||||
QPixmap pixFromDropEvent; |
||||
QString mimeType; |
||||
QString resourcePath; |
||||
if(pEvent->mimeData()->hasText()){ |
||||
resourcePath = pEvent->mimeData()->text(); |
||||
} |
||||
else if(pEvent->mimeData()->hasUrls()){ |
||||
resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); |
||||
} |
||||
else if(pEvent->mimeData()->hasImage()){ |
||||
pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); |
||||
if(!pixFromDropEvent.isNull()) |
||||
mimeType = "image"; |
||||
} |
||||
|
||||
if (mimeType.isEmpty() && resourcePath.isEmpty()){ |
||||
pEvent->acceptProposedAction(); |
||||
return; |
||||
} |
||||
if(!resourcePath.isEmpty()){ |
||||
emit mediaDropped(resourcePath); |
||||
pEvent->acceptProposedAction(); |
||||
} |
||||
} |
||||
|
||||
void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent) |
||||
{ |
||||
pEvent->acceptProposedAction(); |
||||
} |
||||
|
||||
void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent) |
||||
{ |
||||
pEvent->acceptProposedAction(); |
||||
} |
||||
|
||||
void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent) |
||||
{ |
||||
pEvent->accept(); |
||||
} |
||||
|
||||
void UBTBMediaContainer::addMedia(const QString& mediaPath) |
||||
{ |
||||
if(!mediaPath.isEmpty()) |
||||
mMediaList.append(mediaPath); |
||||
else |
||||
qWarning() << __FUNCTION__ << "empty path"; |
||||
|
||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath); |
||||
if(mimeType.contains("image")){ |
||||
QPixmap pix = QPixmap(mediaPath); |
||||
QLabel* label = new QLabel(); |
||||
label->setPixmap(pix); |
||||
label->setScaledContents(true); |
||||
addWidget(label); |
||||
} |
||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
||||
UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); |
||||
mediaPlayer->setFile(mediaPath); |
||||
addWidget(mediaPlayer); |
||||
} |
||||
else{ |
||||
qWarning() << "pMediaPath" << mediaPath; |
||||
qWarning() << "bad idea to come here"; |
||||
} |
||||
} |
||||
|
||||
QStringList UBTBMediaContainer::mediaUrls() |
||||
{ |
||||
return mMediaList; |
||||
} |
||||
|
||||
void UBTBMediaContainer::cleanMedias() |
||||
{ |
||||
mMediaList.clear(); |
||||
} |
||||
|
||||
QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) |
||||
{ |
||||
QWidget* pW = NULL; |
||||
|
||||
if(!url.isEmpty()) |
||||
mMediaList.append(url); |
||||
else |
||||
qWarning() << __FUNCTION__ << "empty path"; |
||||
|
||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); |
||||
if(mimeType.contains("image")){ |
||||
QPixmap pix = QPixmap(url); |
||||
QLabel* label = new QLabel(); |
||||
pix.scaledToWidth(label->width()); |
||||
label->resize(pix.width(), pix.height()); |
||||
label->setPixmap(pix); |
||||
label->setScaledContents(true); |
||||
pW = label; |
||||
} |
||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
||||
UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
||||
mediaPlayer->setFile(url); |
||||
pW = mediaPlayer; |
||||
} |
||||
else{ |
||||
qWarning() << "pMediaPath" << url; |
||||
qWarning() << "bad idea to come here"; |
||||
} |
||||
|
||||
return pW; |
||||
} |
||||
|
||||
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) |
||||
, mpText(NULL) |
||||
, mpLayout(NULL) |
||||
, mpComboLayout(NULL) |
||||
, mpCombo(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
|
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
// Create the GUI
|
||||
mpLayout = new QHBoxLayout(this); |
||||
setLayout(mpLayout); |
||||
|
||||
mpComboLayout = new QVBoxLayout(); |
||||
|
||||
mpCombo = new QComboBox(this); |
||||
mpCombo->setObjectName("DockPaletteWidgetComboBox"); |
||||
mpCombo->setMinimumWidth(80); |
||||
mpCombo->addItem(tr("Teacher")); |
||||
mpCombo->addItem(tr("Student")); |
||||
mpComboLayout->addWidget(mpCombo, 0); |
||||
mpComboLayout->addStretch(1); |
||||
|
||||
mpLayout->addLayout(mpComboLayout, 0); |
||||
|
||||
mpText = new QTextEdit(this); |
||||
mpText->setObjectName("DockPaletteWidgetBox"); |
||||
mpText->setStyleSheet("background:white;"); |
||||
|
||||
mpLayout->addWidget(mpText, 1); |
||||
|
||||
} |
||||
|
||||
UBTeacherStudentAction::~UBTeacherStudentAction() |
||||
{ |
||||
DELETEPTR(mpCombo); |
||||
DELETEPTR(mpText); |
||||
DELETEPTR(mpComboLayout); |
||||
DELETEPTR(mpLayout); |
||||
} |
||||
|
||||
QString UBTeacherStudentAction::text() |
||||
{ |
||||
QString str; |
||||
if(NULL != mpText){ |
||||
str = mpText->document()->toPlainText(); |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
QString UBTeacherStudentAction::comboValue() |
||||
{ |
||||
QString str; |
||||
|
||||
if(NULL != mpCombo){ |
||||
str = QString("%0").arg(mpCombo->currentIndex()); |
||||
} |
||||
|
||||
return str; |
||||
} |
||||
|
||||
void UBTeacherStudentAction::setComboValue(int value) |
||||
{ |
||||
if(NULL != mpCombo){ |
||||
mpCombo->setCurrentIndex(value); |
||||
} |
||||
} |
||||
|
||||
void UBTeacherStudentAction::setText(const QString& text) |
||||
{ |
||||
if(NULL != mpText){ |
||||
mpText->document()->setPlainText(text); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,141 @@ |
||||
#ifndef UBTBPAGEEDITWIDGET_H |
||||
#define UBTBPAGEEDITWIDGET_H |
||||
|
||||
#include <QString> |
||||
#include <QTextEdit> |
||||
#include <QHBoxLayout> |
||||
#include <QVBoxLayout> |
||||
#include <QComboBox> |
||||
#include <QLabel> |
||||
#include <QPushButton> |
||||
|
||||
#include "core/UBPersistenceManager.h" |
||||
#include "customWidgets/UBWidgetList.h" |
||||
#include "interfaces/IDropable.h" |
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
class UBTeacherStudentAction : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); |
||||
~UBTeacherStudentAction(); |
||||
QString text(); |
||||
QString comboValue(); |
||||
void setComboValue(int value); |
||||
void setText(const QString& text); |
||||
|
||||
private: |
||||
QTextEdit* mpText; |
||||
QHBoxLayout* mpLayout; |
||||
QVBoxLayout* mpComboLayout; |
||||
QComboBox* mpCombo; |
||||
}; |
||||
|
||||
class UBUrlWidget : public QWidget |
||||
{ |
||||
public: |
||||
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); |
||||
~UBUrlWidget(); |
||||
|
||||
QString url(); |
||||
void setUrl(const QString& url); |
||||
|
||||
QString title(){return mpTitle->text();} |
||||
void setTitle(const QString& title){mpTitle->setText(title);} |
||||
|
||||
private: |
||||
QVBoxLayout* mpLayout; |
||||
QHBoxLayout* mpLabelLayout; |
||||
QHBoxLayout* mpTitleLayout; |
||||
QLabel* mpUrlLabel; |
||||
QLineEdit* mpUrl; |
||||
|
||||
QLabel* mpTitleLabel; |
||||
QLineEdit* mpTitle; |
||||
}; |
||||
|
||||
class UBTBMediaContainer : public UBWidgetList |
||||
, public IDropable |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer"); |
||||
~UBTBMediaContainer(); |
||||
QStringList mediaUrls(); |
||||
QWidget* generateMediaWidget(const QString& url); |
||||
void cleanMedias(); |
||||
|
||||
signals: |
||||
void mediaDropped(const QString& url); |
||||
|
||||
protected: |
||||
void dropEvent(QDropEvent* pEvent); |
||||
void dragEnterEvent(QDragEnterEvent* pEvent); |
||||
void dragMoveEvent(QDragMoveEvent* pEvent); |
||||
void dragLeaveEvent(QDragLeaveEvent* pEvent); |
||||
|
||||
private: |
||||
void addMedia(const QString& mediaPath); |
||||
|
||||
QStringList mMediaList; |
||||
}; |
||||
|
||||
class UBTBPageEditWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget"); |
||||
~UBTBPageEditWidget(); |
||||
void saveFields(); |
||||
void updateFields(); |
||||
void clearFields(); |
||||
|
||||
signals: |
||||
void valueChanged(); |
||||
void changeTBState(eTeacherBarState state); |
||||
|
||||
private slots: |
||||
void onTitleChanged(); |
||||
void onCommentsChanged(); |
||||
void onActionButton(); |
||||
void onLinkButton(); |
||||
void onMediaDropped(const QString& url); |
||||
void onDocumentEditClicked(); |
||||
void onPagePreviewClicked(); |
||||
|
||||
private: |
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mTitleLayout; |
||||
QVBoxLayout mContainerLayout; |
||||
QHBoxLayout mActionLayout; |
||||
QHBoxLayout mLinkLayout; |
||||
QHBoxLayout mDocumentViewLayout; |
||||
QHBoxLayout mPagePreviewLayout; |
||||
|
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
QLabel* mpTitleLabel; |
||||
QLineEdit* mpTitle; |
||||
QLabel* mpMediaLabel; |
||||
UBTBMediaContainer* mpMediaContainer; |
||||
QLabel* mpActionLabel; |
||||
UBWidgetList* mpActions; |
||||
QPushButton* mpActionButton; |
||||
QLabel* mpLinkLabel; |
||||
UBWidgetList* mpLinks; |
||||
QPushButton* mpLinkButton; |
||||
QLabel* mpCommentLabel; |
||||
QTextEdit* mpComments; |
||||
QPushButton* mpDocumentEditbutton; |
||||
QPushButton* mpPagePreviewButton; |
||||
QWidget* mpContainer; |
||||
|
||||
QVector<UBTeacherStudentAction*> mActions; |
||||
QVector<UBUrlWidget*> mUrls; |
||||
QVector<QWidget*> mMedias; |
||||
QStringList mMediaUrls; |
||||
bool mClearingFields; |
||||
}; |
||||
|
||||
#endif // UBTBPAGEEDITWIDGET_H
|
@ -0,0 +1,184 @@ |
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
#include "core/UBApplication.h" |
||||
#include "core/UBPersistenceManager.h" |
||||
|
||||
#include "board/UBBoardController.h" |
||||
|
||||
#include "customWidgets/UBGlobals.h" |
||||
|
||||
#include "adaptors/UBMetadataDcSubsetAdaptor.h" |
||||
|
||||
|
||||
UBTeacherBarDataMgr::UBTeacherBarDataMgr() |
||||
{ |
||||
|
||||
} |
||||
|
||||
UBTeacherBarDataMgr::~UBTeacherBarDataMgr() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBTeacherBarDataMgr::clearLists() |
||||
{ |
||||
mActionList.clear(); |
||||
mUrlList.clear(); |
||||
mMediaList.clear(); |
||||
mMediaUrls.clear(); |
||||
} |
||||
|
||||
void UBTeacherBarDataMgr::saveContent() |
||||
{ |
||||
// Store the page information in the UBZ
|
||||
sTeacherBarInfos infos; |
||||
|
||||
// Page Title
|
||||
infos.title = mPageTitle; |
||||
// Actions
|
||||
foreach(sAction action, mActionList){ |
||||
infos.actions << QString("%0;%1").arg(action.type).arg(action.content); |
||||
} |
||||
// Media
|
||||
foreach(QString media, mMediaUrls){ |
||||
infos.medias << media; |
||||
} |
||||
// Links
|
||||
foreach(sLink link, mUrlList){ |
||||
if("" != link.title && "" != link.link){ |
||||
infos.urls << QString("%0;%1").arg(link.title).arg(link.link); |
||||
} |
||||
} |
||||
// Comments
|
||||
infos.comments = mComments; |
||||
|
||||
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); |
||||
if(documentProxy){ |
||||
UBPersistenceManager::persistenceManager()->persistTeacherBar(documentProxy, UBApplication::boardController->activeSceneIndex(), infos); |
||||
|
||||
documentProxy->setSessionTitle(mSessionTitle); |
||||
documentProxy->setSessionTarget(mSessionTarget); |
||||
documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); |
||||
documentProxy->setSessionKeywords(mAuthors); |
||||
documentProxy->setSessionLevel(mLevel); |
||||
documentProxy->setSessionTopic(mTopic); |
||||
documentProxy->setSessionAuthor(mAuthors); |
||||
|
||||
UBMetadataDcSubsetAdaptor::persist(documentProxy); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
void UBTeacherBarDataMgr::loadContent(bool docChanged) |
||||
{ |
||||
clearLists(); |
||||
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); |
||||
|
||||
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(documentProxy, UBApplication::boardController->activeSceneIndex()); |
||||
if(true/*docChanged*/){ |
||||
mSessionTitle = documentProxy->sessionTitle(); |
||||
mSessionTarget = documentProxy->sessionTarget(); |
||||
mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); |
||||
mKeywords = documentProxy->sessionKeywords(); |
||||
mLevel = documentProxy->sessionLevel(); |
||||
mTopic = documentProxy->sessionTopic(); |
||||
mAuthors = documentProxy->sessionAuthors(); |
||||
} |
||||
|
||||
// Page Title
|
||||
mPageTitle = nextInfos.title; |
||||
// Actions
|
||||
foreach(QString eachAction, nextInfos.actions){ |
||||
QStringList qslAction = eachAction.split(";"); |
||||
if(2 <= qslAction.size()){ |
||||
sAction action; |
||||
action.type = qslAction.at(0).toInt(); |
||||
action.content = qslAction.at(1); |
||||
mActionList << action; |
||||
} |
||||
} |
||||
// Media URL
|
||||
if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){ |
||||
// Do not retrieve it
|
||||
} |
||||
else{ |
||||
mMediaUrls = nextInfos.medias; |
||||
} |
||||
|
||||
// Links
|
||||
foreach(QString eachUrl, nextInfos.urls){ |
||||
QStringList qslUrl = eachUrl.split(';'); |
||||
if(2 <= qslUrl.size()){ |
||||
sLink link; |
||||
link.title = qslUrl.at(0); |
||||
link.link = qslUrl.at(1); |
||||
mUrlList << link; |
||||
} |
||||
} |
||||
|
||||
// Comments
|
||||
mComments = nextInfos.comments; |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent) |
||||
{ |
||||
setObjectName("UBTBSeparator"); |
||||
setMinimumHeight(5); |
||||
setMaximumHeight(5); |
||||
} |
||||
|
||||
UBTBSeparator::~UBTBSeparator() |
||||
{ |
||||
|
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
UBTBLicenseWidget::UBTBLicenseWidget(QWidget *parent, const char *name):QWidget(parent) |
||||
{ |
||||
setObjectName(name); |
||||
setLayout(&mLayout); |
||||
|
||||
mpIcon = new QLabel(this); |
||||
mpText = new QLabel(this); |
||||
mpText->setWordWrap(true); |
||||
mLayout.addWidget(mpIcon); |
||||
mLayout.addWidget(mpText); |
||||
} |
||||
|
||||
UBTBLicenseWidget::~UBTBLicenseWidget() |
||||
{ |
||||
DELETEPTR(mpIcon); |
||||
DELETEPTR(mpText); |
||||
} |
||||
|
||||
void UBTBLicenseWidget::setLicense(eLicense lic) |
||||
{ |
||||
switch(lic){ |
||||
case eLicense_CCBY: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccby.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY")); |
||||
break; |
||||
case eLicense_CCBYND: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbynd.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-ND")); |
||||
break; |
||||
case eLicense_CCBYNCSA: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncsa.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-SA")); |
||||
break; |
||||
case eLicense_CCBYSA: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbysa.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-SA")); |
||||
break; |
||||
case eLicense_CCBYNC: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbync.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC")); |
||||
break; |
||||
case eLicense_CCBYNCND: |
||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncnd.png")); |
||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-ND")); |
||||
break; |
||||
} |
||||
} |
@ -0,0 +1,141 @@ |
||||
#ifndef UBTEACHERBARDATAMGR_H |
||||
#define UBTEACHERBARDATAMGR_H |
||||
|
||||
#include <QString> |
||||
#include <QWidget> |
||||
#include <QTextEdit> |
||||
#include <QLineEdit> |
||||
#include <QLabel> |
||||
#include <QHBoxLayout> |
||||
#include <QVBoxLayout> |
||||
#include <QComboBox> |
||||
#include <QFrame> |
||||
|
||||
typedef enum{ |
||||
eTeacherBarState_DocumentEdit, |
||||
eTeacherBarState_DocumentPreview, |
||||
eTeacherBarState_PageEdit, |
||||
eTeacherBarState_PagePreview |
||||
}eTeacherBarState; |
||||
|
||||
typedef enum{ |
||||
eActionOwner_Teacher, |
||||
eActionOwner_Student |
||||
}eActionOwner; |
||||
|
||||
typedef struct{ |
||||
int type; |
||||
QString content; |
||||
}sAction; |
||||
|
||||
typedef struct{ |
||||
QString title; |
||||
QString link; |
||||
}sLink; |
||||
|
||||
typedef enum{ |
||||
eLicense_CCBY, |
||||
eLicense_CCBYND, |
||||
eLicense_CCBYNCSA, |
||||
eLicense_CCBYSA, |
||||
eLicense_CCBYNC, |
||||
eLicense_CCBYNCND |
||||
}eLicense; |
||||
|
||||
class UBTBSeparator : public QFrame |
||||
{ |
||||
public: |
||||
UBTBSeparator(QWidget* parent=0, const char* name="UBTBSeparator"); |
||||
~UBTBSeparator(); |
||||
}; |
||||
|
||||
class UBTBLicenseWidget : public QWidget |
||||
{ |
||||
public: |
||||
UBTBLicenseWidget(QWidget* parent=0, const char* name="UBTBLicenseWidget"); |
||||
~UBTBLicenseWidget(); |
||||
void setLicense(eLicense lic); |
||||
|
||||
private: |
||||
QHBoxLayout mLayout; |
||||
QLabel* mpIcon; |
||||
QLabel* mpText; |
||||
}; |
||||
|
||||
class UBTeacherBarDataMgr |
||||
{ |
||||
public: |
||||
UBTeacherBarDataMgr(); |
||||
~UBTeacherBarDataMgr(); |
||||
|
||||
// Session Title
|
||||
void setSessionTitle(const QString& title){mSessionTitle = title;} |
||||
QString sessionTitle(){return mSessionTitle;} |
||||
|
||||
// Session Target
|
||||
void setSessionTarget(const QString& target){mSessionTarget = target;} |
||||
QString sessionTarget(){return mSessionTarget;} |
||||
|
||||
// Licence
|
||||
void setSessionLicence(eLicense licence){mSessionLicence = licence;} |
||||
eLicense sessionLicence(){return mSessionLicence;} |
||||
|
||||
// Page Title
|
||||
void setPageTitle(const QString& title){mPageTitle = title;} |
||||
QString pageTitle(){return mPageTitle;} |
||||
|
||||
// Actions
|
||||
QVector<sAction>* actions(){return &mActionList;} |
||||
|
||||
// Medias
|
||||
QVector<QWidget*>* medias(){return &mMediaList;} |
||||
void addMediaUrl(const QString& url){mMediaUrls << url;} |
||||
QStringList* mediaUrls(){return &mMediaUrls;} |
||||
|
||||
// Urls
|
||||
QVector<sLink>* urls(){return &mUrlList;} |
||||
|
||||
// Comments
|
||||
void setComments(const QString& c){mComments = c;} |
||||
QString comments(){return mComments;} |
||||
|
||||
// Keywords
|
||||
void setKeywords(const QString& kw){mKeywords = kw;} |
||||
QString keywords(){return mKeywords;} |
||||
|
||||
// Level
|
||||
void setLevel(const QString& level){mLevel = level;} |
||||
QString level(){return mLevel;} |
||||
|
||||
// Topic
|
||||
void setTopic(const QString& topic){mTopic = topic;} |
||||
QString topic(){return mTopic;} |
||||
|
||||
// Authors
|
||||
void setAuthors(const QString& authors){mAuthors = authors;} |
||||
QString authors(){return mAuthors;} |
||||
|
||||
|
||||
// Others
|
||||
void clearLists(); |
||||
void saveContent(); |
||||
void loadContent(bool docChanged = false); |
||||
|
||||
private: |
||||
QString mSessionTitle; |
||||
QString mSessionTarget; |
||||
eLicense mSessionLicence; |
||||
QString mPageTitle; |
||||
QString mComments; |
||||
QString mKeywords; |
||||
QString mLevel; |
||||
QString mTopic; |
||||
QString mAuthors; |
||||
|
||||
QVector<sAction> mActionList; |
||||
QVector<sLink> mUrlList; |
||||
QVector<QWidget*> mMediaList; |
||||
QStringList mMediaUrls; |
||||
}; |
||||
|
||||
#endif // UBTEACHERBARDATAMGR_H
|
@ -0,0 +1,354 @@ |
||||
#include "core/UBApplication.h" |
||||
#include "customWidgets/UBGlobals.h" |
||||
#include "board/UBBoardController.h" |
||||
#include "frameworks/UBFileSystemUtils.h" |
||||
|
||||
#include "UBTeacherBarPreviewWidget.h" |
||||
|
||||
|
||||
UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) |
||||
{ |
||||
setObjectName(name); |
||||
mWidget = new UBWidgetList(parent); |
||||
mLayout.addWidget(mWidget); |
||||
setLayout(&mLayout); |
||||
mWidgetList.clear(); |
||||
} |
||||
|
||||
UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() |
||||
{ |
||||
DELETEPTR(mWidget); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewMedia::cleanMedia() |
||||
{ |
||||
foreach(QWidget* eachWidget, mWidgetList.keys()){ |
||||
if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ |
||||
mWidget->removeWidget(eachWidget); |
||||
delete eachWidget; |
||||
eachWidget = NULL; |
||||
} |
||||
else{ |
||||
mWidget->removeWidget(eachWidget); |
||||
} |
||||
} |
||||
mWidgetList.clear(); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewMedia::loadWidgets(QList<QWidget*> pWidgetsList, bool isResizable) |
||||
{ |
||||
foreach(QWidget*eachWidget, pWidgetsList){ |
||||
mWidget->addWidget(eachWidget); |
||||
mWidgetList[eachWidget]="DRAG UNAVAILABLE"; |
||||
} |
||||
} |
||||
|
||||
|
||||
//int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
|
||||
//{
|
||||
// int addedMedia = 0;
|
||||
//// foreach(QString eachString, pMedias){
|
||||
//// if(!eachString.isEmpty()){
|
||||
//// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
|
||||
//// if(mimeType.contains("image")){
|
||||
//// UBDraggableLabel* label = new UBDraggableLabel();
|
||||
//// label->loadImage(eachString);
|
||||
//// mWidget->addWidget(label);
|
||||
//// mWidgetList[label]=eachString;
|
||||
//// addedMedia += 1;
|
||||
//// }
|
||||
//// else if(mimeType.contains("video") || mimeType.contains("audio")){
|
||||
//// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer();
|
||||
//// mediaPlayer->setFile(eachString);
|
||||
//// mWidget->addWidget(mediaPlayer);
|
||||
//// mWidgetList[mediaPlayer] = eachString;
|
||||
//// addedMedia += 1;
|
||||
//// }
|
||||
//// else{
|
||||
//// qWarning() << "pMediaPath" << eachString;
|
||||
//// qWarning() << "bad idea to come here";
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
// return addedMedia;
|
||||
//}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) |
||||
, mpOwner(NULL) |
||||
, mpContent(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
setLayout(&mLayout); |
||||
mpOwner = new QLabel(this); |
||||
mpOwner->setObjectName("UBActionPreviewOwner"); |
||||
mOwnerLayout.addWidget(mpOwner, 0); |
||||
mOwnerLayout.addStretch(1); |
||||
mLayout.addLayout(&mOwnerLayout); |
||||
mpContent = new QTextEdit(this); |
||||
mpContent->setReadOnly(true); |
||||
mpContent->setObjectName("UBActionPreviewContent"); |
||||
//mpContent->setWordWrap(true);
|
||||
mLayout.addWidget(mpContent); |
||||
setContentsMargins(-9, -9, -9, -9); |
||||
} |
||||
|
||||
UBActionPreview::~UBActionPreview() |
||||
{ |
||||
if(NULL != mpOwner){ |
||||
delete mpOwner; |
||||
mpOwner = NULL; |
||||
} |
||||
if(NULL != mpContent){ |
||||
delete mpContent; |
||||
mpContent = NULL; |
||||
} |
||||
} |
||||
|
||||
void UBActionPreview::setOwner(int owner) |
||||
{ |
||||
if(NULL != mpOwner && NULL != mpContent){ |
||||
switch(owner){ |
||||
case eActionOwner_Teacher: |
||||
mpOwner->setText(tr("Teacher")); |
||||
mpContent->setStyleSheet("background:lightblue; border:lightblue;"); |
||||
break; |
||||
|
||||
case eActionOwner_Student: |
||||
mpOwner->setText(tr("Student")); |
||||
mpContent->setStyleSheet("background:lightgreen; border:lightgreen;"); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBActionPreview::setContent(const QString &content) |
||||
{ |
||||
if(NULL != mpContent){ |
||||
mpContent->setText(content); |
||||
setMinimumHeight(mpOwner->height() + mpContent->document()->documentLayout()->documentSize().toSize().height()); |
||||
} |
||||
} |
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) |
||||
{ |
||||
setObjectName(name); |
||||
} |
||||
|
||||
UBTBPreviewContainer::~UBTBPreviewContainer() |
||||
{ |
||||
|
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpEditButton(NULL) |
||||
, mpSessionTitle(NULL) |
||||
, mpTitle(NULL) |
||||
, mpTitleLabel(NULL) |
||||
, mpPageNbrLabel(NULL) |
||||
, mpContentContainer(NULL) |
||||
, mpScheduleLabel(NULL) |
||||
, mpLicenseLabel(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
mpDataMgr = pDataMgr; |
||||
setLayout(&mLayout); |
||||
|
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
// Build the Preview widget
|
||||
// Session Title
|
||||
mTitleContainer.setLayout(&mTitleLayout); |
||||
mpSessionTitle = new QLabel(this); |
||||
mpSessionTitle->setText(tr("Session: ")); |
||||
mpSessionTitle->setWordWrap(true); |
||||
mpSessionTitle->setAlignment(Qt::AlignRight); |
||||
mpSessionTitle->setObjectName("UBTBPreviewSessionTitle"); |
||||
mLayout.addWidget(mpSessionTitle); |
||||
|
||||
// Title
|
||||
mTitleContainer.setLayout(&mTitleLayout); |
||||
mTitleLayout.setContentsMargins(0, 0, 0, 0); |
||||
mpTitleLabel = new QLabel(&mTitleContainer); |
||||
mpTitleLabel->setText(tr("Activity")); |
||||
mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mTitleLayout.addWidget(mpTitleLabel, 0); |
||||
mpTitle = new QLabel(&mTitleContainer); |
||||
mpTitle->setObjectName("UBTeacherBarPreviewTitle"); |
||||
mpTitle->setWordWrap(true); |
||||
mpTitle->setAlignment(Qt::AlignLeft); |
||||
mTitleLayout.addWidget(mpTitle, 1); |
||||
mpPageNbrLabel = new QLabel(tr("Page n° "), &mTitleContainer); |
||||
mpPageNbrLabel->setAlignment(Qt::AlignRight); |
||||
mpPageNbrLabel->setObjectName("UBTBPreviewSessionTitle"); |
||||
mTitleLayout.addWidget(mpPageNbrLabel); |
||||
mTitleLayout.addWidget(&mTitleSeparator); |
||||
mLayout.addWidget(&mTitleContainer); |
||||
|
||||
// Content
|
||||
mpContentContainer = new UBTBPreviewContainer(this); |
||||
mLayout.addWidget(mpContentContainer, 1); |
||||
|
||||
// License
|
||||
mLayout.addWidget(&mLicenseSeparator); |
||||
mpLicenseLabel = new UBTBLicenseWidget(this); |
||||
mLayout.addWidget(mpLicenseLabel); |
||||
|
||||
// Edit button
|
||||
mpEditButton = new QPushButton(tr("Edit infos"), this); |
||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
||||
mEditLayout.addStretch(1); |
||||
mEditLayout.addWidget(mpEditButton, 0); |
||||
mEditLayout.addStretch(1); |
||||
mLayout.addLayout(&mEditLayout, 0); |
||||
|
||||
|
||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
||||
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); |
||||
} |
||||
|
||||
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() |
||||
{ |
||||
DELETEPTR(mpEditButton); |
||||
DELETEPTR(mpLicenseLabel); |
||||
DELETEPTR(mpScheduleLabel); |
||||
DELETEPTR(mpPageNbrLabel); |
||||
DELETEPTR(mpTitle); |
||||
DELETEPTR(mpTitleLabel); |
||||
DELETEPTR(mpSessionTitle); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::onActiveSceneChanged() |
||||
{ |
||||
mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::onEdit() |
||||
{ |
||||
emit showEditMode(); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::updateFields() |
||||
{ |
||||
// Session Title
|
||||
if("" != mpDataMgr->sessionTitle()){ |
||||
mpSessionTitle->setText(mpDataMgr->sessionTitle()); |
||||
mpSessionTitle->setVisible(true); |
||||
}else{ |
||||
mpSessionTitle->setVisible(false); |
||||
} |
||||
|
||||
// Page Title
|
||||
if("" != mpDataMgr->pageTitle()){ |
||||
mpTitle->setText(mpDataMgr->pageTitle()); |
||||
mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); |
||||
mTitleContainer.setVisible(true); |
||||
}else{ |
||||
mTitleContainer.setVisible(false); |
||||
} |
||||
|
||||
// Actions
|
||||
generateActions(); |
||||
|
||||
// Media
|
||||
generateMedias(); |
||||
|
||||
// Comments
|
||||
generateComments(); |
||||
|
||||
// Links
|
||||
generateLinks(); |
||||
|
||||
// License
|
||||
mpLicenseLabel->setLicense(mpDataMgr->sessionLicence()); |
||||
|
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::clearFields() |
||||
{ |
||||
// Session Title
|
||||
mpSessionTitle->setText(""); |
||||
|
||||
// Page Title
|
||||
mpTitle->setText(""); |
||||
|
||||
// Medias
|
||||
if(!mStoredWidgets.empty()){ |
||||
foreach(QWidget* pW, mStoredWidgets){ |
||||
mpContentContainer->removeWidget(pW); |
||||
DELETEPTR(pW); |
||||
} |
||||
mStoredWidgets.clear(); |
||||
} |
||||
|
||||
// License
|
||||
mpLicenseLabel->setLicense(eLicense_CCBY); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::generateActions() |
||||
{ |
||||
if(!mpDataMgr->actions()->empty()){ |
||||
foreach(sAction act, *mpDataMgr->actions()){ |
||||
mpTmpAction = new UBActionPreview(this); |
||||
mpTmpAction->setOwner(act.type); |
||||
mpTmpAction->setContent(act.content); |
||||
mpContentContainer->addWidget(mpTmpAction); |
||||
mStoredWidgets << mpTmpAction; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::generateMedias() |
||||
{ |
||||
if(isVisible()){ |
||||
foreach(QString mediaUrl, *mpDataMgr->mediaUrls()){ |
||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl); |
||||
if(mimeType.contains("image")){ |
||||
mpTmpLabel = new UBDraggableLabel(); |
||||
mpTmpLabel->loadImage(mediaUrl); |
||||
mStoredWidgets << mpTmpLabel; |
||||
mpContentContainer->addWidget(mpTmpLabel); |
||||
} |
||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
||||
UBDraggableMedia* mediaPlayer = new UBDraggableMedia(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
||||
mediaPlayer->setFile(mediaUrl); |
||||
mStoredWidgets << mediaPlayer; |
||||
mpContentContainer->addWidget(mediaPlayer); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::generateLinks() |
||||
{ |
||||
if(!mpDataMgr->urls()->empty()){ |
||||
foreach(sLink link, *mpDataMgr->urls()){ |
||||
mpTmpLink = new QLabel(QString("<a href='%0'>%1</a>").arg(link.link).arg(link.title), this); |
||||
mpTmpLink->setObjectName("UBLinkPreview"); |
||||
mpTmpLink->setOpenExternalLinks(true); |
||||
mpContentContainer->addWidget(mpTmpLink); |
||||
mStoredWidgets << mpTmpLink; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::generateComments() |
||||
{ |
||||
if("" != mpDataMgr->comments()){ |
||||
mpTmpComment = new QTextEdit(this); |
||||
mpTmpComment->setObjectName("UBCommentPreview"); |
||||
mpTmpComment->setPlainText(mpDataMgr->comments()); |
||||
mpTmpComment->setReadOnly(true); |
||||
mpContentContainer->addWidget(mpTmpComment); |
||||
mStoredWidgets << mpTmpComment; |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) |
||||
{ |
||||
updateFields(); |
||||
} |
||||
|
@ -0,0 +1,120 @@ |
||||
#ifndef UBTEACHERBARPREVIEWWIDGET_H |
||||
#define UBTEACHERBARPREVIEWWIDGET_H |
||||
|
||||
#include <QLabel> |
||||
#include <QVBoxLayout> |
||||
#include <QPushButton> |
||||
|
||||
#include "core/UBPersistenceManager.h" |
||||
#include "customWidgets/UBWidgetList.h" |
||||
#include "customWidgets/UBMediaWidget.h" |
||||
#include "customWidgets/UBDraggableMedia.h" |
||||
#include "customWidgets/UBDraggableLabel.h" |
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
class UBTeacherBarPreviewMedia : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); |
||||
~UBTeacherBarPreviewMedia(); |
||||
// int loadMedia(QStringList pMedias);
|
||||
void loadWidgets(QList<QWidget*> pWidgetList, bool isResizable = true); |
||||
void cleanMedia(); |
||||
|
||||
private: |
||||
UBWidgetList* mWidget; |
||||
QVBoxLayout mLayout; |
||||
QMap<QWidget*,QString>mWidgetList; |
||||
}; |
||||
|
||||
class UBActionPreview : public QWidget |
||||
{ |
||||
public: |
||||
UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); |
||||
~UBActionPreview(); |
||||
void setOwner(int owner); |
||||
void setContent(const QString& content); |
||||
|
||||
private: |
||||
QLabel* mpOwner; |
||||
QTextEdit* mpContent; |
||||
|
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mOwnerLayout; |
||||
}; |
||||
|
||||
class UBTBPreviewContainer : public UBWidgetList |
||||
{ |
||||
public: |
||||
UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer"); |
||||
~UBTBPreviewContainer(); |
||||
}; |
||||
|
||||
class UBTeacherBarPreviewWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); |
||||
~UBTeacherBarPreviewWidget(); |
||||
void updateFields(); |
||||
void clearFields(); |
||||
|
||||
signals: |
||||
void showEditMode(); |
||||
|
||||
protected: |
||||
void showEvent(QShowEvent* ev); |
||||
|
||||
private slots: |
||||
void onEdit(); |
||||
void onActiveSceneChanged(); |
||||
|
||||
private: |
||||
void generateActions(); |
||||
void generateMedias(); |
||||
void generateLinks(); |
||||
void generateComments(); |
||||
|
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mEditLayout; |
||||
QPushButton* mpEditButton; |
||||
|
||||
// Titles
|
||||
QVBoxLayout mTitleLayout; |
||||
UBTBSeparator mTitleSeparator; |
||||
QWidget mTitleContainer; |
||||
QLabel* mpSessionTitle; |
||||
QLabel* mpTitle; |
||||
QLabel* mpTitleLabel; |
||||
QLabel* mpPageNbrLabel; |
||||
UBTBPreviewContainer* mpContentContainer; |
||||
|
||||
// Schedule
|
||||
QLabel* mpScheduleLabel; |
||||
|
||||
// License
|
||||
UBTBSeparator mLicenseSeparator; |
||||
// TODO : replace the QLabel of the license by a widget done for that!
|
||||
UBTBLicenseWidget* mpLicenseLabel; |
||||
|
||||
|
||||
/** Pointer to the datas */ |
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
/** The list of stored widgets */ |
||||
QList<QWidget*> mStoredWidgets; |
||||
/** A temporary action widget */ |
||||
UBActionPreview* mpTmpAction; |
||||
/** A temporary media widget */ |
||||
UBTeacherBarPreviewMedia* mpTmpMedia; |
||||
/** A temporary link */ |
||||
QLabel* mpTmpLink; |
||||
/** A temporary comments field */ |
||||
QTextEdit* mpTmpComment; |
||||
/** A temporary media object */ |
||||
UBDraggableMedia* mTmpMedia; |
||||
/** A temporary label object */ |
||||
UBDraggableLabel* mpTmpLabel; |
||||
}; |
||||
|
||||
#endif // UBTEACHERBARPREVIEWWIDGET_H
|
@ -0,0 +1,21 @@ |
||||
#ifndef IDROPABLE_H |
||||
#define IDROPABLE_H |
||||
|
||||
#include <QDropEvent> |
||||
#include <QDragEnterEvent> |
||||
#include <QDragLeaveEvent> |
||||
#include <QDragMoveEvent> |
||||
|
||||
class IDropable |
||||
{ |
||||
public: |
||||
virtual ~IDropable(){} |
||||
|
||||
protected: |
||||
virtual void dropEvent(QDropEvent* pEvent) = 0; |
||||
virtual void dragEnterEvent(QDragEnterEvent* pEvent) = 0; |
||||
virtual void dragMoveEvent(QDragMoveEvent* pEvent) = 0; |
||||
virtual void dragLeaveEvent(QDragLeaveEvent* pEvent) = 0; |
||||
}; |
||||
|
||||
#endif // IDROPABLE_H
|
@ -0,0 +1,15 @@ |
||||
#ifndef IRESIZEABLE_H |
||||
#define IRESIZEABLE_H |
||||
|
||||
#include <QResizeEvent> |
||||
|
||||
class IResizeable |
||||
{ |
||||
public: |
||||
~IResizeable(); |
||||
|
||||
protected: |
||||
virtual void resizeEvent(QResizeEvent* pEvent) = 0; |
||||
}; |
||||
|
||||
#endif // IRESIZEABLE_H
|
@ -0,0 +1,3 @@ |
||||
HEADERS += src/interfaces/IDropable.h \ |
||||
src/interfaces/IDropable.h \ |
||||
src/interfaces/IResizeable.h |