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
0dbba8ba
Commit
0dbba8ba
authored
Apr 12, 2011
by
Ludovic Fauvet
Committed by
Jean-Baptiste Kempf
Apr 12, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: Improved tooltip to view the time at a given mouse position
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
7553aa0f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
4 deletions
+216
-4
modules/gui/qt4/Modules.am
modules/gui/qt4/Modules.am
+3
-0
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+46
-3
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+8
-1
modules/gui/qt4/util/timetooltip.cpp
modules/gui/qt4/util/timetooltip.cpp
+107
-0
modules/gui/qt4/util/timetooltip.hpp
modules/gui/qt4/util/timetooltip.hpp
+52
-0
No files found.
modules/gui/qt4/Modules.am
View file @
0dbba8ba
...
@@ -66,6 +66,7 @@ nodist_SOURCES_qt4 = \
...
@@ -66,6 +66,7 @@ nodist_SOURCES_qt4 = \
components/sout/profile_selector.moc.cpp \
components/sout/profile_selector.moc.cpp \
components/sout/sout_widgets.moc.cpp \
components/sout/sout_widgets.moc.cpp \
util/input_slider.moc.cpp \
util/input_slider.moc.cpp \
util/timetooltip.moc.cpp \
util/customwidgets.moc.cpp \
util/customwidgets.moc.cpp \
util/searchlineedit.moc.cpp \
util/searchlineedit.moc.cpp \
util/qvlcapp.moc.cpp \
util/qvlcapp.moc.cpp \
...
@@ -297,6 +298,7 @@ SOURCES_qt4 = qt4.cpp \
...
@@ -297,6 +298,7 @@ SOURCES_qt4 = qt4.cpp \
components/sout/profile_selector.cpp \
components/sout/profile_selector.cpp \
components/sout/sout_widgets.cpp \
components/sout/sout_widgets.cpp \
util/input_slider.cpp \
util/input_slider.cpp \
util/timetooltip.cpp \
util/customwidgets.cpp \
util/customwidgets.cpp \
util/searchlineedit.cpp \
util/searchlineedit.cpp \
util/registry.cpp \
util/registry.cpp \
...
@@ -370,6 +372,7 @@ noinst_HEADERS = \
...
@@ -370,6 +372,7 @@ noinst_HEADERS = \
components/sout/sout_widgets.hpp \
components/sout/sout_widgets.hpp \
components/sout/profiles.hpp \
components/sout/profiles.hpp \
util/input_slider.hpp \
util/input_slider.hpp \
util/timetooltip.hpp \
util/customwidgets.hpp \
util/customwidgets.hpp \
util/searchlineedit.hpp \
util/searchlineedit.hpp \
util/qvlcframe.hpp \
util/qvlcframe.hpp \
...
...
modules/gui/qt4/util/input_slider.cpp
View file @
0dbba8ba
...
@@ -52,8 +52,14 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
...
@@ -52,8 +52,14 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
b_isSliding
=
false
;
b_isSliding
=
false
;
/* Timer used to fire intermediate updatePos() when sliding */
/* Timer used to fire intermediate updatePos() when sliding */
seekLimitTimer
=
new
QTimer
(
this
);
seekLimitTimer
=
new
QTimer
(
this
);
seekLimitTimer
->
setSingleShot
(
true
);
seekLimitTimer
->
setSingleShot
(
true
);
hideTooltipTimer
=
new
QTimer
(
this
);
hideTooltipTimer
->
setSingleShot
(
true
);
/* Tooltip bubble */
mTimeTooltip
=
new
TimeTooltip
(
this
);
/* Properties */
/* Properties */
setRange
(
MINIMUM
,
MAXIMUM
);
setRange
(
MINIMUM
,
MAXIMUM
);
...
@@ -69,6 +75,9 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
...
@@ -69,6 +75,9 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
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
()
);
mTimeTooltip
->
installEventFilter
(
this
);
}
}
/***
/***
...
@@ -139,8 +148,12 @@ void SeekSlider::mouseMoveEvent(QMouseEvent *event)
...
@@ -139,8 +148,12 @@ void SeekSlider::mouseMoveEvent(QMouseEvent *event)
}
}
/* Tooltip */
/* Tooltip */
QPoint
p
(
event
->
globalX
()
-
mTimeTooltip
->
width
()
/
2
,
QWidget
::
mapToGlobal
(
pos
()
).
y
()
-
(
mTimeTooltip
->
height
()
+
2
)
);
secstotimestr
(
psz_length
,
(
event
->
x
()
*
inputLength
)
/
size
().
width
()
);
secstotimestr
(
psz_length
,
(
event
->
x
()
*
inputLength
)
/
size
().
width
()
);
setToolTip
(
psz_length
);
mTimeTooltip
->
setTime
(
psz_length
);
mTimeTooltip
->
move
(
p
);
event
->
accept
();
event
->
accept
();
}
}
...
@@ -158,6 +171,36 @@ void SeekSlider::wheelEvent( QWheelEvent *event)
...
@@ -158,6 +171,36 @@ void SeekSlider::wheelEvent( QWheelEvent *event)
event
->
accept
();
event
->
accept
();
}
}
void
SeekSlider
::
enterEvent
(
QEvent
*
e
)
{
if
(
isEnabled
())
{
hideTooltipTimer
->
stop
();
mTimeTooltip
->
show
();
}
}
void
SeekSlider
::
leaveEvent
(
QEvent
*
e
)
{
hideTooltipTimer
->
start
(
100
);
}
bool
SeekSlider
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
// This eventFilter avoids a flicker that occurs if the
// mouse cursor leaves the SeekSlider for the TimeTooltip.
if
(
obj
==
mTimeTooltip
)
{
if
(
event
->
type
()
==
QEvent
::
Enter
)
hideTooltipTimer
->
stop
();
else
if
(
event
->
type
()
==
QEvent
::
Leave
)
hideTooltipTimer
->
start
(
100
);
return
false
;
}
else
return
QSlider
::
eventFilter
(
obj
,
event
);
}
QSize
SeekSlider
::
sizeHint
()
const
QSize
SeekSlider
::
sizeHint
()
const
{
{
return
(
orientation
()
==
Qt
::
Horizontal
)
?
QSize
(
100
,
18
)
return
(
orientation
()
==
Qt
::
Horizontal
)
?
QSize
(
100
,
18
)
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
0dbba8ba
...
@@ -25,9 +25,11 @@
...
@@ -25,9 +25,11 @@
#ifndef _INPUTSLIDER_H_
#ifndef _INPUTSLIDER_H_
#define _INPUTSLIDER_H_
#define _INPUTSLIDER_H_
#include <vlc_common.h>
#include "timetooltip.hpp"
#include <QSlider>
#include <QSlider>
#include <vlc_common.h>
#define MSTRTIME_MAX_SIZE 22
#define MSTRTIME_MAX_SIZE 22
class
QMouseEvent
;
class
QMouseEvent
;
...
@@ -47,8 +49,11 @@ protected:
...
@@ -47,8 +49,11 @@ protected:
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
leaveEvent
(
QEvent
*
);
virtual
void
paintEvent
(
QPaintEvent
*
event
);
virtual
void
paintEvent
(
QPaintEvent
*
event
);
virtual
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
QSize
handleSize
()
const
;
QSize
handleSize
()
const
;
QSize
sizeHint
()
const
;
QSize
sizeHint
()
const
;
...
@@ -58,6 +63,8 @@ private:
...
@@ -58,6 +63,8 @@ private:
int
inputLength
;
/* InputLength that can change */
int
inputLength
;
/* InputLength that can change */
char
psz_length
[
MSTRTIME_MAX_SIZE
];
/* Used for the ToolTip */
char
psz_length
[
MSTRTIME_MAX_SIZE
];
/* Used for the ToolTip */
QTimer
*
seekLimitTimer
;
QTimer
*
seekLimitTimer
;
QTimer
*
hideTooltipTimer
;
TimeTooltip
*
mTimeTooltip
;
public
slots
:
public
slots
:
void
setPosition
(
float
,
int64_t
,
int
);
void
setPosition
(
float
,
int64_t
,
int
);
...
...
modules/gui/qt4/util/timetooltip.cpp
0 → 100644
View file @
0dbba8ba
/*****************************************************************************
* Copyright © 2011 VideoLAN
* $Id$
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* 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 2 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "timetooltip.hpp"
#include <QApplication>
#include <QPainter>
#include <QPainterPath>
#include <QBitmap>
#include <QFontMetrics>
#define TIP_HEIGHT 5
TimeTooltip
::
TimeTooltip
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
setWindowFlags
(
Qt
::
ToolTip
);
// Tell Qt that it doesn't need to erase the background before
// a paintEvent occurs. This should save some CPU cycles.
setAttribute
(
Qt
::
WA_OpaquePaintEvent
);
// Inherit from the system default font size -5
mFont
=
QFont
(
"Verdana"
,
qMax
(
qApp
->
font
().
pointSize
()
-
5
,
7
)
);
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
);
mBox
=
QRect
(
0
,
0
,
textbox
.
width
(),
textbox
.
height
()
);
// Resize the widget to fit our needs
resize
(
mBox
.
width
()
+
1
,
mBox
.
height
()
+
TIP_HEIGHT
+
1
);
// Prepare the painter path for future use so
// we only have to generate the text at runtime.
// Draw the text box
mPainterPath
.
addRect
(
mBox
);
// Draw the tip
int
center
=
mBox
.
width
()
/
2
;
QPolygon
polygon
;
polygon
<<
QPoint
(
center
-
3
,
mBox
.
height
()
)
<<
QPoint
(
center
,
mBox
.
height
()
+
TIP_HEIGHT
)
<<
QPoint
(
center
+
3
,
mBox
.
height
()
);
mPainterPath
.
addPolygon
(
polygon
);
// Store the simplified version of the path
mPainterPath
=
mPainterPath
.
simplified
();
// Create the mask used to erase the background
// Note: this is a binary bitmap (black & white)
mMask
=
QBitmap
(
size
()
);
QPainter
painter
(
&
mMask
);
painter
.
fillRect
(
mMask
.
rect
(),
Qt
::
white
);
painter
.
setPen
(
QColor
(
0
,
0
,
0
)
);
painter
.
setBrush
(
QColor
(
0
,
0
,
0
)
);
painter
.
drawPath
(
mPainterPath
);
painter
.
end
();
setMask
(
mMask
);
// Set default text
setTime
(
"00:00"
);
}
void
TimeTooltip
::
setTime
(
const
QString
&
time
)
{
mTime
=
time
;
update
();
}
void
TimeTooltip
::
paintEvent
(
QPaintEvent
*
)
{
QPainter
p
(
this
);
p
.
setRenderHints
(
QPainter
::
HighQualityAntialiasing
|
QPainter
::
TextAntialiasing
);
p
.
setPen
(
Qt
::
black
);
p
.
setBrush
(
qApp
->
palette
().
base
()
);
p
.
drawPath
(
mPainterPath
);
p
.
setFont
(
mFont
);
p
.
setPen
(
QPen
(
qApp
->
palette
().
text
(),
1
)
);
p
.
drawText
(
mBox
,
Qt
::
AlignCenter
,
mTime
);
}
#undef TIP_HEIGHT
modules/gui/qt4/util/timetooltip.hpp
0 → 100644
View file @
0dbba8ba
/*****************************************************************************
* Copyright © 2011 VideoLAN
* $Id$
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* 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 2 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef TIMETOOLTIP_H
#define TIMETOOLTIP_H
#include <QWidget>
#include <QBitmap>
class
QPaintEvent
;
class
QString
;
class
QFont
;
class
QRect
;
class
QPainterPath
;
class
TimeTooltip
:
public
QWidget
{
Q_OBJECT
public:
explicit
TimeTooltip
(
QWidget
*
parent
=
0
);
void
setTime
(
const
QString
&
time
);
protected:
virtual
void
paintEvent
(
QPaintEvent
*
);
private:
QString
mTime
;
QFont
mFont
;
QRect
mBox
;
QPainterPath
mPainterPath
;
QBitmap
mMask
;
};
#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