Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
6ea38362
Commit
6ea38362
authored
Mar 10, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: seekstyle: pass parameters through options.
parent
2893fcef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
35 deletions
+67
-35
modules/gui/qt4/styles/seekstyle.cpp
modules/gui/qt4/styles/seekstyle.cpp
+29
-25
modules/gui/qt4/styles/seekstyle.hpp
modules/gui/qt4/styles/seekstyle.hpp
+13
-1
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+24
-6
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+1
-3
No files found.
modules/gui/qt4/styles/seekstyle.cpp
View file @
6ea38362
...
@@ -33,6 +33,12 @@
...
@@ -33,6 +33,12 @@
#define RADIUS 3
#define RADIUS 3
#define CHAPTERSSPOTSIZE 3
#define CHAPTERSSPOTSIZE 3
SeekStyle
::
SeekStyleOption
::
SeekStyleOption
()
:
QStyleOptionSlider
(),
buffering
(
1.0
),
length
(
0
),
animate
(
false
),
animationopacity
(
1.0
)
{
}
SeekStyle
::
SeekStyle
()
:
QProxyStyle
(
QStyleFactory
::
create
(
QLatin1String
(
"Windows"
)
)
)
SeekStyle
::
SeekStyle
()
:
QProxyStyle
(
QStyleFactory
::
create
(
QLatin1String
(
"Windows"
)
)
)
{
{
...
@@ -54,14 +60,14 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -54,14 +60,14 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
{
{
painter
->
setRenderHints
(
QPainter
::
Antialiasing
);
painter
->
setRenderHints
(
QPainter
::
Antialiasing
);
if
(
const
QStyleOptionSlider
*
slider
=
qstyleoption_cast
<
const
QStyleOptionSlider
*>
(
option
)
)
if
(
const
SeekStyle
::
SeekStyleOption
*
slideroptions
=
qstyleoption_cast
<
const
SeekStyle
::
SeekStyleOption
*>
(
option
)
)
{
{
const
SeekSlider
*
seekSlider
=
qobject_cast
<
const
SeekSlider
*>
(
widget
);
qreal
sliderPos
=
-
1
;
qreal
sliderPos
=
-
1
;
/* Get the needed subcontrols to draw the slider */
/* Get the needed subcontrols to draw the slider */
QRect
groove
=
subControlRect
(
CC_Slider
,
slider
,
SC_SliderGroove
,
widget
);
QRect
groove
=
subControlRect
(
CC_Slider
,
slider
options
,
SC_SliderGroove
,
widget
);
QRect
handle
=
subControlRect
(
CC_Slider
,
slider
,
SC_SliderHandle
,
widget
);
QRect
handle
=
subControlRect
(
CC_Slider
,
slider
options
,
SC_SliderHandle
,
widget
);
/* Adjust the size of the groove so the handle stays centered */
/* Adjust the size of the groove so the handle stays centered */
groove
.
adjust
(
handle
.
width
()
/
2
,
0
,
-
handle
.
width
()
/
2
,
0
);
groove
.
adjust
(
handle
.
width
()
/
2
,
0
,
-
handle
.
width
()
/
2
,
0
);
...
@@ -72,14 +78,14 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -72,14 +78,14 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
// had to remove 1 from the rect bottom.
// had to remove 1 from the rect bottom.
groove
.
adjust
(
0
,
(
qreal
)
groove
.
height
()
/
3.7
,
0
,
(
qreal
)
-
groove
.
height
()
/
3.7
-
1
);
groove
.
adjust
(
0
,
(
qreal
)
groove
.
height
()
/
3.7
,
0
,
(
qreal
)
-
groove
.
height
()
/
3.7
-
1
);
if
(
(
slider
->
subControls
&
SC_SliderGroove
)
&&
groove
.
isValid
()
)
if
(
(
slider
options
->
subControls
&
SC_SliderGroove
)
&&
groove
.
isValid
()
)
{
{
sliderPos
=
(
(
(
qreal
)
groove
.
width
()
)
/
(
qreal
)
slider
->
maximum
)
sliderPos
=
(
(
(
qreal
)
groove
.
width
()
)
/
(
qreal
)
slider
options
->
maximum
)
*
(
qreal
)
slider
->
sliderPosition
;
*
(
qreal
)
slider
options
->
sliderPosition
;
/* set the background color and gradient */
/* set the background color and gradient */
QColor
backgroundBase
(
slider
->
palette
.
window
().
color
()
);
QColor
backgroundBase
(
slider
options
->
palette
.
window
().
color
()
);
QLinearGradient
backgroundGradient
(
0
,
0
,
0
,
slider
->
rect
.
height
()
);
QLinearGradient
backgroundGradient
(
0
,
0
,
0
,
slider
options
->
rect
.
height
()
);
backgroundGradient
.
setColorAt
(
0.0
,
backgroundBase
.
darker
(
140
)
);
backgroundGradient
.
setColorAt
(
0.0
,
backgroundBase
.
darker
(
140
)
);
backgroundGradient
.
setColorAt
(
1.0
,
backgroundBase
);
backgroundGradient
.
setColorAt
(
1.0
,
backgroundBase
);
...
@@ -105,7 +111,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -105,7 +111,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
valueRect
.
setWidth
(
sliderPos
);
valueRect
.
setWidth
(
sliderPos
);
/* draw foreground */
/* draw foreground */
if
(
slider
->
sliderPosition
>
slider
->
minimum
&&
slider
->
sliderPosition
<=
slider
->
maximum
)
if
(
slider
options
->
sliderPosition
>
slideroptions
->
minimum
&&
slideroptions
->
sliderPosition
<=
slideroptions
->
maximum
)
{
{
painter
->
setPen
(
Qt
::
NoPen
);
painter
->
setPen
(
Qt
::
NoPen
);
painter
->
setBrush
(
foregroundGradient
);
painter
->
setBrush
(
foregroundGradient
);
...
@@ -113,10 +119,10 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -113,10 +119,10 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
}
}
/* draw buffering overlay */
/* draw buffering overlay */
if
(
s
eekSlider
&&
seekSlider
->
f_
buffering
<
1.0
)
if
(
s
lideroptions
->
buffering
<
1.0
)
{
{
QRect
innerRect
=
groove
.
adjusted
(
1
,
1
,
QRect
innerRect
=
groove
.
adjusted
(
1
,
1
,
groove
.
width
()
*
(
-
1.0
+
s
eekSlider
->
f_
buffering
)
-
1
,
0
);
groove
.
width
()
*
(
-
1.0
+
s
lideroptions
->
buffering
)
-
1
,
0
);
QColor
overlayColor
=
QColor
(
"Orange"
);
QColor
overlayColor
=
QColor
(
"Orange"
);
overlayColor
.
setAlpha
(
128
);
overlayColor
.
setAlpha
(
128
);
painter
->
setBrush
(
overlayColor
);
painter
->
setBrush
(
overlayColor
);
...
@@ -124,39 +130,38 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -124,39 +130,38 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
}
}
}
}
if
(
slider
->
subControls
&
SC_SliderTickmarks
)
{
if
(
slider
options
->
subControls
&
SC_SliderTickmarks
)
{
QStyleOptionSlider
tmpSlider
=
*
slider
;
QStyleOptionSlider
tmpSlider
=
*
slider
options
;
tmpSlider
.
subControls
=
SC_SliderTickmarks
;
tmpSlider
.
subControls
=
SC_SliderTickmarks
;
QProxyStyle
::
drawComplexControl
(
cc
,
&
tmpSlider
,
painter
,
widget
);
QProxyStyle
::
drawComplexControl
(
cc
,
&
tmpSlider
,
painter
,
widget
);
}
}
if
(
slider
->
subControls
&
SC_SliderHandle
&&
handle
.
isValid
()
)
if
(
slider
options
->
subControls
&
SC_SliderHandle
&&
handle
.
isValid
()
)
{
{
/* Useful for debugging */
/* Useful for debugging */
//painter->setBrush( QColor( 0, 0, 255, 150 ) );
//painter->setBrush( QColor( 0, 0, 255, 150 ) );
//painter->drawRect( handle );
//painter->drawRect( handle );
if
(
option
->
state
&
QStyle
::
State_MouseOver
||
(
seekSlider
&&
seekSlider
->
isAnimationRunning
()
)
)
if
(
option
->
state
&
QStyle
::
State_MouseOver
||
slideroptions
->
animate
)
{
{
QPalette
p
=
slider
->
palette
;
QPalette
p
=
slider
options
->
palette
;
/* draw chapters tickpoints */
/* draw chapters tickpoints */
if
(
s
eekSlider
->
chapters
&&
seekSlider
->
inputL
ength
&&
groove
.
width
()
)
if
(
s
lideroptions
->
points
.
size
()
&&
slideroptions
->
l
ength
&&
groove
.
width
()
)
{
{
QColor
background
=
p
.
color
(
QPalette
::
Active
,
QPalette
::
Window
);
QColor
background
=
p
.
color
(
QPalette
::
Active
,
QPalette
::
Window
);
QColor
foreground
=
p
.
color
(
QPalette
::
Active
,
QPalette
::
WindowText
);
QColor
foreground
=
p
.
color
(
QPalette
::
Active
,
QPalette
::
WindowText
);
foreground
.
setHsv
(
foreground
.
hue
(),
foreground
.
setHsv
(
foreground
.
hue
(),
(
background
.
saturation
()
+
foreground
.
saturation
()
)
/
2
,
(
background
.
saturation
()
+
foreground
.
saturation
()
)
/
2
,
(
background
.
value
()
+
foreground
.
value
()
)
/
2
);
(
background
.
value
()
+
foreground
.
value
()
)
/
2
);
if
(
slider
->
orientation
==
Qt
::
Horizontal
)
/* TODO: vertical */
if
(
slider
options
->
orientation
==
Qt
::
Horizontal
)
/* TODO: vertical */
{
{
QList
<
SeekPoint
>
points
=
seekSlider
->
chapters
->
getPoints
();
foreach
(
int64_t
time
,
slideroptions
->
points
)
foreach
(
SeekPoint
point
,
points
)
{
{
int
x
=
groove
.
x
()
+
point
.
time
/
1000000.0
/
seekSlider
->
inputL
ength
*
groove
.
width
();
int
x
=
groove
.
x
()
+
time
/
1000000.0
/
slideroptions
->
l
ength
*
groove
.
width
();
painter
->
setPen
(
foreground
);
painter
->
setPen
(
foreground
);
painter
->
setBrush
(
Qt
::
NoBrush
);
painter
->
setBrush
(
Qt
::
NoBrush
);
painter
->
drawLine
(
x
,
slider
->
rect
.
height
(),
x
,
slider
->
rect
.
height
()
-
CHAPTERSSPOTSIZE
);
painter
->
drawLine
(
x
,
slider
options
->
rect
.
height
(),
x
,
slideroptions
->
rect
.
height
()
-
CHAPTERSSPOTSIZE
);
}
}
}
}
}
}
...
@@ -190,8 +195,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
...
@@ -190,8 +195,7 @@ void SeekStyle::drawComplexControl( ComplexControl cc, const QStyleOptionComplex
shadowGradient
.
setColorAt
(
1.0
,
shadowLight
);
shadowGradient
.
setColorAt
(
1.0
,
shadowLight
);
painter
->
setPen
(
Qt
::
NoPen
);
painter
->
setPen
(
Qt
::
NoPen
);
if
(
seekSlider
!=
NULL
)
painter
->
setOpacity
(
slideroptions
->
animationopacity
);
painter
->
setOpacity
(
seekSlider
->
mHandleOpacity
);
/* draw the handle's shadow */
/* draw the handle's shadow */
painter
->
setBrush
(
shadowGradient
);
painter
->
setBrush
(
shadowGradient
);
...
...
modules/gui/qt4/styles/seekstyle.hpp
View file @
6ea38362
...
@@ -24,11 +24,23 @@
...
@@ -24,11 +24,23 @@
#define SEEKSTYLE_HPP
#define SEEKSTYLE_HPP
#include <QProxyStyle>
#include <QProxyStyle>
#include <QStyleOptionSlider>
class
SeekStyle
:
public
QProxyStyle
class
SeekStyle
:
public
QProxyStyle
{
{
Q_OBJECT
Q_OBJECT
public:
class
SeekStyleOption
:
public
QStyleOptionSlider
{
public:
SeekStyleOption
();
float
buffering
;
int
length
;
bool
animate
;
qreal
animationopacity
;
QList
<
int64_t
>
points
;
};
public:
public:
SeekStyle
();
SeekStyle
();
virtual
int
pixelMetric
(
PixelMetric
metric
,
const
QStyleOption
*
option
=
0
,
const
QWidget
*
widget
=
0
)
const
;
virtual
int
pixelMetric
(
PixelMetric
metric
,
const
QStyleOption
*
option
=
0
,
const
QWidget
*
widget
=
0
)
const
;
...
...
modules/gui/qt4/util/input_slider.cpp
View file @
6ea38362
...
@@ -380,6 +380,30 @@ void SeekSlider::leaveEvent( QEvent * )
...
@@ -380,6 +380,30 @@ void SeekSlider::leaveEvent( QEvent * )
}
}
}
}
void
SeekSlider
::
paintEvent
(
QPaintEvent
*
ev
)
{
if
(
alternativeStyle
)
{
SeekStyle
::
SeekStyleOption
option
;
option
.
initFrom
(
this
);
option
.
buffering
=
f_buffering
;
option
.
length
=
inputLength
;
option
.
animate
=
(
animHandle
->
state
()
==
QAbstractAnimation
::
Running
||
hideHandleTimer
->
isActive
()
);
option
.
animationopacity
=
mHandleOpacity
;
option
.
sliderPosition
=
sliderPosition
();
option
.
sliderValue
=
value
();
option
.
maximum
=
maximum
();
option
.
minimum
=
minimum
();
foreach
(
const
SeekPoint
&
point
,
chapters
->
getPoints
()
)
option
.
points
<<
point
.
time
;
QPainter
painter
(
this
);
style
()
->
drawComplexControl
(
QStyle
::
CC_Slider
,
&
option
,
&
painter
,
this
);
}
else
QSlider
::
paintEvent
(
ev
);
}
void
SeekSlider
::
hideEvent
(
QHideEvent
*
)
void
SeekSlider
::
hideEvent
(
QHideEvent
*
)
{
{
mTimeTooltip
->
hide
();
mTimeTooltip
->
hide
();
...
@@ -444,12 +468,6 @@ void SeekSlider::hideHandle()
...
@@ -444,12 +468,6 @@ void SeekSlider::hideHandle()
animHandle
->
start
();
animHandle
->
start
();
}
}
bool
SeekSlider
::
isAnimationRunning
()
const
{
return
animHandle
->
state
()
==
QAbstractAnimation
::
Running
||
hideHandleTimer
->
isActive
();
}
/* This work is derived from Amarok's work under GPLv2+
/* This work is derived from Amarok's work under GPLv2+
- Mark Kretschmann
- Mark Kretschmann
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
6ea38362
...
@@ -66,13 +66,13 @@ protected:
...
@@ -66,13 +66,13 @@ protected:
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
hideEvent
(
QHideEvent
*
);
virtual
void
hideEvent
(
QHideEvent
*
);
virtual
void
paintEvent
(
QPaintEvent
*
ev
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
virtual
QSize
sizeHint
()
const
;
virtual
QSize
sizeHint
()
const
;
void
processReleasedButton
();
void
processReleasedButton
();
bool
isAnimationRunning
()
const
;
qreal
handleOpacity
()
const
;
qreal
handleOpacity
()
const
;
void
setHandleOpacity
(
qreal
opacity
);
void
setHandleOpacity
(
qreal
opacity
);
int
handleLength
();
int
handleLength
();
...
@@ -118,8 +118,6 @@ private slots:
...
@@ -118,8 +118,6 @@ private slots:
signals:
signals:
void
sliderDragged
(
float
);
void
sliderDragged
(
float
);
friend
class
SeekStyle
;
};
};
/* Sound Slider inherited directly from QAbstractSlider */
/* Sound Slider inherited directly from QAbstractSlider */
...
...
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