]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/interface_widgets.cpp
UI: prefix/namespace resources for better maintainability
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
index 8f4930814c8b0182cb9a9b17b457d9080d9e2999..5b4d532fc0f0cc7db35da773859644a94d7df8b9 100644 (file)
@@ -76,11 +76,6 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
        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)
@@ -100,11 +95,18 @@ VideoWidget::~VideoWidget()
 /**
  * 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" );
@@ -114,18 +116,18 @@ void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
 #ifndef NDEBUG
     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
 }
 
@@ -173,9 +175,9 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
     label->setMinimumHeight( MIN_BG_SIZE );
     label->setMinimumWidth( MIN_BG_SIZE );
     if( QDate::currentDate().dayOfYear() >= 354 )
-        label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
+        label->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
     else
-        label->setPixmap( QPixmap( ":/vlc128.png" ) );
+        label->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
 
     QGridLayout *backgroundLayout = new QGridLayout( this );
     backgroundLayout->addWidget( label, 0, 1 );
@@ -183,7 +185,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
     backgroundLayout->setColumnStretch( 2, 1 );
 
     CONNECT( THEMIM->getIM(), artChanged( QString ),
-             this, updateArt( QString ) );
+             this, updateArt( const QString& ) );
 }
 
 BackgroundWidget::~BackgroundWidget()
@@ -197,14 +199,14 @@ void BackgroundWidget::resizeEvent( QResizeEvent * event )
         label->show();
 }
 
-void BackgroundWidget::updateArt( QString url )
+void BackgroundWidget::updateArt( const QString& url )
 {
     if( url.isEmpty() )
     {
         if( QDate::currentDate().dayOfYear() >= 354 )
-            label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
+            label->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
         else
-            label->setPixmap( QPixmap( ":/vlc128.png" ) );
+            label->setPixmap( QPixmap( ":/logo/vlc128.png" ) );
     }
     else
     {
@@ -272,11 +274,11 @@ void VisualSelector::next()
 }
 #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 );
@@ -286,18 +288,18 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, const QString text )
     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
  ****************************************************************************/
@@ -327,7 +329,7 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
     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 );
@@ -402,24 +404,25 @@ void SpeedControlWidget::resetRate()
 }
 
 CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
-        : QLabel( parent ), p_intf( _p_i )
+              : QLabel( parent ), p_intf( _p_i )
 {
     setContextMenuPolicy( Qt::ActionsContextMenu );
-    CONNECT( this, updateRequested(), this, doUpdate() );
+    CONNECT( this, updateRequested(), this, askForUpdate() );
     CONNECT( THEMIM->getIM(), artChanged( QString ),
-             this, doUpdate( QString ) );
+             this, showArtUpdate( 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 );
+    CONNECT( action, triggered(), this, askForUpdate() );
     addAction( action );
-    CONNECT( action, triggered(), this, doUpdate() );
 
-    doUpdate();
+    showArtUpdate( "" );
 }
 
 CoverArtLabel::~CoverArtLabel()
@@ -429,7 +432,7 @@ CoverArtLabel::~CoverArtLabel()
         removeAction( act );
 }
 
-void CoverArtLabel::doUpdate( QString url )
+void CoverArtLabel::showArtUpdate( const QString& url )
 {
     QPixmap pix;
     if( !url.isEmpty()  && pix.load( url ) )
@@ -442,7 +445,7 @@ void CoverArtLabel::doUpdate( QString url )
     }
 }
 
-void CoverArtLabel::doUpdate()
+void CoverArtLabel::askForUpdate()
 {
     THEMIM->getIM()->requestArtUpdate();
 }
@@ -493,7 +496,7 @@ void TimeLabel::setCaching( float f_cache )
     QString amount;
     amount.setNum( (int)(100 * f_cache) );
     msg_Dbg( p_intf, "New caching: %d", (int)(100*f_cache));
-    setText( "Buffering " + amount + "%" );
+    setText( "Buff: " + amount + "%" );
 }