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
af1e875a
Commit
af1e875a
authored
Jan 13, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified the audio midget
parent
4c4d569b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
168 deletions
+35
-168
UBMediaWidget.cpp
src/customWidgets/UBMediaWidget.cpp
+30
-10
UBMediaWidget.h
src/customWidgets/UBMediaWidget.h
+4
-2
UBTeacherBarWidget.cpp
src/gui/UBTeacherBarWidget.cpp
+1
-125
UBTeacherBarWidget.h
src/gui/UBTeacherBarWidget.h
+0
-31
No files found.
src/customWidgets/UBMediaWidget.cpp
View file @
af1e875a
...
...
@@ -12,7 +12,8 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
,
mAutoUpdate
(
false
)
,
mGeneratingThumbnail
(
false
)
,
mBorder
(
5
)
,
mpVideoContainer
(
NULL
)
,
mpMediaContainer
(
NULL
)
,
mpCover
(
NULL
)
{
setObjectName
(
name
);
...
...
@@ -50,6 +51,7 @@ UBMediaWidget::~UBMediaWidget()
DELETEPTR
(
mpAudioOutput
);
DELETEPTR
(
mpVideoWidget
);
DELETEPTR
(
mpMediaObject
);
DELETEPTR
(
mpCover
);
}
void
UBMediaWidget
::
setFile
(
const
QString
&
filePath
)
...
...
@@ -72,30 +74,41 @@ eMediaType UBMediaWidget::mediaType()
void
UBMediaWidget
::
createMediaPlayer
()
{
mpMediaContainer
=
new
QWidget
(
this
);
mpMediaContainer
->
setObjectName
(
"UBMediaVideoContainer"
);
mpMediaContainer
->
setLayout
(
&
mMediaLayout
);
if
(
eMediaType_Video
==
mType
){
mMediaLayout
.
setContentsMargins
(
10
,
10
,
25
,
10
);
mpVideoWidget
=
new
Phonon
::
VideoWidget
(
this
);
mpVideoContainer
=
new
QWidget
(
this
);
mpVideoContainer
->
setObjectName
(
"UBMediaVideoContainer"
);
mVideoLayout
.
setContentsMargins
(
10
,
10
,
25
,
10
);
mpVideoContainer
->
setLayout
(
&
mVideoLayout
);
mVideoLayout
.
addWidget
(
mpVideoWidget
,
1
);
mMediaLayout
.
addStretch
(
1
);
mMediaLayout
.
addWidget
(
mpVideoWidget
,
0
);
mMediaLayout
.
addStretch
(
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
){
mMediaLayout
.
setContentsMargins
(
10
,
10
,
10
,
10
);
mpCover
=
new
QLabel
(
mpMediaContainer
);
mpMediaContainer
->
setStyleSheet
(
QString
(
"background: none;"
));
setAudioCover
(
":images/libpalette/soundIcon.svg"
);
mpCover
->
setScaledContents
(
true
);
mMediaLayout
.
addStretch
(
1
);
mMediaLayout
.
addWidget
(
mpCover
,
0
);
mMediaLayout
.
addStretch
(
1
);
mpAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
Phonon
::
createPath
(
mpMediaObject
,
mpAudioOutput
);
}
mLayout
.
addWidget
(
mpMediaContainer
,
1
);
mLayout
.
addLayout
(
&
mSeekerLayout
,
0
);
}
void
UBMediaWidget
::
adaptSizeToVideo
()
{
if
(
NULL
!=
mp
Video
Container
){
int
origW
=
mp
Video
Container
->
width
();
int
origH
=
mp
Video
Container
->
height
();
if
(
NULL
!=
mp
Media
Container
){
int
origW
=
mp
Media
Container
->
width
();
int
origH
=
mp
Media
Container
->
height
();
int
newW
=
width
();
float
scaleFactor
=
(
float
)
origW
/
(
float
)
newW
;
int
newH
=
origH
/
scaleFactor
;
...
...
@@ -179,6 +192,13 @@ void UBMediaWidget::resizeEvent(QResizeEvent* ev)
Q_UNUSED
(
ev
);
}
void
UBMediaWidget
::
setAudioCover
(
const
QString
&
coverPath
)
{
if
(
NULL
!=
mpCover
){
mpCover
->
setPixmap
(
QPixmap
(
coverPath
));
}
}
// -----------------------------------------------------------------------------------------------------------
UBMediaButton
::
UBMediaButton
(
QWidget
*
parent
,
const
char
*
name
)
:
QLabel
(
parent
)
,
mPressed
(
false
)
...
...
src/customWidgets/UBMediaWidget.h
View file @
af1e875a
...
...
@@ -49,6 +49,7 @@ public:
void
setFile
(
const
QString
&
filePath
);
eMediaType
mediaType
();
int
border
();
void
setAudioCover
(
const
QString
&
coverPath
);
protected
:
void
resizeEvent
(
QResizeEvent
*
ev
);
...
...
@@ -78,8 +79,9 @@ private:
bool
mAutoUpdate
;
bool
mGeneratingThumbnail
;
int
mBorder
;
QWidget
*
mpVideoContainer
;
QVBoxLayout
mVideoLayout
;
QWidget
*
mpMediaContainer
;
QHBoxLayout
mMediaLayout
;
QLabel
*
mpCover
;
};
#endif // UBMEDIAWIDGET_H
src/gui/UBTeacherBarWidget.cpp
View file @
af1e875a
...
...
@@ -123,6 +123,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mpMediaLabel
=
new
QLabel
(
tr
(
"Medias"
),
mpContainer
);
mpLayout
->
addWidget
(
mpMediaLabel
,
0
);
mpMediaContainer
=
new
UBTBMediaContainer
(
this
);
mpMediaContainer
->
setEmptyText
(
tr
(
"Drop media here"
));
mpLayout
->
addWidget
(
mpMediaContainer
,
1
);
// Links
...
...
@@ -587,128 +588,6 @@ void UBTeacherStudentAction::setText(const QString& text)
}
}
// ---------------------------------------------------------------------------------------------
UBTeacherBarDropMediaZone
::
UBTeacherBarDropMediaZone
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
{
setObjectName
(
name
);
setAcceptDrops
(
true
);
mWidget
=
new
UBWidgetList
(
parent
);
mWidget
->
setEmptyText
(
tr
(
"Drag media here ..."
));
mLayout
.
addWidget
(
mWidget
);
setLayout
(
&
mLayout
);
// The next line is disgusting. This is a quickfix that must be reworked later
setContentsMargins
(
-
9
,
-
9
,
-
9
,
-
9
);
}
UBTeacherBarDropMediaZone
::~
UBTeacherBarDropMediaZone
()
{
cleanMedias
();
if
(
mWidget
){
delete
mWidget
;
mWidget
=
NULL
;
}
}
void
UBTeacherBarDropMediaZone
::
cleanMedias
()
{
foreach
(
QWidget
*
eachWidget
,
mWidgetList
){
mWidget
->
removeWidget
(
eachWidget
);
delete
eachWidget
;
}
mWidgetList
.
clear
();
mMediaList
.
clear
();
}
bool
UBTeacherBarDropMediaZone
::
empty
()
{
return
mWidget
->
empty
();
}
void
UBTeacherBarDropMediaZone
::
dragEnterEvent
(
QDragEnterEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTeacherBarDropMediaZone
::
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
)
{
pEvent
->
accept
();
}
void
UBTeacherBarDropMediaZone
::
addMedia
(
QString
pMediaPath
)
{
if
(
!
pMediaPath
.
isEmpty
())
mMediaList
.
append
(
pMediaPath
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
pMediaPath
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
pMediaPath
);
QLabel
*
label
=
new
QLabel
();
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
mWidget
->
addWidget
(
label
);
mWidgetList
<<
label
;
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaPlayer
*
mediaPlayer
=
new
UBMediaPlayer
();
mediaPlayer
->
setFile
(
pMediaPath
);
mWidget
->
addWidget
(
mediaPlayer
);
mWidgetList
<<
mediaPlayer
;
}
else
{
qWarning
()
<<
"pMediaPath"
<<
pMediaPath
;
qWarning
()
<<
"bad idea to come here"
;
}
}
void
UBTeacherBarDropMediaZone
::
reloadMedia
(
QStringList
pList
)
{
cleanMedias
();
foreach
(
QString
eachString
,
pList
){
addMedia
(
eachString
);
}
}
void
UBTeacherBarDropMediaZone
::
dropEvent
(
QDropEvent
*
pEvent
)
{
QPixmap
pixFromDropEvent
;
QString
mimeType
;
QString
resourcePath
;
if
(
pEvent
->
mimeData
()
->
hasText
()){
qDebug
()
<<
"pEvent->mimeData()->hasText()"
<<
pEvent
->
mimeData
()
->
text
();
resourcePath
=
pEvent
->
mimeData
()
->
text
();
}
else
if
(
pEvent
->
mimeData
()
->
hasUrls
()){
qDebug
()
<<
"pEvent->mimeData()->hasUrls()"
<<
pEvent
->
mimeData
()
->
urls
().
at
(
0
);
resourcePath
=
pEvent
->
mimeData
()
->
urls
().
at
(
0
).
toLocalFile
();
}
else
if
(
pEvent
->
mimeData
()
->
hasImage
()){
qDebug
()
<<
"pEvent->mimeData()->hasImage()"
;
pixFromDropEvent
.
loadFromData
(
pEvent
->
mimeData
()
->
imageData
().
toByteArray
());
if
(
!
pixFromDropEvent
.
isNull
())
mimeType
=
"image"
;
}
if
(
mimeType
.
isEmpty
()
&&
resourcePath
.
isEmpty
()){
pEvent
->
acceptProposedAction
();
return
;
}
if
(
!
resourcePath
.
isEmpty
())
addMedia
(
resourcePath
);
pEvent
->
acceptProposedAction
();
}
void
UBTeacherBarDropMediaZone
::
dragMoveEvent
(
QDragMoveEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
// ---------------------------------------------------------------------------------------------
UBUrlWidget
::
UBUrlWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpLayout
(
NULL
)
...
...
@@ -997,9 +876,7 @@ UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char*
{
setObjectName
(
name
);
mWidget
=
new
UBWidgetList
(
parent
);
// mWidget->setEmptyText(tr("No media found"));
mLayout
.
addWidget
(
mWidget
);
// mWidget->setStyleSheet(QString("background-color: red;"));
setLayout
(
&
mLayout
);
mWidgetList
.
clear
();
}
...
...
@@ -1235,7 +1112,6 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
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
;
...
...
src/gui/UBTeacherBarWidget.h
View file @
af1e875a
...
...
@@ -52,36 +52,6 @@ private:
QComboBox
*
mpCombo
;
};
class
UBTeacherBarDropMediaZone
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherBarDropMediaZone
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherBarDropMediaZone"
);
~
UBTeacherBarDropMediaZone
();
QStringList
mediaList
()
{
return
mMediaList
;}
void
reloadMedia
(
QStringList
pList
);
void
cleanMedias
();
bool
empty
();
private
:
void
addMedia
(
QString
pMediaPath
);
QStringList
mMediaList
;
QList
<
QWidget
*>
mWidgetList
;
UBWidgetList
*
mWidget
;
QVBoxLayout
mLayout
;
protected
:
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
void
dropEvent
(
QDropEvent
*
pEvent
);
void
dragMoveEvent
(
QDragMoveEvent
*
pEvent
);
void
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
);
};
class
UBTeacherBarPreviewMedia
:
public
QWidget
{
Q_OBJECT
...
...
@@ -176,7 +146,6 @@ private:
UBActionPreview
*
mpTmpAction
;
};
class
UBTBMediaContainer
:
public
UBWidgetList
,
public
IDropable
{
...
...
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