Commit 45bc2960 authored by Ilkka Ollakka's avatar Ilkka Ollakka

remove that kludge to use playlistwidget for getting art for
backgroundwidget, use callback instead and check need of update every
750ms.
parent 1b8c8704
...@@ -49,6 +49,8 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*, ...@@ -49,6 +49,8 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
unsigned int *, unsigned int * ); unsigned int *, unsigned int * );
static void DoRelease( intf_thread_t *, void * ); static void DoRelease( intf_thread_t *, void * );
static int DoControl( intf_thread_t *, void *, int, va_list ); static int DoControl( intf_thread_t *, void *, int, va_list );
static int ItemChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i ) VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
{ {
...@@ -133,7 +135,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -133,7 +135,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
/* A cone in the middle */ /* A cone in the middle */
label = new QLabel; label = new QLabel;
// label->setScaledContents( true ); label->setScaledContents( true );
label->setMargin( 5 ); label->setMargin( 5 );
label->setMaximumHeight( MAX_BG_SIZE ); label->setMaximumHeight( MAX_BG_SIZE );
label->setMaximumWidth( MAX_BG_SIZE ); label->setMaximumWidth( MAX_BG_SIZE );
...@@ -146,18 +148,58 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -146,18 +148,58 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
resize( 300, 150 ); resize( 300, 150 );
updateGeometry(); updateGeometry();
i_runs = 0;
b_need_update = VLC_FALSE;
var_AddCallback( THEPL, "item-change", ItemChanged, this );
ON_TIMEOUT( update() );
} }
BackgroundWidget::~BackgroundWidget() BackgroundWidget::~BackgroundWidget()
{} {
var_DelCallback( THEPL, "item-change", ItemChanged, this );
}
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
BackgroundWidget *p_d = (BackgroundWidget*)param;
p_d->b_need_update = VLC_TRUE;
return VLC_SUCCESS;
}
void BackgroundWidget::setArt( QString url ) void BackgroundWidget::update()
{ {
if( url.isNull() ) /* Timer runs at 150 ms, dont' update more than once every 750ms */
i_runs++;
if( i_runs % 6 != 0 ) return;
/* Get Input and clear if non-existant */
input_thread_t *p_input =
MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead )
{
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
else return;
label->setPixmap( QPixmap( url ) ); }
updateGeometry();
if( b_need_update )
{
vlc_object_yield( p_input );
char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
vlc_object_release( p_input );
QString url = qfu( psz_arturl );
QString arturl = url.replace( "file://",QString("" ) );
if( arturl.isNull() )
label->setPixmap( QPixmap( ":/vlc128.png" ) );
else
{
label->setPixmap( QPixmap( arturl ) );
msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
}
free( psz_arturl );
}
b_need_update = false;
} }
QSize BackgroundWidget::sizeHint() const QSize BackgroundWidget::sizeHint() const
...@@ -167,10 +209,15 @@ QSize BackgroundWidget::sizeHint() const ...@@ -167,10 +209,15 @@ QSize BackgroundWidget::sizeHint() const
void BackgroundWidget::resizeEvent( QResizeEvent *e ) void BackgroundWidget::resizeEvent( QResizeEvent *e )
{ {
msg_Dbg( p_intf, "BG size, %i, %i", e->size().width(), e->size().height() ); if( e->size().height() < MAX_BG_SIZE -1 )
if( e->size().height() < label->height() ) {
label->setMaximumWidth( e->size().height() );
label->setMaximumHeight( e->size().width() );
}
else
{ {
label->resize( e->size().height(), e->size().height() ); label->setMaximumHeight( MAX_BG_SIZE );
label->setMaximumWidth( MAX_BG_SIZE );
} }
} }
......
...@@ -80,15 +80,17 @@ public: ...@@ -80,15 +80,17 @@ public:
virtual ~BackgroundWidget(); virtual ~BackgroundWidget();
QSize widgetSize; QSize widgetSize;
QSize sizeHint() const; QSize sizeHint() const;
bool b_need_update;
private: private:
QPalette plt; QPalette plt;
QLabel *label; QLabel *label;
virtual void resizeEvent( QResizeEvent *e ); virtual void resizeEvent( QResizeEvent *e );
virtual void contextMenuEvent( QContextMenuEvent *event ); virtual void contextMenuEvent( QContextMenuEvent *event );
intf_thread_t *p_intf; intf_thread_t *p_intf;
int i_runs;
public slots: public slots:
void setArt( QString );
void toggle(){ TOGGLEV( this ); } void toggle(){ TOGGLEV( this ); }
void update( void );
}; };
class VisualSelector : public QFrame class VisualSelector : public QFrame
......
...@@ -658,9 +658,6 @@ void MainInterface::togglePlaylist() ...@@ -658,9 +658,6 @@ void MainInterface::togglePlaylist()
{ {
msg_Dbg( p_intf, "Creating a new playlist" ); msg_Dbg( p_intf, "Creating a new playlist" );
playlistWidget = new PlaylistWidget( p_intf, settings ); playlistWidget = new PlaylistWidget( p_intf, settings );
if( bgWidget )
CONNECT( playlistWidget, artSet( QString ),
bgWidget, setArt(QString) );
/* Add it to the parent DockWidget */ /* Add it to the parent DockWidget */
dockPL->setWidget( playlistWidget ); dockPL->setWidget( playlistWidget );
......
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