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 *****************************************************************************/
27 #include "dialogs_provider.hpp"
28 #include "components/interface_widgets.hpp"
29 #include "main_interface.hpp"
30 #include "input_manager.hpp"
32 #include "util/input_slider.hpp"
33 #include "util/customwidgets.hpp"
37 #include <QSpacerItem>
39 #include <QPushButton>
40 #include <QToolButton>
41 #include <QHBoxLayout>
44 #include <QResizeEvent>
47 /**********************************************************************
48 * Video Widget. A simple frame on which video is drawn
49 * This class handles resize issues
50 **********************************************************************/
51 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
52 unsigned int *, unsigned int * );
53 static void DoRelease( intf_thread_t *, void * );
54 static int DoControl( intf_thread_t *, void *, int, va_list );
56 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
58 vlc_mutex_init( p_intf, &lock );
60 hide(); setMinimumSize( 16, 16 );
62 // CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) );
63 CONNECT( this, askVideoWidgetToShow(), this, show() );
64 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
67 VideoWidget::~VideoWidget()
69 vlc_mutex_lock( &lock );
72 if( !p_intf->psz_switch_intf )
74 if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
75 vout_Control( p_vout, VOUT_REPARENT );
79 if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
80 vout_Control( p_vout, VOUT_CLOSE );
83 vlc_mutex_unlock( &lock );
84 vlc_mutex_destroy( &lock );
88 * Request the video to avoid the conflicts
90 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
91 unsigned int *pi_width, unsigned int *pi_height )
93 emit askVideoWidgetToShow();
96 msg_Dbg( p_intf, "embedded video already in use" );
100 return ( void* )winId();
103 /* Set the Widget to the correct Size */
104 void VideoWidget::SetSizing( unsigned int w, unsigned int h )
107 //updateGeometry(); // Needed for deinterlace
108 msg_Dbg( p_intf, "%i %i", sizeHint().height(), sizeHint().width() );
112 void VideoWidget::release( void *p_win )
118 /**********************************************************************
119 * Background Widget. Show a simple image background. Currently,
120 * it's a static cone.
121 **********************************************************************/
122 #define ICON_SIZE 128
123 #define MAX_BG_SIZE 400
124 #define MIN_BG_SIZE 64
126 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
127 QFrame( NULL ), p_intf( _p_i )
129 /* We should use that one to take the more size it can */
130 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
132 /* A dark background */
133 setAutoFillBackground( true );
135 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
136 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
139 /* A cone in the middle */
141 label->setScaledContents( true );
142 label->setMargin( 5 );
143 label->setMaximumHeight( MAX_BG_SIZE );
144 label->setMaximumWidth( MAX_BG_SIZE );
145 label->setMinimumHeight( MIN_BG_SIZE );
146 label->setMinimumWidth( MIN_BG_SIZE );
147 if( QDate::currentDate().dayOfYear() >= 354 )
148 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
150 label->setPixmap( QPixmap( ":/vlc128.png" ) );
152 QHBoxLayout *backgroundLayout = new QHBoxLayout( this );
153 backgroundLayout->addWidget( label );
157 CONNECT( THEMIM, inputChanged( input_thread_t *),
158 this, update( input_thread_t * ) );
161 BackgroundWidget::~BackgroundWidget()
166 void BackgroundWidget::update( input_thread_t *p_input )
168 if( !p_input || p_input->b_dead )
170 if( QDate::currentDate().dayOfYear() >= 354 )
171 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
173 label->setPixmap( QPixmap( ":/vlc128.png" ) );
178 vlc_object_yield( p_input );
179 char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
180 vlc_object_release( p_input );
181 QString url = qfu( psz_arturl );
182 QString arturl = url.replace( "file://",QString("" ) );
183 if( arturl.isNull() )
185 if( QDate::currentDate().dayOfYear() >= 354 )
186 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
188 label->setPixmap( QPixmap( ":/vlc128.png" ) );
192 label->setPixmap( QPixmap( arturl ) );
193 msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
198 QSize BackgroundWidget::sizeHint() const
200 return label->size();
203 void BackgroundWidget::resizeEvent( QResizeEvent *e )
205 if( e->size().height() < MAX_BG_SIZE -1 )
207 label->setMaximumWidth( e->size().height() );
208 label->setMaximumHeight( e->size().width() );
212 label->setMaximumHeight( MAX_BG_SIZE );
213 label->setMaximumWidth( MAX_BG_SIZE );
217 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
219 QVLCMenu::PopupMenu( p_intf, true );
222 /**********************************************************************
223 * Visualization selector panel
224 **********************************************************************/
225 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
226 QFrame( NULL ), p_intf( _p_i )
228 QHBoxLayout *layout = new QHBoxLayout( this );
229 layout->setMargin( 0 );
230 QPushButton *prevButton = new QPushButton( "Prev" );
231 QPushButton *nextButton = new QPushButton( "Next" );
232 layout->addWidget( prevButton );
233 layout->addWidget( nextButton );
235 layout->addItem( new QSpacerItem( 40,20,
236 QSizePolicy::Expanding, QSizePolicy::Minimum ) );
237 layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
239 current = new QLabel( qtr( "None" ) );
240 layout->addWidget( current );
242 BUTTONACT( prevButton, prev() );
243 BUTTONACT( nextButton, next() );
246 setMaximumHeight( 35 );
249 VisualSelector::~VisualSelector()
253 void VisualSelector::prev()
255 char *psz_new = aout_VisualPrev( p_intf );
258 current->setText( qfu( psz_new ) );
263 void VisualSelector::next()
265 char *psz_new = aout_VisualNext( p_intf );
268 current->setText( qfu( psz_new ) );
273 /**********************************************************************
275 **********************************************************************/
277 #define setupSmallButton( aButton ){ \
278 aButton->setMaximumSize( QSize( 26, 26 ) ); \
279 aButton->setMinimumSize( QSize( 26, 26 ) ); \
280 aButton->setIconSize( QSize( 20, 20 ) ); }
282 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
283 QFrame( NULL ), p_intf( _p_i )
285 QHBoxLayout *advLayout = new QHBoxLayout( this );
286 advLayout->setMargin( 0 );
287 advLayout->setSpacing( 0 );
290 ABButton = new QPushButton( "AB" );
291 ABButton->setMaximumSize( QSize( 26, 26 ) );
292 ABButton->setIconSize( QSize( 20, 20 ) );
293 advLayout->addWidget( ABButton );
294 BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
296 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
297 this, AtoBLoop( float, int, int ) );
299 frameButton = new QPushButton( "Fr" );
300 frameButton->setMaximumSize( QSize( 26, 26 ) );
301 frameButton->setIconSize( QSize( 20, 20 ) );
302 advLayout->addWidget( frameButton );
303 BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
305 recordButton = new QPushButton( "R" );
306 recordButton->setMaximumSize( QSize( 26, 26 ) );
307 recordButton->setIconSize( QSize( 20, 20 ) );
308 advLayout->addWidget( recordButton );
309 BUTTON_SET_ACT_I( recordButton, "", record_16px.png,
310 qtr( "Record" ), record() );
312 /* Snapshot Button */
313 snapshotButton = new QPushButton( "S" );
314 snapshotButton->setMaximumSize( QSize( 26, 26 ) );
315 snapshotButton->setIconSize( QSize( 20, 20 ) );
316 advLayout->addWidget( snapshotButton );
317 BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
320 AdvControlsWidget::~AdvControlsWidget()
323 void AdvControlsWidget::enableInput( bool enable )
325 ABButton->setEnabled( enable );
326 recordButton->setEnabled( enable );
329 void AdvControlsWidget::enableVideo( bool enable )
331 snapshotButton->setEnabled( enable );
332 frameButton->setEnabled( enable );
335 void AdvControlsWidget::snapshot()
337 vout_thread_t *p_vout =
338 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
339 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
342 /* Function called when the button is clicked() */
343 void AdvControlsWidget::fromAtoB()
347 timeA = var_GetTime( THEMIM->getInput(), "time" );
348 ABButton->setText( "A->..." );
353 timeB = var_GetTime( THEMIM->getInput(), "time" );
354 var_SetTime( THEMIM->getInput(), "time" , timeA );
355 ABButton->setText( "A<=>B" );
360 ABButton->setText( "AB" );
363 /* Function called regularly when in an AtoB loop */
364 void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
368 if( i_time >= (int)(timeB/1000000) )
369 var_SetTime( THEMIM->getInput(), "time" , timeA );
373 /* FIXME Record function */
374 void AdvControlsWidget::record(){}
376 //FIXME Frame by frame function
377 void AdvControlsWidget::frame(){}
379 /*****************************
380 * DA Control Widget !
381 *****************************/
382 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
383 MainInterface *_p_mi,
386 QFrame( NULL ), p_intf( _p_i )
388 controlLayout = new QGridLayout( this );
389 controlLayout->setSpacing( 0 );
391 controlLayout->setContentsMargins( 9, 6, 9, 6 );
393 controlLayout->setMargin( 6 );
396 setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
398 /** The main Slider **/
399 slider = new InputSlider( Qt::Horizontal, NULL );
400 controlLayout->addWidget( slider, 0, 1, 1, 16 );
401 /* Update the position when the IM has changed */
402 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
403 slider, setPosition( float, int, int ) );
404 /* And update the IM, when the position has changed */
405 CONNECT( slider, sliderDragged( float ),
406 THEMIM->getIM(), sliderUpdate( float ) );
408 /** Slower and faster Buttons **/
409 slowerButton = new QToolButton;
410 slowerButton->setAutoRaise( true );
411 slowerButton->setMaximumSize( QSize( 26, 20 ) );
413 BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
414 controlLayout->addWidget( slowerButton, 0, 0 );
416 fasterButton = new QToolButton;
417 fasterButton->setAutoRaise( true );
418 fasterButton->setMaximumSize( QSize( 26, 20 ) );
420 BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
421 controlLayout->addWidget( fasterButton, 0, 17 );
423 /* advanced Controls handling */
424 b_advancedVisible = b_advControls;
426 advControls = new AdvControlsWidget( p_intf );
427 controlLayout->addWidget( advControls, 1, 3, 2, 4, Qt::AlignBottom );
428 if( !b_advancedVisible ) advControls->hide();
430 /** Disc and Menus handling */
431 discFrame = new QWidget( this );
433 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
434 discLayout->setSpacing( 0 );
435 discLayout->setMargin( 0 );
437 prevSectionButton = new QPushButton( discFrame );
438 setupSmallButton( prevSectionButton );
439 discLayout->addWidget( prevSectionButton );
441 menuButton = new QPushButton( discFrame );
442 setupSmallButton( menuButton );
443 discLayout->addWidget( menuButton );
445 nextSectionButton = new QPushButton( discFrame );
446 setupSmallButton( nextSectionButton );
447 discLayout->addWidget( nextSectionButton );
449 controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
451 BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
452 BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
453 BUTTON_SET_IMG( menuButton, "", previous.png, "" );
457 /* Change the navigation button display when the IM navigation changes */
458 CONNECT( THEMIM->getIM(), navigationChanged( int ),
459 this, setNavigation( int ) );
460 /* Changes the IM navigation when triggered on the nav buttons */
461 CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
463 CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
465 CONNECT( menuButton, clicked(), THEMIM->getIM(),
469 * TODO: Merge with upper menu in a StackLayout
472 telexFrame = new QWidget( this );
473 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
474 telexLayout->setSpacing( 0 );
475 telexLayout->setMargin( 0 );
477 QToolButton *telexOn = new QToolButton;
478 telexOn->setText( qtr( "On" ) );
479 setupSmallButton( telexOn );
480 telexLayout->addWidget( telexOn );
482 QToolButton *telexTransparent = new QToolButton;
483 telexTransparent->setText( qtr( "Transparent" ) );
484 setupSmallButton( telexTransparent );
485 telexLayout->addWidget( telexTransparent );
487 QSpinBox *telexPage = new QSpinBox;
488 telexPage->setRange( 0, 999 );
489 telexPage->setValue( 100 );
490 telexPage->setAlignment( Qt::AlignRight );
491 telexLayout->addWidget( telexPage );
493 controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
496 CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
497 telexGotoPage( int ) );
498 CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
499 telexToggle( bool ) );
500 CONNECT( telexTransparent, clicked( bool ),
501 THEMIM->getIM(), telexSetTransparency( bool ) );
502 CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
503 telexFrame, setVisible( bool ) );
507 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
508 sizePolicy.setHorizontalStretch( 0 );
509 sizePolicy.setVerticalStretch( 0 );
512 playButton = new QPushButton;
513 playButton->setSizePolicy( sizePolicy );
514 playButton->setMaximumSize( QSize( 36, 36 ) );
515 playButton->setMinimumSize( QSize( 36, 36 ) );
516 playButton->setIconSize( QSize( 30, 30 ) );
518 controlLayout->addWidget( playButton, 2, 0, 2, 2 );
520 controlLayout->setColumnMinimumWidth( 2, 20 );
521 controlLayout->setColumnStretch( 2, 0 );
523 /** Prev + Stop + Next Block **/
524 QHBoxLayout *controlButLayout = new QHBoxLayout;
525 controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
528 QPushButton *prevButton = new QPushButton;
529 prevButton->setSizePolicy( sizePolicy );
530 setupSmallButton( prevButton );
532 controlButLayout->addWidget( prevButton );
535 QPushButton *stopButton = new QPushButton;
536 stopButton->setSizePolicy( sizePolicy );
537 setupSmallButton( stopButton );
539 controlButLayout->addWidget( stopButton );
542 QPushButton *nextButton = new QPushButton;
543 nextButton->setSizePolicy( sizePolicy );
544 setupSmallButton( nextButton );
546 controlButLayout->addWidget( nextButton );
548 /* Add this block to the main layout */
549 controlLayout->addLayout( controlButLayout, 3, 3, 1, 3, Qt::AlignBottom );
551 BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
552 BUTTON_SET_ACT_I( prevButton, "" , previous.png,
553 qtr( "Previous" ), prev() );
554 BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
555 BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
557 controlLayout->setColumnMinimumWidth( 7, 20 );
558 controlLayout->setColumnStretch( 7, 0 );
559 controlLayout->setColumnStretch( 8, 0 );
560 controlLayout->setColumnStretch( 9, 0 );
563 * Other first Line buttons
565 /** Fullscreen/Visualisation **/
566 fullscreenButton = new QPushButton( "F" );
567 BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
568 setupSmallButton( fullscreenButton );
569 controlLayout->addWidget( fullscreenButton, 3, 10, Qt::AlignBottom );
571 /** Playlist Button **/
572 playlistButton = new QPushButton;
573 setupSmallButton( playlistButton );
574 controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
575 BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
576 CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
578 /** extended Settings **/
579 QPushButton *extSettingsButton = new QPushButton( "F" );
580 BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
582 setupSmallButton( extSettingsButton );
583 controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom );
585 controlLayout->setColumnStretch( 13, 0 );
586 controlLayout->setColumnMinimumWidth( 13, 24 );
587 controlLayout->setColumnStretch( 14, 5 );
590 VolumeClickHandler *hVolLabel = new VolumeClickHandler( p_intf, this );
592 volMuteLabel = new QLabel;
593 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
594 volMuteLabel->setToolTip( qtr( "Mute" ) );
595 volMuteLabel->installEventFilter( hVolLabel );
596 controlLayout->addWidget( volMuteLabel, 3, 15, Qt::AlignBottom );
600 volumeSlider = new SoundSlider( this,
601 config_GetInt( p_intf, "volume-step" ),
602 config_GetInt( p_intf, "qt-volume-complete" ) );
606 volumeSlider = new QSlider( this );
607 volumeSlider->setOrientation( Qt::Horizontal );
609 volumeSlider->setMaximumSize( QSize( 200, 40 ) );
610 volumeSlider->setMinimumSize( QSize( 106, 30 ) );
611 volumeSlider->setFocusPolicy( Qt::NoFocus );
612 controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom );
614 /* Set the volume from the config */
615 volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
616 VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
618 /* Volume control connection */
619 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
622 ControlsWidget::~ControlsWidget()
625 void ControlsWidget::stop()
630 void ControlsWidget::play()
632 if( THEPL->current.i_size == 0 )
634 /* The playlist is empty, open a file requester */
635 THEDP->openFileDialog();
639 THEMIM->togglePlayPause();
642 void ControlsWidget::prev()
647 void ControlsWidget::next()
652 void ControlsWidget::setNavigation( int navigation )
654 #define HELP_MENU N_( "Menu" )
655 #define HELP_PCH N_( "Previous chapter" )
656 #define HELP_NCH N_( "Next chapter" )
657 #define HELP_PTR N_( "Previous track" )
658 #define HELP_NTR N_( "Next track" )
660 // 1 = chapter, 2 = title, 0 = no
661 if( navigation == 0 )
664 } else if( navigation == 1 ) {
665 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
666 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
670 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
671 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
677 static bool b_my_volume;
678 void ControlsWidget::updateVolume( int i_sliderVolume )
682 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
683 aout_VolumeSet( p_intf, i_res );
685 if( i_sliderVolume == 0 )
686 volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
687 else if( i_sliderVolume < VOLUME_MAX / 3 )
688 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
689 else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
690 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
691 else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
694 void ControlsWidget::updateOnTimer()
697 audio_volume_t i_volume;
698 aout_VolumeGet( p_intf, &i_volume );
699 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
700 int i_gauge = volumeSlider->value();
702 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
705 volumeSlider->setValue( i_volume );
709 /* Activate the interface buttons according to the presence of the input */
710 enableInput( THEMIM->getIM()->hasInput() );
711 //enableVideo( THEMIM->getIM()->hasVideo() );
715 void ControlsWidget::setStatus( int status )
717 if( status == PLAYING_S ) // Playing
718 playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
720 playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
725 * This functions toggle the fullscreen mode
726 * If there is no video, it should first activate Visualisations...
727 * This has also to be fixed in enableVideo()
729 void ControlsWidget::fullscreen()
731 vout_thread_t *p_vout =
732 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
735 var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
736 vlc_object_release( p_vout );
740 void ControlsWidget::extSettings()
742 THEDP->extendedDialog();
745 void ControlsWidget::slower()
747 THEMIM->getIM()->slower();
750 void ControlsWidget::faster()
752 THEMIM->getIM()->faster();
755 void ControlsWidget::enableInput( bool enable )
757 slowerButton->setEnabled( enable );
758 slider->setEnabled( enable );
759 fasterButton->setEnabled( enable );
761 /* Advanced Buttons too */
762 advControls->enableInput( enable );
765 void ControlsWidget::enableVideo( bool enable )
767 // TODO Later make the fullscreenButton toggle Visualisation and so on.
768 fullscreenButton->setEnabled( enable );
770 /* Advanced Buttons too */
771 advControls->enableVideo( enable );
774 void ControlsWidget::toggleAdvanced()
776 if( !VISIBLE( advControls ) )
779 b_advancedVisible = true;
784 b_advancedVisible = false;
786 emit advancedControlsToggled( b_advancedVisible );
790 /**********************************************************************
791 * Speed control widget
792 **********************************************************************/
793 SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :
794 QFrame( NULL ), p_intf( _p_i )
796 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
797 sizePolicy.setHorizontalStretch( 0 );
798 sizePolicy.setVerticalStretch( 0 );
800 speedSlider = new QSlider;
801 speedSlider->setSizePolicy( sizePolicy );
802 speedSlider->setMaximumSize( QSize( 80, 200 ) );
803 speedSlider->setOrientation( Qt::Vertical );
804 speedSlider->setTickPosition( QSlider::TicksRight );
806 speedSlider->setRange( -100, 100 );
807 speedSlider->setSingleStep( 10 );
808 speedSlider->setPageStep( 20 );
809 speedSlider->setTickInterval( 20 );
811 CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
813 QToolButton *normalSpeedButton = new QToolButton( this );
814 normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
815 normalSpeedButton->setAutoRaise( true );
816 normalSpeedButton->setText( "N" );
817 normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
819 CONNECT( normalSpeedButton, clicked(), this, resetRate() );
821 QVBoxLayout *speedControlLayout = new QVBoxLayout;
822 speedControlLayout->addWidget( speedSlider );
823 speedControlLayout->addWidget( normalSpeedButton );
824 setLayout( speedControlLayout );
827 SpeedControlWidget::~SpeedControlWidget()
830 #define RATE_SLIDER_MAXIMUM 3.0
831 #define RATE_SLIDER_MINIMUM 0.3
832 #define RATE_SLIDER_LENGTH 100.0
834 void SpeedControlWidget::updateControls( int rate )
836 if( speedSlider->isSliderDown() )
838 //We don't want to change anything if the user is using the slider
843 double speed = INPUT_RATE_DEFAULT / (double)rate;
845 if( rate >= INPUT_RATE_DEFAULT )
847 if( speed < RATE_SLIDER_MINIMUM )
849 sliderValue = speedSlider->minimum();
853 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
854 / ( 1.0 - RATE_SLIDER_MAXIMUM ) );
859 if( speed > RATE_SLIDER_MAXIMUM )
861 sliderValue = speedSlider->maximum();
865 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
866 / ( RATE_SLIDER_MAXIMUM - 1.0 ) );
870 //Block signals to avoid feedback loop
871 speedSlider->blockSignals( true );
872 speedSlider->setValue( sliderValue );
873 speedSlider->blockSignals( false );
876 void SpeedControlWidget::updateRate( int sliderValue )
880 if( sliderValue < 0.0 )
882 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
883 ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH );
887 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
888 ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH );
891 THEMIM->getIM()->setRate(rate);
894 void SpeedControlWidget::resetRate()
896 THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);