]> git.sesse.net Git - vlc/commitdiff
Split video widget from background image managre
authorClément Stenac <zorglub@videolan.org>
Tue, 19 Sep 2006 11:26:14 +0000 (11:26 +0000)
committerClément Stenac <zorglub@videolan.org>
Tue, 19 Sep 2006 11:26:14 +0000 (11:26 +0000)
modules/gui/qt4/Modules.am
modules/gui/qt4/components/interface_widgets.cpp [moved from modules/gui/qt4/components/video_widget.cpp with 84% similarity]
modules/gui/qt4/components/interface_widgets.hpp [moved from modules/gui/qt4/components/video_widget.hpp with 85% similarity]
modules/gui/qt4/main_interface.cpp

index fd23fc648d3f9315b449bc9c0f2826ca749888ef..3e38bb5251b7aa7e91951d5a96726b217020f409 100644 (file)
@@ -36,7 +36,7 @@ TOMOC = main_interface \
        components/preferences \
        components/simple_preferences \
        components/open \
-       components/video_widget \
+       components/interface_widgets \
        components/playlist/panels \
        components/playlist/selector \
        util/input_slider \
@@ -62,7 +62,7 @@ nodist_SOURCES_qt4 = \
                components/preferences.moc.cpp \
                components/simple_preferences.moc.cpp \
                components/open.moc.cpp \
-               components/video_widget.moc.cpp \
+               components/interface_widgets.moc.cpp \
                components/playlist/panels.moc.cpp \
                components/playlist/selector.moc.cpp \
                util/input_slider.moc.cpp \
@@ -108,7 +108,7 @@ SOURCES_qt4 =       qt4.cpp \
                components/preferences.cpp \
                components/simple_preferences.cpp \
                components/open.cpp \
-               components/video_widget.cpp \
+               components/interface_widgets.cpp \
                components/playlist/standardpanel.cpp \
                components/playlist/selector.cpp \
                util/input_slider.cpp \
@@ -136,7 +136,7 @@ EXTRA_DIST += \
        components/preferences.hpp \
        components/simple_preferences.hpp \
        components/open.hpp \
-       components/video_widget.hpp \
+       components/interface_widgets.hpp \
        components/playlist/panels.hpp \
        components/playlist/selector.hpp \
        util/input_slider.hpp \
similarity index 84%
rename from modules/gui/qt4/components/video_widget.cpp
rename to modules/gui/qt4/components/interface_widgets.cpp
index c68a85e478d22a7fccbd202b88f102e062fda3ba..84c310b99ab0f260cb7f234ae31ac49f749c0cf5 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * video_widget.cpp : Embedded video output
+ * interface_widgets.cpp : Custom widgets for the main interface
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * $Id$
 #include "dialogs_provider.hpp"
 #include <vlc/vout.h>
 #include "qt4.hpp"
-#include "components/video_widget.hpp"
+#include "components/interface_widgets.hpp"
 #include "main_interface.hpp"
 #include "input_manager.hpp"
 #include <QHBoxLayout>
 
 #define ICON_SIZE 128
 
+/**********************************************************************
+ * Video Widget. A simple frame on which video is drawn
+ * This class handles resize issues
+ **********************************************************************/
 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
                         unsigned int *, unsigned int * );
 static void DoRelease( intf_thread_t *, void * );
@@ -38,11 +42,9 @@ static int DoControl( intf_thread_t *, void *, int, va_list );
 
 bool need_update;
 
-VideoWidget::VideoWidget( intf_thread_t *_p_i, bool _always ) : QFrame( NULL ),
-                                                               p_intf( _p_i )
+VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
 {
     vlc_mutex_init( p_intf, &lock );
-    always = _always;
 
     p_intf->pf_request_window  = ::DoRequest;
     p_intf->pf_release_window  = ::DoRelease;
@@ -53,13 +55,6 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i, bool _always ) : QFrame( NULL ),
     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
 
     ON_TIMEOUT( update() );
