Commit e45f26dd authored by zorglub's avatar zorglub

Some cleanup, start integrating audio visualizations

parent 7df78c9f
...@@ -150,12 +150,13 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) : ...@@ -150,12 +150,13 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
{ {
setFrameStyle(QFrame::StyledPanel | QFrame::Raised); setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
QHBoxLayout *layout = new QHBoxLayout( this ); QHBoxLayout *layout = new QHBoxLayout( this );
layout->setMargin( 0 );
QPushButton *prevButton = new QPushButton( "Prev" ); QPushButton *prevButton = new QPushButton( "Prev" );
QPushButton *nextButton = new QPushButton( "Next"); QPushButton *nextButton = new QPushButton( "Next");
layout->addWidget( prevButton ); layout->addWidget( prevButton );
layout->addWidget( nextButton ); layout->addWidget( nextButton );
setLayout( layout ); setLayout( layout );
setMaximumHeight( 30 ); setMaximumHeight( 35 );
} }
VisualSelector::~VisualSelector() VisualSelector::~VisualSelector()
......
...@@ -35,6 +35,8 @@ public: ...@@ -35,6 +35,8 @@ public:
virtual ~InputManager(); virtual ~InputManager();
void delInput(); void delInput();
bool hasAudio() { return b_has_audio; }
bool hasVideo() { return b_has_video; }
bool b_has_audio, b_has_video, b_had_audio, b_had_video; bool b_has_audio, b_has_video, b_had_audio, b_had_video;
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
......
...@@ -51,6 +51,14 @@ ...@@ -51,6 +51,14 @@
ui.button##Button->setIcon( QIcon( ":/pixmaps/"#image ) ); \ ui.button##Button->setIcon( QIcon( ":/pixmaps/"#image ) ); \
ui.button##Button->setToolTip( tooltip ); ui.button##Button->setToolTip( tooltip );
#define VISIBLE(i) (i && i->isVisible())
#define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
#define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
#define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
#define DS(i) i.width(),i.height()
static int InteractCallback( vlc_object_t *, const char *, vlc_value_t, static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void *); vlc_value_t, void *);
/* Video handling */ /* Video handling */
...@@ -110,13 +118,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -110,13 +118,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( slider, sliderDragged( float ), CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) ); THEMIM->getIM(), sliderUpdate( float ) );
/* Actions */
BUTTONACT( ui.playButton, play() );
BUTTONACT( ui.stopButton, stop() );
BUTTONACT( ui.nextButton, next() );
BUTTONACT( ui.prevButton, prev() );
BUTTONACT( ui.playlistButton, playlist() );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this ); var_AddCallback( p_intf, "interaction", InteractCallback, this );
p_intf->b_interaction = VLC_TRUE; p_intf->b_interaction = VLC_TRUE;
...@@ -143,28 +144,23 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -143,28 +144,23 @@ void MainInterface::handleMainUi( QSettings *settings )
ui.hboxLayout->insertWidget( 0, slider ); ui.hboxLayout->insertWidget( 0, slider );
BUTTON_SET( prev, previous.png, qtr( "Previous" ) ); BUTTON_SET( prev, previous.png, qtr( "Previous" ) );
BUTTONACT( ui.prevButton, prev() );
BUTTON_SET( next, next.png , qtr( "Next" ) ); BUTTON_SET( next, next.png , qtr( "Next" ) );
BUTTONACT( ui.nextButton, next() );
BUTTON_SET( play, play.png , qtr( "Play" ) ); BUTTON_SET( play, play.png , qtr( "Play" ) );
BUTTONACT( ui.playButton, play() );
BUTTON_SET( stop, stop.png , qtr( "Stop" ) ); BUTTON_SET( stop, stop.png , qtr( "Stop" ) );
ui.discFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); BUTTONACT( ui.stopButton, stop() );
#define SET( button, image ) ui.button##Button->setText(""); \ BUTTON_SET( visual, stop.png, qtr( "Audio visualizations" ) );
ui.button##Button->setIcon( QIcon( ":/pixmaps/"#image ) ); BUTTONACT( ui.visualButton, visual() );
SET( prev, previous.png );
SET( next, next.png );
SET( play, play.png );
SET( stop, stop.png );
SET( playlist, volume-low.png );
#undef SET
/* Volume */ /* Volume */
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) ); ui.volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
ui.volumeSlider->setMaximum( 100 ); ui.volumeSlider->setMaximum( 100 );
ui.volMuteLabel->setToolTip( qtr( "Mute" ) );
VolumeClickHandler *h = new VolumeClickHandler( this ); VolumeClickHandler *h = new VolumeClickHandler( p_intf, this );
ui.volLowLabel->installEventFilter(h); ui.volMuteLabel->installEventFilter(h);
ui.volHighLabel->installEventFilter(h);
ui.volumeSlider->setFocusPolicy( Qt::NoFocus ); ui.volumeSlider->setFocusPolicy( Qt::NoFocus );
/* Fetch configuration from settings and vlc config */ /* Fetch configuration from settings and vlc config */
...@@ -172,16 +168,37 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -172,16 +168,37 @@ void MainInterface::handleMainUi( QSettings *settings )
if( config_GetInt( p_intf, "embedded-video" ) ) if( config_GetInt( p_intf, "embedded-video" ) )
videoEmbeddedFlag = true; videoEmbeddedFlag = true;
alwaysVideoFlag = false;
if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ))
alwaysVideoFlag = true;
playlistEmbeddedFlag = true; playlistEmbeddedFlag = true;
/// \todo fetch playlist settings /// \todo fetch playlist settings
BUTTON_SET( playlist, volume-low.png, playlistEmbeddedFlag ? BUTTON_SET( playlist, volume-low.png, playlistEmbeddedFlag ?
qtr( "Show playlist" ) : qtr( "Show playlist" ) :
qtr( "Open playlist" ) ); qtr( "Open playlist" ) );
BUTTONACT( ui.playlistButton, playlist() );
/* Set initial size */ /* Set initial size */
resize ( PREF_W, PREF_H ); resize ( PREF_W, PREF_H );
addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H ); addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H );
visualSelector = new VisualSelector( p_intf );
ui.vboxLayout->insertWidget( 0, visualSelector );
visualSelector->hide();
if( alwaysVideoFlag )
{
bgWidget = new BackgroundWidget( p_intf );
bgWidget->widgetSize = settings->value( "backgroundSize",
QSize( 200, 200 ) ).toSize();
bgWidget->resize( bgWidget->widgetSize );
bgWidget->updateGeometry();
ui.vboxLayout->insertWidget( 0, bgWidget );
}
if( videoEmbeddedFlag ) if( videoEmbeddedFlag )
{ {
videoWidget = new VideoWidget( p_intf ); videoWidget = new VideoWidget( p_intf );
...@@ -192,22 +209,10 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -192,22 +209,10 @@ void MainInterface::handleMainUi( QSettings *settings )
p_intf->pf_request_window = ::DoRequest; p_intf->pf_request_window = ::DoRequest;
p_intf->pf_release_window = ::DoRelease; p_intf->pf_release_window = ::DoRelease;
p_intf->pf_control_window = ::DoControl; p_intf->pf_control_window = ::DoControl;
if( config_GetInt( p_intf, "qt-always-video" ))
{
bgWidget = new BackgroundWidget( p_intf );
bgWidget->widgetSize = settings->value( "backgroundSize",
QSize( 200, 200 ) ).toSize();
ui.vboxLayout->insertWidget( 0, bgWidget );
}
} }
// visualSelector = new VisualSelector( p_intf );
// visualSelector->hide();
calculateInterfaceSize(); calculateInterfaceSize();
fprintf( stderr, "Resize to %ix%i\n", mainSize.width(), mainSize.height() );
resize( mainSize ); resize( mainSize );
mainSize = size();
setMinimumSize( PREF_W, addSize.height() ); setMinimumSize( PREF_W, addSize.height() );
} }
...@@ -218,14 +223,13 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -218,14 +223,13 @@ void MainInterface::handleMainUi( QSettings *settings )
void MainInterface::calculateInterfaceSize() void MainInterface::calculateInterfaceSize()
{ {
int width = 0, height = 0; int width = 0, height = 0;
fprintf( stderr, "Calculating size\n" ); if( VISIBLE( bgWidget ) )
if( bgWidget && bgWidget->isVisible() )
{ {
width = bgWidget->widgetSize.width(); width = bgWidget->widgetSize.width();
height = bgWidget->widgetSize.height(); height = bgWidget->widgetSize.height();
assert( !(playlistWidget && playlistWidget->isVisible() ) ); assert( !(playlistWidget && playlistWidget->isVisible() ) );
} }
else if( playlistWidget && playlistWidget->isVisible() ) else if( VISIBLE( playlistWidget ) )
{ {
width = playlistWidget->widgetSize.width(); width = playlistWidget->widgetSize.width();
height = playlistWidget->widgetSize.height(); height = playlistWidget->widgetSize.height();
...@@ -235,55 +239,40 @@ void MainInterface::calculateInterfaceSize() ...@@ -235,55 +239,40 @@ void MainInterface::calculateInterfaceSize()
{ {
width = videoWidget->widgetSize.width() ; width = videoWidget->widgetSize.width() ;
height = videoWidget->widgetSize.height(); height = videoWidget->widgetSize.height();
fprintf( stderr, "Video Size %ix%i\n", videoWidget->widgetSize.width(), videoWidget->widgetSize.height() ); fprintf( stderr, "Video Size %ix%i\n", DS( videoWidget->widgetSize ) );
} }
else else
{ {
width = PREF_W - addSize.width(); width = PREF_W - addSize.width();
height = PREF_H - addSize.height(); height = PREF_H - addSize.height();
} }
fprintf( stderr, "Setting to %ix%i\n", width + addSize.width() , height + addSize.height() ); if( VISIBLE( visualSelector ) )
mainSize.setWidth( width + addSize.width() ); height += visualSelector->height();
mainSize.setHeight( height + addSize.height() );
fprintf( stderr, "Setting to %ix%i\n",
width + addSize.width() , height + addSize.height() );
mainSize = QSize( width + addSize.width(), height + addSize.height() );
} }
void MainInterface::resizeEvent( QResizeEvent *e ) void MainInterface::resizeEvent( QResizeEvent *e )
{ {
fprintf( stderr, "Resize event to %ix%i\n", e->size().width(), e->size().height() ); fprintf( stderr, "Resize event to %ix%i\n", DS( e->size() ) );
/* Width : Always passed to all children. We are guaranteed it will videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
* not go below PREF_W if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
* Height : Only passed to the only visible child {
*/ SET_WH( videoWidget, e->size().width() - addSize.width(),
if( videoWidget ) e->size().height() - addSize.height() );
{
videoWidget->widgetSize.setWidth( e->size().width() -
addSize.width() );
if( videoIsActive && videoWidget->widgetSize.height() > 1 )
{
videoWidget->widgetSize.setHeight( e->size().height() -
addSize.height() );
videoWidget->updateGeometry(); videoWidget->updateGeometry();
fprintf( stderr, "Video set to %ix%i\n", DS( videoWidget->widgetSize) );
} }
fprintf( stderr, "Video set to %ix%i\n", if( VISIBLE( playlistWidget ) )
videoWidget->widgetSize.width(),
videoWidget->widgetSize.height() );
}
if( playlistWidget )
{
if( playlistWidget->isVisible() )
{ {
playlistWidget->widgetSize.setWidth( e->size().width() - SET_WH( playlistWidget , e->size().width() - addSize.width(),
addSize.width() ); e->size().height() - addSize.height() );
playlistWidget->widgetSize.setHeight( e->size().height() -
addSize.height() );
playlistWidget->updateGeometry(); playlistWidget->updateGeometry();
fprintf( stderr, "PL set to %ix%i\n",DS(playlistWidget->widgetSize ) );
} }
fprintf( stderr, "Playlist set to %ix%i\n",playlistWidget->widgetSize.width(), playlistWidget->widgetSize.height() );
}
// videoWidget->widgetSize.setHeight( e->size().height() - addSize.height() );
// videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
// videoWidget->updateGeometry() ;
} }
void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
...@@ -294,16 +283,28 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, ...@@ -294,16 +283,28 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
if( ret ) if( ret )
{ {
videoIsActive = true; videoIsActive = true;
if( playlistWidget && playlistWidget->isVisible() ) if( VISIBLE( playlistWidget ) )
{ {
embeddedPlaylistWasActive = true; embeddedPlaylistWasActive = true;
playlistWidget->hide(); playlistWidget->hide();
} }
if( bgWidget && bgWidget->isVisible() ) bool bgWasVisible = false;
if( VISIBLE( bgWidget) )
{ {
bgWasVisible = true;
bgWidget->hide(); bgWidget->hide();
} }
if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
{
videoWidget->widgetSize = QSize( *pi_width, *pi_height ); videoWidget->widgetSize = QSize( *pi_width, *pi_height );
}
else /* Background widget available, use its size */
{
/* Ok, our visualizations are bad, so don't do this for the moment
* use the requested size anyway */
// videoWidget->widgetSize = bgWidget->widgeTSize;
videoWidget->widgetSize = QSize( *pi_width, *pi_height );
}
videoWidget->updateGeometry(); /// FIXME: Needed ? videoWidget->updateGeometry(); /// FIXME: Needed ?
need_components_update = true; need_components_update = true;
} }
...@@ -359,6 +360,25 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) ...@@ -359,6 +360,25 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
return i_ret; return i_ret;
} }
void MainInterface::visual()
{
if( !VISIBLE( visualSelector) )
{
visualSelector->show();
if( !THEMIM->getIM()->hasVideo() )
{
/* Show the background widget */
}
}
else
{
/* Stop any currently running visualization */
visualSelector->hide();
}
calculateInterfaceSize();
resize( mainSize );
}
void MainInterface::playlist() void MainInterface::playlist()
{ {
// Toggle the playlist dialog // Toggle the playlist dialog
...@@ -382,7 +402,7 @@ void MainInterface::playlist() ...@@ -382,7 +402,7 @@ void MainInterface::playlist()
playlistWidget->hide(); playlistWidget->hide();
} }
/// Todo, reset its size ? /// Todo, reset its size ?
if( playlistWidget->isVisible() ) if( VISIBLE( playlistWidget) )
{ {
fprintf( stderr, "hiding playlist\n" ); fprintf( stderr, "hiding playlist\n" );
playlistWidget->hide(); playlistWidget->hide();
...@@ -404,6 +424,7 @@ void MainInterface::playlist() ...@@ -404,6 +424,7 @@ void MainInterface::playlist()
videoWidget->resize( videoWidget->widgetSize ); videoWidget->resize( videoWidget->widgetSize );
videoWidget->updateGeometry(); videoWidget->updateGeometry();
} }
if( VISIBLE( bgWidget ) ) bgWidget->hide();
} }
calculateInterfaceSize(); calculateInterfaceSize();
......
...@@ -49,8 +49,6 @@ class MainInterface : public QVLCMW ...@@ -49,8 +49,6 @@ class MainInterface : public QVLCMW
public: public:
MainInterface( intf_thread_t *); MainInterface( intf_thread_t *);
virtual ~MainInterface(); virtual ~MainInterface();
void *requestVideo( vout_thread_t *p_nvout, int *pi_x, void *requestVideo( vout_thread_t *p_nvout, int *pi_x,
int *pi_y, unsigned int *pi_width, int *pi_y, unsigned int *pi_width,
unsigned int *pi_height ); unsigned int *pi_height );
...@@ -80,6 +78,7 @@ private: ...@@ -80,6 +78,7 @@ private:
bool playlistEmbeddedFlag; bool playlistEmbeddedFlag;
bool videoEmbeddedFlag; bool videoEmbeddedFlag;
bool alwaysVideoFlag;
InputManager *main_input_manager; InputManager *main_input_manager;
InputSlider *slider; InputSlider *slider;
...@@ -97,6 +96,7 @@ private slots: ...@@ -97,6 +96,7 @@ private slots:
void prev(); void prev();
void next(); void next();
void playlist(); void playlist();
void visual();
void updateVolume( int sliderVolume ); void updateVolume( int sliderVolume );
}; };
...@@ -104,24 +104,21 @@ private slots: ...@@ -104,24 +104,21 @@ private slots:
class VolumeClickHandler : public QObject class VolumeClickHandler : public QObject
{ {
public: public:
VolumeClickHandler( MainInterface *_m ) :QObject(_m) {m = _m; } VolumeClickHandler( intf_thread_t *_p_intf, MainInterface *_m ) :QObject(_m)
{m = _m; p_intf = _p_intf; }
virtual ~VolumeClickHandler() {}; virtual ~VolumeClickHandler() {};
bool eventFilter( QObject *obj, QEvent *e ) bool eventFilter( QObject *obj, QEvent *e )
{ {
if (e->type() == QEvent::MouseButtonPress ) if (e->type() == QEvent::MouseButtonPress )
{ {
if( obj->objectName() == "volLowLabel" ) aout_VolumeMute( p_intf, NULL );
{
m->ui.volumeSlider->setValue( 0 );
}
else
m->ui.volumeSlider->setValue( 100 );
return true; return true;
} }
return false; return false;
} }
private: private:
MainInterface *m; MainInterface *m;
intf_thread_t *p_intf;
}; };
#endif #endif
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="volLowLabel" > <widget class="QLabel" name="volMuteLabel" >
<property name="text" > <property name="text" >
<string/> <string/>
</property> </property>
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="volHighLabel" > <widget class="QPushButton" name="visualButton" >
<property name="text" > <property name="text" >
<string/> <string/>
</property> </property>
...@@ -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> </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