Commit 00f76ba2 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: remove buffering info from TimeLabel

parent bafe1e39
......@@ -730,8 +730,7 @@ void CoverArtLabel::clear()
}
TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
: ClickableQLabel(), p_intf( _p_intf ), bufTimer( new QTimer(this) ),
buffering( false ), showBuffering(false), bufVal( -1 ), displayType( _displayType )
: ClickableQLabel(), p_intf( _p_intf ), displayType( _displayType )
{
b_remainingTime = false;
if( _displayType != TimeLabel::Elapsed )
......@@ -758,22 +757,14 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
}
setAlignment( Qt::AlignRight | Qt::AlignVCenter );
bufTimer->setSingleShot( true );
CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
this, setDisplayPosition( float, int64_t, int ) );
CONNECT( THEMIM->getIM(), cachingChanged( float ),
this, updateBuffering( float ) );
CONNECT( bufTimer, timeout(), this, updateBuffering() );
setStyleSheet( "padding-left: 4px; padding-right: 4px;" );
}
void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
{
showBuffering = false;
bufTimer->stop();
if( pos == -1.f )
{
setMinimumSize( QSize( 0, 0 ) );
......@@ -864,39 +855,3 @@ void TimeLabel::toggleTimeDisplay()
getSettings()->setValue( "MainWindow/ShowRemainingTime", b_remainingTime );
}
void TimeLabel::updateBuffering( float _buffered )
{
bufVal = _buffered;
if( !buffering || bufVal == 0 )
{
showBuffering = false;
buffering = true;
bufTimer->start(200);
}
else if( bufVal == 1 )
{
showBuffering = buffering = false;
bufTimer->stop();
}
update();
}
void TimeLabel::updateBuffering()
{
showBuffering = true;
update();
}
void TimeLabel::paintEvent( QPaintEvent* event )
{
if( showBuffering )
{
QRect r( rect() );
r.setLeft( r.width() * bufVal );
QPainter p( this );
p.setOpacity( 0.4 );
p.fillRect( r, palette().color( QPalette::Highlight ) );
}
QLabel::paintEvent( event );
}
......@@ -200,22 +200,14 @@ private:
intf_thread_t *p_intf;
bool b_remainingTime;
int cachedLength;
QTimer *bufTimer;
bool buffering;
bool showBuffering;
float bufVal;
TimeLabel::Display displayType;
char psz_length[MSTRTIME_MAX_SIZE];
char psz_time[MSTRTIME_MAX_SIZE];
void toggleTimeDisplay();
void paintEvent( QPaintEvent* );
private slots:
void setDisplayPosition( float pos, int64_t time, int length );
void setDisplayPosition( float pos );
void updateBuffering( float );
void updateBuffering();
};
class SpeedLabel : public QLabel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment