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
0eb128ec
Commit
0eb128ec
authored
May 24, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed unused classes
parent
1fd290d6
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
2 additions
and
1015 deletions
+2
-1015
Sankore_3.1.pro
Sankore_3.1.pro
+0
-1
UBBoardView.cpp
src/board/UBBoardView.cpp
+2
-8
UBActionableWidget.cpp
src/customWidgets/UBActionableWidget.cpp
+0
-65
UBActionableWidget.h
src/customWidgets/UBActionableWidget.h
+0
-45
UBDraggableLabel.cpp
src/customWidgets/UBDraggableLabel.cpp
+0
-39
UBDraggableLabel.h
src/customWidgets/UBDraggableLabel.h
+0
-23
UBDraggableMedia.cpp
src/customWidgets/UBDraggableMedia.cpp
+0
-42
UBDraggableMedia.h
src/customWidgets/UBDraggableMedia.h
+0
-19
UBMediaWidget.cpp
src/customWidgets/UBMediaWidget.cpp
+0
-335
UBMediaWidget.h
src/customWidgets/UBMediaWidget.h
+0
-127
UBWidgetList.cpp
src/customWidgets/UBWidgetList.cpp
+0
-229
UBWidgetList.h
src/customWidgets/UBWidgetList.h
+0
-69
customWidgets.pri
src/customWidgets/customWidgets.pri
+0
-13
No files found.
Sankore_3.1.pro
View file @
0eb128ec
...
...
@@ -52,7 +52,6 @@ include(src/tools/tools.pri)
include
(
src
/
desktop
/
desktop
.
pri
)
include
(
src
/
web
/
web
.
pri
)
include
(
src
/
transition
/
transition
.
pri
)
include
(
src
/
customWidgets
/
customWidgets
.
pri
)
include
(
src
/
interfaces
/
interfaces
.
pri
)
DEPENDPATH
+=
src
/
pdf
-
merger
...
...
src/board/UBBoardView.cpp
View file @
0eb128ec
...
...
@@ -49,9 +49,6 @@
#include "document/UBDocumentProxy.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBDraggableMedia.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
...
...
@@ -813,14 +810,11 @@ void UBBoardView::dropEvent (QDropEvent *event)
UBGraphicsWidgetItem
*
graphicsWidget
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
graphicsItemAtPos
);
if
(
graphicsWidget
&&
graphicsWidget
->
acceptDrops
())
{
graphicsWidget
->
processDropEvent
(
event
);
event
->
acceptProposedAction
();
}
else
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QWebView
*>
(
event
->
source
())
||
dynamic_cast
<
UBDraggableMediaPlayer
*>
(
event
->
source
())
||
dynamic_cast
<
UBDraggableLabel
*>
(
event
->
source
())
||
dynamic_cast
<
UBDraggableMedia
*>
(
event
->
source
()))
{
}
else
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
())
||
dynamic_cast
<
QWebView
*>
(
event
->
source
())){
mController
->
processMimeData
(
event
->
mimeData
(),
mapToScene
(
event
->
pos
()));
event
->
acceptProposedAction
();
}
...
...
src/customWidgets/UBActionableWidget.cpp
deleted
100644 → 0
View file @
1fd290d6
#include <QPainter>
#include <QDebug>
#include "UBActionableWidget.h"
UBActionableWidget
::
UBActionableWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mShowActions
(
false
)
{
setObjectName
(
name
);
mActions
.
clear
();
mCloseButtons
.
setIcon
(
QIcon
(
QPixmap
(
":images/close.svg"
)));
mCloseButtons
.
setGeometry
(
0
,
0
,
2
*
ACTIONSIZE
,
ACTIONSIZE
);
mCloseButtons
.
setVisible
(
false
);
connect
(
&
mCloseButtons
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onCloseClicked
()));
}
UBActionableWidget
::~
UBActionableWidget
()
{
}
void
UBActionableWidget
::
addAction
(
eAction
act
)
{
if
(
!
mActions
.
contains
(
act
)){
mActions
<<
act
;
}
}
void
UBActionableWidget
::
removeAction
(
eAction
act
)
{
if
(
mActions
.
contains
(
act
)){
mActions
.
remove
(
mActions
.
indexOf
(
act
));
}
}
void
UBActionableWidget
::
removeAllActions
()
{
mActions
.
clear
();
}
void
UBActionableWidget
::
setActionsVisible
(
bool
bVisible
)
{
if
(
!
mActions
.
empty
()
&&
mActions
.
contains
(
eAction_Close
)){
mCloseButtons
.
setVisible
(
bVisible
);
}
}
void
UBActionableWidget
::
onCloseClicked
()
{
emit
close
(
this
);
}
void
UBActionableWidget
::
setActionsParent
(
QWidget
*
parent
)
{
if
(
mActions
.
contains
(
eAction_Close
)){
mCloseButtons
.
setParent
(
parent
);
}
}
void
UBActionableWidget
::
unsetActionsParent
()
{
if
(
mActions
.
contains
(
eAction_Close
)){
mCloseButtons
.
setParent
(
this
);
}
}
src/customWidgets/UBActionableWidget.h
deleted
100644 → 0
View file @
1fd290d6
#ifndef UBACTIONABLEWIDGET_H
#define UBACTIONABLEWIDGET_H
#include <QWidget>
#include <QPaintEvent>
#include <QToolButton>
#include <QPushButton>
#define ACTIONSIZE 16
typedef
enum
{
eAction_Close
,
eAction_MoveUp
,
eAction_MoveDown
}
eAction
;
class
UBActionableWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBActionableWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBActionableWidget"
);
~
UBActionableWidget
();
void
addAction
(
eAction
act
);
void
removeAction
(
eAction
act
);
void
removeAllActions
();
void
setActionsVisible
(
bool
bVisible
);
signals
:
void
close
(
QWidget
*
w
);
protected
:
void
setActionsParent
(
QWidget
*
parent
);
void
unsetActionsParent
();
QVector
<
eAction
>
mActions
;
QPushButton
mCloseButtons
;
private
slots
:
void
onCloseClicked
();
private
:
bool
mShowActions
;
};
#endif // UBACTIONABLEWIDGET_H
src/customWidgets/UBDraggableLabel.cpp
deleted
100644 → 0
View file @
1fd290d6
#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
();
}
src/customWidgets/UBDraggableLabel.h
deleted
100644 → 0
View file @
1fd290d6
#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
src/customWidgets/UBDraggableMedia.cpp
deleted
100644 → 0
View file @
1fd290d6
#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
);
}
src/customWidgets/UBDraggableMedia.h
deleted
100644 → 0
View file @
1fd290d6
#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
src/customWidgets/UBMediaWidget.cpp
deleted
100644 → 0
View file @
1fd290d6
/*
* 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 "UBMediaWidget.h"
/**
* \brief Constructor
* @param type as the media type
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaWidget
::
UBMediaWidget
(
eMediaType
type
,
QWidget
*
parent
,
const
char
*
name
)
:
UBActionableWidget
(
parent
,
name
)
,
mpMediaObject
(
NULL
)
,
mpVideoWidget
(
NULL
)
,
mpAudioOutput
(
NULL
)
,
mpPlayStopButton
(
NULL
)
,
mpPauseButton
(
NULL
)
,
mpSlider
(
NULL
)
,
mAutoUpdate
(
false
)
,
mGeneratingThumbnail
(
false
)
,
mBorder
(
5
)
,
mpMediaContainer
(
NULL
)
,
mpCover
(
NULL
)
{
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
addAction
(
eAction_Close
);
mType
=
type
;
setLayout
(
&
mLayout
);
mpPlayStopButton
=
new
UBMediaButton
(
this
);
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
=
new
UBMediaButton
(
this
);
mpPauseButton
->
setPixmap
(
QPixmap
(
":images/pause.svg"
));
mpPauseButton
->
setEnabled
(
false
);
mpSlider
=
new
QSlider
(
this
);
mpSlider
->
setOrientation
(
Qt
::
Horizontal
);
mpSlider
->
setMinimum
(
0
);
mpSlider
->
setMaximum
(
0
);
mSeekerLayout
.
addWidget
(
mpPlayStopButton
,
0
);
mSeekerLayout
.
addWidget
(
mpPauseButton
,
0
);
mSeekerLayout
.
addWidget
(
mpSlider
,
1
);
mSeekerLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
);
connect
(
mpPlayStopButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPlayStopClicked
()));
connect
(
mpPauseButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPauseClicked
()));
connect
(
mpSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
onSliderChanged
(
int
)));
}
/**
* \brief Destructor
*/
UBMediaWidget
::~
UBMediaWidget
()
{
unsetActionsParent
();
DELETEPTR
(
mpSlider
);
DELETEPTR
(
mpPauseButton
);
DELETEPTR
(
mpPlayStopButton
);
DELETEPTR
(
mpAudioOutput
);
DELETEPTR
(
mpVideoWidget
);
DELETEPTR
(
mpMediaObject
);
DELETEPTR
(
mpCover
);
}
/**
* \brief Set the media file
* @param filePath as the media file path
*/
void
UBMediaWidget
::
setFile
(
const
QString
&
filePath
)
{
Q_ASSERT
(
""
!=
filePath
);
mFilePath
=
filePath
;
mpMediaObject
=
new
Phonon
::
MediaObject
(
this
);
mpMediaObject
->
setTickInterval
(
TICK_INTERVAL
);
connect
(
mpMediaObject
,
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)),
this
,
SLOT
(
onStateChanged
(
Phonon
::
State
,
Phonon
::
State
)));
connect
(
mpMediaObject
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
onTotalTimeChanged
(
qint64
)));
connect
(
mpMediaObject
,
SIGNAL
(
tick
(
qint64
)),
this
,
SLOT
(
onTick
(
qint64
)));
mpMediaObject
->
setCurrentSource
(
Phonon
::
MediaSource
(
filePath
));
createMediaPlayer
();
}
/**
* \brief Get the media type
* @returns the media type
*/
eMediaType
UBMediaWidget
::
mediaType
()
{
return
mType
;
}
void
UBMediaWidget
::
showEvent
(
QShowEvent
*
event
)
{
if
(
!
mpVideoWidget
){
mpVideoWidget
=
new
Phonon
::
VideoWidget
(
this
);
mMediaLayout
.
addStretch
(
1
);
mMediaLayout
.
addWidget
(
mpVideoWidget
,
0
);
mMediaLayout
.
addStretch
(
1
);
Phonon
::
createPath
(
mpMediaObject
,
mpVideoWidget
);
adaptSizeToVideo
();
mpMediaObject
->
play
();
mpMediaObject
->
stop
();
}
QWidget
::
showEvent
(
event
);
}
/**
* \brief Create the media player
*/
void
UBMediaWidget
::
createMediaPlayer
()
{
mpMediaContainer
=
new
QWidget
(
this
);
mpMediaContainer
->
setObjectName
(
"UBMediaVideoContainer"
);
mpMediaContainer
->
setLayout
(
&
mMediaLayout
);
if
(
eMediaType_Video
==
mType
){
mMediaLayout
.
setContentsMargins
(
10
,
10
,
25
,
10
);
if
(
isVisible
()){
mpVideoWidget
=
new
Phonon
::
VideoWidget
(
this
);
mMediaLayout
.
addStretch
(
1
);
mMediaLayout
.
addWidget
(
mpVideoWidget
,
0
);
mMediaLayout
.
addStretch
(
1
);
Phonon
::
createPath
(
mpMediaObject
,
mpVideoWidget
);
adaptSizeToVideo
();
}
mpAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
VideoCategory
,
this
);
Phonon
::
createPath
(
mpMediaObject
,
mpAudioOutput
);
}
else
if
(
eMediaType_Audio
==
mType
){
mMediaLayout
.
setContentsMargins
(
10
,
10
,
10
,
10
);
mpCover
=
new
QLabel
(
mpMediaContainer
);
mpMediaContainer
->
setStyleSheet
(
QString
(
"background: none;"
));
setAudioCover
(
":images/libpalette/soundIcon.svg"
);
mpCover
->
setScaledContents
(
true
);
mMediaLayout
.
addStretch
(
1
);
mMediaLayout
.
addWidget
(
mpCover
,
0
);
mMediaLayout
.
addStretch
(
1
);
mpAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
Phonon
::
createPath
(
mpMediaObject
,
mpAudioOutput
);
}
mLayout
.
addWidget
(
mpMediaContainer
,
1
);
mLayout
.
addLayout
(
&
mSeekerLayout
,
0
);
setActionsParent
(
mpMediaContainer
);
}
/**
* \brief Adapt the widget size to the video in order to keep the good aspect ratio
*/
void
UBMediaWidget
::
adaptSizeToVideo
()
{
if
(
NULL
!=
mpMediaContainer
){
int
origW
=
mpMediaContainer
->
width
();
int
origH
=
mpMediaContainer
->
height
();
int
newW
=
width
();
float
scaleFactor
=
(
float
)
origW
/
(
float
)
newW
;
int
newH
=
origH
/
scaleFactor
;
resize
(
newW
,
height
()
+
newH
);
}
}
/**
* \brief Handle the media state change notification
* @param newState as the new state
* @param oldState as the old state
*/
void
UBMediaWidget
::
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
)
{
if
(
!
mGeneratingThumbnail
){
if
(
Phonon
::
LoadingState
==
oldState
&&
Phonon
::
StoppedState
==
newState
){
if
(
eMediaType_Video
==
mType
){
// We do that here to generate the thumbnail of the video
mGeneratingThumbnail
=
true
;
mpMediaObject
->
play
();
mpMediaObject
->
pause
();
mGeneratingThumbnail
=
false
;
}
}
else
if
(
Phonon
::
PlayingState
==
oldState
&&
Phonon
::
PausedState
==
newState
){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
->
setEnabled
(
false
);
}
else
if
((
Phonon
::
PausedState
==
oldState
&&
Phonon
::
PlayingState
==
newState
)
||
(
Phonon
::
StoppedState
==
oldState
&&
Phonon
::
PlayingState
==
newState
)){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/stop.svg"
));
mpPauseButton
->
setEnabled
(
true
);
}
else
if
(
Phonon
::
PlayingState
==
oldState
&&
Phonon
::
StoppedState
==
newState
){
mpPlayStopButton
->
setPixmap
(
QPixmap
(
":images/play.svg"
));
mpPauseButton
->
setEnabled
(
false
);
mpSlider
->
setValue
(
0
);
}
}
}
/**
* \brief Handles the total time change notification
* @param total as the new total time
*/
void
UBMediaWidget
::
onTotalTimeChanged
(
qint64
total
)
{
mpSlider
->
setMaximum
(
total
);
}
/**
* \brief Handles the tick notification
* @param currentTime as the current time
*/
void
UBMediaWidget
::
onTick
(
qint64
currentTime
)
{
mAutoUpdate
=
true
;
mpSlider
->
setValue
((
int
)
currentTime
);
mAutoUpdate
=
false
;
}
/**
* \brief Handles the seeker value change notification
* @param value as the new seeker value
*/
void
UBMediaWidget
::
onSliderChanged
(
int
value
)
{
if
(
!
mAutoUpdate
){
mpMediaObject
->
seek
(
value
);
}
}
/**
* \brief Toggle Play-Stop
*/
void
UBMediaWidget
::
onPlayStopClicked
()
{
switch
(
mpMediaObject
->
state
()){
case
Phonon
:
:
PlayingState
:
mpMediaObject
->
stop
();
break
;
case
Phonon
:
:
StoppedState
:
case
Phonon
:
:
PausedState
:
mpMediaObject
->
play
();
break
;
default
:
break
;
}
}
/**
* \brief Pause the media
*/
void
UBMediaWidget
::
onPauseClicked
()
{
mpMediaObject
->
pause
();
}
/**
* Get the border
* @returns the actual border
*/
int
UBMediaWidget
::
border
()
{
return
mBorder
;
}
/**
* \brief Handles the resize event
* @param ev as the resize event
*/
void
UBMediaWidget
::
resizeEvent
(
QResizeEvent
*
ev
)
{
Q_UNUSED
(
ev
);
}
/**
* \brief Set the audio cover
* @param coverPath as the cover image file path
*/
void
UBMediaWidget
::
setAudioCover
(
const
QString
&
coverPath
)
{
if
(
NULL
!=
mpCover
){
mpCover
->
setPixmap
(
QPixmap
(
coverPath
));
}
}
// -----------------------------------------------------------------------------------------------------------
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaButton
::
UBMediaButton
(
QWidget
*
parent
,
const
char
*
name
)
:
QLabel
(
parent
)
,
mPressed
(
false
)
{
setObjectName
(
name
);
resize
(
UBMEDIABUTTON_SIZE
,
UBMEDIABUTTON_SIZE
);
setStyleSheet
(
QString
(
"padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"
));
}
/**
* \brief Destructor
*/
UBMediaButton
::~
UBMediaButton
()
{
}
/**
* \brief Handles the mouse press notification
* @param ev as the mouse press event
*/
void
UBMediaButton
::
mousePressEvent
(
QMouseEvent
*
ev
)
{
Q_UNUSED
(
ev
);
mPressed
=
true
;
}
/**
* \brief Handles the mouse release notification
* @param ev as the mouse release event
*/
void
UBMediaButton
::
mouseReleaseEvent
(
QMouseEvent
*
ev
)
{
Q_UNUSED
(
ev
);
if
(
mPressed
){
mPressed
=
false
;
emit
clicked
();
}
}
src/customWidgets/UBMediaWidget.h
deleted
100644 → 0
View file @
1fd290d6
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMEDIAWIDGET_H
#define UBMEDIAWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
#include <QMouseEvent>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include <phonon/AudioOutput>
#include "interfaces/IResizeable.h"
#include "UBActionableWidget.h"
#define UBMEDIABUTTON_SIZE 32
#define TICK_INTERVAL 1000
/**
* \brief The media type
*/
typedef
enum
{
eMediaType_Video
,
eMediaType_Audio
}
eMediaType
;
class
UBMediaButton
:
public
QLabel
{
Q_OBJECT
public
:
UBMediaButton
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBMediaButton"
);
~
UBMediaButton
();
signals
:
void
clicked
();
protected
:
void
mousePressEvent
(
QMouseEvent
*
ev
);
void
mouseReleaseEvent
(
QMouseEvent
*
ev
);
private
:
/** And indicator of the press event in progress */
bool
mPressed
;
};
class
UBMediaWidget
:
public
UBActionableWidget
{
Q_OBJECT
public
:
UBMediaWidget
(
eMediaType
type
=
eMediaType_Video
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBMediaWidget"
);
~
UBMediaWidget
();
void
setFile
(
const
QString
&
filePath
);
eMediaType
mediaType
();
int
border
();
void
setAudioCover
(
const
QString
&
coverPath
);
void
setUrl
(
const
QString
&
url
){
mUrl
=
url
;}
QString
url
(){
return
mUrl
;}
protected
:
void
resizeEvent
(
QResizeEvent
*
ev
);
void
showEvent
(
QShowEvent
*
event
);
/** The current media file path */
QString
mFilePath
;
private
slots
:
void
onPlayStopClicked
();
void
onPauseClicked
();
void
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
);
void
onTotalTimeChanged
(
qint64
total
);
void
onTick
(
qint64
currentTime
);
void
onSliderChanged
(
int
value
);
private
:
void
createMediaPlayer
();
void
adaptSizeToVideo
();
/** The current media type */
eMediaType
mType
;
/** The media object */
Phonon
::
MediaObject
*
mpMediaObject
;
/** The video renderer */
Phonon
::
VideoWidget
*
mpVideoWidget
;
/** The audio renderer */
Phonon
::
AudioOutput
*
mpAudioOutput
;
/** The principal layout of this widget */
QVBoxLayout
mLayout
;
/** The seeker layout */
QHBoxLayout
mSeekerLayout
;
/** The play-stop button */
UBMediaButton
*
mpPlayStopButton
;
/** The pause button */
UBMediaButton
*
mpPauseButton
;
/** The seeker slider */
QSlider
*
mpSlider
;
/** An indicator of the seeker auto update in progress */
bool
mAutoUpdate
;
/** An indicator of the thumbnail generation in progress */
bool
mGeneratingThumbnail
;
/** The border */
int
mBorder
;
/** A widget that will contain the media */
QWidget
*
mpMediaContainer
;
/** The media layout */
QHBoxLayout
mMediaLayout
;
/** The audio cover */
QLabel
*
mpCover
;
/** The media url */
QString
mUrl
;
};
#endif // UBMEDIAWIDGET_H
src/customWidgets/UBWidgetList.cpp
deleted
100644 → 0
View file @
1fd290d6
#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
();
}
src/customWidgets/UBWidgetList.h
deleted
100644 → 0
View file @
1fd290d6
#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
src/customWidgets/customWidgets.pri
deleted
100644 → 0
View file @
1fd290d6
HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \
src/globals/UBGlobals.h \
src/customWidgets/UBDraggableMedia.h \
src/customWidgets/UBActionableWidget.h
SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp \
src/customWidgets/UBDraggableMedia.cpp \
src/customWidgets/UBActionableWidget.cpp
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