]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/interface_widgets.cpp
Qt: Access-filter 'record' does not exist anymore.
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
index d91580f673c26dcbda0f857462a7836b969389db..f99a660991705961ef22f537569a3d233c983f23 100644 (file)
@@ -73,7 +73,7 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
     hide();
 
     /* Set the policy to expand in both directions */
-    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
+//    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
 
     /* Black background is more coherent for a Video Widget */
     QPalette plt =  palette();
@@ -110,20 +110,12 @@ void VideoWidget::paintEvent(QPaintEvent *ev)
 VideoWidget::~VideoWidget()
 {
     vout_thread_t *p_vout = i_vout ?
-        (vout_thread_t *)vlc_object_get( i_vout ) : NULL;
+        (vout_thread_t *)vlc_object_get( p_intf->p_libvlc, i_vout ) : NULL;
 
     if( p_vout )
     {
-        if( !p_intf->psz_switch_intf )
-        {
-            if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
-                vout_Control( p_vout, VOUT_REPARENT );
-        }
-        else
-        {
-            if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
-                vout_Control( p_vout, VOUT_CLOSE );
-        }
+        if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
+            vout_Control( p_vout, VOUT_REPARENT );
         vlc_object_release( p_vout );
     }
 }
@@ -181,7 +173,7 @@ QSize VideoWidget::sizeHint() const
  **********************************************************************/
 #define ICON_SIZE 128
 #define MAX_BG_SIZE 400
-#define MIN_BG_SIZE 64
+#define MIN_BG_SIZE 128
 
 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
                  :QWidget( NULL ), p_intf( _p_i )
@@ -191,7 +183,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
 
     /* A dark background */
     setAutoFillBackground( true );
-    plt =  palette();
+    plt = palette();
     plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
     plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
     setPalette( plt );
@@ -213,7 +205,8 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
     backgroundLayout->setColumnStretch( 0, 1 );
     backgroundLayout->setColumnStretch( 2, 1 );
 
-    CONNECT( THEMIM->getIM(), artChanged( QString ), this, updateArt( QString ) );
+    CONNECT( THEMIM->getIM(), artChanged( input_item_t* ),
+             this, updateArt( input_item_t* ) );
 }
 
 BackgroundWidget::~BackgroundWidget()
@@ -227,18 +220,28 @@ void BackgroundWidget::resizeEvent( QResizeEvent * event )
         label->show();
 }
 
-void BackgroundWidget::updateArt( QString url )
+void BackgroundWidget::updateArt( input_item_t *p_item )
 {
+    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 )
             label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
         else
             label->setPixmap( QPixmap( ":/vlc128.png" ) );
-        return;
     }
     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 ) );
     }
 }
@@ -347,11 +350,13 @@ AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i, bool b_fsCreation = f
 #endif
 
     /* Record Button */
+#if 0
     recordButton = new QPushButton;
     setupSmallButton( recordButton );
     advLayout->addWidget( recordButton );
     BUTTON_SET_ACT_I( recordButton, "", record,
             qtr( "Record" ), record() );
+#endif
 
     /* Snapshot Button */
     snapshotButton = new QPushButton;
@@ -371,17 +376,19 @@ void AdvControlsWidget::enableInput( bool enable )
     {
         input_item_t *p_item = input_GetItem( THEMIM->getInput() );
         i_input_id = p_item->i_id;
-
-        if( var_Type( THEMIM->getInput(), "record-toggle" ) == VLC_VAR_VOID )
-            recordButton->setVisible( true );
-        else
-            recordButton->setVisible( false );
+#if 0
+        recordButton->setVisible( var_GetBool( THEMIM->getInput(), "can-record" ) );
     }
     else
+    {
         recordButton->setVisible( false );
+#endif
+    }
 
     ABButton->setEnabled( enable );
+#if 0
     recordButton->setEnabled( enable );
+#endif
 
     if( enable && ( i_last_input_id != i_input_id ) )
     {
@@ -403,7 +410,11 @@ void AdvControlsWidget::snapshot()
 {
     vout_thread_t *p_vout =
         (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
-    if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
+    if( p_vout )
+    {
+        vout_Control( p_vout, VOUT_SNAPSHOT );
+        vlc_object_release( p_vout );
+    }
 }
 
 /* Function called when the button is clicked() */
@@ -458,15 +469,15 @@ void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
     }
 }
 
