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
a59edbf5
Commit
a59edbf5
authored
Nov 06, 2014
by
Jarrad Whitaker
Committed by
Jean-Baptiste Kempf
Jan 08, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draw toolbar buttons with DPI-scaled sizes
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
0ec04296
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
21 deletions
+52
-21
modules/gui/qt4/components/controller.cpp
modules/gui/qt4/components/controller.cpp
+11
-4
modules/gui/qt4/components/controller_widget.cpp
modules/gui/qt4/components/controller_widget.cpp
+6
-5
modules/gui/qt4/components/controller_widget.hpp
modules/gui/qt4/components/controller_widget.hpp
+1
-0
modules/gui/qt4/qt4.hpp
modules/gui/qt4/qt4.hpp
+2
-0
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.cpp
+30
-12
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/input_slider.hpp
+2
-0
No files found.
modules/gui/qt4/components/controller.cpp
View file @
a59edbf5
...
...
@@ -100,9 +100,12 @@ void AbstractController::setupButton( QAbstractButton *aButton )
sizePolicy
.
setHorizontalStretch
(
0
);
sizePolicy
.
setVerticalStretch
(
0
);
qreal
scalingFactorX
=
static_cast
<
qreal
>
(
aButton
->
logicalDpiX
())
/
DPI_REF_VALUE
;
qreal
scalingFactorY
=
static_cast
<
qreal
>
(
aButton
->
logicalDpiY
())
/
DPI_REF_VALUE
;
aButton
->
setSizePolicy
(
sizePolicy
);
aButton
->
setFixedSize
(
QSize
(
26
,
26
)
);
aButton
->
setIconSize
(
QSize
(
20
,
20
)
);
aButton
->
setFixedSize
(
QSize
(
26
.0
*
scalingFactorX
,
26.0
*
scalingFactorY
)
);
aButton
->
setIconSize
(
QSize
(
20
.0
*
scalingFactorX
,
20.0
*
scalingFactorY
)
);
aButton
->
setFocusPolicy
(
Qt
::
NoFocus
);
}
...
...
@@ -516,8 +519,12 @@ void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, b
tmpButton
->
setAutoRaise
(
b_flat
);
if
(
b_big
)
{
tmpButton
->
setFixedSize
(
QSize
(
32
,
32
)
);
tmpButton
->
setIconSize
(
QSize
(
26
,
26
)
);
qreal
scalingFactorX
=
static_cast
<
qreal
>
(
tmpButton
->
logicalDpiX
())
/
DPI_REF_VALUE
;
qreal
scalingFactorY
=
static_cast
<
qreal
>
(
tmpButton
->
logicalDpiY
())
/
DPI_REF_VALUE
;
tmpButton
->
setFixedSize
(
QSize
(
32.0
*
scalingFactorX
,
32.0
*
scalingFactorY
)
);
tmpButton
->
setIconSize
(
QSize
(
26.0
*
scalingFactorX
,
26.0
*
scalingFactorY
)
);
}
}
}
...
...
modules/gui/qt4/components/controller_widget.cpp
View file @
a59edbf5
...
...
@@ -50,7 +50,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
/* We need a Label for the pix */
volMuteLabel
=
new
QLabel
;
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-medium"
)
);
volMuteLabelSize
=
QSize
(
16.0
*
logicalDpiX
()
/
DPI_REF_VALUE
,
16.0
*
logicalDpiY
()
/
DPI_REF_VALUE
);
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-medium"
).
scaled
(
volMuteLabelSize
)
);
/* We might need a subLayout too */
QVBoxLayout
*
subLayout
;
...
...
@@ -128,16 +129,16 @@ void SoundWidget::refreshLabels()
if
(
b_is_muted
)
{
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-muted"
)
);
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-muted"
)
.
scaled
(
volMuteLabelSize
)
);
volMuteLabel
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Unmute"
,
"Unmute"
)));
return
;
}
if
(
i_sliderVolume
<
VOLUME_MAX
/
3
)
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-low"
)
);
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-low"
)
.
scaled
(
volMuteLabelSize
)
);
else
if
(
i_sliderVolume
>
(
VOLUME_MAX
*
2
/
3
)
)
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-high"
)
);
else
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-medium"
)
);
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-high"
)
.
scaled
(
volMuteLabelSize
)
);
else
volMuteLabel
->
setPixmap
(
QPixmap
(
":/toolbar/volume-medium"
)
.
scaled
(
volMuteLabelSize
)
);
volMuteLabel
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Mute"
,
"Mute"
))
);
}
...
...
modules/gui/qt4/components/controller_widget.hpp
View file @
a59edbf5
...
...
@@ -106,6 +106,7 @@ protected:
private:
intf_thread_t
*
p_intf
;
QLabel
*
volMuteLabel
;
QSize
volMuteLabelSize
;
QAbstractSlider
*
volumeSlider
;
QFrame
*
volumeControlWidget
;
QMenu
*
volumeMenu
;
...
...
modules/gui/qt4/qt4.hpp
View file @
a59edbf5
...
...
@@ -67,6 +67,8 @@ enum{
NOTIFICATION_ALWAYS
=
2
,
};
#define DPI_REF_VALUE 96.0
class
QVLCApp
;
class
MainInterface
;
class
QSettings
;
...
...
modules/gui/qt4/util/input_slider.cpp
View file @
a59edbf5
...
...
@@ -47,6 +47,7 @@
#include <QPoint>
#include <QPropertyAnimation>
#include <QApplication>
#include <QDebug>
#define MINIMUM 0
#define MAXIMUM 1000
...
...
@@ -479,14 +480,20 @@ void SeekSlider::hideHandle()
- Mark Kretschmann
- Gábor Lehel
*/
#define WLENGTH 80 // px
#define WHEIGHT 22 // px
#define WLENGTH
_BASE
80 // px
#define WHEIGHT
_BASE
22 // px
#define SOUNDMIN 0 // %
SoundSlider
::
SoundSlider
(
QWidget
*
_parent
,
float
_i_step
,
char
*
psz_colors
,
int
max
)
:
QAbstractSlider
(
_parent
)
{
qreal
scalingFactorX
=
static_cast
<
qreal
>
(
logicalDpiX
())
/
DPI_REF_VALUE
;
qreal
scalingFactorY
=
static_cast
<
qreal
>
(
logicalDpiY
())
/
DPI_REF_VALUE
;
wlength
=
WLENGTH_BASE
*
scalingFactorX
;
wheight
=
WHEIGHT_BASE
*
scalingFactorY
;
f_step
=
(
float
)(
_i_step
*
10000
)
/
(
float
)((
max
-
SOUNDMIN
)
*
AOUT_VOLUME_DEFAULT
);
setRange
(
SOUNDMIN
,
max
);
...
...
@@ -495,9 +502,20 @@ SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
b_mouseOutside
=
true
;
b_isMuted
=
false
;
pixOutside
=
QPixmap
(
":/toolbar/volslide-outside"
);
const
QPixmap
pixOutsideRaw
(
":/toolbar/volslide-outside"
);
const
QSize
pixOutsideSize
(
static_cast
<
qreal
>
(
pixOutsideRaw
.
width
())
*
scalingFactorX
,
static_cast
<
qreal
>
(
pixOutsideRaw
.
height
())
*
scalingFactorY
);
pixOutside
=
pixOutsideRaw
.
scaled
(
pixOutsideSize
);
const
QPixmap
tempRaw
(
":/toolbar/volslide-inside"
);
const
QSize
tempSize
(
static_cast
<
qreal
>
(
tempRaw
.
width
())
*
scalingFactorX
,
static_cast
<
qreal
>
(
tempRaw
.
height
())
*
scalingFactorY
);
const
QPixmap
temp
=
tempRaw
.
scaled
(
tempSize
);
const
QPixmap
temp
(
":/toolbar/volslide-inside"
);
const
QBitmap
mask
(
temp
.
createHeuristicMask
()
);
setFixedSize
(
pixOutside
.
size
()
);
...
...
@@ -506,8 +524,8 @@ SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
pixGradient2
=
QPixmap
(
mask
.
size
()
);
/* Gradient building from the preferences */
QLinearGradient
gradient
(
paddingL
,
2
,
WLENGTH
+
paddingL
,
2
);
QLinearGradient
gradient2
(
paddingL
,
2
,
WLENGTH
+
paddingL
,
2
);
QLinearGradient
gradient
(
paddingL
,
2
,
wlength
+
paddingL
,
2
);
QLinearGradient
gradient2
(
paddingL
,
2
,
wlength
+
paddingL
,
2
);
QStringList
colorList
=
qfu
(
psz_colors
).
split
(
";"
);
free
(
psz_colors
);
...
...
@@ -523,8 +541,8 @@ SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
(
background
.
saturation
()
+
foreground
.
saturation
()
)
/
2
,
(
background
.
value
()
+
foreground
.
value
()
)
/
2
);
textfont
.
setP
ixel
Size
(
9
);
textrect
.
setRect
(
0
,
0
,
34
,
15
);
textfont
.
setP
oint
Size
(
9
);
textrect
.
setRect
(
0
,
0
,
34
.0
*
scalingFactorX
,
15.0
*
scalingFactorY
);
/* Regular colors */
#define c(i) colorList.at(i).toInt()
...
...
@@ -615,7 +633,7 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event )
if
(
isSliding
)
{
QRect
rect
(
paddingL
-
15
,
-
1
,
WLENGTH
+
15
*
2
,
WHEIGHT
+
5
);
wlength
+
15
*
2
,
wheight
+
5
);
if
(
!
rect
.
contains
(
event
->
pos
()
)
)
{
/* We are outside */
if
(
!
b_mouseOutside
)
...
...
@@ -631,7 +649,7 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event )
}
else
{
int
i
=
(
(
event
->
x
()
-
paddingL
)
*
maximum
()
+
40
)
/
WLENGTH
;
int
i
=
(
(
event
->
x
()
-
paddingL
)
*
maximum
()
+
40
)
/
wlength
;
i
=
__MIN
(
__MAX
(
0
,
i
),
maximum
()
);
setToolTip
(
QString
(
"%1 %"
).
arg
(
i
)
);
}
...
...
@@ -639,7 +657,7 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event )
void
SoundSlider
::
changeValue
(
int
x
)
{
setValue
(
(
x
*
maximum
()
+
40
)
/
WLENGTH
);
setValue
(
(
x
*
maximum
()
+
40
)
/
wlength
);
}
void
SoundSlider
::
setMuted
(
bool
m
)
...
...
@@ -658,7 +676,7 @@ void SoundSlider::paintEvent( QPaintEvent *e )
painter
.
begin
(
this
);
const
int
offset
=
int
(
(
WLENGTH
*
value
()
+
100
)
/
maximum
()
)
+
paddingL
;
const
int
offset
=
int
(
(
wlength
*
value
()
+
100
)
/
maximum
()
)
+
paddingL
;
const
QRectF
boundsG
(
0
,
0
,
offset
,
paintGradient
->
height
()
);
painter
.
drawPixmap
(
boundsG
,
*
paintGradient
,
boundsG
);
...
...
modules/gui/qt4/util/input_slider.hpp
View file @
a59edbf5
...
...
@@ -150,6 +150,8 @@ private:
int
i_oldvalue
;
/* Store the old Value before changing */
float
f_step
;
/* How much do we increase each time we wheel */
bool
b_isMuted
;
int
wlength
;
int
wheight
;
QPixmap
pixGradient
;
/* Gradient pix storage */
QPixmap
pixGradient2
;
/* Muted Gradient pix storage */
...
...
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