-
-    if( always )
-    {
-        DrawBackground();
-        CONNECT( THEMIM->getIM(), audioStarted(), this, hasAudio() );
-        CONNECT( THEMIM->getIM(), audioStarted(), this, hasVideo() );
-    }
     need_update = false;
 }
 
@@ -93,9 +88,6 @@ VideoWidget::~VideoWidget()
     p_intf->pf_control_window = NULL;
     vlc_mutex_unlock( &lock );
     vlc_mutex_destroy( &lock );
-
-    if( always )
-        CleanBackground();
 }
 
 QSize VideoWidget::sizeHint() const
@@ -119,19 +111,6 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
     }
     p_vout = p_nvout;
 
-    // if( THEMIM->getIM()->b_has_video )
-    // {
-    //      We are really running a video
-    //      Close the existing vout
-    //      Set visual to disabled
-    // }
-    // else
-    // {
-    //      We are getting a request for visual
-    //      Just go on.
-    // }
-    // Check THEMIM->b_has_audio. If true, hide audio.
-
     setMinimumSize( 1,1 );
     p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height );
     updateGeometry();
@@ -144,15 +123,6 @@ static void DoRelease( intf_thread_t *p_intf, void *p_win )
     return p_intf->p_sys->p_video->Release( p_win );
 }
 
-void VideoWidget::resizeEvent( QResizeEvent *e )
-{
-    if( !always )return;
-    if( e->size().height() < ICON_SIZE -1 )
-        label->setMaximumWidth( e->size().height() );
-    else
-        label->setMaximumWidth( ICON_SIZE );
-}
-
 void VideoWidget::Release( void *p_win )
 {
     p_vout = NULL;
@@ -164,57 +134,11 @@ void VideoWidget::Release( void *p_win )
     }
 }
 
-void VideoWidget::hasAudio()
-{
-    /* We have video already, do nothing */
-    if( THEMIM->getIM()->b_has_video )
-    {
-
-    }
-    else
-    {
-        /* Show the panel to the user */
-        fprintf( stderr, "Showing panel\n" );
-    }
-}
-
-void VideoWidget::hasVideo()
-{
-    // if panel is shown, hide it
-}
-
 static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
 {
     return p_intf->p_sys->p_video->Control( p_win, i_q, a );
 }
 
-int VideoWidget::DrawBackground()
-{
-    setAutoFillBackground( true );
-    plt =  palette();
-    plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
-    plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
-    setPalette( plt );
-
-    backgroundLayout = new QHBoxLayout;
-    label = new QLabel( "" );
-    label->setMaximumHeight( ICON_SIZE );
-    label->setMaximumWidth( ICON_SIZE );
-    label->setScaledContents( true );
-    label->setPixmap( QPixmap( ":/vlc128.png" ) );
-    backgroundLayout = new QHBoxLayout;
-    backgroundLayout->addWidget( label );
-    setLayout( backgroundLayout );
-    return 0;
-}
-
-int VideoWidget::CleanBackground()
-{
-    backgroundLayout->takeAt(0);
-    delete backgroundLayout;
-    return 0;
-}
-
 int VideoWidget::Control( void *p_window, int i_query, va_list args )
 {
     int i_ret = VLC_EGENERIC;
@@ -255,3 +179,64 @@ int VideoWidget::Control( void *p_window, int i_query, va_list args )
     vlc_mutex_unlock( &lock );
     return i_ret;
 }