-/* FIXME Record function */
+// TODO: On-the-fly record needs to be reimplemented
 void AdvControlsWidget::record()
 {
     input_thread_t *p_input = THEMIM->getInput();
     if( p_input )
     {
         /* This method won't work fine if the stream can't be cut anywhere */
-        if( var_Type( p_input, "record-toggle" ) == VLC_VAR_VOID )
-            var_TriggerCallback( p_input, "record-toggle" );
+        const bool b_recording = var_GetBool( p_input, "record" );
+        var_SetBool( p_input, "record", !b_recording );
 #if 0
         else
         {
@@ -668,6 +679,9 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     /*
      * Other first Line buttons
      */
+    /* */
+    CONNECT( THEMIM->getIM(), voutChanged(bool), this, enableVideo(bool) );
+
     /** Fullscreen/Visualisation **/
     fullscreenButton = new QPushButton;
     BUTTON_SET_ACT_I( fullscreenButton, "", fullscreen,
@@ -808,7 +822,7 @@ void ControlsWidget::toggleTeletextTransparency()
     }
     else
     {
-        telexTransparent->setIcon( QIcon( ":/tvtelx-transparent" ) );
+        telexTransparent->setIcon( QIcon( ":/tvtelx-trans" ) );
         telexTransparent->setToolTip( qtr( "Transparent" ) );
         b_telexTransparent = true;
     }
@@ -851,13 +865,13 @@ void ControlsWidget::setNavigation( int navigation )
     {
         discFrame->hide();
     } else if( navigation == 1 ) {
-        prevSectionButton->setToolTip( qfu( HELP_PCH ) );
-        nextSectionButton->setToolTip( qfu( HELP_NCH ) );
+        prevSectionButton->setToolTip( qtr( HELP_PCH ) );
+        nextSectionButton->setToolTip( qtr( HELP_NCH ) );
         menuButton->show();
         discFrame->show();
     } else {
-        prevSectionButton->setToolTip( qfu( HELP_PCH ) );
-        nextSectionButton->setToolTip( qfu( HELP_NCH ) );
+        prevSectionButton->setToolTip( qtr( HELP_PCH ) );
+        nextSectionButton->setToolTip( qtr( HELP_NCH ) );
         menuButton->hide();
         discFrame->show();
     }
@@ -906,7 +920,7 @@ void ControlsWidget::updateInput()
 {
     /* Activate the interface buttons according to the presence of the input */
     enableInput( THEMIM->getIM()->hasInput() );
-    enableVideo( THEMIM->getIM()->hasVideo() && THEMIM->getIM()->hasInput() );
+    enableVideo( THEMIM->getIM()->hasVideo() );
 }
 
 void ControlsWidget::setStatus( int status )
@@ -990,7 +1004,6 @@ void ControlsWidget::toggleAdvanced()
     emit advancedControlsToggled( b_advancedVisible );
 }
 
-
 /**********************************************************************
  * Fullscrenn control widget
  **********************************************************************/
@@ -1008,13 +1021,14 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
     setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
 
     QGridLayout *fsLayout = new QGridLayout( this );
-    fsLayout->setLayoutMargins( 5, 1, 5, 1, 5 );
+    fsLayout->setLayoutMargins( 5, 2, 5, 2, 5 );
 
     /* First line */
     slider->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum);
+    slider->setMinimumWidth( 220 );
     fsLayout->addWidget( slowerButton, 0, 0 );
-    fsLayout->addWidget( slider, 0, 1, 1, 8 );
-    fsLayout->addWidget( fasterButton, 0, 9 );
+    fsLayout->addWidget( slider, 0, 1, 1, 9 );
+    fsLayout->addWidget( fasterButton, 0, 10 );
 
     fsLayout->addWidget( playButton, 1, 0, 1, 2 );
     fsLayout->addLayout( controlButLayout, 1, 2 );
@@ -1024,8 +1038,9 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
     fsLayout->addWidget( fullscreenButton, 1, 5 );
     fsLayout->addWidget( advControls, 1, 6, Qt::AlignVCenter );
 
-    fsLayout->addWidget( volMuteLabel, 1, 7 );
-    fsLayout->addWidget( volumeSlider, 1, 8, 1, 2 );
+    fsLayout->setColumnStretch( 7, 10 );
+    fsLayout->addWidget( volMuteLabel, 1, 8 );
+    fsLayout->addWidget( volumeSlider, 1, 9, 1, 2 );
 
     /* hiding timer */
     p_hideTimer = new QTimer( this );
@@ -1441,3 +1456,98 @@ void SpeedControlWidget::resetRate()
 {
     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()
+{
+    setContextMenuPolicy( Qt::ActionsContextMenu );
+    CONNECT( this, updateRequested(), this, doUpdate() );
+
+    playlist_t *p_playlist = pl_Yield( p_this );
+    var_AddCallback( p_playlist, "item-change",
+                     downloadCoverCallback, this );
+    pl_Release( p_this );
+
+    setMinimumHeight( 128 );
+    setMinimumWidth( 128 );
+    setMaximumHeight( 128 );
+    setMaximumWidth( 128 );
+    setScaledContents( true );
+
+    doUpdate();
+}
+
+void CoverArtLabel::downloadCover()
+{
+    if( p_input )
+    {
+        playlist_t *p_playlist = pl_Yield( p_this );
+        playlist_AskForArtEnqueue( p_playlist, p_input );
+        pl_Release( p_this );
+    }
+}
+
+void CoverArtLabel::doUpdate()
+{
+    if( !p_input )
+    {
+        setPixmap( QPixmap( ":/noart.png" ) );
+        QList< QAction* > artActions = actions();
+        if( !artActions.isEmpty() )
+            foreach( QAction *act, artActions )
+                removeAction( act );
+        prevArt = "";
+    }
+    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 )
+                setPixmap( QPixmap( artUrl ) );
+            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 );
+    }
+}
+