THEMIM->getIM()->requestArtUpdate();
}
-TimeLabel::TimeLabel( intf_thread_t *_p_intf )
+TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
: QLabel(), p_intf( _p_intf ), bufTimer( new QTimer(this) ),
- buffering( false ), showBuffering(false), bufVal( -1 )
+ buffering( false ), showBuffering(false), bufVal( -1 ), displayType( _displayType )
{
b_remainingTime = false;
- setText( " --:--/--:-- " );
+ switch( _displayType ) {
+ case TimeLabel::Elapsed:
+ setText( " --:-- " );
+ setToolTip( qtr("Elapsed time") );
+ break;
+ case TimeLabel::Remaining:
+ setText( " --:-- " );
+ setToolTip( qtr("Total/Remaining time")
+ + QString("\n-")
+ + qtr("Click to toggle between total and remaining time")
+ );
+ break;
+ case TimeLabel::Both:
+ setText( " --:--/--:-- " );
+ setToolTip( QString( "- " )
+ + qtr( "Click to toggle between elapsed and remaining time" )
+ + QString( "\n- " )
+ + qtr( "Double click to jump to a chosen time position" ) );
+ break;
+ }
setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- setToolTip( QString( "- " )
- + qtr( "Click to toggle between elapsed and remaining time" )
- + QString( "\n- " )
- + qtr( "Double click to jump to a chosen time position" ) );
+
bufTimer->setSingleShot( true );
CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
CONNECT( THEMIM->getIM(), cachingChanged( float ),
this, updateBuffering( float ) );
CONNECT( bufTimer, timeout(), this, updateBuffering() );
+
+ this->setContentsMargins( 4, 0, 4, 0 );
}
void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
if( pos == -1.f )
{
- setText( " --:--/--:-- " );
+ if( displayType == TimeLabel::Both )
+ setText( " --:--/--:-- " );
+ else
+ setText( " --:-- " );
return;
}
secstotimestr( psz_length, length );
secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
: time );
-
- QString timestr = QString( " %1%2/%3 " )
+ switch( displayType )
+ {
+ case TimeLabel::Elapsed:
+ setText( QString(" ") + QString( psz_time ) + QString(" ") );
+ break;
+ case TimeLabel::Remaining:
+ if( b_remainingTime )
+ setText( QString(" -") + QString( psz_time ) + QString(" ") );
+ else
+ setText( QString(" ") + QString( psz_length ) + QString(" ") );
+ break;
+ case TimeLabel::Both:
+ default:
+ QString timestr = QString( " %1%2/%3 " )
.arg( QString( (b_remainingTime && length) ? "-" : "" ) )
.arg( QString( psz_time ) )
.arg( QString( ( !length && time ) ? "--:--" : psz_length ) );
- setText( timestr );
-
+ setText( timestr );
+ break;
+ }
cachedLength = length;
}
{
Q_OBJECT
public:
- TimeLabel( intf_thread_t *_p_intf );
+ enum Display
+ {
+ Elapsed,
+ Remaining,
+ Both
+ };
+
+ TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType = TimeLabel::Both );
protected:
virtual void mousePressEvent( QMouseEvent *event )
{
+ if( displayType == TimeLabel::Elapsed ) return;
toggleTimeDisplay();
event->accept();
}
virtual void mouseDoubleClickEvent( QMouseEvent *event )
{
+ if( displayType != TimeLabel::Both ) return;
event->accept();
toggleTimeDisplay();
emit timeLabelDoubleClicked();
bool buffering;
bool showBuffering;
float bufVal;
+ TimeLabel::Display displayType;
char psz_length[MSTRTIME_MAX_SIZE];
char psz_time[MSTRTIME_MAX_SIZE];
widget = new SpeedLabel( p_intf, this );
widgetItem->setText( qtr("Speed selector") );
break;
+ case TIME_LABEL_ELAPSED:
+ widget = new QLabel( "2:42", this );
+ widgetItem->setText( qtr("Elasped time") );
+ break;
+ case TIME_LABEL_REMAINING:
+ widget = new QLabel( "-2:42", this );
+ widgetItem->setText( qtr("Total/Remaining time") );
+ break;
default:
msg_Warn( p_intf, "This should not happen %i", i );
break;