commit
33d2bfab24
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
@ -1,39 +0,0 @@ |
|||||||
#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(); |
|
||||||
} |
|
@ -1,23 +0,0 @@ |
|||||||
#ifndef UBDRAGGABLELABEL_H |
|
||||||
#define UBDRAGGABLELABEL_H |
|
||||||
|
|
||||||
#include <QLabel> |
|
||||||
|
|
||||||
class UBDraggableLabel : public QLabel |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBDraggableLabel(QWidget *parent = 0); |
|
||||||
~UBDraggableLabel(); |
|
||||||
void loadImage(QString imagePath); |
|
||||||
signals: |
|
||||||
|
|
||||||
public slots: |
|
||||||
|
|
||||||
protected: |
|
||||||
QString mSourcePath; |
|
||||||
void mousePressEvent(QMouseEvent *event); |
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBDRAGGABLELABEL_H
|
|
@ -1,42 +0,0 @@ |
|||||||
#include <QApplication> |
|
||||||
#include <QUrl> |
|
||||||
|
|
||||||
#include "UBDraggableMedia.h" |
|
||||||
|
|
||||||
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) |
|
||||||
{ |
|
||||||
removeAllActions(); |
|
||||||
} |
|
||||||
|
|
||||||
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); |
|
||||||
|
|
||||||
drag->exec(Qt::CopyAction | Qt::MoveAction); |
|
||||||
} |
|
@ -1,19 +0,0 @@ |
|||||||
#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
|
|
@ -1,229 +0,0 @@ |
|||||||
#include <QDebug> |
|
||||||
#include <QScrollBar> |
|
||||||
#include <QApplication> |
|
||||||
#include <QPainter> |
|
||||||
|
|
||||||
#include "globals/UBGlobals.h" |
|
||||||
#include "UBWidgetList.h" |
|
||||||
|
|
||||||
UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) |
|
||||||
, mCanRemove(true) |
|
||||||
, mpLayout(NULL) |
|
||||||
, mpContainer(NULL) |
|
||||||
, mMargin(10) |
|
||||||
, mListElementsSpacing(10) |
|
||||||
, mpEmptyLabel(NULL) |
|
||||||
, mpCurrentWidget(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); |
|
||||||
} |
|
||||||
if(mpCurrentWidget == widget){ |
|
||||||
mpCurrentWidget = NULL; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
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::mousePressEvent(QMouseEvent *ev) |
|
||||||
{ |
|
||||||
Q_UNUSED(ev); |
|
||||||
if(mCanRemove){ |
|
||||||
QWidget* pWAt = widgetAt(ev->pos()); |
|
||||||
if(NULL != mpCurrentWidget){ |
|
||||||
if(pWAt != mpCurrentWidget){ |
|
||||||
mpCurrentWidget->setActionsVisible(false); |
|
||||||
update(); |
|
||||||
} |
|
||||||
} |
|
||||||
mpCurrentWidget = dynamic_cast<UBActionableWidget*>(pWAt); |
|
||||||
if(NULL != mpCurrentWidget){ |
|
||||||
mpCurrentWidget->setActionsVisible(true); |
|
||||||
update(); |
|
||||||
} |
|
||||||
} |
|
||||||
update(); |
|
||||||
} |
|
||||||
|
|
||||||
QWidget* UBWidgetList::widgetAt(QPoint p) |
|
||||||
{ |
|
||||||
QWidget* pW = NULL; |
|
||||||
pW = childAt(p); |
|
||||||
if(NULL != pW){ |
|
||||||
do{ |
|
||||||
if( "UBTeacherStudentAction" == pW->objectName() || |
|
||||||
"UBUrlWidget" == pW->objectName() || |
|
||||||
"UBTBMediaPicture" == pW->objectName() || |
|
||||||
"UBMediaWidget" == pW->objectName()){ |
|
||||||
return pW; |
|
||||||
}else{ |
|
||||||
pW = pW->parentWidget(); |
|
||||||
} |
|
||||||
}while(NULL != pW && this != pW); |
|
||||||
} |
|
||||||
|
|
||||||
return pW; |
|
||||||
} |
|
||||||
|
|
||||||
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(); |
|
||||||
} |
|
@ -1,69 +0,0 @@ |
|||||||
#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" |
|
||||||
#include "customWidgets/UBActionableWidget.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; } |
|
||||||
|
|
||||||
signals: |
|
||||||
void closeWidget(QWidget* w); |
|
||||||
|
|
||||||
protected: |
|
||||||
bool mCanRemove; |
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent* ev); |
|
||||||
void mousePressEvent(QMouseEvent* ev); |
|
||||||
|
|
||||||
private: |
|
||||||
QWidget* widgetAt(QPoint p); |
|
||||||
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; |
|
||||||
UBActionableWidget* mpCurrentWidget; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBWIDGETLIST_H
|
|
@ -1,13 +1,8 @@ |
|||||||
|
|
||||||
HEADERS += src/customWidgets/UBWidgetList.h \ |
HEADERS += \ |
||||||
src/customWidgets/UBDraggableLabel.h \ |
|
||||||
src/customWidgets/UBMediaWidget.h \ |
src/customWidgets/UBMediaWidget.h \ |
||||||
src/globals/UBGlobals.h \ |
|
||||||
src/customWidgets/UBDraggableMedia.h \ |
|
||||||
src/customWidgets/UBActionableWidget.h |
src/customWidgets/UBActionableWidget.h |
||||||
|
|
||||||
SOURCES += src/customWidgets/UBWidgetList.cpp \ |
SOURCES += \ |
||||||
src/customWidgets/UBDraggableLabel.cpp \ |
|
||||||
src/customWidgets/UBMediaWidget.cpp \ |
src/customWidgets/UBMediaWidget.cpp \ |
||||||
src/customWidgets/UBDraggableMedia.cpp \ |
|
||||||
src/customWidgets/UBActionableWidget.cpp |
src/customWidgets/UBActionableWidget.cpp |
||||||
|
@ -0,0 +1,44 @@ |
|||||||
|
/*
|
||||||
|
* 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 "globals/UBGlobals.h" |
||||||
|
|
||||||
|
#include "UBDockTeacherGuideWidget.h" |
||||||
|
#include "UBTeacherGuideWidget.h" |
||||||
|
|
||||||
|
|
||||||
|
UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name): |
||||||
|
UBDockPaletteWidget(parent,name) |
||||||
|
, mpTeacherGuideWidget(NULL) |
||||||
|
{ |
||||||
|
mName = "TeacherGuide"; |
||||||
|
|
||||||
|
SET_STYLE_SHEET(); |
||||||
|
|
||||||
|
mIconToLeft = QPixmap(":images/teacher_open.png"); |
||||||
|
mIconToRight = QPixmap(":images/teacher_close.png"); |
||||||
|
|
||||||
|
mpLayout = new QVBoxLayout(this); |
||||||
|
setLayout(mpLayout); |
||||||
|
mpTeacherGuideWidget = new UBTeacherGuideWidget(this); |
||||||
|
mpLayout->addWidget(mpTeacherGuideWidget); |
||||||
|
} |
||||||
|
|
||||||
|
UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpTeacherGuideWidget); |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBDOCKTEACHERGUIDEWIDGET_H |
||||||
|
#define UBDOCKTEACHERGUIDEWIDGET_H |
||||||
|
|
||||||
|
class QVBoxLayout; |
||||||
|
class UBTeacherGuideWidget; |
||||||
|
|
||||||
|
#include "UBDockPaletteWidget.h" |
||||||
|
|
||||||
|
|
||||||
|
class UBDockTeacherGuideWidget : public UBDockPaletteWidget |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
UBDockTeacherGuideWidget(QWidget* parent=0, const char* name="UBDockTeacherGuideWidget"); |
||||||
|
~UBDockTeacherGuideWidget(); |
||||||
|
|
||||||
|
bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; } |
||||||
|
|
||||||
|
private: |
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
UBTeacherGuideWidget* mpTeacherGuideWidget; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBDOCKTEACHERGUIDEWIDGET_H
|
@ -1,389 +0,0 @@ |
|||||||
#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])); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
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) |
|
||||||
{ |
|
||||||
Q_UNUSED(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(); |
|
||||||
} |
|
||||||
|
|
@ -1,107 +0,0 @@ |
|||||||
#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,34 @@ |
|||||||
|
|
||||||
|
#include <QApplication> |
||||||
|
#include <QStyleOptionButton> |
||||||
|
#include <QStyledItemDelegate> |
||||||
|
#include <QStyleOptionViewItem> |
||||||
|
#include <QPainter> |
||||||
|
#include <QModelIndex> |
||||||
|
#include "UBTGWidgetTreeDelegate.h" |
||||||
|
|
||||||
|
UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) : |
||||||
|
QStyledItemDelegate(parent) |
||||||
|
{ |
||||||
|
//NOOP
|
||||||
|
} |
||||||
|
|
||||||
|
void UBTGWidgetTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const |
||||||
|
{ |
||||||
|
if(index.data(Qt::UserRole) != eUBTGAddSubItemWidgetType_None){ |
||||||
|
painter->setBackgroundMode(Qt::OpaqueMode); |
||||||
|
painter->setBackground(QBrush(QColor(Qt::red))); |
||||||
|
QStyleOptionButton styleButton; |
||||||
|
styleButton.text = "pipo"; |
||||||
|
styleButton.rect = option.rect; |
||||||
|
QApplication::style()->drawControl(QStyle::CE_PushButtonLabel,&styleButton,painter); |
||||||
|
} |
||||||
|
else |
||||||
|
QStyledItemDelegate::paint(painter,option,index); |
||||||
|
} |
||||||
|
|
||||||
|
QSize UBTGWidgetTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const |
||||||
|
{ |
||||||
|
QSize size = QStyledItemDelegate::sizeHint(option,index); |
||||||
|
return size; |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
#ifndef UBTGWIDGETTREEDELEGATE_H |
||||||
|
#define UBTGWIDGETTREEDELEGATE_H |
||||||
|
|
||||||
|
class QPainter; |
||||||
|
class QStyleOptionViewItem; |
||||||
|
class QModelIndex; |
||||||
|
|
||||||
|
#include <QStyledItemDelegate> |
||||||
|
|
||||||
|
|
||||||
|
typedef enum |
||||||
|
{ |
||||||
|
eUBTGAddSubItemWidgetType_None, |
||||||
|
eUBTGAddSubItemWidgetType_Action , |
||||||
|
eUBTGAddSubItemWidgetType_Media, |
||||||
|
eUBTGAddSubItemWidgetType_Url |
||||||
|
}eUBTGAddSubItemWidgetType; |
||||||
|
|
||||||
|
|
||||||
|
class UBTGWidgetTreeDelegate : public QStyledItemDelegate |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
explicit UBTGWidgetTreeDelegate(QObject *parent = 0); |
||||||
|
|
||||||
|
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; |
||||||
|
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||||||
|
|
||||||
|
signals: |
||||||
|
|
||||||
|
public slots: |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBTGWIDGETTREEDELEGATE_H
|
@ -0,0 +1,5 @@ |
|||||||
|
#include "UBTeacherGuideDelegate.h" |
||||||
|
|
||||||
|
UBTeacherGuideDelegate::UBTeacherGuideDelegate() |
||||||
|
{ |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
#ifndef UBTEACHERGUIDEDELEGATE_H |
||||||
|
#define UBTEACHERGUIDEDELEGATE_H |
||||||
|
|
||||||
|
class UBTeacherGuideDelegate |
||||||
|
{ |
||||||
|
public: |
||||||
|
UBTeacherGuideDelegate(); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBTEACHERGUIDEDELEGATE_H
|
@ -0,0 +1,500 @@ |
|||||||
|
/*
|
||||||
|
* 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 <QDebug> |
||||||
|
#include <QLabel> |
||||||
|
#include <QVBoxLayout> |
||||||
|
#include <QHeaderView> |
||||||
|
#include <QTreeWidget> |
||||||
|
#include <QPushButton> |
||||||
|
|
||||||
|
#include "UBTeacherGuideWidget.h" |
||||||
|
|
||||||
|
#include "core/UBApplication.h" |
||||||
|
|
||||||
|
#include "globals/UBGlobals.h" |
||||||
|
|
||||||
|
#include "board/UBBoardController.h" |
||||||
|
#include "board/UBBoardView.h" |
||||||
|
#include "board/UBBoardPaletteManager.h" |
||||||
|
|
||||||
|
#include "gui/UBStylusPalette.h" |
||||||
|
#include "gui/UBActionPalette.h" |
||||||
|
|
||||||
|
#include "web/UBWebController.h" |
||||||
|
|
||||||
|
#define UBTG_SEPARATOR_FIXED_HEIGHT 3 |
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuideEditionWidget * |
||||||
|
***************************************************************************/ |
||||||
|
|
||||||
|
UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const char* name) : |
||||||
|
QWidget(parent) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpDocumentTitle(NULL) |
||||||
|
, mpPageNumberLabel(NULL) |
||||||
|
, mpPageTitle(NULL) |
||||||
|
, mpComment(NULL) |
||||||
|
, mpSeparator(NULL) |
||||||
|
, mpTreeWidget(NULL) |
||||||
|
, mpRootWidgetItem(NULL) |
||||||
|
, mpAddAnActionItem(NULL) |
||||||
|
, mpAddAMediaItem(NULL) |
||||||
|
, mpAddALinkItem(NULL) |
||||||
|
, mpTreeDelegate(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
|
||||||
|
mpLayout = new QVBoxLayout(this); |
||||||
|
mpPageNumberLabel = new QLabel(this); |
||||||
|
mpPageNumberLabel->setAlignment(Qt::AlignRight); |
||||||
|
mpPageNumberLabel->setObjectName("UBTGEditionPageNumberLabel"); |
||||||
|
mpLayout->addWidget(mpPageNumberLabel); |
||||||
|
// tree basic configuration
|
||||||
|
mpDocumentTitle = new QLabel(this); |
||||||
|
mpDocumentTitle->setText("Document title"); |
||||||
|
mpDocumentTitle->setObjectName("UBTGEditionDocumentTitle"); |
||||||
|
mpLayout->addWidget(mpDocumentTitle); |
||||||
|
|
||||||
|
mpPageTitle = new UBTGAdaptableText(0,this); |
||||||
|
mpPageTitle->setObjectName("UBTGEditionPageTitle"); |
||||||
|
mpPageTitle->setPlaceHolderText(tr("Type title here ...")); |
||||||
|
mpLayout->addWidget(mpPageTitle); |
||||||
|
|
||||||
|
mpComment = new UBTGAdaptableText(0,this); |
||||||
|
mpComment->setObjectName("UBTGEditionComment"); |
||||||
|
mpComment->setPlaceHolderText(tr("Type comment here ...")); |
||||||
|
mpLayout->addWidget(mpComment); |
||||||
|
|
||||||
|
mpSeparator = new QFrame(this); |
||||||
|
mpSeparator->setObjectName("UBTGEditionSeparator"); |
||||||
|
mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); |
||||||
|
mpLayout->addWidget(mpSeparator); |
||||||
|
|
||||||
|
mpTreeWidget = new QTreeWidget(this); |
||||||
|
mpLayout->addWidget(mpTreeWidget); |
||||||
|
|
||||||
|
mpTreeDelegate = new UBTGWidgetTreeDelegate(); |
||||||
|
|
||||||
|
mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); |
||||||
|
//mpTreeWidget->setItemDelegate(mpTreeDelegate);
|
||||||
|
mpTreeWidget->setRootIsDecorated(false); |
||||||
|
mpTreeWidget->setIndentation(0); |
||||||
|
mpTreeWidget->setDropIndicatorShown(false); |
||||||
|
mpTreeWidget->header()->close(); |
||||||
|
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||||
|
mpTreeWidget->setColumnCount(2); |
||||||
|
mpTreeWidget->header()->setStretchLastSection(false); |
||||||
|
mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); |
||||||
|
mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); |
||||||
|
mpTreeWidget->header()->setDefaultSectionSize(18); |
||||||
|
|
||||||
|
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); |
||||||
|
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); |
||||||
|
|
||||||
|
mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget); |
||||||
|
mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget); |
||||||
|
mpAddALinkItem = new UBAddItem(tr("Add a link"),eUBTGAddSubItemWidgetType_Url,mpTreeWidget); |
||||||
|
|
||||||
|
mpRootWidgetItem->addChild(mpAddAnActionItem); |
||||||
|
mpRootWidgetItem->addChild(mpAddAMediaItem); |
||||||
|
mpRootWidgetItem->addChild(mpAddALinkItem); |
||||||
|
} |
||||||
|
|
||||||
|
UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpDocumentTitle); |
||||||
|
DELETEPTR(mpPageNumberLabel); |
||||||
|
DELETEPTR(mpPageTitle); |
||||||
|
DELETEPTR(mpComment); |
||||||
|
DELETEPTR(mpSeparator); |
||||||
|
DELETEPTR(mpAddAnActionItem); |
||||||
|
DELETEPTR(mpAddAMediaItem); |
||||||
|
DELETEPTR(mpAddALinkItem); |
||||||
|
DELETEPTR(mpTreeDelegate); |
||||||
|
DELETEPTR(mpTreeWidget) |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) |
||||||
|
{ |
||||||
|
mpPageTitle->setFocus(); |
||||||
|
mpComment->setFocus(); |
||||||
|
setFocus(); |
||||||
|
QWidget::showEvent(event); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideEditionWidget::onActiveSceneChanged() |
||||||
|
{ |
||||||
|
cleanData(); |
||||||
|
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideEditionWidget::cleanData() |
||||||
|
{ |
||||||
|
mpPageTitle->setText(""); |
||||||
|
mpComment->setText(""); |
||||||
|
QList<QTreeWidgetItem*> children = mpAddAnActionItem->takeChildren(); |
||||||
|
children << mpAddAMediaItem->takeChildren(); |
||||||
|
children << mpAddALinkItem->takeChildren(); |
||||||
|
|
||||||
|
foreach(QTreeWidgetItem* item, children){ |
||||||
|
DELETEPTR(item); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> UBTeacherGuideEditionWidget::getChildrenList(QTreeWidgetItem* widgetItem) |
||||||
|
{ |
||||||
|
QList<QTreeWidgetItem*>result; |
||||||
|
for(int i=0;i<widgetItem->childCount();i+=1) |
||||||
|
result << widgetItem->child(i); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getPageAndCommentData() |
||||||
|
{ |
||||||
|
QVector<tUBGEElementNode*>result; |
||||||
|
tUBGEElementNode* pageTitle = new tUBGEElementNode(); |
||||||
|
pageTitle->type = "pageTitle"; |
||||||
|
pageTitle->attributes.insert("value",mpPageTitle->text()); |
||||||
|
result << pageTitle; |
||||||
|
|
||||||
|
tUBGEElementNode* comment = new tUBGEElementNode(); |
||||||
|
comment->type = "comment"; |
||||||
|
comment->attributes.insert("value",mpComment->text()); |
||||||
|
result << comment; |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getData() |
||||||
|
{ |
||||||
|
QVector<tUBGEElementNode*>result; |
||||||
|
QList<QTreeWidgetItem*> children = getChildrenList(mpAddAnActionItem); |
||||||
|
children << getChildrenList(mpAddAMediaItem); |
||||||
|
children << getChildrenList(mpAddALinkItem); |
||||||
|
result << getPageAndCommentData(); |
||||||
|
foreach(QTreeWidgetItem* widgetItem, children){ |
||||||
|
tUBGEElementNode* node = dynamic_cast<iUBTGSavableData*>(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); |
||||||
|
if(node) |
||||||
|
result << node; |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) |
||||||
|
{ |
||||||
|
int addSubItemWidgetType = widget->data(column,Qt::UserRole).toInt(); |
||||||
|
if(column == 0 && addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){ |
||||||
|
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget); |
||||||
|
newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None); |
||||||
|
newWidgetItem->setData(1,Qt::UserRole,eUBTGAddSubItemWidgetType_None); |
||||||
|
newWidgetItem->setIcon(1,QIcon(":images/close.svg")); |
||||||
|
switch(addSubItemWidgetType) |
||||||
|
{ |
||||||
|
case eUBTGAddSubItemWidgetType_Action: |
||||||
|
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGActionWidget(widget)); |
||||||
|
break; |
||||||
|
case eUBTGAddSubItemWidgetType_Media: |
||||||
|
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGMediaWidget(widget)); |
||||||
|
break; |
||||||
|
case eUBTGAddSubItemWidgetType_Url: |
||||||
|
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGUrlWidget()); |
||||||
|
break; |
||||||
|
default: |
||||||
|
delete newWidgetItem; |
||||||
|
qCritical() << "onAddItemClicked no action set"; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() ) |
||||||
|
widget->setExpanded(true); |
||||||
|
else{ |
||||||
|
//to update the tree and subtrees
|
||||||
|
widget->setExpanded(false); |
||||||
|
widget->setExpanded(true); |
||||||
|
} |
||||||
|
} |
||||||
|
else if(column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None){ |
||||||
|
int index = mpTreeWidget->currentIndex().row(); |
||||||
|
QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index); |
||||||
|
delete toBeDeletedWidgetItem; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuidePresentationWidget * |
||||||
|
***************************************************************************/ |
||||||
|
typedef enum
|
||||||
|
{ |
||||||
|
tUBTGActionAssociateOnClickItem_NONE, |
||||||
|
tUBTGActionAssociateOnClickItem_URL, |
||||||
|
tUBTGActionAssociateOnClickItem_MEDIA, |
||||||
|
tUBTGActionAssociateOnClickItem_EXPAND |
||||||
|
}tUBTGActionAssociateOnClickItem; |
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{ |
||||||
|
tUBTGTreeWidgetItemRole_HasAnAction = Qt::UserRole, |
||||||
|
tUBTGTreeWidgetItemRole_HasAnUrl |
||||||
|
}tUBTGTreeWidgetItemRole; |
||||||
|
|
||||||
|
|
||||||
|
UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : QWidget(parent) |
||||||
|
, mpPageTitle(NULL) |
||||||
|
, mpComment(NULL) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpButtonTitleLayout(NULL) |
||||||
|
, mpDocumentTitle(NULL) |
||||||
|
, mpPageNumberLabel(NULL) |
||||||
|
, mpSeparator(NULL) |
||||||
|
, mpModePushButton(NULL) |
||||||
|
, mpTreeWidget(NULL) |
||||||
|
, mpRootWidgetItem(NULL) |
||||||
|
, mpMediaSwitchItem(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
|
||||||
|
mpLayout = new QVBoxLayout(this); |
||||||
|
|
||||||
|
mpPageNumberLabel = new QLabel(this); |
||||||
|
mpPageNumberLabel->setAlignment(Qt::AlignRight); |
||||||
|
mpPageNumberLabel->setObjectName("UBTGPresentationPageNumberLabel"); |
||||||
|
|
||||||
|
mpLayout->addWidget(mpPageNumberLabel); |
||||||
|
|
||||||
|
mpButtonTitleLayout = new QHBoxLayout(0); |
||||||
|
|
||||||
|
mpModePushButton = new QPushButton(this); |
||||||
|
mpModePushButton->setIcon(QIcon(":images/pencil.svg")); |
||||||
|
mpModePushButton->setMaximumWidth(32); |
||||||
|
|
||||||
|
connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode())); |
||||||
|
|
||||||
|
mpDocumentTitle = new QLabel(this); |
||||||
|
mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); |
||||||
|
mpDocumentTitle->setText(tr("Document title")); |
||||||
|
|
||||||
|
mpButtonTitleLayout->addWidget(mpModePushButton); |
||||||
|
mpButtonTitleLayout->addWidget(mpDocumentTitle); |
||||||
|
|
||||||
|
mpLayout->addLayout(mpButtonTitleLayout); |
||||||
|
|
||||||
|
mpPageTitle = new UBTGAdaptableText(0,this); |
||||||
|
mpPageTitle->setObjectName("UBTGPresentationPageTitle"); |
||||||
|
mpPageTitle->setReadOnly(true); |
||||||
|
mpPageTitle->setStyleSheet("background-color:transparent"); |
||||||
|
mpLayout->addWidget(mpPageTitle); |
||||||
|
|
||||||
|
mpComment = new UBTGAdaptableText(0,this); |
||||||
|
mpComment->setObjectName("UBTGPresentationComment"); |
||||||
|
mpComment->setReadOnly(true); |
||||||
|
mpComment->setStyleSheet("background-color:transparent"); |
||||||
|
mpLayout->addWidget(mpComment); |
||||||
|
|
||||||
|
mpSeparator = new QFrame(this); |
||||||
|
mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); |
||||||
|
mpSeparator->setObjectName("UBTGPresentationSepartor"); |
||||||
|
mpLayout->addWidget(mpSeparator); |
||||||
|
|
||||||
|
mpTreeWidget = new QTreeWidget(this); |
||||||
|
mpLayout->addWidget(mpTreeWidget); |
||||||
|
|
||||||
|
mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); |
||||||
|
mpTreeWidget->setRootIsDecorated(false); |
||||||
|
mpTreeWidget->setIndentation(0); |
||||||
|
mpTreeWidget->setDropIndicatorShown(false); |
||||||
|
mpTreeWidget->header()->close(); |
||||||
|
mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||||
|
connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); |
||||||
|
connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); |
||||||
|
} |
||||||
|
|
||||||
|
UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpComment); |
||||||
|
DELETEPTR(mpPageTitle); |
||||||
|
DELETEPTR(mpPageNumberLabel); |
||||||
|
DELETEPTR(mpSeparator); |
||||||
|
DELETEPTR(mpMediaSwitchItem); |
||||||
|
DELETEPTR(mpModePushButton); |
||||||
|
DELETEPTR(mpDocumentTitle); |
||||||
|
DELETEPTR(mpButtonTitleLayout); |
||||||
|
DELETEPTR(mpTreeWidget); |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuidePresentationWidget::cleanData() |
||||||
|
{ |
||||||
|
mpPageTitle->showText(""); |
||||||
|
mpComment->showText(""); |
||||||
|
//tree clean
|
||||||
|
QList<QTreeWidgetItem*> itemToRemove = mpRootWidgetItem->takeChildren(); |
||||||
|
foreach(QTreeWidgetItem* eachItem, itemToRemove){ |
||||||
|
DELETEPTR(eachItem); |
||||||
|
} |
||||||
|
// the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero
|
||||||
|
mpMediaSwitchItem = NULL; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuidePresentationWidget::onActiveSceneChanged() |
||||||
|
{ |
||||||
|
cleanData(); |
||||||
|
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuidePresentationWidget::createMediaButtonItem() |
||||||
|
{ |
||||||
|
if(!mpMediaSwitchItem){ |
||||||
|
//create the media button
|
||||||
|
mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem); |
||||||
|
//mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg"));
|
||||||
|
mpMediaSwitchItem->setText(0,"+"); |
||||||
|
mpMediaSwitchItem->setExpanded(false); |
||||||
|
mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND); |
||||||
|
mpMediaSwitchItem->setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); |
||||||
|
mpMediaSwitchItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),16))); |
||||||
|
mpMediaSwitchItem->setData(0,Qt::TextAlignmentRole,QVariant(Qt::AlignCenter)); |
||||||
|
mpRootWidgetItem->addChild(mpMediaSwitchItem); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data) |
||||||
|
{ |
||||||
|
cleanData(); |
||||||
|
|
||||||
|
foreach(tUBGEElementNode* element, data){ |
||||||
|
if(element->type == "pageTitle") |
||||||
|
mpPageTitle->showText(element->attributes.value("value")); |
||||||
|
else if (element->type == "comment") |
||||||
|
mpComment->showText(element->attributes.value("value")); |
||||||
|
else if(element->type == "action"){ |
||||||
|
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); |
||||||
|
newWidgetItem->setText(0,element->attributes.value("task")); |
||||||
|
QColor color = element->attributes.value("owner").toInt() == 0 ? QColor(Qt::red):QColor(Qt::green); |
||||||
|
newWidgetItem->setData(0,Qt::ForegroundRole,QBrush(color)); |
||||||
|
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); |
||||||
|
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); |
||||||
|
mpRootWidgetItem->addChild(newWidgetItem); |
||||||
|
} |
||||||
|
else if(element->type == "media"){ |
||||||
|
createMediaButtonItem(); |
||||||
|
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); |
||||||
|
newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/"+ element->attributes.value("mediaType") +".png")); |
||||||
|
newWidgetItem->setText(0,element->attributes.value("title")); |
||||||
|
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); |
||||||
|
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); |
||||||
|
mpRootWidgetItem->addChild(newWidgetItem); |
||||||
|
|
||||||
|
QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); |
||||||
|
//mediaItem->setBackground(0,QBrush(QColor("#EEEEEF")));
|
||||||
|
mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); |
||||||
|
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem); |
||||||
|
newWidgetItem->setExpanded(false); |
||||||
|
mpTreeWidget->setItemWidget(mediaItem,0,mediaWidget); |
||||||
|
} |
||||||
|
else if(element->type == "link"){ |
||||||
|
createMediaButtonItem(); |
||||||
|
QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); |
||||||
|
newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/link.png")); |
||||||
|
newWidgetItem->setText(0,element->attributes.value("title")); |
||||||
|
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL); |
||||||
|
newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url"))); |
||||||
|
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); |
||||||
|
mpRootWidgetItem->addChild(newWidgetItem); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) |
||||||
|
{ |
||||||
|
int associateAction = widget->data(column,tUBTGTreeWidgetItemRole_HasAnAction).toInt(); |
||||||
|
if(column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE){ |
||||||
|
switch(associateAction) |
||||||
|
{ |
||||||
|
case tUBTGActionAssociateOnClickItem_EXPAND: |
||||||
|
widget->setExpanded(!widget->isExpanded()); |
||||||
|
if(widget->isExpanded()) |
||||||
|
mpMediaSwitchItem->setText(0,"-"); |
||||||
|
else |
||||||
|
mpMediaSwitchItem->setText(0,"+"); |
||||||
|
break; |
||||||
|
case tUBTGActionAssociateOnClickItem_URL: |
||||||
|
widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString(); |
||||||
|
UBApplication::webController->loadUrl(QUrl(widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString())); |
||||||
|
break; |
||||||
|
case tUBTGActionAssociateOnClickItem_MEDIA: |
||||||
|
widget->setExpanded(!widget->isExpanded()); |
||||||
|
break; |
||||||
|
default: |
||||||
|
qDebug() << "associateAction no action set " << associateAction; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuideWidget * |
||||||
|
***************************************************************************/ |
||||||
|
UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget *parent, const char *name): QStackedWidget(parent) |
||||||
|
, mpEditionWidget(NULL) |
||||||
|
, mpPresentationWidget(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
|
||||||
|
mpEditionWidget = new UBTeacherGuideEditionWidget(this); |
||||||
|
addWidget(mpEditionWidget); |
||||||
|
mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); |
||||||
|
addWidget(mpPresentationWidget); |
||||||
|
|
||||||
|
setCurrentWidget(mpPresentationWidget); |
||||||
|
connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); |
||||||
|
connectToStylusPalette(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
UBTeacherGuideWidget::~UBTeacherGuideWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpEditionWidget); |
||||||
|
DELETEPTR(mpPresentationWidget); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideWidget::connectToStylusPalette() |
||||||
|
{ |
||||||
|
if(UBApplication::boardController->paletteManager()) |
||||||
|
connect(UBApplication::boardController->paletteManager()->stylusPalette(),SIGNAL(itemOnActionPaletteChanged()),this,SLOT(showPresentationMode())); |
||||||
|
else |
||||||
|
QTimer::singleShot(500,this,SLOT(connectToStylusPalette())); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideWidget::showPresentationMode() |
||||||
|
{ |
||||||
|
if(currentWidget()!=mpPresentationWidget){ |
||||||
|
mCurrentData = mpEditionWidget->getData(); |
||||||
|
mpPresentationWidget->showData(mCurrentData); |
||||||
|
setCurrentWidget(mpPresentationWidget); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBTeacherGuideWidget::changeMode() |
||||||
|
{ |
||||||
|
if(currentWidget() == mpEditionWidget) |
||||||
|
setCurrentWidget(mpPresentationWidget); |
||||||
|
else |
||||||
|
setCurrentWidget(mpEditionWidget); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,123 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBTEACHERGUIDEWIDGET_H |
||||||
|
#define UBTEACHERGUIDEWIDGET_H |
||||||
|
|
||||||
|
class QTreeWidget; |
||||||
|
class QHeaderView; |
||||||
|
class QLabel; |
||||||
|
class QVBoxLayout; |
||||||
|
class QPushButton; |
||||||
|
|
||||||
|
#include "UBTeacherGuideWidgetsTools.h" |
||||||
|
#include "UBTGWidgetTreeDelegate.h" |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuideEditionWidget * |
||||||
|
***************************************************************************/ |
||||||
|
class UBTeacherGuideEditionWidget : public QWidget |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
explicit UBTeacherGuideEditionWidget(QWidget* parent = 0, const char* name="UBTeacherGuideEditionWidget"); |
||||||
|
~UBTeacherGuideEditionWidget(); |
||||||
|
void cleanData(); |
||||||
|
QVector<tUBGEElementNode*> getData(); |
||||||
|
|
||||||
|
public slots: |
||||||
|
void onAddItemClicked(QTreeWidgetItem* widget, int column); |
||||||
|
void onActiveSceneChanged(); |
||||||
|
void showEvent(QShowEvent* event); |
||||||
|
|
||||||
|
private: |
||||||
|
QList<QTreeWidgetItem*> getChildrenList(QTreeWidgetItem* widgetItem); |
||||||
|
QVector<tUBGEElementNode*> getPageAndCommentData(); |
||||||
|
|
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
QLabel* mpDocumentTitle; |
||||||
|
QLabel* mpPageNumberLabel; |
||||||
|
UBTGAdaptableText* mpPageTitle; |
||||||
|
UBTGAdaptableText* mpComment; |
||||||
|
QFrame* mpSeparator; |
||||||
|
QTreeWidget* mpTreeWidget; |
||||||
|
QTreeWidgetItem* mpRootWidgetItem; |
||||||
|
UBAddItem* mpAddAnActionItem; |
||||||
|
UBAddItem* mpAddAMediaItem; |
||||||
|
UBAddItem* mpAddALinkItem; |
||||||
|
UBTGWidgetTreeDelegate* mpTreeDelegate; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuidePresentationWidget * |
||||||
|
***************************************************************************/ |
||||||
|
class UBTeacherGuidePresentationWidget : public QWidget |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName"); |
||||||
|
~UBTeacherGuidePresentationWidget(); |
||||||
|
void showData(QVector<tUBGEElementNode*>data); |
||||||
|
void cleanData(); |
||||||
|
|
||||||
|
public slots: |
||||||
|
void onAddItemClicked(QTreeWidgetItem* widget, int column); |
||||||
|
void onActiveSceneChanged(); |
||||||
|
|
||||||
|
private: |
||||||
|
void createMediaButtonItem(); |
||||||
|
|
||||||
|
UBTGAdaptableText* mpPageTitle; |
||||||
|
UBTGAdaptableText* mpComment; |
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
QHBoxLayout* mpButtonTitleLayout; |
||||||
|
QLabel* mpDocumentTitle; |
||||||
|
QLabel* mpPageNumberLabel; |
||||||
|
QFrame* mpSeparator; |
||||||
|
QPushButton* mpModePushButton; |
||||||
|
QTreeWidget* mpTreeWidget; |
||||||
|
QTreeWidgetItem* mpRootWidgetItem; |
||||||
|
QTreeWidgetItem* mpMediaSwitchItem; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTeacherGuideWidget * |
||||||
|
***************************************************************************/ |
||||||
|
|
||||||
|
class UBTeacherGuideWidget : public QStackedWidget |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget"); |
||||||
|
~UBTeacherGuideWidget(); |
||||||
|
|
||||||
|
public slots: |
||||||
|
void changeMode(); |
||||||
|
void showPresentationMode(); |
||||||
|
void connectToStylusPalette(); |
||||||
|
|
||||||
|
private: |
||||||
|
UBTeacherGuideEditionWidget* mpEditionWidget; |
||||||
|
UBTeacherGuidePresentationWidget* mpPresentationWidget; |
||||||
|
QVector<tUBGEElementNode*>mCurrentData; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBTEACHERGUIDEWIDGET_H
|
@ -0,0 +1,423 @@ |
|||||||
|
/*
|
||||||
|
* 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 <QTreeWidget> |
||||||
|
#include <QVBoxLayout> |
||||||
|
#include <QComboBox> |
||||||
|
#include <QColor> |
||||||
|
#include <QLabel> |
||||||
|
#include <QDebug> |
||||||
|
#include <QUrl> |
||||||
|
#include <QWebSettings> |
||||||
|
#include <QDomElement> |
||||||
|
#include <QDomDocument> |
||||||
|
#include <QApplication> |
||||||
|
|
||||||
|
#include "UBTeacherGuideWidgetsTools.h" |
||||||
|
#include "UBTGWidgetTreeDelegate.h" |
||||||
|
|
||||||
|
#include "globals/UBGlobals.h" |
||||||
|
|
||||||
|
#include "frameworks/UBFileSystemUtils.h" |
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBAddItem * |
||||||
|
***************************************************************************/ |
||||||
|
UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidget* parent): QTreeWidgetItem(parent) |
||||||
|
{ |
||||||
|
setIcon(0,QIcon(":images/increase.svg")); |
||||||
|
setText(0,string); |
||||||
|
setData(0,Qt::UserRole,QVariant(addSubItemWidgetType)); |
||||||
|
setData(1,Qt::UserRole,QVariant(addSubItemWidgetType)); |
||||||
|
setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); |
||||||
|
setData(1,Qt::BackgroundRole,QVariant(QColor(200,200,200))); |
||||||
|
setData(0,Qt::FontRole,QVariant(QFont(QApplication::font().family(),12))); |
||||||
|
} |
||||||
|
|
||||||
|
UBAddItem::~UBAddItem() |
||||||
|
{ |
||||||
|
//NOOP
|
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTGActionWidget * |
||||||
|
***************************************************************************/ |
||||||
|
UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, const char* name) : QWidget(parent) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpOwner(NULL) |
||||||
|
, mpTask(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
SET_STYLE_SHEET(); |
||||||
|
mpLayout = new QVBoxLayout(this); |
||||||
|
mpOwner = new QComboBox(this); |
||||||
|
mpOwner->setObjectName("DockPaletteWidgetComboBox"); |
||||||
|
mpOwner->setMinimumHeight(22); |
||||||
|
QStringList qslOwner; |
||||||
|
qslOwner << tr("Teacher") << tr("Student"); |
||||||
|
mpOwner->insertItems(0,qslOwner); |
||||||
|
mpOwner->setCurrentIndex(0); |
||||||
|
mpTask = new UBTGAdaptableText(widget,this); |
||||||
|
mpTask->setAcceptRichText(true); |
||||||
|
mpTask->setTextColor(QColor().green()); |
||||||
|
mpTask->setObjectName("ActionWidgetTaskTextEdit"); |
||||||
|
mpLayout->addWidget(mpOwner,0); |
||||||
|
mpLayout->addWidget(mpTask,1); |
||||||
|
} |
||||||
|
|
||||||
|
UBTGActionWidget::~UBTGActionWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpOwner); |
||||||
|
DELETEPTR(mpTask); |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
} |
||||||
|
|
||||||
|
tUBGEElementNode* UBTGActionWidget::saveData() |
||||||
|
{ |
||||||
|
tUBGEElementNode* result = new tUBGEElementNode(); |
||||||
|
result->type = "action"; |
||||||
|
result->attributes.insert("owner",QString("%0").arg(mpOwner->currentIndex())); |
||||||
|
result->attributes.insert("task",mpTask->text()); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTGAdaptableText * |
||||||
|
***************************************************************************/ |
||||||
|
UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, const char* name):QTextEdit(parent) |
||||||
|
, mBottomMargin(5) |
||||||
|
, mpTreeWidgetItem(widget) |
||||||
|
, mMinimumHeight(20) |
||||||
|
, mHasPlaceHolder(false) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
setStyleSheet( "QWidget {background: white; border:1 solid #999999; border-radius : 10px; padding: 2px;}"); |
||||||
|
connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); |
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||||
|
setMinimumHeight(mMinimumHeight); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGAdaptableText::setPlaceHolderText(QString text) |
||||||
|
{ |
||||||
|
|
||||||
|
// the space addition is to make this string unique and check against it to know
|
||||||
|
// if we are talking about a typed string or the placeholder string
|
||||||
|
mPlaceHolderText = text + " "; |
||||||
|
setTextColor(QColor(Qt::lightGray)); |
||||||
|
setText(mPlaceHolderText); |
||||||
|
onTextChanged(); |
||||||
|
if(isHidden()) |
||||||
|
show(); |
||||||
|
mHasPlaceHolder = true; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGAdaptableText::focusInEvent(QFocusEvent *e) |
||||||
|
{ |
||||||
|
if(mHasPlaceHolder && toPlainText() == mPlaceHolderText){ |
||||||
|
setText(""); |
||||||
|
setTextColor(QColor(Qt::black)); |
||||||
|
} |
||||||
|
|
||||||
|
e->accept(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void UBTGAdaptableText::focusOutEvent(QFocusEvent *e) |
||||||
|
{ |
||||||
|
if(mHasPlaceHolder && toPlainText().length() == 0){ |
||||||
|
setTextColor(QColor(Qt::lightGray)); |
||||||
|
setText(mPlaceHolderText); |
||||||
|
} |
||||||
|
e->accept(); |
||||||
|
} |
||||||
|
|
||||||
|
QString UBTGAdaptableText::text() |
||||||
|
{ |
||||||
|
QString result = toPlainText(); |
||||||
|
if(mHasPlaceHolder && result == mPlaceHolderText) |
||||||
|
return ""; |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGAdaptableText::onTextChanged() |
||||||
|
{ |
||||||
|
if(document()->size().height() < mMinimumHeight) |
||||||
|
setFixedHeight(mMinimumHeight); |
||||||
|
else |
||||||
|
setFixedHeight(document()->size().height()+mBottomMargin); |
||||||
|
updateGeometry(); |
||||||
|
//to trig the widget item to resize it
|
||||||
|
if(mpTreeWidgetItem){ |
||||||
|
mpTreeWidgetItem->setExpanded(false); |
||||||
|
mpTreeWidgetItem->setExpanded(true); |
||||||
|
setFocus(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGAdaptableText::showText(const QString & text) |
||||||
|
{ |
||||||
|
setText(text); |
||||||
|
//A first rendering has to be done to calculate the text's size.
|
||||||
|
show(); |
||||||
|
hide(); |
||||||
|
setReadOnly(true); |
||||||
|
onTextChanged(); |
||||||
|
if(isHidden()) |
||||||
|
show(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGAdaptableText::bottomMargin(int newValue) |
||||||
|
{ |
||||||
|
mBottomMargin = newValue; |
||||||
|
onTextChanged(); |
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTGMediaWidget * |
||||||
|
***************************************************************************/ |
||||||
|
UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) |
||||||
|
, mpTreeWidgetItem(widget) |
||||||
|
, mpDropMeWidget(NULL) |
||||||
|
, mpWorkWidget(NULL) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpTitle(NULL) |
||||||
|
, mpMediaLabelWidget(NULL) |
||||||
|
, mpMediaWidget(NULL) |
||||||
|
, mpWebView(NULL) |
||||||
|
, mRelativePath(QString("")) |
||||||
|
, mIsPresentationMode(false) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
mpDropMeWidget = new QLabel(); |
||||||
|
mpDropMeWidget->setObjectName("UBTGMediaDropMeLabel"); |
||||||
|
mpDropMeWidget->setText(tr("drop media here ...")); |
||||||
|
mpDropMeWidget->setAlignment(Qt::AlignCenter); |
||||||
|
setAcceptDrops(true); |
||||||
|
addWidget(mpDropMeWidget); |
||||||
|
|
||||||
|
setMinimumHeight(100); |
||||||
|
} |
||||||
|
|
||||||
|
UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) |
||||||
|
, mpTreeWidgetItem(widget) |
||||||
|
, mpDropMeWidget(NULL) |
||||||
|
, mpWorkWidget(NULL) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpTitle(NULL) |
||||||
|
, mpMediaLabelWidget(NULL) |
||||||
|
, mpMediaWidget(NULL) |
||||||
|
, mpWebView(NULL) |
||||||
|
, mRelativePath(relativePath) |
||||||
|
, mIsPresentationMode(true) |
||||||
|
, mMediaType("") |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
setAcceptDrops(false); |
||||||
|
createWorkWidget(mRelativePath); |
||||||
|
setMinimumHeight(200); |
||||||
|
} |
||||||
|
|
||||||
|
UBTGMediaWidget::~UBTGMediaWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpTitle); |
||||||
|
DELETEPTR(mpMediaLabelWidget); |
||||||
|
DELETEPTR(mpMediaWidget); |
||||||
|
DELETEPTR(mpWebView); |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
|
||||||
|
removeWidget(mpDropMeWidget); |
||||||
|
DELETEPTR(mpDropMeWidget); |
||||||
|
removeWidget(mpWorkWidget); |
||||||
|
DELETEPTR(mpWorkWidget); |
||||||
|
} |
||||||
|
|
||||||
|
tUBGEElementNode* UBTGMediaWidget::saveData() |
||||||
|
{ |
||||||
|
if(!mpTitle) |
||||||
|
return 0; |
||||||
|
tUBGEElementNode* result = new tUBGEElementNode(); |
||||||
|
result->type = "media"; |
||||||
|
result->attributes.insert("title",mpTitle->text()); |
||||||
|
result->attributes.insert("relativePath",mRelativePath); |
||||||
|
result->attributes.insert("mediaType",mMediaType); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event) |
||||||
|
{ |
||||||
|
event->accept(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::createWorkWidget(QString& path) |
||||||
|
{ |
||||||
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); |
||||||
|
qDebug() << mimeType; |
||||||
|
bool setMedia = true; |
||||||
|
if(mimeType.contains("audio") || mimeType.contains("video")){ |
||||||
|
mMediaType = mimeType.contains("audio")? "audio":"movie"; |
||||||
|
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
||||||
|
mpMediaWidget->setFile(path); |
||||||
|
} |
||||||
|
else if(mimeType.contains("image")){ |
||||||
|
mMediaType = "image"; |
||||||
|
mpMediaLabelWidget = new QLabel(); |
||||||
|
QPixmap pixmap = QPixmap(QUrl(path).toLocalFile()); |
||||||
|
pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width()); |
||||||
|
mpMediaLabelWidget->setPixmap(pixmap); |
||||||
|
mpMediaLabelWidget->setScaledContents(true); |
||||||
|
} |
||||||
|
else if(mimeType.contains("application")){ |
||||||
|
mMediaType = "w3c"; |
||||||
|
mpWebView = new QWebView(0); |
||||||
|
mpWebView->setAcceptDrops(false); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); |
||||||
|
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
||||||
|
mpWebView->load(QUrl(path)); |
||||||
|
mpWebView->show(); |
||||||
|
} |
||||||
|
else{ |
||||||
|
qDebug() << "createWorkWidget mime type not handled" << mimeType; |
||||||
|
setMedia=false; |
||||||
|
} |
||||||
|
|
||||||
|
if(setMedia){ |
||||||
|
mRelativePath = path; |
||||||
|
setAcceptDrops(false); |
||||||
|
mpWorkWidget = new QWidget(this); |
||||||
|
mpLayout = new QVBoxLayout(mpWorkWidget); |
||||||
|
if(!mIsPresentationMode){ |
||||||
|
mpTitle = new UBTGAdaptableText(mpTreeWidgetItem,mpWorkWidget); |
||||||
|
mpLayout->addWidget(mpTitle,1); |
||||||
|
} |
||||||
|
if(mpMediaLabelWidget){ |
||||||
|
mpMediaLabelWidget->setParent(mpWorkWidget); |
||||||
|
mpLayout->addWidget(mpMediaLabelWidget); |
||||||
|
} |
||||||
|
else if (mpMediaWidget){ |
||||||
|
mpMediaWidget->setMaximumHeight(mpTreeWidgetItem->treeWidget()->size().width()); |
||||||
|
mpMediaWidget->setParent(mpWorkWidget); |
||||||
|
mpLayout->addWidget(mpMediaWidget); |
||||||
|
} |
||||||
|
else if (mpWebView){ |
||||||
|
mpWebView->setParent(mpWorkWidget); |
||||||
|
mpLayout->addWidget(mpWebView); |
||||||
|
} |
||||||
|
mpWorkWidget->setLayout(mpLayout); |
||||||
|
addWidget(mpWorkWidget); |
||||||
|
setCurrentWidget(mpWorkWidget); |
||||||
|
updateSize(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) |
||||||
|
{ |
||||||
|
QString path; |
||||||
|
if(pMimeData){ |
||||||
|
if(pMimeData->hasText()){ |
||||||
|
path = QUrl::fromLocalFile(pMimeData->text()).toString(); |
||||||
|
} |
||||||
|
else if(pMimeData->hasUrls()){ |
||||||
|
path = pMimeData->urls().at(0).toString(); |
||||||
|
} |
||||||
|
else if(pMimeData->hasImage()){ |
||||||
|
qDebug() << "Not yet implemented"; |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
qDebug() << "No mime data present"; |
||||||
|
|
||||||
|
createWorkWidget(path); |
||||||
|
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); |
||||||
|
qDebug() << mimeType; |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::dropEvent(QDropEvent* event) |
||||||
|
{ |
||||||
|
parseMimeData(event->mimeData()); |
||||||
|
event->accept(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) |
||||||
|
{ |
||||||
|
if (!mIsPresentationMode) |
||||||
|
event->ignore(); |
||||||
|
else{ |
||||||
|
|
||||||
|
QDrag *drag = new QDrag(this); |
||||||
|
QMimeData *mimeData = new QMimeData; |
||||||
|
QList<QUrl> urlList; |
||||||
|
urlList << QUrl(mRelativePath); |
||||||
|
mimeData->setUrls(urlList); |
||||||
|
drag->setMimeData(mimeData); |
||||||
|
|
||||||
|
drag->exec(); |
||||||
|
event->accept(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBTGMediaWidget::updateSize() |
||||||
|
{ |
||||||
|
if(mpTreeWidgetItem){ |
||||||
|
mpTreeWidgetItem->setExpanded(false); |
||||||
|
mpTreeWidgetItem->setExpanded(true); |
||||||
|
if(!mIsPresentationMode) |
||||||
|
mpTitle->setFocus(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* class UBTGUrlWdiget * |
||||||
|
***************************************************************************/ |
||||||
|
UBTGUrlWidget::UBTGUrlWidget(QWidget* parent, const char* name ):QWidget(parent) |
||||||
|
, mpLayout(NULL) |
||||||
|
, mpTitle(NULL) |
||||||
|
, mpUrl(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
SET_STYLE_SHEET(); |
||||||
|
mpLayout = new QVBoxLayout(this); |
||||||
|
mpTitle = new QLineEdit(this); |
||||||
|
mpTitle->setObjectName("UBTGLineEdit"); |
||||||
|
mpTitle->setPlaceholderText(tr("Insert link title here...")); |
||||||
|
mpUrl = new QLineEdit(this); |
||||||
|
mpUrl->setObjectName("UBTGLineEdit"); |
||||||
|
mpUrl->setPlaceholderText("http://"); |
||||||
|
mpLayout->addWidget(mpTitle); |
||||||
|
mpLayout->addWidget(mpUrl); |
||||||
|
} |
||||||
|
|
||||||
|
UBTGUrlWidget::~UBTGUrlWidget() |
||||||
|
{ |
||||||
|
DELETEPTR(mpTitle); |
||||||
|
DELETEPTR(mpUrl); |
||||||
|
DELETEPTR(mpLayout); |
||||||
|
} |
||||||
|
|
||||||
|
tUBGEElementNode* UBTGUrlWidget::saveData() |
||||||
|
{ |
||||||
|
tUBGEElementNode* result = new tUBGEElementNode(); |
||||||
|
result->type = "link"; |
||||||
|
result->attributes.insert("title",mpTitle->text()); |
||||||
|
result->attributes.insert("url",mpUrl->text()); |
||||||
|
return result; |
||||||
|
} |
@ -0,0 +1,157 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBTEACHERGUIDEWIDGETSTOOLS_H |
||||||
|
#define UBTEACHERGUIDEWIDGETSTOOLS_H |
||||||
|
|
||||||
|
#include <QObject> |
||||||
|
#include <QTreeWidgetItem> |
||||||
|
#include <QTextEdit> |
||||||
|
#include <QLabel> |
||||||
|
#include <QDragEnterEvent> |
||||||
|
#include <QDropEvent> |
||||||
|
#include <QLineEdit> |
||||||
|
#include <QMimeData> |
||||||
|
#include <QStackedWidget> |
||||||
|
#include <QWebView> |
||||||
|
|
||||||
|
#include "customWidgets/UBMediaWidget.h" |
||||||
|
|
||||||
|
class QTreeWidget; |
||||||
|
class QVBoxLayout; |
||||||
|
class QComboBox; |
||||||
|
class QTextEdit; |
||||||
|
class QWidget; |
||||||
|
class UBTGAdaptableText; |
||||||
|
class QDomElement; |
||||||
|
|
||||||
|
typedef struct |
||||||
|
{ |
||||||
|
QString type; |
||||||
|
QMap<QString,QString> attributes; |
||||||
|
}tUBGEElementNode; |
||||||
|
|
||||||
|
|
||||||
|
class iUBTGSavableData |
||||||
|
{ |
||||||
|
public: |
||||||
|
virtual tUBGEElementNode* saveData() = 0; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class UBAddItem : public QTreeWidgetItem |
||||||
|
{ |
||||||
|
public: |
||||||
|
explicit UBAddItem(const QString &strings, int addSubItemWidgetType, QTreeWidget* parent = 0); |
||||||
|
~UBAddItem(); |
||||||
|
|
||||||
|
signals: |
||||||
|
|
||||||
|
public slots: |
||||||
|
}; |
||||||
|
|
||||||
|
class UBTGActionWidget : public QWidget, public iUBTGSavableData |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
|
||||||
|
public: |
||||||
|
explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBTGActionWidget"); |
||||||
|
~UBTGActionWidget(); |
||||||
|
void update(); |
||||||
|
tUBGEElementNode* saveData(); |
||||||
|
|
||||||
|
private: |
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
QComboBox* mpOwner; |
||||||
|
UBTGAdaptableText* mpTask; |
||||||
|
|
||||||
|
protected: |
||||||
|
QTreeWidgetItem* mpTreeWidgetItem; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class UBTGAdaptableText : public QTextEdit |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText"); |
||||||
|
void showText(const QString & text); |
||||||
|
void bottomMargin(int newValue); |
||||||
|
void setPlaceHolderText(QString text); |
||||||
|
QString text(); |
||||||
|
|
||||||
|
public slots: |
||||||
|
void onTextChanged(); |
||||||
|
|
||||||
|
protected: |
||||||
|
void focusInEvent(QFocusEvent *e); |
||||||
|
void focusOutEvent(QFocusEvent *e); |
||||||
|
private: |
||||||
|
int mBottomMargin; |
||||||
|
QTreeWidgetItem* mpTreeWidgetItem; |
||||||
|
int mMinimumHeight; |
||||||
|
bool mHasPlaceHolder; |
||||||
|
QString mPlaceHolderText; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class UBTGMediaWidget : public QStackedWidget , public iUBTGSavableData |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
UBTGMediaWidget(QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); |
||||||
|
UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); |
||||||
|
~UBTGMediaWidget(); |
||||||
|
tUBGEElementNode* saveData(); |
||||||
|
|
||||||
|
protected: |
||||||
|
void dragEnterEvent(QDragEnterEvent* event); |
||||||
|
void dropEvent(QDropEvent* event); |
||||||
|
void mousePressEvent(QMouseEvent* event); |
||||||
|
|
||||||
|
private: |
||||||
|
void parseMimeData(const QMimeData* pMimeData); |
||||||
|
void createWorkWidget(QString& path); |
||||||
|
void updateSize(); |
||||||
|
|
||||||
|
QTreeWidgetItem* mpTreeWidgetItem; |
||||||
|
QLabel* mpDropMeWidget; |
||||||
|
QWidget* mpWorkWidget; |
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
UBTGAdaptableText* mpTitle; |
||||||
|
QLabel* mpMediaLabelWidget; |
||||||
|
UBMediaWidget* mpMediaWidget; |
||||||
|
QWebView* mpWebView; |
||||||
|
QString mRelativePath; |
||||||
|
bool mIsPresentationMode; |
||||||
|
QString mMediaType; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class UBTGUrlWidget : public QWidget , public iUBTGSavableData |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
UBTGUrlWidget(QWidget* parent = 0, const char* name = "UBTGUrlWidget"); |
||||||
|
~UBTGUrlWidget(); |
||||||
|
tUBGEElementNode* saveData(); |
||||||
|
private: |
||||||
|
QVBoxLayout* mpLayout; |
||||||
|
QLineEdit* mpTitle; |
||||||
|
QLineEdit* mpUrl; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
#endif // UBTEACHERGUIDEWIDGETSTOOLS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,421 +1,423 @@ |
|||||||
/*
|
/*
|
||||||
* This program is free software: you can redistribute it and/or modify |
* 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 |
* it under the terms of the GNU General Public License as published by |
||||||
* the Free Software Foundation, either version 3 of the License, or |
* the Free Software Foundation, either version 3 of the License, or |
||||||
* (at your option) any later version. |
* (at your option) any later version. |
||||||
* |
* |
||||||
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
* GNU General Public License for more details. |
* GNU General Public License for more details. |
||||||
* |
* |
||||||
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef UBTHUMBNAILWIDGET_H_ |
#ifndef UBTHUMBNAILWIDGET_H_ |
||||||
#define UBTHUMBNAILWIDGET_H_ |
#define UBTHUMBNAILWIDGET_H_ |
||||||
|
|
||||||
#include <QtGui> |
#include <QtGui> |
||||||
#include <QtSvg> |
#include <QtSvg> |
||||||
#include <QTime> |
#include <QTime> |
||||||
#include <QGraphicsSceneHoverEvent> |
#include <QGraphicsSceneHoverEvent> |
||||||
|
|
||||||
#include "frameworks/UBCoreGraphicsScene.h" |
#include "frameworks/UBCoreGraphicsScene.h" |
||||||
#include "core/UBSettings.h" |
#include "core/UBSettings.h" |
||||||
#include "domain/UBItem.h" |
#include "domain/UBItem.h" |
||||||
|
|
||||||
#define STARTDRAGTIME 1000000 |
#define STARTDRAGTIME 1000000 |
||||||
#define BUTTONSIZE 48 |
#define BUTTONSIZE 48 |
||||||
#define BUTTONSPACING 5 |
#define BUTTONSPACING 5 |
||||||
|
|
||||||
class UBDocumentProxy; |
class UBDocumentProxy; |
||||||
class UBThumbnailTextItem; |
class UBThumbnailTextItem; |
||||||
class UBThumbnail; |
class UBThumbnail; |
||||||
|
|
||||||
class UBThumbnailWidget : public QGraphicsView |
class UBThumbnailWidget : public QGraphicsView |
||||||
{ |
{ |
||||||
Q_OBJECT; |
Q_OBJECT; |
||||||
|
|
||||||
public: |
public: |
||||||
UBThumbnailWidget(QWidget* parent); |
UBThumbnailWidget(QWidget* parent); |
||||||
virtual ~UBThumbnailWidget(); |
virtual ~UBThumbnailWidget(); |
||||||
|
|
||||||
QList<QGraphicsItem*> selectedItems(); |
QList<QGraphicsItem*> selectedItems(); |
||||||
void selectItemAt(int pIndex, bool extend = false); |
void selectItemAt(int pIndex, bool extend = false); |
||||||
void unselectItemAt(int pIndex); |
void unselectItemAt(int pIndex); |
||||||
|
|
||||||
qreal thumbnailWidth() |
qreal thumbnailWidth() |
||||||
{ |
{ |
||||||
return mThumbnailWidth; |
return mThumbnailWidth; |
||||||
} |
} |
||||||
|
|
||||||
void setBackgroundBrush(const QBrush& brush) |
void setBackgroundBrush(const QBrush& brush) |
||||||
{ |
{ |
||||||
mThumbnailsScene.setBackgroundBrush(brush); |
mThumbnailsScene.setBackgroundBrush(brush); |
||||||
} |
} |
||||||
|
|
||||||
public slots: |
public slots: |
||||||
void setThumbnailWidth(qreal pThumbnailWidth); |
void setThumbnailWidth(qreal pThumbnailWidth); |
||||||
void setSpacing(qreal pSpacing); |
void setSpacing(qreal pSpacing); |
||||||
virtual void setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems, const QList<QUrl>& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString("")); |
virtual void setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems, const QList<QUrl>& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString("")); |
||||||
void refreshScene(); |
void refreshScene(); |
||||||
void sceneSelectionChanged(); |
void sceneSelectionChanged(); |
||||||
|
|
||||||
signals: |
signals: |
||||||
void resized(); |
void resized(); |
||||||
void selectionChanged(); |
void selectionChanged(); |
||||||
void mouseDoubleClick(QGraphicsItem* item, int index); |
void mouseDoubleClick(QGraphicsItem* item, int index); |
||||||
void mouseClick(QGraphicsItem* item, int index); |
void mouseClick(QGraphicsItem* item, int index); |
||||||
|
|
||||||
|
|
||||||
protected: |
protected: |
||||||
virtual void mousePressEvent(QMouseEvent *event); |
virtual void mousePressEvent(QMouseEvent *event); |
||||||
virtual void mouseMoveEvent(QMouseEvent *event); |
virtual void mouseMoveEvent(QMouseEvent *event); |
||||||
virtual void mouseReleaseEvent(QMouseEvent *event); |
virtual void mouseReleaseEvent(QMouseEvent *event); |
||||||
virtual void resizeEvent(QResizeEvent * event); |
virtual void resizeEvent(QResizeEvent * event); |
||||||
void mouseDoubleClickEvent(QMouseEvent * event); |
void mouseDoubleClickEvent(QMouseEvent * event); |
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *event); |
virtual void keyPressEvent(QKeyEvent *event); |
||||||
virtual void focusInEvent(QFocusEvent *event); |
virtual void focusInEvent(QFocusEvent *event); |
||||||
|
|
||||||
QList<QGraphicsItem*> mGraphicItems; |
QList<QGraphicsItem*> mGraphicItems; |
||||||
QList<UBThumbnailTextItem*> mLabelsItems; |
QList<UBThumbnailTextItem*> mLabelsItems; |
||||||
QPointF mMousePressScenePos; |
QPointF mMousePressScenePos; |
||||||
QPoint mMousePressPos; |
QPoint mMousePressPos; |
||||||
|
|
||||||
protected: |
protected: |
||||||
qreal spacing() { return mSpacing; } |
qreal spacing() { return mSpacing; } |
||||||
QList<QUrl> mItemsPaths; |
QList<QUrl> mItemsPaths; |
||||||
QStringList mLabels; |
QStringList mLabels; |
||||||
bool bSelectionInProgress; |
bool bSelectionInProgress; |
||||||
bool bCanDrag; |
bool bCanDrag;
|
||||||
|
|
||||||
private: |
private: |
||||||
void selectAll(); |
void selectAll(); |
||||||
void unselectAll(); |
void selectItems(int startIndex, int count); |
||||||
void selectItems(int startIndex, int count); |
int rowCount() const; |
||||||
int rowCount() const; |
int columnCount() const; |
||||||
int columnCount() const; |
|
||||||
|
static bool thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2); |
||||||
static bool thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2); |
|
||||||
|
void deleteLasso(); |
||||||
void deleteLasso(); |
|
||||||
|
UBCoreGraphicsScene mThumbnailsScene; |
||||||
UBCoreGraphicsScene mThumbnailsScene; |
|
||||||
|
QString mMimeType; |
||||||
QString mMimeType; |
|
||||||
|
QPointF prevMoveMousePos; |
||||||
qreal mThumbnailWidth; |
|
||||||
qreal mThumbnailHeight; |
qreal mThumbnailWidth; |
||||||
qreal mSpacing; |
qreal mThumbnailHeight; |
||||||
|
qreal mSpacing; |
||||||
UBThumbnail *mLastSelectedThumbnail; |
|
||||||
int mSelectionSpan; |
UBThumbnail *mLastSelectedThumbnail; |
||||||
QGraphicsRectItem *mLassoRectItem; |
int mSelectionSpan; |
||||||
QList<QGraphicsItem*> mSelectedThumbnailItems; |
QGraphicsRectItem *mLassoRectItem; |
||||||
QTime mClickTime; |
QSet<QGraphicsItem*> mSelectedThumbnailItems; |
||||||
}; |
QSet<QGraphicsItem*> mPreviouslyIncrementalSelectedItems; |
||||||
|
QTime mClickTime; |
||||||
|
}; |
||||||
class UBThumbnail |
|
||||||
{ |
|
||||||
public: |
class UBThumbnail |
||||||
UBThumbnail(); |
{ |
||||||
|
public: |
||||||
virtual ~UBThumbnail(); |
UBThumbnail(); |
||||||
|
|
||||||
QStyleOptionGraphicsItem muteStyleOption(const QStyleOptionGraphicsItem *option) |
virtual ~UBThumbnail(); |
||||||
{ |
|
||||||
// Never draw the rubber band, we draw our custom selection with the DelegateFrame
|
QStyleOptionGraphicsItem muteStyleOption(const QStyleOptionGraphicsItem *option) |
||||||
QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); |
{ |
||||||
styleOption.state &= ~QStyle::State_Selected; |
// Never draw the rubber band, we draw our custom selection with the DelegateFrame
|
||||||
|
QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); |
||||||
return styleOption; |
styleOption.state &= ~QStyle::State_Selected; |
||||||
} |
|
||||||
|
return styleOption; |
||||||
virtual void itemChange(QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) |
} |
||||||
{ |
|
||||||
Q_UNUSED(value); |
virtual void itemChange(QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) |
||||||
|
{ |
||||||
if ((change == QGraphicsItem::ItemSelectedHasChanged |
Q_UNUSED(value); |
||||||
|| change == QGraphicsItem::ItemTransformHasChanged |
|
||||||
|| change == QGraphicsItem::ItemPositionHasChanged) |
if ((change == QGraphicsItem::ItemSelectedHasChanged |
||||||
&& item->scene()) |
|| change == QGraphicsItem::ItemTransformHasChanged |
||||||
{ |
|| change == QGraphicsItem::ItemPositionHasChanged) |
||||||
if (item->isSelected()) |
&& item->scene()) |
||||||
{ |
{ |
||||||
if (!mSelectionItem->scene()) |
if (item->isSelected()) |
||||||
{ |
{ |
||||||
item->scene()->addItem(mSelectionItem); |
if (!mSelectionItem->scene()) |
||||||
mSelectionItem->setZValue(item->zValue() - 1); |
{ |
||||||
// UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1);
|
item->scene()->addItem(mSelectionItem); |
||||||
mAddedToScene = true; |
mSelectionItem->setZValue(item->zValue() - 1); |
||||||
} |
// UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1);
|
||||||
|
mAddedToScene = true; |
||||||
mSelectionItem->setRect( |
} |
||||||
item->sceneBoundingRect().x() - 5, |
|
||||||
item->sceneBoundingRect().y() - 5, |
mSelectionItem->setRect( |
||||||
item->sceneBoundingRect().width() + 10, |
item->sceneBoundingRect().x() - 5, |
||||||
item->sceneBoundingRect().height() + 10); |
item->sceneBoundingRect().y() - 5, |
||||||
|
item->sceneBoundingRect().width() + 10, |
||||||
mSelectionItem->show(); |
item->sceneBoundingRect().height() + 10); |
||||||
|
|
||||||
} |
mSelectionItem->show(); |
||||||
else |
|
||||||
{ |
} |
||||||
mSelectionItem->hide(); |
else |
||||||
} |
{ |
||||||
} |
mSelectionItem->hide(); |
||||||
} |
} |
||||||
|
} |
||||||
int column() { return mColumn; } |
} |
||||||
void setColumn(int column) { mColumn = column; } |
|
||||||
int row() { return mRow; } |
int column() { return mColumn; } |
||||||
void setRow(int row) { mRow = row; } |
void setColumn(int column) { mColumn = column; } |
||||||
|
int row() { return mRow; } |
||||||
protected: |
void setRow(int row) { mRow = row; } |
||||||
QGraphicsRectItem *mSelectionItem; |
|
||||||
private: |
protected: |
||||||
bool mAddedToScene; |
QGraphicsRectItem *mSelectionItem; |
||||||
|
private: |
||||||
int mColumn; |
bool mAddedToScene; |
||||||
int mRow; |
|
||||||
}; |
int mColumn; |
||||||
|
int mRow; |
||||||
|
}; |
||||||
class UBThumbnailSvg : public QGraphicsSvgItem, public UBThumbnail |
|
||||||
{ |
|
||||||
public: |
class UBThumbnailSvg : public QGraphicsSvgItem, public UBThumbnail |
||||||
UBThumbnailSvg(const QString& path) |
{ |
||||||
: QGraphicsSvgItem(path) |
public: |
||||||
{ |
UBThumbnailSvg(const QString& path) |
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
: QGraphicsSvgItem(path) |
||||||
} |
{ |
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
||||||
virtual ~UBThumbnailSvg() |
} |
||||||
{ |
|
||||||
// NOOP
|
virtual ~UBThumbnailSvg() |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
} |
||||||
{ |
|
||||||
QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); |
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
||||||
QGraphicsSvgItem::paint(painter, &styleOption, widget); |
{ |
||||||
} |
QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); |
||||||
|
QGraphicsSvgItem::paint(painter, &styleOption, widget); |
||||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) |
} |
||||||
{ |
|
||||||
UBThumbnail::itemChange(this, change, value); |
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) |
||||||
return QGraphicsSvgItem::itemChange(change, value); |
{ |
||||||
} |
UBThumbnail::itemChange(this, change, value); |
||||||
|
return QGraphicsSvgItem::itemChange(change, value); |
||||||
}; |
} |
||||||
|
|
||||||
|
}; |
||||||
class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail |
|
||||||
{ |
|
||||||
public: |
class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail |
||||||
UBThumbnailPixmap(const QPixmap& pix) |
{ |
||||||
: QGraphicsPixmapItem(pix) |
public: |
||||||
{ |
UBThumbnailPixmap(const QPixmap& pix) |
||||||
setTransformationMode(Qt::SmoothTransformation); // UB 4.3 may be expensive -- make configurable
|
: QGraphicsPixmapItem(pix) |
||||||
setShapeMode(QGraphicsPixmapItem::BoundingRectShape); |
{ |
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
setTransformationMode(Qt::SmoothTransformation); // UB 4.3 may be expensive -- make configurable
|
||||||
} |
setShapeMode(QGraphicsPixmapItem::BoundingRectShape); |
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
||||||
virtual ~UBThumbnailPixmap() |
} |
||||||
{ |
|
||||||
// NOOP
|
virtual ~UBThumbnailPixmap() |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
virtual QPainterPath shape () const |
} |
||||||
{ |
|
||||||
QPainterPath path; |
virtual QPainterPath shape () const |
||||||
path.addRect(boundingRect()); |
{ |
||||||
return path; |
QPainterPath path; |
||||||
} |
path.addRect(boundingRect()); |
||||||
|
return path; |
||||||
|
} |
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
||||||
{ |
|
||||||
QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); |
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
||||||
QGraphicsPixmapItem::paint(painter, &styleOption, widget); |
{ |
||||||
} |
QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); |
||||||
|
QGraphicsPixmapItem::paint(painter, &styleOption, widget); |
||||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) |
} |
||||||
{ |
|
||||||
UBThumbnail::itemChange(this, change, value); |
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) |
||||||
return QGraphicsPixmapItem::itemChange(change, value); |
{ |
||||||
} |
UBThumbnail::itemChange(this, change, value); |
||||||
}; |
return QGraphicsPixmapItem::itemChange(change, value); |
||||||
|
} |
||||||
|
}; |
||||||
class UBSceneThumbnailPixmap : public UBThumbnailPixmap |
|
||||||
{ |
|
||||||
public: |
class UBSceneThumbnailPixmap : public UBThumbnailPixmap |
||||||
UBSceneThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) |
{ |
||||||
: UBThumbnailPixmap(pix) |
public: |
||||||
, mProxy(proxy) |
UBSceneThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) |
||||||
, mSceneIndex(pSceneIndex) |
: UBThumbnailPixmap(pix) |
||||||
{ |
, mProxy(proxy) |
||||||
// NOOP
|
, mSceneIndex(pSceneIndex) |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
virtual ~UBSceneThumbnailPixmap() |
} |
||||||
{ |
|
||||||
// NOOP
|
virtual ~UBSceneThumbnailPixmap() |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
UBDocumentProxy* proxy() |
} |
||||||
{ |
|
||||||
return mProxy; |
UBDocumentProxy* proxy() |
||||||
} |
{ |
||||||
|
return mProxy; |
||||||
int sceneIndex() |
} |
||||||
{ |
|
||||||
return mSceneIndex; |
int sceneIndex() |
||||||
} |
{ |
||||||
|
return mSceneIndex; |
||||||
void highlight() |
} |
||||||
{ |
|
||||||
//NOOP
|
void highlight() |
||||||
} |
{ |
||||||
|
//NOOP
|
||||||
private: |
} |
||||||
UBDocumentProxy* mProxy; |
|
||||||
int mSceneIndex; |
private: |
||||||
}; |
UBDocumentProxy* mProxy; |
||||||
|
int mSceneIndex; |
||||||
class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap |
}; |
||||||
{ |
|
||||||
public: |
class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap |
||||||
UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex); |
{ |
||||||
~UBSceneThumbnailNavigPixmap(); |
public: |
||||||
|
UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex); |
||||||
protected: |
~UBSceneThumbnailNavigPixmap(); |
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
protected: |
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event); |
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
||||||
private: |
void mousePressEvent(QGraphicsSceneMouseEvent *event); |
||||||
void updateButtonsState(); |
|
||||||
void deletePage(); |
private: |
||||||
void moveUpPage(); |
void updateButtonsState(); |
||||||
void moveDownPage(); |
void deletePage(); |
||||||
|
void moveUpPage(); |
||||||
bool bButtonsVisible; |
void moveDownPage(); |
||||||
bool bCanDelete; |
|
||||||
bool bCanMoveUp; |
bool bButtonsVisible; |
||||||
bool bCanMoveDown; |
bool bCanDelete; |
||||||
}; |
bool bCanMoveUp; |
||||||
|
bool bCanMoveDown; |
||||||
class UBThumbnailVideo : public UBThumbnailPixmap |
}; |
||||||
{ |
|
||||||
public: |
class UBThumbnailVideo : public UBThumbnailPixmap |
||||||
UBThumbnailVideo(const QUrl &path) |
{ |
||||||
: UBThumbnailPixmap(QPixmap(":/images/movie.svg")) |
public: |
||||||
, mPath(path) |
UBThumbnailVideo(const QUrl &path) |
||||||
{ |
: UBThumbnailPixmap(QPixmap(":/images/movie.svg")) |
||||||
// NOOP
|
, mPath(path) |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
virtual ~UBThumbnailVideo() |
} |
||||||
{ |
|
||||||
// NOOP
|
virtual ~UBThumbnailVideo() |
||||||
} |
{ |
||||||
|
// NOOP
|
||||||
QUrl path() |
} |
||||||
{ |
|
||||||
return mPath; |
QUrl path() |
||||||
} |
{ |
||||||
|
return mPath; |
||||||
private: |
} |
||||||
|
|
||||||
QUrl mPath; |
private: |
||||||
}; |
|
||||||
|
QUrl mPath; |
||||||
class UBThumbnailTextItem : public QGraphicsTextItem |
}; |
||||||
{ |
|
||||||
public: |
class UBThumbnailTextItem : public QGraphicsTextItem |
||||||
UBThumbnailTextItem(const QString& text) |
{ |
||||||
: QGraphicsTextItem(text) |
public: |
||||||
, mUnelidedText(text) |
UBThumbnailTextItem(const QString& text) |
||||||
, mIsHighlighted(false) |
: QGraphicsTextItem(text) |
||||||
{ |
, mUnelidedText(text) |
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
, mIsHighlighted(false) |
||||||
} |
{ |
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
||||||
QRectF boundingRect() const { return QRectF(QPointF(0.0, 0.0), QSize(mWidth, QFontMetricsF(font()).height() + 5));} |
} |
||||||
|
|
||||||
void setWidth(qreal pWidth) |
QRectF boundingRect() const { return QRectF(QPointF(0.0, 0.0), QSize(mWidth, QFontMetricsF(font()).height() + 5));} |
||||||
{ |
|
||||||
if (mWidth != pWidth) |
void setWidth(qreal pWidth) |
||||||
{ |
{ |
||||||
prepareGeometryChange(); |
if (mWidth != pWidth) |
||||||
mWidth = pWidth; |
{ |
||||||
computeText(); |
prepareGeometryChange(); |
||||||
} |
mWidth = pWidth; |
||||||
}; |
computeText(); |
||||||
|
} |
||||||
qreal width() {return mWidth;} |
}; |
||||||
|
|
||||||
void highlight() |
qreal width() {return mWidth;} |
||||||
{ |
|
||||||
if (!mIsHighlighted) |
void highlight() |
||||||
{ |
{ |
||||||
mIsHighlighted = true; |
if (!mIsHighlighted) |
||||||
computeText(); |
{ |
||||||
} |
mIsHighlighted = true; |
||||||
} |
computeText(); |
||||||
|
} |
||||||
void computeText() |
} |
||||||
{ |
|
||||||
QFontMetricsF fm(font()); |
void computeText() |
||||||
QString elidedText = fm.elidedText(mUnelidedText, Qt::ElideRight, mWidth); |
{ |
||||||
|
QFontMetricsF fm(font()); |
||||||
if (mIsHighlighted) |
QString elidedText = fm.elidedText(mUnelidedText, Qt::ElideRight, mWidth); |
||||||
{ |
|
||||||
setHtml("<span style=\"color: #6682b5\">" + elidedText + "</span>"); |
if (mIsHighlighted) |
||||||
} |
{ |
||||||
else |
setHtml("<span style=\"color: #6682b5\">" + elidedText + "</span>"); |
||||||
{ |
} |
||||||
setPlainText(elidedText); |
else |
||||||
} |
{ |
||||||
} |
setPlainText(elidedText); |
||||||
|
} |
||||||
private: |
} |
||||||
qreal mWidth; |
|
||||||
QString mUnelidedText; |
private: |
||||||
bool mIsHighlighted; |
qreal mWidth; |
||||||
}; |
QString mUnelidedText; |
||||||
|
bool mIsHighlighted; |
||||||
class UBImgTextThumbnailElement |
}; |
||||||
{ |
|
||||||
private: |
class UBImgTextThumbnailElement |
||||||
QGraphicsItem* thumbnail; |
{ |
||||||
UBThumbnailTextItem* caption; |
private: |
||||||
int border; |
QGraphicsItem* thumbnail; |
||||||
|
UBThumbnailTextItem* caption; |
||||||
public: |
int border; |
||||||
UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) |
|
||||||
{ |
public: |
||||||
this->thumbnail = thumb; |
UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) |
||||||
this->caption = text; |
{ |
||||||
} |
this->thumbnail = thumb; |
||||||
|
this->caption = text; |
||||||
QGraphicsItem* getThumbnail() const { return this->thumbnail; } |
} |
||||||
void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } |
|
||||||
|
QGraphicsItem* getThumbnail() const { return this->thumbnail; } |
||||||
UBThumbnailTextItem* getCaption() const { return this->caption; } |
void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } |
||||||
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } |
|
||||||
|
UBThumbnailTextItem* getCaption() const { return this->caption; } |
||||||
void Place(int row, int col, qreal width, qreal height); |
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } |
||||||
|
|
||||||
int getBorder() const { return this->border; } |
void Place(int row, int col, qreal width, qreal height); |
||||||
void setBorder(int newBorder) { this->border = newBorder; } |
|
||||||
}; |
int getBorder() const { return this->border; } |
||||||
|
void setBorder(int newBorder) { this->border = newBorder; } |
||||||
|
}; |
||||||
#endif /* UBTHUMBNAILWIDGET_H_ */ |
|
||||||
|
|
||||||
|
#endif /* UBTHUMBNAILWIDGET_H_ */ |
||||||
|
Loading…
Reference in new issue