[vlc-devel] [PATCH 2/2] qt: don't display time position in Timelabel if media is not seekable
Pierre Lamot
pierre at videolabs.io
Fri Jan 26 17:00:41 CET 2018
---
modules/gui/qt/components/interface_widgets.cpp | 20 ++++++++++++++++++--
modules/gui/qt/components/interface_widgets.hpp | 2 ++
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 a640424ee9..b96aa77a9f 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -904,6 +904,7 @@ void CoverArtLabel::clear()
TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
: ClickableQLabel(), p_intf( _p_intf ), displayType( _displayType )
{
+ b_seekable = true;
b_remainingTime = false;
if( _displayType != TimeLabel::Elapsed )
b_remainingTime = getSettings()->value( "MainWindow/ShowRemainingTime", false ).toBool();
@@ -938,6 +939,9 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
CONNECT( THEMIM->getIM(), remainingTimeChanged( bool ),
this, setRemainingTime( bool ) );
+ CONNECT( THEMIM->getIM(), inputCanSeek( bool ),
+ this, setSeekable( bool ) );
+
setStyleSheet( "QLabel { padding-left: 4px; padding-right: 4px; }" );
}
@@ -948,7 +952,7 @@ void TimeLabel::setRemainingTime( bool remainingTime )
void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
{
- if( pos == -1.f )
+ if( pos == -1.f || !b_seekable )
{
setMinimumSize( QSize( 0, 0 ) );
if( displayType == TimeLabel::Both )
@@ -1013,7 +1017,7 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
void TimeLabel::setDisplayPosition( float pos )
{
- if( pos == -1.f || cachedLength == 0 )
+ if( pos == -1.f || cachedLength == 0 || !b_seekable )
{
setText( " --:--/--:-- " );
return;
@@ -1039,3 +1043,15 @@ void TimeLabel::toggleTimeDisplay()
emit broadcastRemainingTime( b_remainingTime );
}
+
+void TimeLabel::setSeekable( bool seekable )
+{
+ b_seekable = seekable;
+ if ( !b_seekable )
+ {
+ if( displayType == TimeLabel::Both )
+ setText( "--:--/--:--" );
+ else
+ setText( "--:--" );
+ }
+}
diff --git a/modules/gui/qt/components/interface_widgets.hpp b/modules/gui/qt/components/interface_widgets.hpp
index a4353a0d1d..fcf3d60d4c 100644
--- a/modules/gui/qt/components/interface_widgets.hpp
+++ b/modules/gui/qt/components/interface_widgets.hpp
@@ -199,6 +199,7 @@ private:
intf_thread_t *p_intf;
bool b_remainingTime;
int cachedLength;
+ bool b_seekable;
TimeLabel::Display displayType;
char psz_length[MSTRTIME_MAX_SIZE];
@@ -208,6 +209,7 @@ private slots:
void setRemainingTime( bool );
void setDisplayPosition( float pos, int64_t time, int length );
void setDisplayPosition( float pos );
+ void setSeekable( bool );
signals:
void broadcastRemainingTime( bool );
};
--
2.14.1
More information about the vlc-devel
mailing list