Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a3ecaf15
Commit
a3ecaf15
authored
Jan 29, 2015
by
Jonathan Calmels
Committed by
Jean-Baptiste Kempf
Jan 29, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: add a loading bar animation when the cache is empty
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
9d679e90
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
modules/gui/qt4/styles/seekstyle.cpp
modules/gui/qt4/styles/seekstyle.cpp
+11
-0
modules/gui/qt4/styles/seekstyle.hpp
modules/gui/qt4/styles/seekstyle.hpp
+1
-0
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+48
-0
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+7
-0
No files found.
modules/gui/qt4/styles/seekstyle.cpp
View file @
a3ecaf15
...
...
@@ -127,6 +127,17 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
painter
->
drawRoundedRect
(
valueRect
,
RADIUS
,
RADIUS
);
}
if
(
slideroptions
->
buffering
==
0.0
&&
slideroptions
->
animationloading
>
0.0
)
{
int
width
=
groove
.
width
()
-
groove
.
width
()
/
6
;
QRect
innerRect
=
groove
.
adjusted
(
slideroptions
->
animationloading
*
width
+
1
,
1
,
width
*
(
-
1.0
+
slideroptions
->
animationloading
)
-
1
,
0
);
QColor
overlayColor
=
QColor
(
"Orange"
);
overlayColor
.
setAlpha
(
128
);
painter
->
setBrush
(
overlayColor
);
painter
->
drawRoundedRect
(
innerRect
,
RADIUS
,
RADIUS
);
}
/* draw buffering overlay */
if
(
slideroptions
->
buffering
>
0.0
&&
slideroptions
->
buffering
<
1.0
)
{
...
...
modules/gui/qt4/styles/seekstyle.hpp
View file @
a3ecaf15
...
...
@@ -41,6 +41,7 @@ public:
int
length
;
bool
animate
;
qreal
animationopacity
;
qreal
animationloading
;
QList
<
int64_t
>
points
;
};
...
...
modules/gui/qt4/util/input_slider.cpp
View file @
a3ecaf15
...
...
@@ -32,6 +32,7 @@
#include "util/input_slider.hpp"
#include "util/timetooltip.hpp"
#include "adapters/seekpoints.hpp"
#include "input_manager.hpp"
#include <QPaintEvent>
#include <QPainter>
...
...
@@ -48,6 +49,7 @@
#include <QPropertyAnimation>
#include <QApplication>
#include <QDebug>
#include <QSequentialAnimationGroup>
#define MINIMUM 0
#define MAXIMUM 1000
...
...
@@ -62,6 +64,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
isJumping
=
false
;
f_buffering
=
0.0
;
mHandleOpacity
=
1.0
;
mLoading
=
0.0
;
chapters
=
NULL
;
mHandleLength
=
-
1
;
b_seekable
=
true
;
...
...
@@ -130,10 +133,27 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
animHandle
->
setStartValue
(
0.0
);
animHandle
->
setEndValue
(
1.0
);
QPropertyAnimation
*
animLoadingIn
=
new
QPropertyAnimation
(
this
,
"loadingProperty"
,
this
);
animLoadingIn
->
setDuration
(
2000
);
animLoadingIn
->
setStartValue
(
0.0
);
animLoadingIn
->
setEndValue
(
1.0
);
animLoadingIn
->
setEasingCurve
(
QEasingCurve
::
OutBounce
);
QPropertyAnimation
*
animLoadingOut
=
new
QPropertyAnimation
(
this
,
"loadingProperty"
,
this
);
animLoadingOut
->
setDuration
(
2000
);
animLoadingOut
->
setStartValue
(
1.0
);
animLoadingOut
->
setEndValue
(
0.0
);
animLoadingOut
->
setEasingCurve
(
QEasingCurve
::
OutBounce
);
animLoading
=
new
QSequentialAnimationGroup
();
animLoading
->
addAnimation
(
animLoadingIn
);
animLoading
->
addAnimation
(
animLoadingOut
);
animLoading
->
setLoopCount
(
-
1
);
hideHandleTimer
=
new
QTimer
(
this
);
hideHandleTimer
->
setSingleShot
(
true
);
hideHandleTimer
->
setInterval
(
FADEOUTDELAY
);
CONNECT
(
MainInputManager
::
getInstance
(),
inputChanged
(
input_thread_t
*
),
this
,
inputUpdated
(
input_thread_t
*
)
);
CONNECT
(
this
,
sliderMoved
(
int
),
this
,
startSeekTimer
()
);
CONNECT
(
seekLimitTimer
,
timeout
(),
this
,
updatePos
()
);
CONNECT
(
hideHandleTimer
,
timeout
(),
this
,
hideHandle
()
);
...
...
@@ -202,9 +222,24 @@ void SeekSlider::updateBuffering( float f_buffering_ )
if
(
f_buffering_
<
f_buffering
)
bufferingStart
=
QTime
::
currentTime
();
f_buffering
=
f_buffering_
;
if
(
f_buffering
>
0.0
||
isEnabled
()
)
{
animLoading
->
stop
();
mLoading
=
0.0
;
}
repaint
();
}
void
SeekSlider
::
inputUpdated
(
input_thread_t
*
p_input
)
{
if
(
p_input
==
NULL
)
{
animLoading
->
stop
();
mLoading
=
0.0
;
repaint
();
}
else
if
(
f_buffering
==
0.0
&&
!
isEnabled
()
)
animLoading
->
start
();
}
void
SeekSlider
::
processReleasedButton
()
{
if
(
!
isSliding
&&
!
isJumping
)
return
;
...
...
@@ -398,6 +433,7 @@ void SeekSlider::paintEvent( QPaintEvent *ev )
option
.
animate
=
(
animHandle
->
state
()
==
QAbstractAnimation
::
Running
||
hideHandleTimer
->
isActive
()
);
option
.
animationopacity
=
mHandleOpacity
;
option
.
animationloading
=
mLoading
;
option
.
sliderPosition
=
sliderPosition
();
option
.
sliderValue
=
value
();
option
.
maximum
=
maximum
();
...
...
@@ -446,6 +482,11 @@ qreal SeekSlider::handleOpacity() const
return
mHandleOpacity
;
}
qreal
SeekSlider
::
loading
()
const
{
return
mLoading
;
}
void
SeekSlider
::
setHandleOpacity
(
qreal
opacity
)
{
mHandleOpacity
=
opacity
;
...
...
@@ -453,6 +494,13 @@ void SeekSlider::setHandleOpacity(qreal opacity)
update
();
}
void
SeekSlider
::
setLoading
(
qreal
loading
)
{
mLoading
=
loading
;
/* Request a new paintevent */
update
();
}
inline
int
SeekSlider
::
handleLength
()
{
if
(
mHandleLength
>
0
)
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
a3ecaf15
...
...
@@ -46,12 +46,14 @@ class SeekPoints;
class
QPropertyAnimation
;
class
QCommonStyle
;
class
TimeTooltip
;
class
QSequentialAnimationGroup
;
/* Input Slider derived from QSlider */
class
SeekSlider
:
public
QSlider
{
Q_OBJECT
Q_PROPERTY
(
qreal
handleOpacity
READ
handleOpacity
WRITE
setHandleOpacity
)
Q_PROPERTY
(
qreal
loadingProperty
READ
loading
WRITE
setLoading
)
public:
SeekSlider
(
Qt
::
Orientation
q
,
QWidget
*
_parent
=
0
,
bool
_classic
=
false
);
virtual
~
SeekSlider
();
...
...
@@ -73,7 +75,9 @@ protected:
void
processReleasedButton
();
qreal
handleOpacity
()
const
;
qreal
loading
()
const
;
void
setHandleOpacity
(
qreal
opacity
);
void
setLoading
(
qreal
loading
);
int
handleLength
();
private:
...
...
@@ -102,7 +106,9 @@ private:
/* Handle's animation */
qreal
mHandleOpacity
;
qreal
mLoading
;
QPropertyAnimation
*
animHandle
;
QSequentialAnimationGroup
*
animLoading
;
QTimer
*
hideHandleTimer
;
public
slots
:
...
...
@@ -114,6 +120,7 @@ public slots:
private
slots
:
void
startSeekTimer
();
void
updatePos
();
void
inputUpdated
(
input_thread_t
*
p_input
);
signals:
void
sliderDragged
(
float
);
...
...
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