Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
955e9289
Commit
955e9289
authored
Jan 12, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
partial backup of the ubmediawidget
parent
81ed0c74
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
628 additions
and
47 deletions
+628
-47
Sankore_3.1.pro
Sankore_3.1.pro
+1
-0
style.qss
resources/style.qss
+16
-1
UBGlobals.h
src/customWidgets/UBGlobals.h
+9
-0
UBMediaWidget.cpp
src/customWidgets/UBMediaWidget.cpp
+209
-0
UBMediaWidget.h
src/customWidgets/UBMediaWidget.h
+85
-0
UBWidgetList.cpp
src/customWidgets/UBWidgetList.cpp
+42
-26
UBWidgetList.h
src/customWidgets/UBWidgetList.h
+5
-2
customWidgets.pri
src/customWidgets/customWidgets.pri
+5
-5
UBMediaPlayer.cpp
src/gui/UBMediaPlayer.cpp
+12
-0
UBMediaPlayer.h
src/gui/UBMediaPlayer.h
+3
-0
UBTeacherBarWidget.cpp
src/gui/UBTeacherBarWidget.cpp
+170
-12
UBTeacherBarWidget.h
src/gui/UBTeacherBarWidget.h
+32
-1
IDropable.h
src/interfaces/IDropable.h
+21
-0
IResizeable.h
src/interfaces/IResizeable.h
+15
-0
interfaces.pri
src/interfaces/interfaces.pri
+3
-0
No files found.
Sankore_3.1.pro
View file @
955e9289
...
...
@@ -54,6 +54,7 @@ include(src/web/web.pri)
include
(
src
/
softwareupdate
/
softwareupdate
.
pri
)
include
(
src
/
transition
/
transition
.
pri
)
include
(
src
/
customWidgets
/
customWidgets
.
pri
)
include
(
src
/
interfaces
/
interfaces
.
pri
)
DEPENDPATH
+=
src
/
pdf
-
merger
INCLUDEPATH
+=
src
/
pdf
-
merger
...
...
resources/style.qss
View file @
955e9289
...
...
@@ -5,13 +5,23 @@ QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget,
QWidget#UBWidgetList,
QWidget#UBTeacherBarDropMediaZone
QWidget#UBTeacherBarDropMediaZone,
QWidget#UBTBMediaContainer
{
background: #EEEEEE;
border-radius: 10px;
border: 2px solid #999999;
}
QWidget#UBMediaVideoContainer
{
background: #000000;
border-radius: 10px;
border: 2px solid #999999;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
QWidget#UBTeacherBarPreviewWidget
{
background: #FFFFFF;
...
...
@@ -26,6 +36,11 @@ QLabel#UBTeacherBarPreviewTitle
font-weight:bold;
}
QLabel#UBMediaPlayerButton
{
padding: 0px 0px 0px 0px;
}
QLabel#UBTeacherBarPreviewSubtitle
{
color: #555555;
...
...
src/customWidgets/UBGlobals.h
0 → 100644
View file @
955e9289
#ifndef UBGLOBALS_H
#define UBGLOBALS_H
#define DELETEPTR(ptr) if(NULL != ptr){ \
delete ptr; \
ptr = NULL; \
}
#endif // UBGLOBALS_H
src/customWidgets/UBMediaWidget.cpp
0 → 100644
View file @
955e9289
#include "core/UBApplication.h"
#include "UBGlobals.h"
#include "UBMediaWidget.h"
UBMediaWidget
::
UBMediaWidget
(
eMediaType
type
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpMediaObject
(
NULL
)
,
mpVideoWidget
(
NULL
)
,
mpAudioOutput
(
NULL
)
,
mpPlayStopButton
(
NULL
)
,
mpPauseButton
(
NULL
)
,
mpSlider
(
NULL
)
,
mAutoUpdate
(
false
)
,
mGeneratingThumbnail
(
false
)
,
mBorder
(
5
)
,
mpVideoContainer
(
NULL
)
{
setObjectName
(
name
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
mType
=
type
;
setLayout
(
&
mLayout
);
mpPlayStopButton
=
new
UBMediaButton
(
this
);
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
=
new
UBMediaButton
(
this
);
mpPauseButton
->
setPixmap
(
QPixmap
(
":images/pause.svg"
));
mpPauseButton
->
setEnabled
(
false
);
mpSlider
=
new
QSlider
(
this
);
mpSlider
->
setOrientation
(
Qt
::
Horizontal
);
mpSlider
->
setMinimum
(
0
);
mpSlider
->
setMaximum
(
0
);
mSeekerLayout
.
addWidget
(
mpPlayStopButton
,
0
);
mSeekerLayout
.
addWidget
(
mpPauseButton
,
0
);
mSeekerLayout
.
addWidget
(
mpSlider
,
1
);
connect
(
mpPlayStopButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPlayStopClicked
()));
connect
(
mpPauseButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPauseClicked
()));
connect
(
mpSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
onSliderChanged
(
int
)));
}
UBMediaWidget
::~
UBMediaWidget
()
{
DELETEPTR
(
mpSlider
);
DELETEPTR
(
mpPauseButton
);
DELETEPTR
(
mpPlayStopButton
);
DELETEPTR
(
mpAudioOutput
);
DELETEPTR
(
mpVideoWidget
);
DELETEPTR
(
mpVideoContainer
);
DELETEPTR
(
mpMediaObject
);
}
void
UBMediaWidget
::
setFile
(
const
QString
&
filePath
)
{
Q_ASSERT
(
""
!=
filePath
);
mFilePath
=
filePath
;
mpMediaObject
=
new
Phonon
::
MediaObject
(
this
);
mpMediaObject
->
setTickInterval
(
TICK_INTERVAL
);
connect
(
mpMediaObject
,
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)),
this
,
SLOT
(
onStateChanged
(
Phonon
::
State
,
Phonon
::
State
)));
connect
(
mpMediaObject
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
onTotalTimeChanged
(
qint64
)));
connect
(
mpMediaObject
,
SIGNAL
(
tick
(
qint64
)),
this
,
SLOT
(
onTick
(
qint64
)));
mpMediaObject
->
setCurrentSource
(
Phonon
::
MediaSource
(
filePath
));
createMediaPlayer
();
}
eMediaType
UBMediaWidget
::
mediaType
()
{
return
mType
;
}
void
UBMediaWidget
::
createMediaPlayer
()
{
if
(
eMediaType_Video
==
mType
){
mpVideoWidget
=
new
Phonon
::
VideoWidget
(
this
);
mpVideoWidget
->
setStyleSheet
(
QString
(
"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"
));
mpVideoContainer
=
new
QWidget
(
this
);
mpVideoContainer
->
setObjectName
(
"UBMediaVideoContainer"
);
mpVideoContainer
->
setLayout
(
&
mVideoLayout
);
mVideoLayout
.
addWidget
(
mpVideoWidget
,
1
);
Phonon
::
createPath
(
mpMediaObject
,
mpVideoWidget
);
adaptSizeToVideo
();
mLayout
.
addWidget
(
mpVideoContainer
,
1
);
mpAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
VideoCategory
,
this
);
Phonon
::
createPath
(
mpMediaObject
,
mpAudioOutput
);
}
else
if
(
eMediaType_Audio
==
mType
){
mpAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
Phonon
::
createPath
(
mpMediaObject
,
mpAudioOutput
);
}
mLayout
.
addLayout
(
&
mSeekerLayout
,
0
);
}
void
UBMediaWidget
::
adaptSizeToVideo
()
{
if
(
NULL
!=
mpVideoWidget
){
int
origW
=
mpVideoWidget
->
width
();
int
origH
=
mpVideoWidget
->
height
();
int
newW
=
width
();
float
scaleFactor
=
(
float
)
origW
/
(
float
)
newW
;
int
newH
=
origH
/
scaleFactor
;
resize
(
width
(),
height
()
+
newH
);
}
}
void
UBMediaWidget
::
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
)
{
if
(
!
mGeneratingThumbnail
){
if
(
Phonon
::
LoadingState
==
oldState
&&
Phonon
::
StoppedState
==
newState
){
if
(
eMediaType_Video
==
mType
){
// We do that here to generate the thumbnail of the video
mGeneratingThumbnail
=
true
;
mpMediaObject
->
play
();
mpMediaObject
->
pause
();
mGeneratingThumbnail
=
false
;
}
}
else
if
(
Phonon
::
PlayingState
==
oldState
&&
Phonon
::
PausedState
==
newState
){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
->
setEnabled
(
false
);
}
else
if
((
Phonon
::
PausedState
==
oldState
&&
Phonon
::
PlayingState
==
newState
)
||
(
Phonon
::
StoppedState
==
oldState
&&
Phonon
::
PlayingState
==
newState
)){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/stop.svg"
));
mpPauseButton
->
setEnabled
(
true
);
}
else
if
(
Phonon
::
PlayingState
==
oldState
&&
Phonon
::
StoppedState
==
newState
){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
->
setEnabled
(
false
);
mpSlider
->
setValue
(
0
);
}
}
}
void
UBMediaWidget
::
onTotalTimeChanged
(
qint64
total
)
{
mpSlider
->
setMaximum
(
total
);
}
void
UBMediaWidget
::
onTick
(
qint64
currentTime
)
{
mAutoUpdate
=
true
;
mpSlider
->
setValue
((
int
)
currentTime
);
mAutoUpdate
=
false
;
}
void
UBMediaWidget
::
onSliderChanged
(
int
value
)
{
if
(
!
mAutoUpdate
){
mpMediaObject
->
seek
(
value
);
}
}
void
UBMediaWidget
::
onPlayStopClicked
()
{
switch
(
mpMediaObject
->
state
()){
case
Phonon
:
:
PlayingState
:
mpMediaObject
->
stop
();
break
;
case
Phonon
:
:
StoppedState
:
case
Phonon
:
:
PausedState
:
mpMediaObject
->
play
();
break
;
default
:
break
;
}
}
void
UBMediaWidget
::
onPauseClicked
()
{
mpMediaObject
->
pause
();
}
int
UBMediaWidget
::
border
()
{
return
mBorder
;
}
void
UBMediaWidget
::
resizeEvent
(
QResizeEvent
*
ev
)
{
Q_UNUSED
(
ev
);
}
// -----------------------------------------------------------------------------------------------------------
UBMediaButton
::
UBMediaButton
(
QWidget
*
parent
,
const
char
*
name
)
:
QLabel
(
parent
)
,
mPressed
(
false
)
{
setObjectName
(
name
);
resize
(
UBMEDIABUTTON_SIZE
,
UBMEDIABUTTON_SIZE
);
setStyleSheet
(
QString
(
"padding:0px 0px 0px 0px;"
));
}
UBMediaButton
::~
UBMediaButton
()
{
}
void
UBMediaButton
::
mousePressEvent
(
QMouseEvent
*
ev
)
{
Q_UNUSED
(
ev
);
mPressed
=
true
;
}
void
UBMediaButton
::
mouseReleaseEvent
(
QMouseEvent
*
ev
)
{
Q_UNUSED
(
ev
);
if
(
mPressed
){
mPressed
=
false
;
emit
clicked
();
}
}
src/customWidgets/UBMediaWidget.h
0 → 100644
View file @
955e9289
#ifndef UBMEDIAWIDGET_H
#define UBMEDIAWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
#include <QMouseEvent>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include <phonon/AudioOutput>
#include "interfaces/IResizeable.h"
#define UBMEDIABUTTON_SIZE 32
#define TICK_INTERVAL 1000
typedef
enum
{
eMediaType_Video
,
eMediaType_Audio
}
eMediaType
;
class
UBMediaButton
:
public
QLabel
{
Q_OBJECT
public
:
UBMediaButton
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBMediaButton"
);
~
UBMediaButton
();
signals
:
void
clicked
();
protected
:
void
mousePressEvent
(
QMouseEvent
*
ev
);
void
mouseReleaseEvent
(
QMouseEvent
*
ev
);
private
:
bool
mPressed
;
};
class
UBMediaWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBMediaWidget
(
eMediaType
type
=
eMediaType_Video
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBMediaWidget"
);
~
UBMediaWidget
();
void
setFile
(
const
QString
&
filePath
);
eMediaType
mediaType
();
int
border
();
protected
:
void
resizeEvent
(
QResizeEvent
*
ev
);
private
slots
:
void
onPlayStopClicked
();
void
onPauseClicked
();
void
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
);
void
onTotalTimeChanged
(
qint64
total
);
void
onTick
(
qint64
currentTime
);
void
onSliderChanged
(
int
value
);
private
:
void
createMediaPlayer
();
void
adaptSizeToVideo
();
QString
mFilePath
;
eMediaType
mType
;
Phonon
::
MediaObject
*
mpMediaObject
;
Phonon
::
VideoWidget
*
mpVideoWidget
;
Phonon
::
AudioOutput
*
mpAudioOutput
;
QVBoxLayout
mLayout
;
QHBoxLayout
mSeekerLayout
;
UBMediaButton
*
mpPlayStopButton
;
UBMediaButton
*
mpPauseButton
;
QSlider
*
mpSlider
;
bool
mAutoUpdate
;
bool
mGeneratingThumbnail
;
int
mBorder
;
QWidget
*
mpVideoContainer
;
QVBoxLayout
mVideoLayout
;
};
#endif // UBMEDIAWIDGET_H
src/customWidgets/UBWidgetList.cpp
View file @
955e9289
#include <QDebug>
#include <QScrollBar>
#include "UBGlobals.h"
#include "UBWidgetList.h"
UBWidgetList
::
UBWidgetList
(
QWidget
*
parent
,
eWidgetListOrientation
orientation
,
const
char
*
name
)
:
QScrollArea
(
parent
)
...
...
@@ -20,13 +23,11 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation,
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
mpLayout
=
new
QVBoxLayout
(
mpContainer
);
mpContainer
->
resize
(
mpContainer
->
width
(),
mpContainer
->
height
());
}
else
{
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
mpLayout
=
new
QHBoxLayout
(
mpContainer
);
mpContainer
->
resize
(
mpContainer
->
width
(),
mpContainer
->
height
());
}
mpLayout
->
setContentsMargins
(
margin
(),
margin
(),
margin
(),
margin
());
mpContainer
->
setLayout
(
mpLayout
);
...
...
@@ -35,28 +36,22 @@ UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation,
UBWidgetList
::~
UBWidgetList
()
{
if
(
NULL
!=
mpEmptyLabel
){
delete
mpEmptyLabel
;
mpEmptyLabel
=
NULL
;
}
if
(
NULL
!=
mpLayout
){
delete
mpLayout
;
mpLayout
=
NULL
;
}
if
(
NULL
!=
mpContainer
){
delete
mpContainer
;
mpContainer
=
NULL
;
}
DELETEPTR
(
mpEmptyLabel
);
DELETEPTR
(
mpLayout
);
DELETEPTR
(
mpContainer
);
}
void
UBWidgetList
::
addWidget
(
QWidget
*
widget
)
{
if
(
NULL
!=
mpLayout
){
if
(
NULL
!=
mpLayout
&&
NULL
!=
widget
){
widget
->
setParent
(
mpContainer
);
mpEmptyLabel
->
setVisible
(
false
);
mWidgetInfo
[
widget
]
=
widget
->
size
();
qDebug
()
<<
__FUNCTION__
<<
"widget->size () "
<<
widget
->
size
();
updateView
(
size
());
mpLayout
->
addWidget
(
widget
);
// This call is used only to refresh the size of the widgets
updateSizes
();
}
}
...
...
@@ -78,7 +73,6 @@ int UBWidgetList::scaleWidgets(QSize pSize)
{
// to remove the first spacing that shouldn't be there.
int
result
=
-
mListElementsSpacing
;
int
count
=
0
;
foreach
(
QWidget
*
eachWidget
,
mWidgetInfo
.
keys
()){
qreal
scaleFactor
=
0
;
int
newWidgetWidth
=
pSize
.
width
();
...
...
@@ -87,21 +81,12 @@ int UBWidgetList::scaleWidgets(QSize pSize)
scaleFactor
=
(
float
)
mWidgetInfo
[
eachWidget
].
width
()
/
(
float
)
pSize
.
width
();
newWidgetHeight
=
mWidgetInfo
[
eachWidget
].
height
()
/
scaleFactor
;
result
+=
newWidgetHeight
;
eachWidget
->
setMinimumHeight
(
newWidgetHeight
);
}
else
{
scaleFactor
=
(
float
)
mWidgetInfo
[
eachWidget
].
height
()
/
(
float
)
pSize
.
height
();
newWidgetWidth
=
mWidgetInfo
[
eachWidget
].
width
()
/
scaleFactor
;
result
+=
newWidgetWidth
;
}
#ifndef Q_WS_WIN
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"widget "
<<
&
eachWidget
;
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"count "
<<
count
++
;
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"widget orignal size "
<<
mWidgetInfo
[
eachWidget
];
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"containes size "
<<
pSize
;
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"scale factor "
<<
scaleFactor
;
qDebug
()
<<
__PRETTY_FUNCTION__
<<
"new height "
<<
result
;
#endif
//Adding a vertical/horizontal space between each element of the list
result
+=
mListElementsSpacing
;
}
...
...
@@ -132,11 +117,42 @@ void UBWidgetList::updateView(QSize pSize)
void
UBWidgetList
::
resizeEvent
(
QResizeEvent
*
ev
)
{
Q_UNUSED
(
ev
);
mpEmptyLabel
->
setGeometry
((
width
()
-
mpEmptyLabel
->
width
())
/
2
,
(
height
()
-
mpEmptyLabel
->
height
())
/
2
,
mpEmptyLabel
->
width
(),
mpEmptyLabel
->
height
());
updateView
(
size
());
updateSizes
();
}
void
UBWidgetList
::
updateSizes
()
{
// Resize all the widgets
foreach
(
QWidget
*
eachWidget
,
mWidgetInfo
.
keys
()){
if
(
NULL
!=
eachWidget
){
QSize
originalSize
=
mWidgetInfo
[
eachWidget
];
int
currentWidth
=
mpContainer
->
width
();
int
currentHeight
=
mpContainer
->
height
();
if
(
eWidgetListOrientation_Vertical
==
mOrientation
){
if
(
verticalScrollBar
()
->
isVisible
()){
currentWidth
-=
verticalScrollBar
()
->
width
();
eachWidget
->
setStyleSheet
(
QString
(
"margin-right:%0;"
).
arg
(
verticalScrollBar
()
->
width
()));
}
float
scaleFactor
=
(
float
)
currentWidth
/
(
float
)
originalSize
.
width
();
currentHeight
=
originalSize
.
height
()
*
scaleFactor
;
}
else
{
if
(
horizontalScrollBar
()
->
isVisible
()){
currentHeight
-=
horizontalScrollBar
()
->
height
();
eachWidget
->
setStyleSheet
(
QString
(
"padding-bottom:%0;"
).
arg
(
horizontalScrollBar
()
->
height
()));
}
float
scaleFactor
=
(
float
)
currentHeight
/
(
float
)
originalSize
.
height
();
currentWidth
=
originalSize
.
width
()
*
scaleFactor
;
}
eachWidget
->
resize
(
currentWidth
,
currentHeight
);
}
}
}
void
UBWidgetList
::
setMargin
(
int
margin
)
...
...
src/customWidgets/UBWidgetList.h
View file @
955e9289
...
...
@@ -3,13 +3,15 @@
#include <QWidget>
#include <QScrollArea>
#include <QLayout>
#include <Q
Box
Layout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QVector>
#include <QLabel>
#include "interfaces/IResizeable.h"
typedef
enum
{
eWidgetListOrientation_Vertical
,
eWidgetListOrientation_Horizontal
...
...
@@ -39,7 +41,8 @@ private:
int
scaleWidgets
(
QSize
pSize
);
void
scaleContainer
(
QSize
pSize
,
int
updateValue
);
void
updateView
(
QSize
pSize
);
QLayout
*
mpLayout
;
void
updateSizes
();
QBoxLayout
*
mpLayout
;
QWidget
*
mpContainer
;
eWidgetListOrientation
mOrientation
;
int
mMargin
;
...
...
src/customWidgets/customWidgets.pri
View file @
955e9289
HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h
src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \
src/customWidgets/UBGlobals.h
SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp
src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp
src/gui/UBMediaPlayer.cpp
View file @
955e9289
...
...
@@ -346,6 +346,18 @@ void UBMediaPlayer::hasVideoChanged(bool bHasVideo)
m_videoWindow
.
setVisible
(
bHasVideo
);
}
void
UBMediaPlayer
::
resizeEvent
(
QResizeEvent
*
pEvent
)
{
// int origWidth = m_videoWindow.width();
// int origHeight = m_videoWindow.height();
// float scaleFactor = (float)origWidth / (float)width();
// int newWidth = width();
// int newHeigth = origHeight/scaleFactor;
// m_videoWindow.resize(newWidth, newHeigth);
}
//*************************************************************************
UBDraggableMediaPlayer
::
UBDraggableMediaPlayer
()
:
UBMediaPlayer
()
{
...
...
src/gui/UBMediaPlayer.h
View file @
955e9289
...
...
@@ -62,6 +62,9 @@ public slots:
void
finished
();
void
playPause
();
protected
:
void
resizeEvent
(
QResizeEvent
*
pEvent
);
private
slots
:
void
stateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
bufferStatus
(
int
percent
);
...
...
src/gui/UBTeacherBarWidget.cpp
View file @
955e9289
...
...
@@ -16,6 +16,7 @@
#include "frameworks/UBFileSystemUtils.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBMediaWidget.h"
#include "core/memcheck.h"
...
...
@@ -27,7 +28,6 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
,
mpDurationLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpMediaLabel
(
NULL
)
,
mpDropMediaZone
(
NULL
)
,
mpContainer
(
NULL
)
,
mpContainerLayout
(
NULL
)
,
mpDuration1
(
NULL
)
...
...
@@ -46,6 +46,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
,
mpLinkLayout
(
NULL
)
,
mpStackWidget
(
NULL
)
,
mpPreview
(
NULL
)
,
mpMediaContainer
(
NULL
)
{
setObjectName
(
name
);
mName
=
"TeacherBarWidget"
;
...
...
@@ -121,8 +122,8 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
// Media
mpMediaLabel
=
new
QLabel
(
tr
(
"Media"
),
mpContainer
);
mpLayout
->
addWidget
(
mpMediaLabel
,
0
);
mp
DropMediaZone
=
new
UBTeacherBarDropMediaZone
(
mpContainer
);
mpLayout
->
addWidget
(
mp
DropMediaZone
,
1
);
mp
MediaContainer
=
new
UBTBMediaContainer
(
this
);
mpLayout
->
addWidget
(
mp
MediaContainer
,
1
);
// Links
mpLinkLabel
=
new
QLabel
(
tr
(
"Links"
),
mpContainer
);
...
...
@@ -151,10 +152,15 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
connect
(
mpActionButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onActionButton
()));
connect
(
mpLinkButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onLinkButton
()));
connect
(
mpPreview
,
SIGNAL
(
showEditMode
()),
this
,
SLOT
(
onShowEditMode
()));
connect
(
mpMediaContainer
,
SIGNAL
(
mediaDropped
(
QString
)),
this
,
SLOT
(
onMediaDropped
(
QString
)));
}
UBTeacherBarWidget
::~
UBTeacherBarWidget
()
{
if
(
NULL
!=
mpMediaContainer
){
delete
mpMediaContainer
;
mpMediaContainer
=
NULL
;
}
if
(
NULL
!=
mpComments
){
delete
mpComments
;
mpComments
=
NULL
;
...
...
@@ -179,10 +185,6 @@ UBTeacherBarWidget::~UBTeacherBarWidget()
delete
mpLinkLayout
;
mpLinkLayout
=
NULL
;
}
if
(
NULL
!=
mpDropMediaZone
){
delete
mpDropMediaZone
;
mpDropMediaZone
=
NULL
;
}
if
(
NULL
!=
mpMediaLabel
){
delete
mpMediaLabel
;
mpMediaLabel
=
NULL
;
...
...
@@ -291,8 +293,9 @@ void UBTeacherBarWidget::saveContent()
infos
.
actions
<<
QString
(
"%0;%1"
).
arg
(
mActionList
.
at
(
i
)
->
comboValue
()).
arg
(
mActionList
.
at
(
i
)
->
text
());
}
// Media
// TODO : Get the url of the dropped medias and store them in infos.medias
infos
.
medias
=
mpDropMediaZone
->
mediaList
();
foreach
(
QString
media
,
mpMediaContainer
->
mediaUrls
()){
infos
.
medias
<<
media
;
}
// Links
for
(
int
j
=
0
;
j
<
mUrlList
.
size
();
j
++
){
...
...
@@ -335,7 +338,15 @@ void UBTeacherBarWidget::loadContent()
}
}
// Media
mpDropMediaZone
->
reloadMedia
(
nextInfos
.
medias
);
foreach
(
QString
url
,
nextInfos
.
medias
){
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mMediaList
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
}
// Links
for
(
int
j
=
0
;
j
<
nextInfos
.
urls
.
size
();
j
++
){
...
...
@@ -411,7 +422,7 @@ bool UBTeacherBarWidget::isEmpty()
return
mpTitle
->
text
()
==
""
&&
mpLinks
->
empty
()
&&
mpActions
->
empty
()
&&
mp
DropMediaZone
->
empty
()
&&
mp
MediaContainer
->
empty
()
&&
mpComments
->
document
()
->
toPlainText
()
==
""
;
}
...
...
@@ -436,11 +447,19 @@ void UBTeacherBarWidget::onLinkButton()
void
UBTeacherBarWidget
::
clearWidgetLists
()
{
mpDropMediaZone
->
cleanMedias
();
if
(
NULL
!=
mpMediaContainer
){
for
(
int
i
=
0
;
i
<
mMediaList
.
size
();
i
++
){
mpMediaContainer
->
removeWidget
(
mMediaList
.
at
(
i
));
delete
mMediaList
.
at
(
i
);
}
mMediaList
.
clear
();
mpMediaContainer
->
cleanMedias
();
}
if
(
NULL
!=
mpActions
){
for
(
int
i
=
0
;
i
<
mActionList
.
size
();
i
++
){
mpActions
->
removeWidget
(
mActionList
.
at
(
i
));
delete
mActionList
.
at
(
i
);
}
mActionList
.
clear
();
}
...
...
@@ -448,6 +467,7 @@ void UBTeacherBarWidget::clearWidgetLists()
if
(
NULL
!=
mpLinks
){
for
(
int
i
=
0
;
i
<
mUrlList
.
size
();
i
++
){
mpLinks
->
removeWidget
(
mUrlList
.
at
(
i
));
delete
mUrlList
.
at
(
i
);
}
mUrlList
.
clear
();
}
...
...
@@ -458,6 +478,17 @@ void UBTeacherBarWidget::onShowEditMode()
mpStackWidget
->
setCurrentWidget
(
mpContainer
);
}
void
UBTeacherBarWidget
::
onMediaDropped
(
const
QString
&
url
)
{
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mMediaList
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
}
// ---------------------------------------------------------------------------------------------
UBTeacherStudentAction
::
UBTeacherStudentAction
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpText
(
NULL
)
...
...
@@ -1071,3 +1102,130 @@ void UBActionPreview::setContent(const QString &content)
mpContent
->
setText
(
content
);
}
}
// ------------------------------------------------------------------------------------------------------------------------------------
UBTBMediaContainer
::
UBTBMediaContainer
(
QWidget
*
parent
,
const
char
*
name
)
:
UBWidgetList
(
parent
)
{
setObjectName
(
name
);
setAcceptDrops
(
true
);
}
UBTBMediaContainer
::~
UBTBMediaContainer
()
{
}
void
UBTBMediaContainer
::
dropEvent
(
QDropEvent
*
pEvent
)
{
QPixmap
pixFromDropEvent
;
QString
mimeType
;
QString
resourcePath
;
if
(
pEvent
->
mimeData
()
->
hasText
()){
qDebug
()
<<
"text dropped"
;
resourcePath
=
pEvent
->
mimeData
()
->
text
();
}
else
if
(
pEvent
->
mimeData
()
->
hasUrls
()){
qDebug
()
<<
"url dropped"
;
resourcePath
=
pEvent
->
mimeData
()
->
urls
().
at
(
0
).
toLocalFile
();
}
else
if
(
pEvent
->
mimeData
()
->
hasImage
()){
qDebug
()
<<
"image dropped"
;
pixFromDropEvent
.
loadFromData
(
pEvent
->
mimeData
()
->
imageData
().
toByteArray
());
if
(
!
pixFromDropEvent
.
isNull
())
mimeType
=
"image"
;
}
if
(
mimeType
.
isEmpty
()
&&
resourcePath
.
isEmpty
()){
pEvent
->
acceptProposedAction
();
return
;
}
if
(
!
resourcePath
.
isEmpty
()){
qDebug
()
<<
"emitting 'mediaDropped'"
;
emit
mediaDropped
(
resourcePath
);
pEvent
->
acceptProposedAction
();
}
}
void
UBTBMediaContainer
::
dragEnterEvent
(
QDragEnterEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragMoveEvent
(
QDragMoveEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
)
{
pEvent
->
accept
();
}
void
UBTBMediaContainer
::
addMedia
(
const
QString
&
mediaPath
)
{
if
(
!
mediaPath
.
isEmpty
())
mMediaList
.
append
(
mediaPath
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
mediaPath
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
mediaPath
);
QLabel
*
label
=
new
QLabel
();
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
addWidget
(
label
);
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaPlayer
*
mediaPlayer
=
new
UBMediaPlayer
();
mediaPlayer
->
setFile
(
mediaPath
);
addWidget
(
mediaPlayer
);
}
else
{
qWarning
()
<<
"pMediaPath"
<<
mediaPath
;
qWarning
()
<<
"bad idea to come here"
;
}
}
QStringList
UBTBMediaContainer
::
mediaUrls
()
{
return
mMediaList
;
}
void
UBTBMediaContainer
::
cleanMedias
()
{
mMediaList
.
clear
();
}
QWidget
*
UBTBMediaContainer
::
generateMediaWidget
(
const
QString
&
url
)
{
QWidget
*
pW
=
NULL
;
if
(
!
url
.
isEmpty
())
mMediaList
.
append
(
url
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
url
);
QLabel
*
label
=
new
QLabel
();
pix
.
scaledToWidth
(
label
->
width
());
label
->
resize
(
pix
.
width
(),
pix
.
height
());
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
pW
=
label
;
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaPlayer
*
mediaPlayer
=
new
UBMediaPlayer
();
//UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
mediaPlayer
->
setFile
(
url
);
pW
=
mediaPlayer
;
}
else
{
qWarning
()
<<
"pMediaPath"
<<
url
;
qWarning
()
<<
"bad idea to come here"
;
}
return
pW
;
}
src/gui/UBTeacherBarWidget.h
View file @
955e9289
...
...
@@ -18,6 +18,7 @@ class UBMediaPlayer;
#include "UBDockPaletteWidget.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#define LABEL_MINWIDHT 80
...
...
@@ -174,6 +175,33 @@ private:
UBActionPreview
*
mpTmpAction
;
};
class
UBTBMediaContainer
:
public
UBWidgetList
,
public
IDropable
{
Q_OBJECT
public
:
UBTBMediaContainer
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBMediaContainer"
);
~
UBTBMediaContainer
();
QStringList
mediaUrls
();
QWidget
*
generateMediaWidget
(
const
QString
&
url
);
void
cleanMedias
();
signals
:
void
mediaDropped
(
const
QString
&
url
);
protected
:
void
dropEvent
(
QDropEvent
*
pEvent
);
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
void
dragMoveEvent
(
QDragMoveEvent
*
pEvent
);
void
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
);
private
:
void
addMedia
(
const
QString
&
mediaPath
);
QStringList
mMediaList
;
};
class
UBTeacherBarWidget
:
public
UBDockPaletteWidget
{
Q_OBJECT
...
...
@@ -189,6 +217,7 @@ private slots:
void
onActionButton
();
void
onLinkButton
();
void
onShowEditMode
();
void
onMediaDropped
(
const
QString
&
url
);
private
:
void
clearWidgetLists
();
...
...
@@ -200,7 +229,6 @@ private:
QLabel
*
mpDurationLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpMediaLabel
;
UBTeacherBarDropMediaZone
*
mpDropMediaZone
;
QWidget
*
mpContainer
;
QVBoxLayout
*
mpContainerLayout
;
QCheckBox
*
mpDuration1
;
...
...
@@ -222,6 +250,9 @@ private:
QVector
<
UBTeacherStudentAction
*>
mActionList
;
QVector
<
UBUrlWidget
*>
mUrlList
;
QVector
<
QWidget
*>
mMediaList
;
UBTBMediaContainer
*
mpMediaContainer
;
};
#endif // UBTEACHERBARWIDGET_H
src/interfaces/IDropable.h
0 → 100644
View file @
955e9289
#ifndef IDROPABLE_H
#define IDROPABLE_H
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
class
IDropable
{
public
:
virtual
~
IDropable
(){}
protected
:
virtual
void
dropEvent
(
QDropEvent
*
pEvent
)
=
0
;
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
)
=
0
;
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
pEvent
)
=
0
;
virtual
void
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
)
=
0
;
};
#endif // IDROPABLE_H
src/interfaces/IResizeable.h
0 → 100644
View file @
955e9289
#ifndef IRESIZEABLE_H
#define IRESIZEABLE_H
#include <QResizeEvent>
class
IResizeable
{
public
:
~
IResizeable
();
protected
:
virtual
void
resizeEvent
(
QResizeEvent
*
pEvent
)
=
0
;
};
#endif // IRESIZEABLE_H
src/interfaces/interfaces.pri
0 → 100644
View file @
955e9289
HEADERS += src/interfaces/IDropable.h \
src/interfaces/IDropable.h \
src/interfaces/IResizeable.h
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment