[vlc-devel] [PATCH v2 2/2] qt: refresh time labels on display mode change
Romain Vimont
rom1v at videolabs.io
Mon Apr 9 18:33:46 CEST 2018
Toggling remaining-time/total-time did not update the time labels, so
they were only refreshed on the next positionUpdated() (which is not
called while paused).
Instead, store the position/time on every update, and refresh the time
labels immediately on remaining-time/total-time toggle.
Fixes #19810
---
Changes from v1:
- add '#' for ticket reference in commit message
- move fields initialization from in-class to constructor
- move refresh() out of the slots section
.../gui/qt/components/interface_widgets.cpp | 19 +++++++++++++++++--
.../gui/qt/components/interface_widgets.hpp | 3 +++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index 5ce20a28e0..0373748ade 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -900,7 +900,12 @@ void CoverArtLabel::clear()
}
TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
- : ClickableQLabel(), p_intf( _p_intf ), displayType( _displayType )
+ : ClickableQLabel()
+ , p_intf( _p_intf )
+ , cachedPos( -1 )
+ , cachedTime( 0 )
+ , cachedLength( 0 )
+ , displayType( _displayType )
{
b_remainingTime = false;
if( _displayType != TimeLabel::Elapsed )
@@ -944,12 +949,21 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
void TimeLabel::setRemainingTime( bool remainingTime )
{
- if (displayType != TimeLabel::Elapsed)
+ if( displayType != TimeLabel::Elapsed )
+ {
b_remainingTime = remainingTime;
+ refresh();
+ }
+}
+
+void TimeLabel::refresh()
+{
+ setDisplayPosition( cachedPos, cachedTime, cachedLength );
}
void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
{
+ cachedPos = pos;
if( pos == -1.f )
{
setMinimumSize( QSize( 0, 0 ) );
@@ -1011,6 +1025,7 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
break;
}
cachedLength = length;
+ cachedTime = t;
}
void TimeLabel::setDisplayPosition( float pos )
diff --git a/modules/gui/qt/components/interface_widgets.hpp b/modules/gui/qt/components/interface_widgets.hpp
index a4353a0d1d..772a6b7232 100644
--- a/modules/gui/qt/components/interface_widgets.hpp
+++ b/modules/gui/qt/components/interface_widgets.hpp
@@ -198,12 +198,15 @@ protected:
private:
intf_thread_t *p_intf;
bool b_remainingTime;
+ float cachedPos;
+ int64_t cachedTime;
int cachedLength;
TimeLabel::Display displayType;
char psz_length[MSTRTIME_MAX_SIZE];
char psz_time[MSTRTIME_MAX_SIZE];
void toggleTimeDisplay();
+ void refresh();
private slots:
void setRemainingTime( bool );
void setDisplayPosition( float pos, int64_t time, int length );
--
2.17.0
More information about the vlc-devel
mailing list