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
7b3e31f9
Commit
7b3e31f9
authored
Jul 19, 2011
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: TimeToolTip: Show Chapters too
parent
e9a99cda
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
8 deletions
+44
-8
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+15
-1
modules/gui/qt4/util/timetooltip.cpp
modules/gui/qt4/util/timetooltip.cpp
+24
-6
modules/gui/qt4/util/timetooltip.hpp
modules/gui/qt4/util/timetooltip.hpp
+5
-1
No files found.
modules/gui/qt4/util/input_slider.cpp
View file @
7b3e31f9
...
...
@@ -221,12 +221,26 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event )
{
int
posX
=
qMax
(
rect
().
left
(),
qMin
(
rect
().
right
(),
event
->
x
()
)
);
QString
chapterLabel
;
QPoint
p
(
event
->
globalX
()
-
(
event
->
x
()
-
posX
)
-
(
mTimeTooltip
->
width
()
/
2
),
QWidget
::
mapToGlobal
(
pos
()
).
y
()
-
(
mTimeTooltip
->
height
()
+
2
)
);
if
(
orientation
()
==
Qt
::
Horizontal
)
/* TODO: vertical */
{
QList
<
SeekPoint
>
points
=
chapters
->
getPoints
();
int
i_selected
=
-
1
;
for
(
int
i
=
0
;
i
<
points
.
count
()
;
i
++
)
{
int
x
=
points
.
at
(
i
).
time
/
1000000.0
/
inputLength
*
size
().
width
();
if
(
event
->
x
()
>=
x
)
i_selected
=
i
;
}
if
(
i_selected
>=
0
)
chapterLabel
=
points
.
at
(
i_selected
).
name
;
}
secstotimestr
(
psz_length
,
(
posX
*
inputLength
)
/
size
().
width
()
);
mTimeTooltip
->
setT
ime
(
psz_length
);
mTimeTooltip
->
setT
ext
(
psz_length
,
chapterLabel
);
mTimeTooltip
->
move
(
p
);
}
event
->
accept
();
...
...
modules/gui/qt4/util/timetooltip.cpp
View file @
7b3e31f9
...
...
@@ -40,11 +40,24 @@ TimeTooltip::TimeTooltip( QWidget *parent ) :
// Inherit from the system default font size -5
mFont
=
QFont
(
"Verdana"
,
qMax
(
qApp
->
font
().
pointSize
()
-
5
,
7
)
);
mPreviousMetricsWidth
=
0
;
// Set default text
setText
(
"00:00:00"
,
""
);
}
void
TimeTooltip
::
buildPath
()
{
QFontMetrics
metrics
(
mFont
);
// Get the bounding box required to print the text and add some padding
QRect
textbox
=
metrics
.
boundingRect
(
"00:00:00"
).
adjusted
(
-
2
,
-
2
,
2
,
2
);
QRect
textbox
=
metrics
.
boundingRect
(
mDisplayedText
).
adjusted
(
-
2
,
-
2
,
2
,
2
);
if
(
mPreviousMetricsWidth
==
textbox
.
width
()
)
return
;
//same width == same path
else
mPreviousMetricsWidth
=
textbox
.
width
();
mBox
=
QRect
(
0
,
0
,
textbox
.
width
(),
textbox
.
height
()
);
// Resize the widget to fit our needs
...
...
@@ -54,6 +67,7 @@ TimeTooltip::TimeTooltip( QWidget *parent ) :
// we only have to generate the text at runtime.
// Draw the text box
mPainterPath
=
QPainterPath
();
mPainterPath
.
addRect
(
mBox
);
// Draw the tip
...
...
@@ -79,14 +93,18 @@ TimeTooltip::TimeTooltip( QWidget *parent ) :
painter
.
end
();
setMask
(
mMask
);
// Set default text
setTime
(
"00:00"
);
}
void
TimeTooltip
::
setT
ime
(
const
QString
&
time
)
void
TimeTooltip
::
setT
ext
(
const
QString
&
time
,
const
QString
&
text
)
{
mDisplayedText
=
time
;
if
(
!
mText
.
isEmpty
()
)
mDisplayedText
.
append
(
" - "
+
text
);
if
(
time
.
length
()
!=
mTime
.
length
()
||
mText
!=
text
)
buildPath
();
mTime
=
time
;
mText
=
text
;
update
();
}
...
...
@@ -101,7 +119,7 @@ void TimeTooltip::paintEvent( QPaintEvent * )
p
.
setFont
(
mFont
);
p
.
setPen
(
QPen
(
qApp
->
palette
().
text
(),
1
)
);
p
.
drawText
(
mBox
,
Qt
::
AlignCenter
,
m
Time
);
p
.
drawText
(
mBox
,
Qt
::
AlignCenter
,
m
DisplayedText
);
}
#undef TIP_HEIGHT
modules/gui/qt4/util/timetooltip.hpp
View file @
7b3e31f9
...
...
@@ -36,17 +36,21 @@ class TimeTooltip : public QWidget
Q_OBJECT
public:
explicit
TimeTooltip
(
QWidget
*
parent
=
0
);
void
setT
ime
(
const
QString
&
time
);
void
setT
ext
(
const
QString
&
time
,
const
QString
&
text
);
protected:
virtual
void
paintEvent
(
QPaintEvent
*
);
private:
void
buildPath
();
QString
mTime
;
QString
mText
;
QString
mDisplayedText
;
QFont
mFont
;
QRect
mBox
;
QPainterPath
mPainterPath
;
QBitmap
mMask
;
int
mPreviousMetricsWidth
;
};
#endif // TIMETOOLTIP_H
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