Commit ba42d61b authored by Clément Stenac's avatar Clément Stenac

Add ability to put some background when there is no video

parent a593fa18
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "components/video_widget.hpp" #include "components/video_widget.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include <QHBoxLayout>
static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*, static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
unsigned int *, unsigned int * ); unsigned int *, unsigned int * );
...@@ -34,10 +35,11 @@ static int DoControl( intf_thread_t *, void *, int, va_list ); ...@@ -34,10 +35,11 @@ static int DoControl( intf_thread_t *, void *, int, va_list );
bool need_update; bool need_update;
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), VideoWidget::VideoWidget( intf_thread_t *_p_i, bool _always ) : QFrame( NULL ),
p_intf( _p_i ) p_intf( _p_i )
{ {
vlc_mutex_init( p_intf, &lock ); vlc_mutex_init( p_intf, &lock );
always = _always;
p_intf->pf_request_window = ::DoRequest; p_intf->pf_request_window = ::DoRequest;
p_intf->pf_release_window = ::DoRelease; p_intf->pf_release_window = ::DoRelease;
...@@ -50,6 +52,9 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), ...@@ -50,6 +52,9 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ),
connect( DialogsProvider::getInstance(NULL)->fixed_timer, connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT( update() ) ); SIGNAL( timeout() ), this, SLOT( update() ) );
if( always )
DrawBackground();
need_update = false; need_update = false;
} }
...@@ -106,6 +111,9 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y, ...@@ -106,6 +111,9 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
} }
p_vout = p_nvout; p_vout = p_nvout;
if( always )
CleanBackground();
setMinimumSize( 1,1 ); setMinimumSize( 1,1 );
p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height ); p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height );
updateGeometry(); updateGeometry();
...@@ -120,24 +128,41 @@ static void DoRelease( intf_thread_t *p_intf, void *p_win ) ...@@ -120,24 +128,41 @@ static void DoRelease( intf_thread_t *p_intf, void *p_win )
void VideoWidget::Release( void *p_win ) void VideoWidget::Release( void *p_win )
{ {
if( !config_GetInt( p_intf, "qt-always-video" ) ); p_vout = NULL;
if( config_GetInt( p_intf, "qt-always-video" ) == 0 )
{ {
p_intf->p_sys->p_mi->videoSize = QSize ( 1,1 ); p_intf->p_sys->p_mi->videoSize = QSize ( 1,1 );
}
updateGeometry(); updateGeometry();
if( !config_GetInt( p_intf, "qt-always-video" ) )
need_update = true; need_update = true;
p_vout = NULL; }
} else
{
DrawBackground();
}
}
static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a ) 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 ); return p_intf->p_sys->p_video->Control( p_win, i_q, a );
} }
int VideoWidget::DrawBackground()
{
QLabel *label = new QLabel( "VLC Rulez d4 Worldz" );
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 VideoWidget::Control( void *p_window, int i_query, va_list args )
{ {
int i_ret = VLC_EGENERIC; int i_ret = VLC_EGENERIC;
...@@ -160,8 +185,9 @@ int VideoWidget::Control( void *p_window, int i_query, va_list args ) ...@@ -160,8 +185,9 @@ int VideoWidget::Control( void *p_window, int i_query, va_list args )
if( !i_width && p_vout ) i_width = p_vout->i_window_width; if( !i_width && p_vout ) i_width = p_vout->i_window_width;
if( !i_height && p_vout ) i_height = p_vout->i_window_height; if( !i_height && p_vout ) i_height = p_vout->i_window_height;
p_intf->p_sys->p_mi->videoSize = QSize( i_width, i_height );
frame->resize( i_width, i_height ); updateGeometry();
need_update = true;
i_ret = VLC_SUCCESS; i_ret = VLC_SUCCESS;
break; break;
} }
......
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
#include <QWidget> #include <QWidget>
#include <QFrame> #include <QFrame>
class QHBoxLayout;
class VideoWidget : public QFrame class VideoWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
VideoWidget( intf_thread_t *); VideoWidget( intf_thread_t *, bool );
virtual ~VideoWidget(); virtual ~VideoWidget();
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
...@@ -45,7 +47,11 @@ public: ...@@ -45,7 +47,11 @@ public:
int i_video_height, i_video_width; int i_video_height, i_video_width;
vout_thread_t *p_vout; vout_thread_t *p_vout;
private: private:
int DrawBackground();
int CleanBackground();
bool always;
QWidget *frame; QWidget *frame;
QHBoxLayout *backgroundLayout;
intf_thread_t *p_intf; intf_thread_t *p_intf;
vlc_mutex_t lock; vlc_mutex_t lock;
private slots: private slots:
......
...@@ -60,6 +60,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -60,6 +60,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) ); ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) ); ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
ui.volumeSlider->setMaximum( 100 ); ui.volumeSlider->setMaximum( 100 );
ui.playlistButton->setIcon( QIcon( ":/pixmaps/volume-low.png" ) );
VolumeClickHandler *h = new VolumeClickHandler( this ); VolumeClickHandler *h = new VolumeClickHandler( this );
ui.volLowLabel->installEventFilter(h); ui.volLowLabel->installEventFilter(h);
...@@ -76,7 +78,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -76,7 +78,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
// if( config_GetInt( p_intf, "embedded" ) ) // if( config_GetInt( p_intf, "embedded" ) )
{ {
videoWidget = new VideoWidget( p_intf ); videoWidget = new VideoWidget( p_intf, config_GetInt( p_intf, "qt-always-video" ) ? true:false );
if( config_GetInt( p_intf, "qt-always-video" ) ) if( config_GetInt( p_intf, "qt-always-video" ) )
{ {
QSettings settings( "VideoLAN", "VLC" ); QSettings settings( "VideoLAN", "VLC" );
...@@ -92,12 +94,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -92,12 +94,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
readSettings( "MainWindow" ); readSettings( "MainWindow" );
addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H ); addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H );
if( config_GetInt( p_intf, "qt-always-video" ) ) // if( config_GetInt( p_intf, "qt-always-video" ) )
mainSize = videoSize + addSize; mainSize.setWidth( videoSize.width() + addSize.width() );
else mainSize.setHeight( videoSize.height() + addSize.height() );
mainSize = QSize( PREF_W, PREF_H ); // else
// mainSize = QSize( PREF_W, PREF_H );
fprintf( stderr, "Resulting size %ix%i", mainSize.width(), mainSize.height() );
resize( mainSize ); resize( mainSize );
mainSize = size(); mainSize = size();
fprintf( stderr, "After size %ix%i", mainSize.width(), mainSize.height() );
setMinimumSize( PREF_W, addSize.height() ); setMinimumSize( PREF_W, addSize.height() );
......
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
<item> <item>
<widget class="QPushButton" name="playlistButton" > <widget class="QPushButton" name="playlistButton" >
<property name="text" > <property name="text" >
<string>_("Playlist")</string> <string> </string>
</property> </property>
</widget> </widget>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment