[vlc-commits] qt: refresh time labels on display mode change

Romain Vimont git at videolan.org
Wed Apr 11 16:39:33 CEST 2018


vlc/vlc-3.0 | branch: master | Romain Vimont <rom1v at videolabs.io> | Mon Apr  9 18:33:46 2018 +0200| [2c1a21700245633024a20cef0a0525f1945fc95f] | committer: Hugo Beauzée-Luyssen

qt: refresh time labels on display mode change

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

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit bc06f0c87a4676eb62a3ff5e14f2510f26007c95)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=2c1a21700245633024a20cef0a0525f1945fc95f
---

 modules/gui/qt/components/interface_widgets.cpp | 19 +++++++++++++++++--
 modules/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 b9bf121dcb..78dbc2f9c3 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -901,7 +901,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 )
@@ -945,12 +950,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 ) );
@@ -1012,6 +1026,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 );



More information about the vlc-commits mailing list