]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.cpp
qt4 fullscreen: Uses FIND_ANYWHERE to find vout, fixes trax issue 24
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
1 /*****************************************************************************
2  * interface_widgets.cpp : Custom widgets for the main interface
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #include "dialogs_provider.hpp"
27 #include "qt4.hpp"
28 #include "components/interface_widgets.hpp"
29 #include "main_interface.hpp"
30 #include "input_manager.hpp"
31
32 #include "util/input_slider.hpp"
33 #include <vlc_vout.h>
34
35 #include <QLabel>
36 #include <QSpacerItem>
37 #include <QCursor>
38 #include <QPushButton>
39 #include <QHBoxLayout>
40 #include <QMenu>
41 #include <QPalette>
42 #include <QResizeEvent>
43
44 #define ICON_SIZE 300
45
46 /**********************************************************************
47  * Video Widget. A simple frame on which video is drawn
48  * This class handles resize issues
49  **********************************************************************/
50 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
51                         unsigned int *, unsigned int * );
52 static void DoRelease( intf_thread_t *, void * );
53 static int DoControl( intf_thread_t *, void *, int, va_list );
54
55 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
56 {
57     vlc_mutex_init( p_intf, &lock );
58     p_vout = NULL;
59     CONNECT( this, askResize(), this, SetMinSize() );
60     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
61 }
62
63 VideoWidget::~VideoWidget()
64 {
65     vlc_mutex_lock( &lock );
66     if( p_vout )
67     {
68         if( !p_intf->psz_switch_intf )
69         {
70             if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
71                 vout_Control( p_vout, VOUT_REPARENT );
72         }
73         else
74         {
75             if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
76                 vout_Control( p_vout, VOUT_CLOSE );
77         }
78     }
79     vlc_mutex_unlock( &lock );
80     vlc_mutex_destroy( &lock );
81 }
82
83 QSize VideoWidget::sizeHint() const
84 {
85     return widgetSize;
86 }
87
88 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
89                            unsigned int *pi_width, unsigned int *pi_height )
90 {
91     if( p_vout )
92     {
93         msg_Dbg( p_intf, "embedded video already in use" );
94         return NULL;
95     }
96     p_vout = p_nvout;
97     emit askResize();
98     return ( void* )winId();
99 }
100
101 void VideoWidget::SetMinSize()
102 {
103     setMinimumSize( 16, 16 );
104 }
105
106 void VideoWidget::release( void *p_win )
107 {
108     p_vout = NULL;
109 }
110 /**********************************************************************
111  * Background Widget. Show a simple image background. Currently,
112  * it's a static cone.
113  **********************************************************************/
114 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
115                                         QFrame( NULL ), p_intf( _p_i )
116 {
117
118     setAutoFillBackground( true );
119     plt =  palette();
120     plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
121     plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
122     setPalette( plt );
123
124     label = new QLabel( "" );
125     label->setMaximumHeight( ICON_SIZE );
126     label->setMaximumWidth( ICON_SIZE );
127     label->setScaledContents( true );
128     label->setPixmap( QPixmap( ":/vlc128.png" ) );
129     backgroundLayout = new QHBoxLayout;
130     backgroundLayout->addWidget( label );
131     setLayout( backgroundLayout );
132 }
133
134 BackgroundWidget::~BackgroundWidget()
135 {
136     backgroundLayout->takeAt( 0 );
137     delete backgroundLayout;
138 }
139
140 void BackgroundWidget::setArt( QString url )
141 {
142     if( url.isNull() )
143         label->setPixmap( QPixmap( ":/vlc128.png" ) );
144     else
145         label->setPixmap( QPixmap( url ) );
146 }
147
148 QSize BackgroundWidget::sizeHint() const
149 {
150     return widgetSize;
151 }
152
153 void BackgroundWidget::resizeEvent( QResizeEvent *e )
154 {
155     if( e->size().height() < ICON_SIZE -1 )
156         label->setMaximumWidth( e->size().height() );
157     else
158         label->setMaximumWidth( ICON_SIZE );
159 }
160
161 /**********************************************************************
162  * Visualization selector panel
163  **********************************************************************/
164 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
165                                                 QFrame( NULL ), p_intf( _p_i )
166 {
167     QHBoxLayout *layout = new QHBoxLayout( this );
168     layout->setMargin( 0 );
169     QPushButton *prevButton = new QPushButton( "Prev" );
170     QPushButton *nextButton = new QPushButton( "Next" );
171     layout->addWidget( prevButton );
172     layout->addWidget( nextButton );
173
174     layout->addItem( new QSpacerItem( 40,20,
175                               QSizePolicy::Expanding, QSizePolicy::Minimum ) );
176     layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
177
178     current = new QLabel( qtr( "None" ) );
179     layout->addWidget( current );
180
181     BUTTONACT( prevButton, prev() );
182     BUTTONACT( nextButton, next() );
183
184     setLayout( layout );
185     setMaximumHeight( 35 );
186 }
187
188 VisualSelector::~VisualSelector()
189 {
190 }
191
192 void VisualSelector::prev()
193 {
194     char *psz_new = aout_VisualPrev( p_intf );
195     if( psz_new )
196     {
197         current->setText( qfu( psz_new ) );
198         free( psz_new );
199     }
200 }
201
202 void VisualSelector::next()
203 {
204     char *psz_new = aout_VisualNext( p_intf );
205     if( psz_new )
206     {
207         current->setText( qfu( psz_new ) );
208         free( psz_new );
209     }
210 }
211
212 /**********************************************************************
213  * TEH controls
214  **********************************************************************/
215
216 #define setupSmallButton( aButton ){  \
217     aButton->setMaximumSize( QSize( 26, 26 ) ); \
218     aButton->setMinimumSize( QSize( 26, 26 ) ); \
219     aButton->setIconSize( QSize( 20, 20 ) ); }
220
221 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
222                                            QFrame( NULL ), p_intf( _p_i )
223 {
224     QHBoxLayout *advLayout = new QHBoxLayout( this );
225     advLayout->setMargin( 0 );
226     advLayout->setSpacing( 0 );
227
228 /* FIXME A to B function */
229     ABButton = new QPushButton( "AB" );
230     ABButton->setMaximumSize( QSize( 26, 26 ) );
231     ABButton->setIconSize( QSize( 20, 20 ) );
232     advLayout->addWidget( ABButton );
233     BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
234
235     snapshotButton = new QPushButton( "S" );
236     snapshotButton->setMaximumSize( QSize( 26, 26 ) );
237     snapshotButton->setIconSize( QSize( 20, 20 ) );
238     advLayout->addWidget( snapshotButton );
239     BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
240
241 //FIXME Frame by frame function
242     frameButton = new QPushButton( "Fr" );
243     frameButton->setMaximumSize( QSize( 26, 26 ) );
244     frameButton->setIconSize( QSize( 20, 20 ) );
245     advLayout->addWidget( frameButton );
246     BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
247
248 /* FIXME Record function */
249     recordButton = new QPushButton( "R" );
250     recordButton->setMaximumSize( QSize( 26, 26 ) );
251     recordButton->setIconSize( QSize( 20, 20 ) );
252     advLayout->addWidget( recordButton );
253     BUTTON_SET_ACT( recordButton, "R", qtr( "Record" ), record() );
254
255     normalButton = new QPushButton( "N" );
256     normalButton->setMaximumSize( QSize( 26, 26 ) );
257     normalButton->setIconSize( QSize( 20, 20 ) );
258     advLayout->addWidget( normalButton );
259     BUTTON_SET_ACT( normalButton, "N", qtr( "Normal rate" ), normal() );
260
261 }
262
263 AdvControlsWidget::~AdvControlsWidget()
264 {
265 }
266
267 void AdvControlsWidget::enableInput( bool enable )
268 {
269     ABButton->setEnabled( enable );
270     recordButton->setEnabled( enable );
271     normalButton->setEnabled( enable );
272 }
273 void AdvControlsWidget::enableVideo( bool enable )
274 {
275     snapshotButton->setEnabled( enable );
276     frameButton->setEnabled( enable );
277 }
278
279 void AdvControlsWidget::normal()
280 {
281     THEMIM->getIM()->normalRate();
282 }
283
284 void AdvControlsWidget::snapshot()
285 {
286     vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
287     if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
288 }
289
290 void AdvControlsWidget::frame(){}
291 void AdvControlsWidget::fromAtoB(){}
292 void AdvControlsWidget::record(){}
293
294 /*****************************
295  * DA Control Widget !
296  *****************************/
297 ControlsWidget::ControlsWidget( intf_thread_t *_p_i, bool b_advControls ) :
298                              QFrame( NULL ), p_intf( _p_i )
299 {
300     //QSize size( 500, 200 );
301     //resize( size );
302     controlLayout = new QGridLayout( this );
303
304 #if DEBUG_COLOR
305     QPalette palette2;
306     palette2.setColor(this->backgroundRole(), Qt::magenta);
307     setPalette(palette2);
308 #endif
309
310     /** The main Slider **/
311     slider = new InputSlider( Qt::Horizontal, NULL );
312     controlLayout->addWidget( slider, 0, 1, 1, 16 );
313     /* Update the position when the IM has changed */
314     CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
315              slider, setPosition( float,int, int ) );
316     /* And update the IM, when the position has changed */
317     CONNECT( slider, sliderDragged( float ),
318              THEMIM->getIM(), sliderUpdate( float ) );
319
320     /** Slower and faster Buttons **/
321     slowerButton = new QPushButton( "S" );
322     BUTTON_SET_ACT( slowerButton, "S", qtr( "Slower" ), slower() );
323     controlLayout->addWidget( slowerButton, 0, 0 );
324     slowerButton->setMaximumSize( QSize( 26, 20 ) );
325
326     fasterButton = new QPushButton( "F" );
327     BUTTON_SET_ACT( fasterButton, "F", qtr( "Faster" ), faster() );
328     controlLayout->addWidget( fasterButton, 0, 17 );
329     fasterButton->setMaximumSize( QSize( 26, 20 ) );
330
331     /** TODO: Insert here the AdvControls Widget 
332      * Then fix all the size issues in main_interface.cpp
333      **/
334     /* advanced Controls handling */
335     b_advancedVisible = b_advControls;
336
337     advControls = new AdvControlsWidget( p_intf );
338     controlLayout->addWidget( advControls, 1, 3, 2, 5, Qt::AlignBottom );
339     if( !b_advancedVisible ) advControls->hide();
340     //THIS should be removed.    need_components_update = true;
341
342     /** Disc and Menus handling */
343     discFrame = new QFrame( this );
344
345     QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
346     discLayout->setSpacing( 0 );
347     discLayout->setMargin( 0 );
348
349     prevSectionButton = new QPushButton( discFrame );
350     setupSmallButton( prevSectionButton );
351     discLayout->addWidget( prevSectionButton );
352
353     menuButton = new QPushButton( discFrame );
354     setupSmallButton( menuButton );
355     discLayout->addWidget( menuButton );
356
357     nextSectionButton = new QPushButton( discFrame );
358     setupSmallButton( nextSectionButton );
359     discLayout->addWidget( nextSectionButton );
360
361     controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
362
363     BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
364     BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
365     BUTTON_SET_IMG( menuButton, "", previous.png, "" );
366
367     discFrame->hide();
368
369     /* Change the navigation button display when the IM navigation changes */
370     CONNECT( THEMIM->getIM(), navigationChanged( int ),
371              this, setNavigation( int ) );
372     /* Changes the IM navigation when triggered on the nav buttons */
373     CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
374              sectionPrev() );
375     CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
376              sectionNext() );
377     CONNECT( menuButton, clicked(), THEMIM->getIM(),
378              sectionMenu() );
379
380     /** TODO
381      * Telextext QFrame
382      **/
383
384     /** Play Buttons **/
385     QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
386     sizePolicy.setHorizontalStretch( 0 );
387     sizePolicy.setVerticalStretch( 0 );
388
389     /* Play */
390     playButton = new QPushButton;
391     playButton->setSizePolicy( sizePolicy );
392     playButton->setMaximumSize( QSize( 45, 45 ) );
393     playButton->setIconSize( QSize( 30, 30 ) );
394
395     controlLayout->addWidget( playButton, 2, 0, 2, 2, Qt::AlignBottom );
396     
397     controlLayout->setColumnMinimumWidth( 2, 20 );
398     controlLayout->setColumnStretch( 2, 0 );
399
400     /** Prev + Stop + Next Block **/
401     QHBoxLayout *controlButLayout = new QHBoxLayout;
402     controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
403
404     /* Prev */
405     QPushButton *prevButton = new QPushButton;
406     prevButton->setSizePolicy( sizePolicy );
407     setupSmallButton( prevButton );
408
409     controlButLayout->addWidget( prevButton );
410
411     /* Stop */
412     QPushButton *stopButton = new QPushButton;
413     stopButton->setSizePolicy( sizePolicy );
414     setupSmallButton( stopButton );
415
416     controlButLayout->addWidget( stopButton );
417
418     /* next */
419     QPushButton *nextButton = new QPushButton;
420     nextButton->setSizePolicy( sizePolicy );
421     setupSmallButton( nextButton );
422
423     controlButLayout->addWidget( nextButton );
424
425     /* Add this block to the main layout */
426     controlLayout->addLayout( controlButLayout, 3, 3, 1, 3 );
427
428     BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
429     BUTTON_SET_ACT_I( prevButton, "" , previous.png,
430                       qtr( "Previous" ), prev() );
431     BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
432     BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
433
434     controlLayout->setColumnStretch( 8 , 10 );
435     controlLayout->setColumnStretch( 9, 0 );
436     
437     /*
438      * Other first Line buttons
439      * Might need to be inside a frame to avoid a few resizing pb
440      * FIXME
441      */
442     /** Fullscreen/Visualisation **/
443     fullscreenButton = new QPushButton( "F" );
444     BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
445     setupSmallButton( fullscreenButton );
446     controlLayout->addWidget( fullscreenButton, 3, 10 );
447
448     /** Playlist Button **/
449     playlistButton = new QPushButton;
450     setupSmallButton( playlistButton );
451     controlLayout->addWidget( playlistButton, 3, 11 );
452
453     /** extended Settings **/
454     QPushButton *extSettingsButton = new QPushButton( "F" );
455     BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
456             extSettings() );
457     setupSmallButton( extSettingsButton );
458     controlLayout->addWidget( extSettingsButton, 3, 12 );
459
460     /** Preferences **/
461     QPushButton *prefsButton = new QPushButton( "P" );
462     BUTTON_SET_ACT( prefsButton, "P", qtr( "Preferences / Settings" ),
463             prefs() );
464     setupSmallButton( prefsButton );
465     controlLayout->addWidget( prefsButton, 3, 13 );
466
467     controlLayout->setColumnStretch( 14, 5 );
468
469     /* Volume */
470     VolumeClickHandler *h = new VolumeClickHandler( p_intf, this );
471
472     volMuteLabel = new QLabel;
473     volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
474     volMuteLabel->setToolTip( qtr( "Mute" ) );
475     volMuteLabel->installEventFilter( h );
476
477     /** TODO:
478      * Change this slider to use a nice Amarok-like one 
479      * Add a Context menu to change to the most useful %
480      * **/
481     /** FIXME
482      *  THis percerntage thing has to be handled correctly
483      *  This has to match to the OSD
484      **/
485     volumeSlider = new QSlider;
486     volumeSlider->setSizePolicy( sizePolicy );
487     volumeSlider->setMaximumSize( QSize( 80, 200 ) );
488     volumeSlider->setOrientation( Qt::Horizontal );
489
490     volumeSlider->setMaximum( 100 );
491     volumeSlider->setFocusPolicy( Qt::NoFocus );
492     controlLayout->addWidget( volMuteLabel, 3, 15 );
493     controlLayout->addWidget( volumeSlider, 3, 16, 1, 2 );
494
495     /* Volume control connection */
496     CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
497
498 }
499 ControlsWidget::~ControlsWidget()
500 {
501 }
502 void ControlsWidget::stop()
503 {
504     THEMIM->stop();
505 }
506
507 void ControlsWidget::play()
508 {
509     if( THEPL )
510         msg_Dbg( p_intf, "There is %i playlist items", THEPL->items.i_size ); /* FIXME: remove me */
511     if( playlist_IsEmpty( THEPL ) )
512     {
513         /* The playlist is empty, open a file requester */
514         THEDP->openFileDialog();
515         setStatus( 0 );
516         return;
517     }
518     THEMIM->togglePlayPause();
519 }
520
521 void ControlsWidget::prev()
522 {
523     THEMIM->prev();
524 }
525
526 void ControlsWidget::next()
527 {
528     THEMIM->next();
529 }
530
531 void ControlsWidget::setNavigation( int navigation )
532 {
533 #define HELP_MENU N_( "Menu" )
534 #define HELP_PCH N_( "Previous chapter" )
535 #define HELP_NCH N_( "Next chapter" )
536 #define HELP_PTR N_( "Previous track" )
537 #define HELP_NTR N_( "Next track" )
538
539     // 1 = chapter, 2 = title, 0 = no
540     if( navigation == 0 )
541     {
542         discFrame->hide();
543     } else if( navigation == 1 ) {
544         prevSectionButton->setToolTip( qfu( HELP_PCH ) );
545         nextSectionButton->setToolTip( qfu( HELP_NCH ) );
546         menuButton->show();
547         discFrame->show();
548     } else {
549         prevSectionButton->setToolTip( qfu( HELP_PCH ) );
550         nextSectionButton->setToolTip( qfu( HELP_NCH ) );
551         menuButton->hide();
552         discFrame->show();
553     }
554 }
555
556 static bool b_my_volume;
557 void ControlsWidget::updateVolume( int i_sliderVolume )
558 {
559     if( !b_my_volume )
560     {
561         int i_res = i_sliderVolume * AOUT_VOLUME_MAX /
562                             ( 2*volumeSlider->maximum() );
563         aout_VolumeSet( p_intf, i_res );
564     }
565 }
566
567 void ControlsWidget::updateOnTimer()
568 {
569     /* Audio part */
570     audio_volume_t i_volume;
571     aout_VolumeGet( p_intf, &i_volume );
572     i_volume = ( i_volume *  200 )/ AOUT_VOLUME_MAX ;
573     int i_gauge = volumeSlider->value();
574     b_my_volume = false;
575     if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
576     {
577         b_my_volume = true;
578         volumeSlider->setValue( i_volume );
579         b_my_volume = false;
580     }
581     if( i_volume == 0 )
582         volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
583     else if( i_volume < volumeSlider->maximum()/2 )
584         volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
585     else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
586
587     /* Activate the interface buttons according to the presence of the input */
588     enableInput( THEMIM->getIM()->hasInput() );
589     //enableVideo( THEMIM->getIM()->hasVideo() );
590     enableVideo( true );
591 }
592
593 void ControlsWidget::setStatus( int status )
594 {
595     if( status == PLAYING_S ) // Playing
596         playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
597     else
598         playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
599 }
600
601 /**
602  * TODO
603  * This functions toggle the fullscreen mode
604  * If there is no video, it should first activate Visualisations... 
605  *  This has also to be fixed in enableVideo()
606  */
607 void ControlsWidget::fullscreen()
608 {
609     vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
610     if( p_vout)
611     {
612         var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
613     }
614 }
615
616 void ControlsWidget::extSettings()
617 {
618     THEDP->extendedDialog();
619 }
620 void ControlsWidget::prefs()
621 {
622     THEDP->prefsDialog();
623 }
624
625 void ControlsWidget::slower()
626 {
627     THEMIM->getIM()->slower();
628 }
629
630 void ControlsWidget::faster()
631 {
632     THEMIM->getIM()->faster();
633 }
634
635 void ControlsWidget::enableInput( bool enable )
636 {
637     slowerButton->setEnabled( enable );
638     slider->setEnabled( enable );
639     fasterButton->setEnabled( enable );
640
641     /* Advanced Buttons too */
642     advControls->enableInput( enable );
643 }
644
645 void ControlsWidget::enableVideo( bool enable )
646 {
647     // TODO Later make the fullscreenButton toggle Visualisation and so on.
648     fullscreenButton->setEnabled( enable );
649
650     /* Advanced Buttons too */
651     advControls->enableVideo( enable );
652 }
653
654 void ControlsWidget::toggleAdvanced()
655 {
656     if( !VISIBLE( advControls ) )
657     {
658         advControls->show();
659         b_advancedVisible = true;
660     }
661     else
662     {
663         advControls->hide();
664         b_advancedVisible = false;
665     }
666     //FIXME connect this one :D
667     emit advancedControlsToggled( b_advancedVisible );  //  doComponentsUpdate();
668 }
669
670 /**********************************************************************
671  * Playlist Widget. The embedded playlist
672  **********************************************************************/
673 #include "components/playlist/panels.hpp"
674 #include "components/playlist/selector.hpp"
675
676 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
677                                 p_intf ( _p_intf )
678 {
679     /* Left Part and design */
680     QWidget *leftW = new QWidget( this );
681     QVBoxLayout *left = new QVBoxLayout( leftW );
682
683     /* Source Selector */
684     selector = new PLSelector( this, p_intf, THEPL );
685     left->addWidget( selector );
686
687     /* Art label */
688     art = new QLabel( "" );
689     art->setMinimumHeight( 128 );
690     art->setMinimumWidth( 128 );
691     art->setMaximumHeight( 128 );
692     art->setMaximumWidth( 128 );
693     art->setScaledContents( true );
694     art->setPixmap( QPixmap( ":/noart.png" ) );
695     left->addWidget( art );
696
697     /* Initialisation of the playlist */
698     playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
699                                                 THEPL->p_local_category );
700
701     rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
702                               p_intf, THEPL, p_root ) );
703
704     /* Connects */
705     CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
706
707     CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
708              artSet( QString ) , this, setArt( QString ) );
709     /* Forward removal requests from the selector to the main panel */
710     CONNECT( qobject_cast<PLSelector *>( selector )->model,
711              shouldRemove( int ),
712              qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
713
714     connect( selector, SIGNAL( activated( int ) ),
715              this, SIGNAL( rootChanged( int ) ) );
716     emit rootChanged( p_root->i_id );
717
718     /* Add the two sides of the QSplitter */
719     addWidget( leftW );
720     addWidget( rightPanel );
721
722     leftW->setMaximumWidth( 250 );
723     setCollapsible( 1, false );
724
725     QList<int> sizeList;
726     sizeList << 180 << 520 ;
727     setSizes( sizeList );
728 }
729
730 void PlaylistWidget::setArt( QString url )
731 {
732     if( url.isNull() )
733         art->setPixmap( QPixmap( ":/noart.png" ) );
734     else if( prevArt != url )
735         art->setPixmap( QPixmap( url ) );
736     prevArt = url;
737     emit artSet( url );
738 }
739
740 PlaylistWidget::~PlaylistWidget()
741 {
742 }
743
744 QSize PlaylistWidget::sizeHint() const
745 {
746     return widgetSize;
747 }
748