]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/interface_widgets.cpp
Qt: PLModel: move zoom value out of model
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
index 6f7b80dac355f6d47ca8f5b7476a00e5d9571499..85ce5325a8db7b28de59ab54c08ca3dcee5f9d44 100644 (file)
@@ -120,12 +120,14 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
     plt.setColor( QPalette::Window, Qt::black );
     stable->setPalette( plt );
     stable->setAutoFillBackground(true);
+    /* Force the widget to be native so that it gets a winId() */
+    stable->setAttribute( Qt::WA_NativeWindow, true );
     /* Indicates that the widget wants to draw directly onto the screen.
        Widgets with this attribute set do not participate in composition
        management */
     /* This is currently disabled on X11 as it does not seem to improve
      * performance, but causes the video widget to be transparent... */
-#ifndef Q_WS_X11
+#if !defined (Q_WS_X11) && !defined (Q_WS_QPA)
     stable->setAttribute( Qt::WA_PaintOnScreen, true );
 #endif
 
@@ -352,7 +354,7 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
     setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
     setLineWidth( 1 );
 
-    setRate( var_InheritFloat( p_intf, "rate" ) );
+    setRate( var_InheritFloat( THEPL, "rate" ) );
 }
 
 SpeedLabel::~SpeedLabel()
@@ -503,18 +505,17 @@ void SpeedControlWidget::resetRate()
 }
 
 CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
-              : QLabel( parent ), p_intf( _p_i )
+    : QLabel( parent ), p_intf( _p_i ), p_item( NULL )
 {
     setContextMenuPolicy( Qt::ActionsContextMenu );
-    CONNECT( this, updateRequested(), this, askForUpdate() );
+    CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
+             this, showArtUpdate( input_item_t * ) );
 
     setMinimumHeight( 128 );
     setMinimumWidth( 128 );
-    setMaximumHeight( 128 );
     setScaledContents( false );
     setAlignment( Qt::AlignCenter );
 
-    QList< QAction* > artActions = actions();
     QAction *action = new QAction( qtr( "Download cover art" ), this );
     CONNECT( action, triggered(), this, askForUpdate() );
     addAction( action );
@@ -527,6 +528,14 @@ CoverArtLabel::~CoverArtLabel()
     QList< QAction* > artActions = actions();
     foreach( QAction *act, artActions )
         removeAction( act );
+    if ( p_item ) vlc_gc_decref( p_item );
+}
+
+void CoverArtLabel::setItem( input_item_t *_p_item )
+{
+    if ( p_item ) vlc_gc_decref( p_item );
+    p_item = _p_item;
+    if ( p_item ) vlc_gc_incref( p_item );
 }
 
 void CoverArtLabel::showArtUpdate( const QString& url )
@@ -534,7 +543,7 @@ void CoverArtLabel::showArtUpdate( const QString& url )
     QPixmap pix;
     if( !url.isEmpty() && pix.load( url ) )
     {
-        pix = pix.scaled( minimumWidth(), maximumHeight(),
+        pix = pix.scaled( minimumWidth(), minimumHeight(),
                           Qt::KeepAspectRatioByExpanding,
                           Qt::SmoothTransformation );
     }
@@ -545,9 +554,20 @@ void CoverArtLabel::showArtUpdate( const QString& url )
     setPixmap( pix );
 }
 
+void CoverArtLabel::showArtUpdate( input_item_t *_p_item )
+{
+    /* not for me */
+    if ( _p_item != p_item )
+        return;
+
+    QString url;
+    if ( _p_item ) url = THEMIM->getIM()->decodeArtURL( _p_item );
+    showArtUpdate( url );
+}
+
 void CoverArtLabel::askForUpdate()
 {
-    THEMIM->getIM()->requestArtUpdate();
+    THEMIM->getIM()->requestArtUpdate( p_item );
 }
 
 TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType  )
@@ -555,6 +575,8 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType  )
       buffering( false ), showBuffering(false), bufVal( -1 ), displayType( _displayType )
 {
     b_remainingTime = false;
+    if( _displayType != TimeLabel::Elapsed )
+        b_remainingTime = getSettings()->value( "MainWindow/ShowRemainingTime", false ).toBool();
     switch( _displayType ) {
         case TimeLabel::Elapsed:
             setText( " --:-- " );
@@ -611,7 +633,7 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
 
     // compute the minimum size that will be required for the psz_length
     // and use it to enforce a minimal size to avoid "dancing" widgets
-    QSize minsize;
+    QSize minsize( 0, 0 );
     if ( length > 0 )
     {
         QMargins margins = contentsMargins();
@@ -680,6 +702,7 @@ void TimeLabel::setDisplayPosition( float pos )
 void TimeLabel::toggleTimeDisplay()
 {
     b_remainingTime = !b_remainingTime;
+    getSettings()->setValue( "MainWindow/ShowRemainingTime", b_remainingTime );
 }