+
+/**********************************************************************
+ * Background Widget. Show a simple image background. Currently,
+ * it's a static cone.
+ **********************************************************************/
+BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
+                                        QFrame( NULL ), p_intf( _p_i )
+{
+    DrawBackground();
+    CONNECT( THEMIM->getIM(), audioStarted(), this, hasAudio() );
+    CONNECT( THEMIM->getIM(), audioStarted(), this, hasVideo() );
+}
+
+int BackgroundWidget::DrawBackground()
+{
+   setAutoFillBackground( true );
+    plt =  palette();
+    plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
+    plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
+    setPalette( plt );
+
+    backgroundLayout = new QHBoxLayout;
+    label = new QLabel( "" );
+    label->setMaximumHeight( ICON_SIZE );
+    label->setMaximumWidth( ICON_SIZE );
+    label->setScaledContents( true );
+    label->setPixmap( QPixmap( ":/vlc128.png" ) );
+    backgroundLayout = new QHBoxLayout;
+    backgroundLayout->addWidget( label );
+    setLayout( backgroundLayout );
+    return 0;
+}
+
+int BackgroundWidget::CleanBackground()
+{
+    backgroundLayout->takeAt(0);
+    delete backgroundLayout;
+    return 0;
+}
+
+void BackgroundWidget::hasAudio()
+{
+    /* We have video already, do nothing */
+    if( THEMIM->getIM()->b_has_video )
+    {
+
+    }
+    else
+    {
+        /* Show the panel to the user */
+        fprintf( stderr, "Showing panel\n" );
+    }
+}
+
+void BackgroundWidget::resizeEvent( QResizeEvent *e )
+{
+    if( e->size().height() < ICON_SIZE -1 )
+        label->setMaximumWidth( e->size().height() );
+    else
+        label->setMaximumWidth( ICON_SIZE );
+}
similarity index 85%
rename from modules/gui/qt4/components/video_widget.hpp
rename to modules/gui/qt4/components/interface_widgets.hpp
index fd137bf6bb6c1f79876f45f9b107d77451029c28..9400397028d0ef9d3977a028ed849eaa12b75706 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * video_widget.hpp : Embedded video
+ * interface_widgets.hpp : Custom widgets for the main interface
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * $Id$
@@ -21,8 +21,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#ifndef _VIDEO_H_
-#define _VIDEO_H_
+#ifndef _INTFWIDGETS_H_
+#define _INTFWIDGETS_H_
 
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
@@ -40,7 +40,7 @@ class VideoWidget : public QFrame
 {
     Q_OBJECT
 public:
-    VideoWidget( intf_thread_t *, bool );
+    VideoWidget( intf_thread_t * );
     virtual ~VideoWidget();
 
     virtual QSize sizeHint() const;
@@ -52,20 +52,34 @@ public:
     int i_video_height, i_video_width;
     vout_thread_t *p_vout;
 private:
-    virtual void resizeEvent( QResizeEvent *e );
-    int DrawBackground();
-    int CleanBackground();
-    bool always;
-    QPalette plt;
-    QLabel *label;
     QWidget *frame;
-    QHBoxLayout *backgroundLayout;
     intf_thread_t *p_intf;
     vlc_mutex_t lock;
 private slots:
     void update();
+};
+
+class BackgroundWidget : public QFrame
+{
+    Q_OBJECT
+public:
+    BackgroundWidget( intf_thread_t * );
+    virtual ~BackgroundWidget();
+private:
+    QPalette plt;
+    QLabel *label;
+    QHBoxLayout *backgroundLayout;
+    virtual void resizeEvent( QResizeEvent *e );
+    int DrawBackground();
+    int CleanBackground();
+    intf_thread_t *p_intf;
+private slots:
     void hasAudio();
     void hasVideo();
 };
 
+
+
+
+
 #endif
index b9d3d8f41cae84d5819a9e21e3ef0ef7651fea9c..c04fc1e13556fc2ab6566d4124e3d59cc308388a 100644 (file)
@@ -26,7 +26,7 @@
 #include "util/input_slider.hpp"
 #include "util/qvlcframe.hpp"
 #include "dialogs_provider.hpp"
-#include "components/video_widget.hpp"
+#include "components/interface_widgets.hpp"
 #include <QCloseEvent>
 #include <assert.h>
 #include <QPushButton>
@@ -88,8 +88,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     resize ( PREF_W, PREF_H );
     if( config_GetInt( p_intf, "embedded" ) )
     {
-        videoWidget = new VideoWidget( p_intf, config_GetInt( p_intf,
-                                         "qt-always-video" ) ? true:false );
+        videoWidget = new VideoWidget( p_intf );
         if( config_GetInt( p_intf, "qt-always-video" ) )
         {
             QSettings settings( "VideoLAN", "VLC" );