vlc/vlc-3.0 | branch: master | Romain Vimont <ro...@videolabs.io> | Mon Apr  9 
15:05:15 2018 +0200| [7a5aaf1665427c1edf79bfec151413a94fd8c6b3] | committer: 
Hugo Beauzée-Luyssen

qt: update all time labels on seek request

There are 3 time labels in the main interface, containing:
 - the elapsed time (on the left of the seekbar);
 - the remaining or total time (on the right of the seekbar);
 - both (in the statusbar).

Only the one from the statusbar was updated on seek request: it was
individually connected to its own specific slot. As a consequence, the
others were not updated on seek (especially visible while paused).

Instead, factorize the slot implementation so that all time label
updates are handled by setDisplayPosition(), and connect seekRequested()
from the TimeLabel constructor (like positionUpdated()) to update them
all on seek request.

Signed-off-by: Hugo Beauzée-Luyssen <h...@beauzee.fr>
(cherry picked from commit ec699bd1023fe6a9417e425f48a531eb8dbbb1b5)
Signed-off-by: Hugo Beauzée-Luyssen <h...@beauzee.fr>

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

 modules/gui/qt/components/interface_widgets.cpp | 22 +++++-----------------
 modules/gui/qt/main_interface.cpp               |  3 ---
 2 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt/components/interface_widgets.cpp 
b/modules/gui/qt/components/interface_widgets.cpp
index 575970c1b8..5ce20a28e0 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -927,6 +927,9 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, 
TimeLabel::Display _displayType  )
     }
     setAlignment( Qt::AlignRight | Qt::AlignVCenter );
 
+    CONNECT( THEMIM->getIM(), seekRequested( float ),
+             this, setDisplayPosition( float ) );
+
     CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
               this, setDisplayPosition( float, int64_t, int ) );
 
@@ -1012,25 +1015,10 @@ void TimeLabel::setDisplayPosition( float pos, int64_t 
t, int length )
 
 void TimeLabel::setDisplayPosition( float pos )
 {
-    if( pos == -1.f || cachedLength == 0 )
-    {
-        setText( " --:--/--:-- " );
-        return;
-    }
-
-    int time = pos * cachedLength;
-    secstotimestr( psz_time,
-                   ( b_remainingTime && cachedLength ?
-                   cachedLength - time : time ) );
-    QString timestr = QString( "%1%2/%3" )
-        .arg( QString( (b_remainingTime && cachedLength) ? "-" : "" ) )
-        .arg( QString( psz_time ) )
-        .arg( QString( ( !cachedLength && time ) ? "--:--" : psz_length ) );
-
-    setText( timestr );
+    int64_t time = pos * cachedLength * 1000000;
+    setDisplayPosition( pos, time, cachedLength );
 }
 
-
 void TimeLabel::toggleTimeDisplay()
 {
     b_remainingTime = !b_remainingTime;
diff --git a/modules/gui/qt/main_interface.cpp 
b/modules/gui/qt/main_interface.cpp
index d0522e08e9..3545ab6094 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -590,9 +590,6 @@ inline void MainInterface::createStatusBar()
     CONNECT( THEMIM->getIM(), encryptionChanged( bool ),
              this, showCryptedLabel( bool ) );
 
-    CONNECT( THEMIM->getIM(), seekRequested( float ),
-             timeLabel, setDisplayPosition( float ) );
-
     /* This shouldn't be necessary, but for somehow reason, the statusBarr
        starts at height of 20px and when a text is shown it needs more space.
        But, as the QMainWindow policy doesn't allow statusBar to change QMW's

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to