Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
6bd01d08
Commit
6bd01d08
authored
Mar 13, 2012
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: TimeLabel: compute minimal size to avoid 'dancing' with surrounding widgets
parent
d3a13c63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.cpp
+25
-0
No files found.
modules/gui/qt4/components/interface_widgets.cpp
View file @
6bd01d08
...
...
@@ -595,6 +595,7 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
if
(
pos
==
-
1.
f
)
{
setMinimumSize
(
QSize
(
0
,
0
)
);
if
(
displayType
==
TimeLabel
::
Both
)
setText
(
"--:--/--:--"
);
else
...
...
@@ -607,16 +608,40 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
secstotimestr
(
psz_length
,
length
);
secstotimestr
(
psz_time
,
(
b_remainingTime
&&
length
)
?
length
-
time
:
time
);
// compute the minimum size that will be required for the psz_length
// and use it to enforce a minimal size to avoid "dancing" widgets
QSize
minsize
;
if
(
length
>
0
)
{
QMargins
margins
=
contentsMargins
();
minsize
+=
QSize
(
fontMetrics
().
size
(
0
,
QString
(
psz_length
),
0
,
0
).
width
(),
sizeHint
().
height
()
);
minsize
+=
QSize
(
margins
.
left
()
+
margins
.
right
()
+
8
,
0
);
/* +padding */
if
(
b_remainingTime
)
minsize
+=
QSize
(
fontMetrics
().
size
(
0
,
"-"
,
0
,
0
).
width
(),
0
);
}
switch
(
displayType
)
{
case
TimeLabel
::
Elapsed
:
setMinimumSize
(
minsize
);
setText
(
QString
(
psz_time
)
);
break
;
case
TimeLabel
::
Remaining
:
if
(
b_remainingTime
)
{
setMinimumSize
(
minsize
);
setText
(
QString
(
"-"
)
+
QString
(
psz_time
)
);
}
else
{
setMinimumSize
(
QSize
(
0
,
0
)
);
setText
(
QString
(
psz_length
)
);
}
break
;
case
TimeLabel
::
Both
:
default:
...
...
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