1 /*****************************************************************************
2 * interface_widgets.cpp : Custom widgets for the main interface
3 ****************************************************************************
4 * Copyright ( C ) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Rafaël Carré <funman@videolanorg>
10 * Ilkka Ollakka <ileoo@videolan.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * ( at your option ) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
30 #include "dialogs_provider.hpp"
31 #include "components/interface_widgets.hpp"
32 #include "main_interface.hpp"
33 #include "input_manager.hpp"
35 #include "util/input_slider.hpp"
36 #include "util/customwidgets.hpp"
40 #include <QSpacerItem>
42 #include <QPushButton>
43 #include <QToolButton>
44 #include <QHBoxLayout>
47 #include <QResizeEvent>
50 /**********************************************************************
51 * Video Widget. A simple frame on which video is drawn
52 * This class handles resize issues
53 **********************************************************************/
54 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
55 unsigned int *, unsigned int * );
56 static void DoRelease( intf_thread_t *, void * );
57 static int DoControl( intf_thread_t *, void *, int, va_list );
59 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
62 vlc_mutex_init( p_intf, &lock );
64 hide(); setMinimumSize( 16, 16 );
65 videoSize.rwidth() = -1;
66 videoSize.rheight() = -1;
68 /* Black background is more coherent for a Video Widget IMVHO */
69 QPalette plt = palette();
70 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
71 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
74 /* The core can ask through a callback to show the video */
75 CONNECT( this, askVideoWidgetToShow(), this, show() );
76 /* The core can ask through a callback to resize the video */
77 // CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) );
80 VideoWidget::~VideoWidget()
82 vlc_mutex_lock( &lock );
85 if( !p_intf->psz_switch_intf )
87 if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
88 vout_Control( p_vout, VOUT_REPARENT );
92 if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
93 vout_Control( p_vout, VOUT_CLOSE );
96 vlc_mutex_unlock( &lock );
97 vlc_mutex_destroy( &lock );
101 * Request the video to avoid the conflicts
103 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
104 unsigned int *pi_width, unsigned int *pi_height )
106 msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
107 emit askVideoWidgetToShow();
110 msg_Dbg( p_intf, "embedded video already in use" );
114 return ( void* )winId();
117 /* Set the Widget to the correct Size */
118 /* Function has to be called by the parent
119 Parent has to care about resizing himself*/
120 void VideoWidget::SetSizing( unsigned int w, unsigned int h )
122 msg_Dbg( p_intf, "Video is resizing to: %i %i", w, h );
123 videoSize.rwidth() = w;
124 videoSize.rheight() = h;
125 updateGeometry(); // Needed for deinterlace
128 void VideoWidget::release( void *p_win )
130 msg_Dbg( p_intf, "Video is non needed anymore" );
132 videoSize.rwidth() = 0;
133 videoSize.rheight() = 0;
135 updateGeometry(); // Needed for deinterlace
138 QSize VideoWidget::sizeHint() const
143 /**********************************************************************
144 * Background Widget. Show a simple image background. Currently,
145 * it's album art if present or cone.
146 **********************************************************************/
147 #define ICON_SIZE 128
148 #define MAX_BG_SIZE 400
149 #define MIN_BG_SIZE 64
151 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
152 :QWidget( NULL ), p_intf( _p_i )
154 /* We should use that one to take the more size it can */
155 // setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
157 /* A dark background */
158 setAutoFillBackground( true );
160 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
161 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
164 /* A cone in the middle */
166 label->setMargin( 5 );
167 label->setMaximumHeight( MAX_BG_SIZE );
168 label->setMaximumWidth( MAX_BG_SIZE );
169 label->setMinimumHeight( MIN_BG_SIZE );
170 label->setMinimumWidth( MIN_BG_SIZE );
171 if( QDate::currentDate().dayOfYear() >= 354 )
172 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
174 label->setPixmap( QPixmap( ":/vlc128.png" ) );
176 QGridLayout *backgroundLayout = new QGridLayout( this );
177 backgroundLayout->addWidget( label, 0, 1 );
178 backgroundLayout->setColumnStretch( 0, 1 );
179 backgroundLayout->setColumnStretch( 2, 1 );
181 CONNECT( THEMIM->getIM(), artChanged( QString ), this, updateArt( QString ) );
184 BackgroundWidget::~BackgroundWidget()
188 void BackgroundWidget::resizeEvent( QResizeEvent * event )
190 if( event->size().height() <= MIN_BG_SIZE )
196 void BackgroundWidget::updateArt( QString url )
200 if( QDate::currentDate().dayOfYear() >= 354 )
201 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
203 label->setPixmap( QPixmap( ":/vlc128.png" ) );
208 label->setPixmap( QPixmap( url ) );
212 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
214 QVLCMenu::PopupMenu( p_intf, true );
217 /**********************************************************************
218 * Visualization selector panel
219 **********************************************************************/
220 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
221 QFrame( NULL ), p_intf( _p_i )
223 QHBoxLayout *layout = new QHBoxLayout( this );
224 layout->setMargin( 0 );
225 QPushButton *prevButton = new QPushButton( "Prev" );
226 QPushButton *nextButton = new QPushButton( "Next" );
227 layout->addWidget( prevButton );
228 layout->addWidget( nextButton );
230 layout->addItem( new QSpacerItem( 40,20,
231 QSizePolicy::Expanding, QSizePolicy::Minimum ) );
232 layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
234 current = new QLabel( qtr( "None" ) );
235 layout->addWidget( current );
237 BUTTONACT( prevButton, prev() );
238 BUTTONACT( nextButton, next() );
241 setMaximumHeight( 35 );
244 VisualSelector::~VisualSelector()
248 void VisualSelector::prev()
250 char *psz_new = aout_VisualPrev( p_intf );
253 current->setText( qfu( psz_new ) );
258 void VisualSelector::next()
260 char *psz_new = aout_VisualNext( p_intf );
263 current->setText( qfu( psz_new ) );
268 /**********************************************************************
270 **********************************************************************/
272 #define setupSmallButton( aButton ){ \
273 aButton->setMaximumSize( QSize( 26, 26 ) ); \
274 aButton->setMinimumSize( QSize( 26, 26 ) ); \
275 aButton->setIconSize( QSize( 20, 20 ) ); }
277 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
278 QFrame( NULL ), p_intf( _p_i )
280 QHBoxLayout *advLayout = new QHBoxLayout( this );
281 advLayout->setMargin( 0 );
282 advLayout->setSpacing( 0 );
283 advLayout->setAlignment( Qt::AlignBottom );
286 ABButton = new QPushButton( "AB" );
287 ABButton->setMaximumSize( QSize( 26, 26 ) );
288 ABButton->setIconSize( QSize( 20, 20 ) );
289 advLayout->addWidget( ABButton );
290 BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
292 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
293 this, AtoBLoop( float, int, int ) );
295 frameButton = new QPushButton( "Fr" );
296 frameButton->setMaximumSize( QSize( 26, 26 ) );
297 frameButton->setIconSize( QSize( 20, 20 ) );
298 advLayout->addWidget( frameButton );
299 BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
302 recordButton = new QPushButton( "R" );
303 recordButton->setMaximumSize( QSize( 26, 26 ) );
304 recordButton->setIconSize( QSize( 20, 20 ) );
305 advLayout->addWidget( recordButton );
306 BUTTON_SET_ACT_I( recordButton, "", record_16px.png,
307 qtr( "Record" ), record() );
309 /* Snapshot Button */
310 snapshotButton = new QPushButton( "S" );
311 snapshotButton->setMaximumSize( QSize( 26, 26 ) );
312 snapshotButton->setIconSize( QSize( 20, 20 ) );
313 advLayout->addWidget( snapshotButton );
314 BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
317 AdvControlsWidget::~AdvControlsWidget()
320 void AdvControlsWidget::enableInput( bool enable )
322 ABButton->setEnabled( enable );
323 recordButton->setEnabled( enable );
326 void AdvControlsWidget::enableVideo( bool enable )
328 snapshotButton->setEnabled( enable );
330 frameButton->setEnabled( enable );
334 void AdvControlsWidget::snapshot()
336 vout_thread_t *p_vout =
337 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
338 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
341 /* Function called when the button is clicked() */
342 void AdvControlsWidget::fromAtoB()
346 timeA = var_GetTime( THEMIM->getInput(), "time" );
347 ABButton->setText( "A->..." );
352 timeB = var_GetTime( THEMIM->getInput(), "time" );
353 var_SetTime( THEMIM->getInput(), "time" , timeA );
354 ABButton->setText( "A<=>B" );
359 ABButton->setText( "AB" );
362 /* Function called regularly when in an AtoB loop */
363 void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
367 if( i_time >= (int)(timeB/1000000) )
368 var_SetTime( THEMIM->getInput(), "time" , timeA );
372 /* FIXME Record function */
373 void AdvControlsWidget::record(){}
376 //FIXME Frame by frame function
377 void AdvControlsWidget::frame(){}
380 /*****************************
381 * DA Control Widget !
382 *****************************/
383 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
384 MainInterface *_p_mi,
387 QFrame( NULL ), p_intf( _p_i )
389 controlLayout = new QGridLayout( this );
390 controlLayout->setSpacing( 0 );
392 controlLayout->setContentsMargins( 9, 6, 9, 6 );
394 controlLayout->setMargin( 6 );
397 setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
399 /** The main Slider **/
400 slider = new InputSlider( Qt::Horizontal, NULL );
401 controlLayout->addWidget( slider, 0, 1, 1, 16 );
402 /* Update the position when the IM has changed */
403 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
404 slider, setPosition( float, int, int ) );
405 /* And update the IM, when the position has changed */
406 CONNECT( slider, sliderDragged( float ),
407 THEMIM->getIM(), sliderUpdate( float ) );
409 /** Slower and faster Buttons **/
410 slowerButton = new QToolButton;
411 slowerButton->setAutoRaise( true );
412 slowerButton->setMaximumSize( QSize( 26, 20 ) );
414 BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
415 controlLayout->addWidget( slowerButton, 0, 0 );
417 fasterButton = new QToolButton;
418 fasterButton->setAutoRaise( true );
419 fasterButton->setMaximumSize( QSize( 26, 20 ) );
421 BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
422 controlLayout->addWidget( fasterButton, 0, 17 );
424 /* advanced Controls handling */
425 b_advancedVisible = b_advControls;
427 advControls = new AdvControlsWidget( p_intf );
428 controlLayout->addWidget( advControls, 1, 3, 2, 4, Qt::AlignBottom );
429 if( !b_advancedVisible ) advControls->hide();
431 /** Disc and Menus handling */
432 discFrame = new QWidget( this );
434 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
435 discLayout->setSpacing( 0 );
436 discLayout->setMargin( 0 );
438 prevSectionButton = new QPushButton( discFrame );
439 setupSmallButton( prevSectionButton );
440 discLayout->addWidget( prevSectionButton );
442 menuButton = new QPushButton( discFrame );
443 setupSmallButton( menuButton );
444 discLayout->addWidget( menuButton );
446 nextSectionButton = new QPushButton( discFrame );
447 setupSmallButton( nextSectionButton );
448 discLayout->addWidget( nextSectionButton );
450 controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
452 BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
453 BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
454 BUTTON_SET_IMG( menuButton, "", previous.png, "" );
458 /* Change the navigation button display when the IM navigation changes */
459 CONNECT( THEMIM->getIM(), navigationChanged( int ),
460 this, setNavigation( int ) );
461 /* Changes the IM navigation when triggered on the nav buttons */
462 CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
464 CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
466 CONNECT( menuButton, clicked(), THEMIM->getIM(),
470 * TODO: Merge with upper menu in a StackLayout
473 telexFrame = new QWidget( this );
474 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
475 telexLayout->setSpacing( 0 );
476 telexLayout->setMargin( 0 );
478 QToolButton *telexOn = new QToolButton;
479 telexOn->setText( qtr( "On" ) );
480 setupSmallButton( telexOn );
481 telexLayout->addWidget( telexOn );
483 QToolButton *telexTransparent = new QToolButton;
484 telexTransparent->setText( qtr( "Transparent" ) );
485 setupSmallButton( telexTransparent );
486 telexLayout->addWidget( telexTransparent );
488 QSpinBox *telexPage = new QSpinBox;
489 telexPage->setRange( 0, 999 );
490 telexPage->setValue( 100 );
491 telexPage->setAccelerated( true );
492 telexPage->setWrapping( true );
493 telexPage->setAlignment( Qt::AlignRight );
494 telexPage->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
495 telexLayout->addWidget( telexPage );
497 controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
500 CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
501 telexGotoPage( int ) );
502 CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
503 telexToggle( bool ) );
504 CONNECT( telexTransparent, clicked( bool ),
505 THEMIM->getIM(), telexSetTransparency( bool ) );
506 CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
507 telexFrame, setVisible( bool ) );
511 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
512 sizePolicy.setHorizontalStretch( 0 );
513 sizePolicy.setVerticalStretch( 0 );
516 playButton = new QPushButton;
517 playButton->setSizePolicy( sizePolicy );
518 playButton->setMaximumSize( QSize( 36, 36 ) );
519 playButton->setMinimumSize( QSize( 36, 36 ) );
520 playButton->setIconSize( QSize( 30, 30 ) );
522 controlLayout->addWidget( playButton, 2, 0, 2, 2 );
524 controlLayout->setColumnMinimumWidth( 2, 20 );
525 controlLayout->setColumnStretch( 2, 0 );
527 /** Prev + Stop + Next Block **/
528 QHBoxLayout *controlButLayout = new QHBoxLayout;
529 controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
532 QPushButton *prevButton = new QPushButton;
533 prevButton->setSizePolicy( sizePolicy );
534 setupSmallButton( prevButton );
536 controlButLayout->addWidget( prevButton );
539 QPushButton *stopButton = new QPushButton;
540 stopButton->setSizePolicy( sizePolicy );
541 setupSmallButton( stopButton );
543 controlButLayout->addWidget( stopButton );
546 QPushButton *nextButton = new QPushButton;
547 nextButton->setSizePolicy( sizePolicy );
548 setupSmallButton( nextButton );
550 controlButLayout->addWidget( nextButton );
552 /* Add this block to the main layout */
553 controlLayout->addLayout( controlButLayout, 3, 3, 1, 3 );
555 BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
556 BUTTON_SET_ACT_I( prevButton, "" , previous.png,
557 qtr( "Previous" ), prev() );
558 BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
559 BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
561 controlLayout->setColumnMinimumWidth( 7, 20 );
562 controlLayout->setColumnStretch( 7, 0 );
563 controlLayout->setColumnStretch( 8, 0 );
564 controlLayout->setColumnStretch( 9, 0 );
567 * Other first Line buttons
569 /** Fullscreen/Visualisation **/
570 fullscreenButton = new QPushButton( "F" );
571 BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
572 setupSmallButton( fullscreenButton );
573 controlLayout->addWidget( fullscreenButton, 3, 10, Qt::AlignBottom );
575 /** Playlist Button **/
576 playlistButton = new QPushButton;
577 setupSmallButton( playlistButton );
578 controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
579 BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
580 CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
582 /** extended Settings **/
583 QPushButton *extSettingsButton = new QPushButton( "F" );
584 BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
586 setupSmallButton( extSettingsButton );
587 controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom );
589 controlLayout->setColumnStretch( 13, 0 );
590 controlLayout->setColumnMinimumWidth( 13, 24 );
591 controlLayout->setColumnStretch( 14, 5 );
594 VolumeClickHandler *hVolLabel = new VolumeClickHandler( p_intf, this );
596 volMuteLabel = new QLabel;
597 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
598 volMuteLabel->setToolTip( qtr( "Mute" ) );
599 volMuteLabel->installEventFilter( hVolLabel );
600 controlLayout->addWidget( volMuteLabel, 3, 15, Qt::AlignBottom );
604 volumeSlider = new SoundSlider( this,
605 config_GetInt( p_intf, "volume-step" ),
606 config_GetInt( p_intf, "qt-volume-complete" ),
607 config_GetPsz( p_intf, "qt-slider-colours" ) );
611 volumeSlider = new QSlider( this );
612 volumeSlider->setOrientation( Qt::Horizontal );
614 volumeSlider->setMaximumSize( QSize( 200, 40 ) );
615 volumeSlider->setMinimumSize( QSize( 106, 30 ) );
616 volumeSlider->setFocusPolicy( Qt::NoFocus );
617 controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom );
619 /* Set the volume from the config */
620 volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
621 VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
623 /* Force the update at build time in order to have a muted icon if needed */
624 updateVolume( volumeSlider->value() );
626 /* Volume control connection */
627 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
628 CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
633 ControlsWidget::~ControlsWidget()
636 void ControlsWidget::stop()
641 void ControlsWidget::play()
643 if( THEPL->current.i_size == 0 )
645 /* The playlist is empty, open a file requester */
646 THEDP->openFileDialog();
650 THEMIM->togglePlayPause();
653 void ControlsWidget::prev()
658 void ControlsWidget::next()
663 void ControlsWidget::setNavigation( int navigation )
665 #define HELP_MENU N_( "Menu" )
666 #define HELP_PCH N_( "Previous chapter" )
667 #define HELP_NCH N_( "Next chapter" )
668 #define HELP_PTR N_( "Previous track" )
669 #define HELP_NTR N_( "Next track" )
671 // 1 = chapter, 2 = title, 0 = no
672 if( navigation == 0 )
675 } else if( navigation == 1 ) {
676 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
677 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
681 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
682 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
688 static bool b_my_volume;
689 void ControlsWidget::updateVolume( int i_sliderVolume )
693 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
694 aout_VolumeSet( p_intf, i_res );
696 if( i_sliderVolume == 0 )
697 volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
698 else if( i_sliderVolume < VOLUME_MAX / 3 )
699 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
700 else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
701 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
702 else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
705 void ControlsWidget::updateVolume()
708 audio_volume_t i_volume;
709 aout_VolumeGet( p_intf, &i_volume );
710 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
711 int i_gauge = volumeSlider->value();
713 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
716 volumeSlider->setValue( i_volume );
721 void ControlsWidget::updateInput()
723 /* Activate the interface buttons according to the presence of the input */
724 enableInput( THEMIM->getIM()->hasInput() );
725 enableVideo( THEMIM->getIM()->hasVideo() && THEMIM->getIM()->hasInput() );
728 void ControlsWidget::setStatus( int status )
730 if( status == PLAYING_S ) /* Playing */
732 playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
733 playButton->setToolTip( qtr( "Pause" ) );
737 playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
738 playButton->setToolTip( qtr( "Play" ) );
744 * This functions toggle the fullscreen mode
745 * If there is no video, it should first activate Visualisations...
746 * This has also to be fixed in enableVideo()
748 void ControlsWidget::fullscreen()
750 vout_thread_t *p_vout =
751 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
754 var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
755 vlc_object_release( p_vout );
759 void ControlsWidget::extSettings()
761 THEDP->extendedDialog();
764 void ControlsWidget::slower()
766 THEMIM->getIM()->slower();
769 void ControlsWidget::faster()
771 THEMIM->getIM()->faster();
774 void ControlsWidget::enableInput( bool enable )
776 slowerButton->setEnabled( enable );
777 slider->setEnabled( enable );
778 fasterButton->setEnabled( enable );
780 /* Advanced Buttons too */
781 advControls->enableInput( enable );
784 void ControlsWidget::enableVideo( bool enable )
786 // TODO Later make the fullscreenButton toggle Visualisation and so on.
787 fullscreenButton->setEnabled( enable );
789 /* Advanced Buttons too */
790 advControls->enableVideo( enable );
793 void ControlsWidget::toggleAdvanced()
795 if( !VISIBLE( advControls ) )
798 b_advancedVisible = true;
803 b_advancedVisible = false;
805 emit advancedControlsToggled( b_advancedVisible );
809 /**********************************************************************
810 * Speed control widget
811 **********************************************************************/
812 SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :
813 QFrame( NULL ), p_intf( _p_i )
815 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
816 sizePolicy.setHorizontalStretch( 0 );
817 sizePolicy.setVerticalStretch( 0 );
819 speedSlider = new QSlider;
820 speedSlider->setSizePolicy( sizePolicy );
821 speedSlider->setMaximumSize( QSize( 80, 200 ) );
822 speedSlider->setOrientation( Qt::Vertical );
823 speedSlider->setTickPosition( QSlider::TicksRight );
825 speedSlider->setRange( -100, 100 );
826 speedSlider->setSingleStep( 10 );
827 speedSlider->setPageStep( 20 );
828 speedSlider->setTickInterval( 20 );
830 CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
832 QToolButton *normalSpeedButton = new QToolButton( this );
833 normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
834 normalSpeedButton->setAutoRaise( true );
835 normalSpeedButton->setText( "N" );
836 normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
838 CONNECT( normalSpeedButton, clicked(), this, resetRate() );
840 QVBoxLayout *speedControlLayout = new QVBoxLayout;
841 speedControlLayout->addWidget( speedSlider );
842 speedControlLayout->addWidget( normalSpeedButton );
843 setLayout( speedControlLayout );
846 SpeedControlWidget::~SpeedControlWidget()
849 void SpeedControlWidget::setEnable( bool b_enable )
851 speedSlider->setEnabled( b_enable );
854 #define RATE_SLIDER_MAXIMUM 3.0
855 #define RATE_SLIDER_MINIMUM 0.3
856 #define RATE_SLIDER_LENGTH 100.0
858 void SpeedControlWidget::updateControls( int rate )
860 if( speedSlider->isSliderDown() )
862 //We don't want to change anything if the user is using the slider
867 double speed = INPUT_RATE_DEFAULT / (double)rate;
869 if( rate >= INPUT_RATE_DEFAULT )
871 if( speed < RATE_SLIDER_MINIMUM )
873 sliderValue = speedSlider->minimum();
877 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
878 / ( 1.0 - RATE_SLIDER_MAXIMUM ) );
883 if( speed > RATE_SLIDER_MAXIMUM )
885 sliderValue = speedSlider->maximum();
889 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
890 / ( RATE_SLIDER_MAXIMUM - 1.0 ) );
894 //Block signals to avoid feedback loop
895 speedSlider->blockSignals( true );
896 speedSlider->setValue( sliderValue );
897 speedSlider->blockSignals( false );
900 void SpeedControlWidget::updateRate( int sliderValue )
904 if( sliderValue < 0.0 )
906 rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
907 ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH ));
911 rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
912 ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH ));
915 THEMIM->getIM()->setRate(rate);
918 void SpeedControlWidget::resetRate()
920 THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);