Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
b00fb1c3
Commit
b00fb1c3
authored
Apr 16, 2011
by
Ludovic Fauvet
Committed by
Jean-Baptiste Kempf
Apr 16, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt4: cosmectics
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
1f2eb819
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
41 deletions
+52
-41
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+46
-35
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+6
-6
No files found.
modules/gui/qt4/util/input_slider.cpp
View file @
b00fb1c3
...
@@ -66,7 +66,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
...
@@ -66,7 +66,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
setRange
(
MINIMUM
,
MAXIMUM
);
setRange
(
MINIMUM
,
MAXIMUM
);
setSingleStep
(
2
);
setSingleStep
(
2
);
setPageStep
(
10
);
setPageStep
(
10
);
setMouseTracking
(
true
);
setMouseTracking
(
true
);
setTracking
(
true
);
setTracking
(
true
);
setFocusPolicy
(
Qt
::
NoFocus
);
setFocusPolicy
(
Qt
::
NoFocus
);
...
@@ -74,7 +74,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
...
@@ -74,7 +74,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
setPosition
(
-
1.0
,
0
,
0
);
setPosition
(
-
1.0
,
0
,
0
);
secstotimestr
(
psz_length
,
0
);
secstotimestr
(
psz_length
,
0
);
CONNECT
(
this
,
sliderMoved
(
int
),
this
,
startSeekTimer
(
int
)
);
CONNECT
(
this
,
sliderMoved
(
int
),
this
,
startSeekTimer
(
int
)
);
CONNECT
(
seekLimitTimer
,
timeout
(),
this
,
updatePos
()
);
CONNECT
(
seekLimitTimer
,
timeout
(),
this
,
updatePos
()
);
CONNECT
(
hideTooltipTimer
,
timeout
(),
mTimeTooltip
,
hide
()
);
CONNECT
(
hideTooltipTimer
,
timeout
(),
mTimeTooltip
,
hide
()
);
...
@@ -99,7 +99,7 @@ void SeekSlider::setPosition( float pos, int64_t time, int length )
...
@@ -99,7 +99,7 @@ void SeekSlider::setPosition( float pos, int64_t time, int length )
setEnabled
(
true
);
setEnabled
(
true
);
if
(
!
b_isSliding
)
if
(
!
b_isSliding
)
setValue
(
(
int
)(
pos
*
1000.0
)
);
setValue
(
(
int
)(
pos
*
1000.0
)
);
inputLength
=
length
;
inputLength
=
length
;
}
}
...
@@ -113,7 +113,7 @@ void SeekSlider::startSeekTimer( int new_value )
...
@@ -113,7 +113,7 @@ void SeekSlider::startSeekTimer( int new_value )
void
SeekSlider
::
updatePos
()
void
SeekSlider
::
updatePos
()
{
{
float
f_pos
=
(
float
)(
value
())
/
1000.0
;
float
f_pos
=
(
float
)(
value
()
)
/
1000.0
;
emit
sliderDragged
(
f_pos
);
/* Send new position to VLC's core */
emit
sliderDragged
(
f_pos
);
/* Send new position to VLC's core */
}
}
...
@@ -126,7 +126,7 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
...
@@ -126,7 +126,7 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
updatePos
();
updatePos
();
}
}
void
SeekSlider
::
mousePressEvent
(
QMouseEvent
*
event
)
void
SeekSlider
::
mousePressEvent
(
QMouseEvent
*
event
)
{
{
/* Right-click */
/* Right-click */
if
(
event
->
button
()
!=
Qt
::
LeftButton
&&
if
(
event
->
button
()
!=
Qt
::
LeftButton
&&
...
@@ -137,11 +137,11 @@ void SeekSlider::mousePressEvent(QMouseEvent* event)
...
@@ -137,11 +137,11 @@ void SeekSlider::mousePressEvent(QMouseEvent* event)
}
}
b_isSliding
=
true
;
b_isSliding
=
true
;
setValue
(
QStyle
::
sliderValueFromPosition
(
MINIMUM
,
MAXIMUM
,
event
->
x
(),
width
(),
false
)
);
setValue
(
QStyle
::
sliderValueFromPosition
(
MINIMUM
,
MAXIMUM
,
event
->
x
(),
width
(),
false
)
);
event
->
accept
();
event
->
accept
();
}
}
void
SeekSlider
::
mouseMoveEvent
(
QMouseEvent
*
event
)
void
SeekSlider
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
{
if
(
b_isSliding
)
if
(
b_isSliding
)
{
{
...
@@ -153,29 +153,29 @@ void SeekSlider::mouseMoveEvent(QMouseEvent *event)
...
@@ -153,29 +153,29 @@ void SeekSlider::mouseMoveEvent(QMouseEvent *event)
QPoint
p
(
event
->
globalX
()
-
mTimeTooltip
->
width
()
/
2
,
QPoint
p
(
event
->
globalX
()
-
mTimeTooltip
->
width
()
/
2
,
QWidget
::
mapToGlobal
(
pos
()
).
y
()
-
(
mTimeTooltip
->
height
()
+
2
)
);
QWidget
::
mapToGlobal
(
pos
()
).
y
()
-
(
mTimeTooltip
->
height
()
+
2
)
);
secstotimestr
(
psz_length
,
(
event
->
x
()
*
inputLength
)
/
size
().
width
()
);
secstotimestr
(
psz_length
,
(
event
->
x
()
*
inputLength
)
/
size
().
width
()
);
mTimeTooltip
->
setTime
(
psz_length
);
mTimeTooltip
->
setTime
(
psz_length
);
mTimeTooltip
->
move
(
p
);
mTimeTooltip
->
move
(
p
);
event
->
accept
();
event
->
accept
();
}
}
void
SeekSlider
::
wheelEvent
(
QWheelEvent
*
event
)
void
SeekSlider
::
wheelEvent
(
QWheelEvent
*
event
)
{
{
/* Don't do anything if we are for somehow reason sliding */
/* Don't do anything if we are for somehow reason sliding */
if
(
!
b_isSliding
)
if
(
!
b_isSliding
)
{
{
setValue
(
value
()
+
event
->
delta
()
/
12
);
/* 12 = 8 * 15 / 10
setValue
(
value
()
+
event
->
delta
()
/
12
);
/* 12 = 8 * 15 / 10
Since delta is in 1/8 of ° and mouse have steps of 15 °
Since delta is in 1/8 of ° and mouse have steps of 15 °
and that our slider is in 0.1% and we want one step to be a 1%
and that our slider is in 0.1% and we want one step to be a 1%
increment of position */
increment of position */
emit
sliderDragged
(
value
()
/
1000.0
);
emit
sliderDragged
(
value
()
/
1000.0
);
}
}
event
->
accept
();
event
->
accept
();
}
}
void
SeekSlider
::
enterEvent
(
QEvent
*
e
)
void
SeekSlider
::
enterEvent
(
QEvent
*
e
)
{
{
if
(
isEnabled
()
)
if
(
isEnabled
()
)
{
{
hideTooltipTimer
->
stop
();
hideTooltipTimer
->
stop
();
mTimeTooltip
->
show
();
mTimeTooltip
->
show
();
...
@@ -184,19 +184,19 @@ void SeekSlider::enterEvent( QEvent *e )
...
@@ -184,19 +184,19 @@ void SeekSlider::enterEvent( QEvent *e )
void
SeekSlider
::
leaveEvent
(
QEvent
*
e
)
void
SeekSlider
::
leaveEvent
(
QEvent
*
e
)
{
{
hideTooltipTimer
->
start
(
100
);
hideTooltipTimer
->
start
(
100
);
}
}
bool
SeekSlider
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
bool
SeekSlider
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
{
// This eventFilter avoids a flicker that occurs if the
// This eventFilter avoids a flicker that occurs if the
// mouse cursor leaves the SeekSlider for the TimeTooltip.
// mouse cursor leaves the SeekSlider for the TimeTooltip.
if
(
obj
==
mTimeTooltip
)
if
(
obj
==
mTimeTooltip
)
{
{
if
(
event
->
type
()
==
QEvent
::
Enter
)
if
(
event
->
type
()
==
QEvent
::
Enter
)
hideTooltipTimer
->
stop
();
hideTooltipTimer
->
stop
();
else
if
(
event
->
type
()
==
QEvent
::
Leave
)
else
if
(
event
->
type
()
==
QEvent
::
Leave
)
hideTooltipTimer
->
start
(
100
);
hideTooltipTimer
->
start
(
100
);
return
false
;
return
false
;
}
}
else
else
...
@@ -230,20 +230,25 @@ void SeekSlider::paintEvent( QPaintEvent *event )
...
@@ -230,20 +230,25 @@ void SeekSlider::paintEvent( QPaintEvent *event )
const
int
barCorner
=
3
;
const
int
barCorner
=
3
;
qreal
sliderPos
=
-
1
;
qreal
sliderPos
=
-
1
;
int
range
=
MAXIMUM
;
int
range
=
MAXIMUM
;
QRect
barRect
=
rect
();
QRect
barRect
=
rect
();
if
(
option
.
sliderPosition
!=
0
)
{
if
(
option
.
sliderPosition
!=
0
)
switch
(
orientation
()
)
{
{
switch
(
orientation
()
)
{
case
Qt
:
:
Horizontal
:
case
Qt
:
:
Horizontal
:
sliderPos
=
(
(
(
qreal
)
width
()
)
/
(
qreal
)
range
)
*
(
qreal
)
option
.
sliderPosition
;
sliderPos
=
(
(
(
qreal
)
width
()
)
/
(
qreal
)
range
)
*
(
qreal
)
option
.
sliderPosition
;
break
;
break
;
case
Qt
:
:
Vertical
:
case
Qt
:
:
Vertical
:
sliderPos
=
(
(
(
qreal
)
height
()
)
/
(
qreal
)
range
)
*
(
qreal
)
option
.
sliderPosition
;
sliderPos
=
(
(
(
qreal
)
height
()
)
/
(
qreal
)
range
)
*
(
qreal
)
option
.
sliderPosition
;
break
;
break
;
}
}
}
}
switch
(
orientation
()
)
{
switch
(
orientation
()
)
{
case
Qt
:
:
Horizontal
:
case
Qt
:
:
Horizontal
:
barRect
.
setHeight
(
handleSize
().
height
()
/
2
);
barRect
.
setHeight
(
handleSize
().
height
()
/
2
);
break
;
break
;
...
@@ -274,7 +279,8 @@ void SeekSlider::paintEvent( QPaintEvent *event )
...
@@ -274,7 +279,8 @@ void SeekSlider::paintEvent( QPaintEvent *event )
QRect
valueRect
=
barRect
.
adjusted
(
1
,
1
,
-
1
,
0
);
QRect
valueRect
=
barRect
.
adjusted
(
1
,
1
,
-
1
,
0
);
switch
(
orientation
()
)
{
switch
(
orientation
()
)
{
case
Qt
:
:
Horizontal
:
case
Qt
:
:
Horizontal
:
valueRect
.
setWidth
(
qMin
(
width
(),
int
(
sliderPos
)
)
);
valueRect
.
setWidth
(
qMin
(
width
(),
int
(
sliderPos
)
)
);
break
;
break
;
...
@@ -284,34 +290,39 @@ void SeekSlider::paintEvent( QPaintEvent *event )
...
@@ -284,34 +290,39 @@ void SeekSlider::paintEvent( QPaintEvent *event )
break
;
break
;
}
}
if
(
option
.
sliderPosition
>
minimum
()
&&
option
.
sliderPosition
<=
maximum
()
)
{
if
(
option
.
sliderPosition
>
minimum
()
&&
option
.
sliderPosition
<=
maximum
()
)
{
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
setBrush
(
foregroundGradient
);
painter
.
setBrush
(
foregroundGradient
);
painter
.
drawRoundedRect
(
valueRect
,
barCorner
,
barCorner
);
painter
.
drawRoundedRect
(
valueRect
,
barCorner
,
barCorner
);
}
}
// draw handle
// draw handle
if
(
option
.
state
&
QStyle
::
State_MouseOver
)
{
if
(
option
.
state
&
QStyle
::
State_MouseOver
)
{
if
(
sliderPos
!=
-
1
)
{
if
(
sliderPos
!=
-
1
)
{
const
int
margin
=
0
;
const
int
margin
=
0
;
QSize
hs
=
handleSize
()
-
QSize
(
5
,
5
);
QSize
hs
=
handleSize
()
-
QSize
(
5
,
5
);
QPoint
pos
;
QPoint
pos
;
switch
(
orientation
()
)
{
switch
(
orientation
()
)
{
case
Qt
:
:
Horizontal
:
case
Qt
:
:
Horizontal
:
pos
=
QPoint
(
sliderPos
-
(
hs
.
width
()
/
2
),
2
);
pos
=
QPoint
(
sliderPos
-
(
hs
.
width
()
/
2
),
2
);
pos
.
rx
()
=
qMax
(
margin
,
pos
.
x
()
);
pos
.
rx
()
=
qMax
(
margin
,
pos
.
x
()
);
pos
.
rx
()
=
qMin
(
width
()
-
hs
.
width
()
-
margin
,
pos
.
x
()
);
pos
.
rx
()
=
qMin
(
width
()
-
hs
.
width
()
-
margin
,
pos
.
x
()
);
break
;
break
;
case
Qt
:
:
Vertical
:
case
Qt
:
:
Vertical
:
pos
=
QPoint
(
2
,
height
()
-
(
sliderPos
+
(
hs
.
height
()
/
2
)
)
);
pos
=
QPoint
(
2
,
height
()
-
(
sliderPos
+
(
hs
.
height
()
/
2
)
)
);
pos
.
ry
()
=
qMax
(
margin
,
pos
.
y
()
);
pos
.
ry
()
=
qMax
(
margin
,
pos
.
y
()
);
pos
.
ry
()
=
qMin
(
height
()
-
hs
.
height
()
-
margin
,
pos
.
y
()
);
pos
.
ry
()
=
qMin
(
height
()
-
hs
.
height
()
-
margin
,
pos
.
y
()
);
break
;
break
;
}
}
QRadialGradient
buttonGradient
(
pos
.
x
()
+
(
hs
.
width
()
/
2
)
-
2
,
pos
.
y
()
+
(
hs
.
height
()
/
2
)
-
2
,
qMax
(
hs
.
width
(),
hs
.
height
()
)
);
QRadialGradient
buttonGradient
(
pos
.
x
()
+
(
hs
.
width
()
/
2
)
-
2
,
pos
.
y
()
+
(
hs
.
height
()
/
2
)
-
2
,
qMax
(
hs
.
width
(),
hs
.
height
()
)
);
buttonGradient
.
setColorAt
(
0.0
,
QColor
(
0
,
0
,
0
)
);
buttonGradient
.
setColorAt
(
0.0
,
QColor
(
0
,
0
,
0
)
);
buttonGradient
.
setColorAt
(
1.0
,
QColor
(
80
,
80
,
80
)
);
buttonGradient
.
setColorAt
(
1.0
,
QColor
(
80
,
80
,
80
)
);
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
b00fb1c3
...
@@ -45,15 +45,15 @@ public:
...
@@ -45,15 +45,15 @@ public:
SeekSlider
(
Qt
::
Orientation
q
,
QWidget
*
_parent
);
SeekSlider
(
Qt
::
Orientation
q
,
QWidget
*
_parent
);
protected:
protected:
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
virtual
void
wheelEvent
(
QWheelEvent
*
event
);
virtual
void
wheelEvent
(
QWheelEvent
*
event
);
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
paintEvent
(
QPaintEvent
*
event
);
virtual
void
paintEvent
(
QPaintEvent
*
event
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
QSize
handleSize
()
const
;
QSize
handleSize
()
const
;
QSize
sizeHint
()
const
;
QSize
sizeHint
()
const
;
...
@@ -92,7 +92,7 @@ protected:
...
@@ -92,7 +92,7 @@ protected:
const
static
int
paddingL
=
3
;
const
static
int
paddingL
=
3
;
const
static
int
paddingR
=
2
;
const
static
int
paddingR
=
2
;
virtual
void
paintEvent
(
QPaintEvent
*
);
virtual
void
paintEvent
(
QPaintEvent
*
);
virtual
void
wheelEvent
(
QWheelEvent
*
event
);
virtual
void
wheelEvent
(
QWheelEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
);
virtual
void
mousePressEvent
(
QMouseEvent
*
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
);
...
...
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