Widgets with this attribute set do not participate in composition
management */
setAttribute( Qt::WA_PaintOnScreen, true );
-
- /* The core can ask through a callback to show the video. */
- connect( this, SIGNAL(askVideoWidgetToShow( unsigned int, unsigned int)),
- this, SLOT(SetSizing(unsigned int, unsigned int )),
- Qt::BlockingQueuedConnection );
}
void VideoWidget::paintEvent(QPaintEvent *ev)
/**
* Request the video to avoid the conflicts
**/
-void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
- unsigned int *pi_width, unsigned int *pi_height )
+WId VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
+ unsigned int *pi_width, unsigned int *pi_height,
+ bool b_keep_size )
{
msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
- emit askVideoWidgetToShow( *pi_width, *pi_height );
+
+ if( b_keep_size )
+ {
+ *pi_width = size().width();
+ *pi_height = size().height();
+ }
+
if( p_vout )
{
msg_Dbg( p_intf, "embedded video already in use" );
}
p_vout = p_nvout;
#ifndef NDEBUG
- msg_Dbg( p_intf, "embedded video ready (handle %p)", winId() );
+ msg_Dbg( p_intf, "embedded video ready (handle %p)", (void *)winId() );
#endif
- return ( void* )winId();
+ return winId();
}
/* Set the Widget to the correct Size */
/* Function has to be called by the parent
- Parent has to care about resizing himself*/
+ Parent has to care about resizing itself */
void VideoWidget::SetSizing( unsigned int w, unsigned int h )
{
msg_Dbg( p_intf, "Video is resizing to: %i %i", w, h );
videoSize.rwidth() = w;
videoSize.rheight() = h;
- if( isHidden() ) show();
+ if( !isVisible() ) show();
updateGeometry(); // Needed for deinterlace
}
backgroundLayout->setColumnStretch( 0, 1 );
backgroundLayout->setColumnStretch( 2, 1 );
- CONNECT( THEMIM->getIM(), artChanged( input_item_t* ),
- this, updateArt( input_item_t* ) );
+ CONNECT( THEMIM->getIM(), artChanged( QString ),
+ this, updateArt( const QString& ) );
}
BackgroundWidget::~BackgroundWidget()
label->show();
}
-void BackgroundWidget::updateArt( input_item_t *p_item )
+void BackgroundWidget::updateArt( const QString& url )
{
- QString url;
- if( p_item )
- {
- char *psz_art = input_item_GetArtURL( p_item );
- url = psz_art;
- free( psz_art );
- }
-
if( url.isEmpty() )
{
if( QDate::currentDate().dayOfYear() >= 354 )
}
else
{
- url = url.replace( "file://", QString("" ) );
- /* Taglib seems to define a attachment://, It won't work yet */
- url = url.replace( "attachment://", QString("" ) );
label->setPixmap( QPixmap( url ) );
}
}
void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
{
QVLCMenu::PopupMenu( p_intf, true );
+ event->accept();
}
#if 0
}
#endif
-SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, const QString text )
- : QLabel( text ), p_intf( _p_intf )
+SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, const QString& text,
+ QWidget *parent )
+ : QLabel( text, parent ), p_intf( _p_intf )
{
- setToolTip( qtr( "Current playback speed.\nRight click to adjust" ) );
- setContextMenuPolicy ( Qt::CustomContextMenu );
+ setToolTip( qtr( "Current playback speed.\nClick to adjust" ) );
/* Create the Speed Control Widget */
speedControl = new SpeedControlWidget( p_intf, this );
widgetAction->setDefaultWidget( speedControl );
speedControlMenu->addAction( widgetAction );
- /* Speed Label behaviour:
- - right click gives the vertical speed slider */
- CONNECT( this, customContextMenuRequested( QPoint ),
- this, showSpeedMenu( QPoint ) );
-
/* Change the SpeedRate in the Status Bar */
CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
CONNECT( THEMIM, inputChanged( input_thread_t * ),
speedControl, activateOnState() );
-}
+}
+SpeedLabel::~SpeedLabel()
+{
+ delete speedControl;
+ delete speedControlMenu;
+}
/****************************************************************************
* Small right-click menu for rate control
****************************************************************************/
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
- speedSlider = new QSlider;
+ speedSlider = new QSlider( this );
speedSlider->setSizePolicy( sizePolicy );
speedSlider->setMaximumSize( QSize( 80, 200 ) );
speedSlider->setOrientation( Qt::Vertical );
THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
}
-static int downloadCoverCallback( vlc_object_t *p_this,
- char const *psz_var,
- vlc_value_t oldvar, vlc_value_t newvar,
- void *data )
-{
- if( !strcmp( psz_var, "item-change" ) )
- {
- CoverArtLabel *art = static_cast< CoverArtLabel* >( data );
- if( art )
- art->requestUpdate();
- }
- return VLC_SUCCESS;
-}
-
-CoverArtLabel::CoverArtLabel( QWidget *parent,
- vlc_object_t *_p_this,
- input_item_t *_p_input )
- : QLabel( parent ), p_this( _p_this), p_input( _p_input ), prevArt()
+CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
+ : QLabel( parent ), p_intf( _p_i )
{
setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, doUpdate() );
-
- playlist_t *p_playlist = pl_Hold( p_this );
- var_AddCallback( p_playlist, "item-change",
- downloadCoverCallback, this );
- pl_Release( p_this );
+ CONNECT( THEMIM->getIM(), artChanged( QString ),
+ this, doUpdate( const QString& ) );
setMinimumHeight( 128 );
setMinimumWidth( 128 );
setMaximumHeight( 128 );
setMaximumWidth( 128 );
setScaledContents( true );
+ QList< QAction* > artActions = actions();
+ QAction *action = new QAction( qtr( "Download cover art" ), this );
+ addAction( action );
+ CONNECT( action, triggered(), this, doUpdate() );
doUpdate();
}
CoverArtLabel::~CoverArtLabel()
{
- playlist_t *p_playlist = pl_Hold( p_this );
- var_DelCallback( p_playlist, "item-change", downloadCoverCallback, this );
- pl_Release( p_this );
-
- if( p_input )
- vlc_gc_decref( p_input );
-};
-
-void CoverArtLabel::downloadCover()
-{
- if( p_input )
- {
- playlist_t *p_playlist = pl_Hold( p_this );
- playlist_AskForArtEnqueue( p_playlist, p_input, pl_Unlocked );
- pl_Release( p_this );
- }
+ QList< QAction* > artActions = actions();
+ foreach( QAction *act, artActions )
+ removeAction( act );
}
-void CoverArtLabel::doUpdate()
+void CoverArtLabel::doUpdate( const QString& url )
{
- if( !p_input )
+ QPixmap pix;
+ if( !url.isEmpty() && pix.load( url ) )
{
- setPixmap( QPixmap( ":/noart.png" ) );
- QList< QAction* > artActions = actions();
- if( !artActions.isEmpty() )
- foreach( QAction *act, artActions )
- removeAction( act );
- prevArt = "";
+ setPixmap( pix );
}
else
{
- char *psz_meta = input_item_GetArtURL( p_input );
- if( psz_meta && !strncmp( psz_meta, "file://", 7 ) )
- {
- QString artUrl = qfu( psz_meta ).replace( "file://", "" );
- if( artUrl != prevArt )
- {
- QPixmap pix;
- if( pix.load( artUrl ) )
- setPixmap( pix );
- else
- {
- msg_Dbg( p_this, "Qt could not load image '%s'",
- qtu( artUrl ) );
- setPixmap( QPixmap( ":/noart.png" ) );
- }
- }
- QList< QAction* > artActions = actions();
- if( !artActions.isEmpty() )
- {
- foreach( QAction *act, artActions )
- removeAction( act );
- }
- prevArt = artUrl;
- }
- else
- {
- if( prevArt != "" )
- setPixmap( QPixmap( ":/noart.png" ) );
- prevArt = "";
- QList< QAction* > artActions = actions();
- if( artActions.isEmpty() )
- {
- QAction *action = new QAction( qtr( "Download cover art" ),
- this );
- addAction( action );
- CONNECT( action, triggered(),
- this, downloadCover() );
- }
- }
- free( psz_meta );
+ setPixmap( QPixmap( ":/noart.png" ) );
}
}
+void CoverArtLabel::doUpdate()
+{
+ THEMIM->getIM()->requestArtUpdate();
+}
+
TimeLabel::TimeLabel( intf_thread_t *_p_intf ) :QLabel(), p_intf( _p_intf )
{
b_remainingTime = false;
void TimeLabel::setDisplayPosition( float pos, int time, int length )
{
+ if( pos == -1.f )
+ {
+ setText( " --:--/--:-- " );
+ return;
+ }
+
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
secstotimestr( psz_length, length );
secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
void TimeLabel::setCaching( float f_cache )
{
- setText( "Buffering" );
+ QString amount;
+ amount.setNum( (int)(100 * f_cache) );
+ msg_Dbg( p_intf, "New caching: %d", (int)(100*f_cache));
+ setText( "Buff: " + amount + "%" );
}