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 );
87 QSize VideoWidget::sizeHint() const
93 * Request the video to avoid the conflicts
95 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
96 unsigned int *pi_width, unsigned int *pi_height )
98 emit askVideoWidgetToShow();
101 msg_Dbg( p_intf, "embedded video already in use" );
105 return ( void* )winId();
108 /* Set the Widget to the correct Size */
109 void VideoWidget::SetSizing( unsigned int w, unsigned int h )
111 widgetSize = QSize( w, h );
113 //updateGeometry(); // Needed for deinterlace
114 msg_Dbg( p_intf, "%i %i", sizeHint().height(), sizeHint().width() );
118 void VideoWidget::release( void *p_win )
124 /**********************************************************************
125 * Background Widget. Show a simple image background. Currently,
126 * it's a static cone.
127 **********************************************************************/
128 #define ICON_SIZE 128
129 #define MAX_BG_SIZE 400
130 #define MIN_BG_SIZE 64
132 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
133 QFrame( NULL ), p_intf( _p_i )
135 /* We should use that one to take the more size it can */
136 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
138 /* A dark background */
139 setAutoFillBackground( true );
141 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
142 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
145 /* A cone in the middle */
147 label->setScaledContents( true );
148 label->setMargin( 5 );
149 label->setMaximumHeight( MAX_BG_SIZE );
150 label->setMaximumWidth( MAX_BG_SIZE );
151 label->setMinimumHeight( MIN_BG_SIZE );
152 label->setMinimumWidth( MIN_BG_SIZE );
153 if( QDate::currentDate().dayOfYear() >= 354 )
154 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
156 label->setPixmap( QPixmap( ":/vlc128.png" ) );
158 QHBoxLayout *backgroundLayout = new QHBoxLayout( this );
159 backgroundLayout->addWidget( label );
163 CONNECT( THEMIM, inputChanged( input_thread_t *),
164 this, update( input_thread_t * ) );
167 BackgroundWidget::~BackgroundWidget()
172 void BackgroundWidget::update( input_thread_t *p_input )
174 if( !p_input || p_input->b_dead )
176 if( QDate::currentDate().dayOfYear() >= 354 )
177 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
179 label->setPixmap( QPixmap( ":/vlc128.png" ) );
184 vlc_object_yield( p_input );
185 char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
186 vlc_object_release( p_input );
187 QString url = qfu( psz_arturl );
188 QString arturl = url.replace( "file://",QString("" ) );
189 if( arturl.isNull() )
191 if( QDate::currentDate().dayOfYear() >= 354 )
192 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
194 label->setPixmap( QPixmap( ":/vlc128.png" ) );
198 label->setPixmap( QPixmap( arturl ) );
199 msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
204 QSize BackgroundWidget::sizeHint() const
206 return label->size();
209 void BackgroundWidget::resizeEvent( QResizeEvent *e )
211 if( e->size().height() < MAX_BG_SIZE -1 )
213 label->setMaximumWidth( e->size().height() );
214 label->setMaximumHeight( e->size().width() );
218 label->setMaximumHeight( MAX_BG_SIZE );
219 label->setMaximumWidth( MAX_BG_SIZE );
223 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
225 QVLCMenu::PopupMenu( p_intf, true );
228 /**********************************************************************
229 * Visualization selector panel
230 **********************************************************************/
231 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
232 QFrame( NULL ), p_intf( _p_i )
234 QHBoxLayout *layout = new QHBoxLayout( this );
235 layout->setMargin( 0 );
236 QPushButton *prevButton = new QPushButton( "Prev" );
237 QPushButton *nextButton = new QPushButton( "Next" );
238 layout->addWidget( prevButton );
239 layout->addWidget( nextButton );
241 layout->addItem( new QSpacerItem( 40,20,
242 QSizePolicy::Expanding, QSizePolicy::Minimum ) );
243 layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
245 current = new QLabel( qtr( "None" ) );
246 layout->addWidget( current );
248 BUTTONACT( prevButton, prev() );
249 BUTTONACT( nextButton, next() );
252 setMaximumHeight( 35 );
255 VisualSelector::~VisualSelector()
259 void VisualSelector::prev()
261 char *psz_new = aout_VisualPrev( p_intf );
264 current->setText( qfu( psz_new ) );
269 void VisualSelector::next()
271 char *psz_new = aout_VisualNext( p_intf );
274 current->setText( qfu( psz_new ) );
279 /**********************************************************************
281 **********************************************************************/
283 #define setupSmallButton( aButton ){ \
284 aButton->setMaximumSize( QSize( 26, 26 ) ); \
285 aButton->setMinimumSize( QSize( 26, 26 ) ); \
286 aButton->setIconSize( QSize( 20, 20 ) ); }
288 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
289 QFrame( NULL ), p_intf( _p_i )
291 QHBoxLayout *advLayout = new QHBoxLayout( this );
292 advLayout->setMargin( 0 );
293 advLayout->setSpacing( 0 );
296 ABButton = new QPushButton( "AB" );
297 ABButton->setMaximumSize( QSize( 26, 26 ) );
298 ABButton->setIconSize( QSize( 20, 20 ) );
299 advLayout->addWidget( ABButton );
300 BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
302 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
303 this, AtoBLoop( float, int, int ) );
305 frameButton = new QPushButton( "Fr" );
306 frameButton->setMaximumSize( QSize( 26, 26 ) );
307 frameButton->setIconSize( QSize( 20, 20 ) );
308 advLayout->addWidget( frameButton );
309 BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
311 recordButton = new QPushButton( "R" );
312 recordButton->setMaximumSize( QSize( 26, 26 ) );
313 recordButton->setIconSize( QSize( 20, 20 ) );
314 advLayout->addWidget( recordButton );
315 BUTTON_SET_ACT_I( recordButton, "", record_16px.png,
316 qtr( "Record" ), record() );
318 /* Snapshot Button */
319 snapshotButton = new QPushButton( "S" );
320 snapshotButton->setMaximumSize( QSize( 26, 26 ) );
321 snapshotButton->setIconSize( QSize( 20, 20 ) );
322 advLayout->addWidget( snapshotButton );
323 BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
326 AdvControlsWidget::~AdvControlsWidget()
329 void AdvControlsWidget::enableInput( bool enable )
331 ABButton->setEnabled( enable );
332 recordButton->setEnabled( enable );
335 void AdvControlsWidget::enableVideo( bool enable )
337 snapshotButton->setEnabled( enable );
338 frameButton->setEnabled( enable );
341 void AdvControlsWidget::snapshot()
343 vout_thread_t *p_vout =
344 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
345 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
348 /* Function called when the button is clicked() */
349 void AdvControlsWidget::fromAtoB()
353 timeA = var_GetTime( THEMIM->getInput(), "time" );
354 ABButton->setText( "A->..." );
359 timeB = var_GetTime( THEMIM->getInput(), "time" );
360 var_SetTime( THEMIM->getInput(), "time" , timeA );
361 ABButton->setText( "A<=>B" );
366 ABButton->setText( "AB" );
369 /* Function called regularly when in an AtoB loop */
370 void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
374 if( i_time >= (int)(timeB/1000000) )
375 var_SetTime( THEMIM->getInput(), "time" , timeA );
379 /* FIXME Record function */
380 void AdvControlsWidget::record(){}
382 //FIXME Frame by frame function
383 void AdvControlsWidget::frame(){}
385 /*****************************
386 * DA Control Widget !
387 *****************************/
388 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
389 MainInterface *_p_mi,
392 QFrame( NULL ), p_intf( _p_i )
394 controlLayout = new QGridLayout( this );
395 controlLayout->setSpacing( 0 );
397 controlLayout->setContentsMargins( 9, 6, 9, 6 );
399 controlLayout->setMargin( 6 );
402 setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
404 /** The main Slider **/
405 slider = new InputSlider( Qt::Horizontal, NULL );
406 controlLayout->addWidget( slider, 0, 1, 1, 16 );
407 /* Update the position when the IM has changed */
408 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
409 slider, setPosition( float, int, int ) );
410 /* And update the IM, when the position has changed */
411 CONNECT( slider, sliderDragged( float ),
412 THEMIM->getIM(), sliderUpdate( float ) );
414 /** Slower and faster Buttons **/
415 slowerButton = new QToolButton;
416 slowerButton->setAutoRaise( true );
417 slowerButton->setMaximumSize( QSize( 26, 20 ) );
419 BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
420 controlLayout->addWidget( slowerButton, 0, 0 );
422 fasterButton = new QToolButton;
423 fasterButton->setAutoRaise( true );
424 fasterButton->setMaximumSize( QSize( 26, 20 ) );
426 BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
427 controlLayout->addWidget( fasterButton, 0, 17 );
429 /* advanced Controls handling */
430 b_advancedVisible = b_advControls;
432 advControls = new AdvControlsWidget( p_intf );
433 controlLayout->addWidget( advControls, 1, 3, 2, 4, Qt::AlignBottom );
434 if( !b_advancedVisible ) advControls->hide();
436 /** Disc and Menus handling */
437 discFrame = new QWidget( this );
439 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
440 discLayout->setSpacing( 0 );
441 discLayout->setMargin( 0 );
443 prevSectionButton = new QPushButton( discFrame );
444 setupSmallButton( prevSectionButton );
445 discLayout->addWidget( prevSectionButton );
447 menuButton = new QPushButton( discFrame );
448 setupSmallButton( menuButton );
449 discLayout->addWidget( menuButton );
451 nextSectionButton = new QPushButton( discFrame );
452 setupSmallButton( nextSectionButton );
453 discLayout->addWidget( nextSectionButton );
455 controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
457 BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
458 BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
459 BUTTON_SET_IMG( menuButton, "", previous.png, "" );
463 /* Change the navigation button display when the IM navigation changes */
464 CONNECT( THEMIM->getIM(), navigationChanged( int ),
465 this, setNavigation( int ) );
466 /* Changes the IM navigation when triggered on the nav buttons */
467 CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
469 CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
471 CONNECT( menuButton, clicked(), THEMIM->getIM(),
475 * TODO: Merge with upper menu in a StackLayout
478 telexFrame = new QWidget( this );
479 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
480 telexLayout->setSpacing( 0 );
481 telexLayout->setMargin( 0 );
483 QToolButton *telexOn = new QToolButton;
484 telexOn->setText( qtr( "On" ) );
485 setupSmallButton( telexOn );
486 telexLayout->addWidget( telexOn );
488 QToolButton *telexTransparent = new QToolButton;
489 telexTransparent->setText( qtr( "Transparent" ) );
490 setupSmallButton( telexTransparent );
491 telexLayout->addWidget( telexTransparent );
493 QSpinBox *telexPage = new QSpinBox;
494 telexPage->setRange( 0, 999 );
495 telexPage->setValue( 100 );
496 telexPage->setAlignment( Qt::AlignRight );
497 telexLayout->addWidget( telexPage );
499 controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
502 CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
503 telexGotoPage( int ) );
504 CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
505 telexToggle( bool ) );
506 CONNECT( telexTransparent, clicked( bool ),
507 THEMIM->getIM(), telexSetTransparency( bool ) );
508 CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
509 telexFrame, setVisible( bool ) );
513 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
514 sizePolicy.setHorizontalStretch( 0 );
515 sizePolicy.setVerticalStretch( 0 );
518 playButton = new QPushButton;
519 playButton->setSizePolicy( sizePolicy );
520 playButton->setMaximumSize( QSize( 36, 36 ) );
521 playButton->setMinimumSize( QSize( 36, 36 ) );
522 playButton->setIconSize( QSize( 30, 30 ) );
524 controlLayout->addWidget( playButton, 2, 0, 2, 2 );
526 controlLayout->setColumnMinimumWidth( 2, 20 );
527 controlLayout->setColumnStretch( 2, 0 );
529 /** Prev + Stop + Next Block **/
530 QHBoxLayout *controlButLayout = new QHBoxLayout;
531 controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
534 QPushButton *prevButton = new QPushButton;
535 prevButton->setSizePolicy( sizePolicy );
536 setupSmallButton( prevButton );
538 controlButLayout->addWidget( prevButton );
541 QPushButton *stopButton = new QPushButton;
542 stopButton->setSizePolicy( sizePolicy );
543 setupSmallButton( stopButton );
545 controlButLayout->addWidget( stopButton );
548 QPushButton *nextButton = new QPushButton;
549 nextButton->setSizePolicy( sizePolicy );
550 setupSmallButton( nextButton );
552 controlButLayout->addWidget( nextButton );
554 /* Add this block to the main layout */
555 controlLayout->addLayout( controlButLayout, 3, 3, 1, 3, Qt::AlignBottom );
557 BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
558 BUTTON_SET_ACT_I( prevButton, "" , previous.png,
559 qtr( "Previous" ), prev() );
560 BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
561 BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
563 controlLayout->setColumnMinimumWidth( 7, 20 );
564 controlLayout->setColumnStretch( 7, 0 );
565 controlLayout->setColumnStretch( 8, 0 );
566 controlLayout->setColumnStretch( 9, 0 );
569 * Other first Line buttons
571 /** Fullscreen/Visualisation **/
572 fullscreenButton = new QPushButton( "F" );
573 BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
574 setupSmallButton( fullscreenButton );
575 controlLayout->addWidget( fullscreenButton, 3, 10, Qt::AlignBottom );
577 /** Playlist Button **/
578 playlistButton = new QPushButton;
579 setupSmallButton( playlistButton );
580 controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
581 BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
582 CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
584 /** extended Settings **/
585 QPushButton *extSettingsButton = new QPushButton( "F" );
586 BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
588 setupSmallButton( extSettingsButton );
589 controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom );
591 controlLayout->setColumnStretch( 13, 0 );
592 controlLayout->setColumnMinimumWidth( 13, 24 );
593 controlLayout->setColumnStretch( 14, 5 );
596 VolumeClickHandler *hVolLabel = new VolumeClickHandler( p_intf, this );
598 volMuteLabel = new QLabel;
599 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
600 volMuteLabel->setToolTip( qtr( "Mute" ) );
601 volMuteLabel->installEventFilter( hVolLabel );
602 controlLayout->addWidget( volMuteLabel, 3, 15, Qt::AlignBottom );
606 volumeSlider = new SoundSlider( this,
607 config_GetInt( p_intf, "volume-step" ),
608 config_GetInt( p_intf, "qt-volume-complete" ) );
612 volumeSlider = new QSlider( this );
613 volumeSlider->setOrientation( Qt::Horizontal );
615 volumeSlider->setMaximumSize( QSize( 200, 40 ) );
616 volumeSlider->setMinimumSize( QSize( 106, 30 ) );
617 volumeSlider->setFocusPolicy( Qt::NoFocus );
618 controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom );
620 /* Set the volume from the config */
621 volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
622 VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
624 /* Volume control connection */
625 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
628 ControlsWidget::~ControlsWidget()
631 void ControlsWidget::stop()
636 void ControlsWidget::play()
638 if( THEPL->current.i_size == 0 )
640 /* The playlist is empty, open a file requester */
641 THEDP->openFileDialog();
645 THEMIM->togglePlayPause();
648 void ControlsWidget::prev()
653 void ControlsWidget::next()
658 void ControlsWidget::setNavigation( int navigation )
660 #define HELP_MENU N_( "Menu" )
661 #define HELP_PCH N_( "Previous chapter" )
662 #define HELP_NCH N_( "Next chapter" )
663 #define HELP_PTR N_( "Previous track" )
664 #define HELP_NTR N_( "Next track" )
666 // 1 = chapter, 2 = title, 0 = no
667 if( navigation == 0 )
670 } else if( navigation == 1 ) {
671 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
672 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
676 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
677 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
683 static bool b_my_volume;
684 void ControlsWidget::updateVolume( int i_sliderVolume )
688 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
689 aout_VolumeSet( p_intf, i_res );
691 if( i_sliderVolume == 0 )
692 volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
693 else if( i_sliderVolume < VOLUME_MAX / 2 )
694 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
695 else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
698 void ControlsWidget::updateOnTimer()
701 audio_volume_t i_volume;
702 aout_VolumeGet( p_intf, &i_volume );
703 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
704 int i_gauge = volumeSlider->value();
706 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
709 volumeSlider->setValue( i_volume );
713 /* Activate the interface buttons according to the presence of the input */
714 enableInput( THEMIM->getIM()->hasInput() );
715 //enableVideo( THEMIM->getIM()->hasVideo() );
719 void ControlsWidget::setStatus( int status )
721 if( status == PLAYING_S ) // Playing
722 playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
724 playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
729 * This functions toggle the fullscreen mode
730 * If there is no video, it should first activate Visualisations...
731 * This has also to be fixed in enableVideo()
733 void ControlsWidget::fullscreen()
735 vout_thread_t *p_vout =
736 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
739 var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
740 vlc_object_release( p_vout );
744 void ControlsWidget::extSettings()
746 THEDP->extendedDialog();
749 void ControlsWidget::slower()
751 THEMIM->getIM()->slower();
754 void ControlsWidget::faster()
756 THEMIM->getIM()->faster();
759 void ControlsWidget::enableInput( bool enable )
761 slowerButton->setEnabled( enable );
762 slider->setEnabled( enable );
763 fasterButton->setEnabled( enable );
765 /* Advanced Buttons too */
766 advControls->enableInput( enable );
769 void ControlsWidget::enableVideo( bool enable )
771 // TODO Later make the fullscreenButton toggle Visualisation and so on.
772 fullscreenButton->setEnabled( enable );
774 /* Advanced Buttons too */
775 advControls->enableVideo( enable );
778 void ControlsWidget::toggleAdvanced()
780 if( !VISIBLE( advControls ) )
783 b_advancedVisible = true;
788 b_advancedVisible = false;
790 emit advancedControlsToggled( b_advancedVisible );
794 /**********************************************************************
795 * Speed control widget
796 **********************************************************************/
797 SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :
798 QFrame( NULL ), p_intf( _p_i )
800 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
801 sizePolicy.setHorizontalStretch( 0 );
802 sizePolicy.setVerticalStretch( 0 );
804 speedSlider = new QSlider;
805 speedSlider->setSizePolicy( sizePolicy );
806 speedSlider->setMaximumSize( QSize( 80, 200 ) );
807 speedSlider->setOrientation( Qt::Vertical );
808 speedSlider->setTickPosition( QSlider::TicksRight );
810 speedSlider->setRange( -100, 100 );
811 speedSlider->setSingleStep( 10 );
812 speedSlider->setPageStep( 20 );
813 speedSlider->setTickInterval( 20 );
815 CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
817 QToolButton *normalSpeedButton = new QToolButton( this );
818 normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
819 normalSpeedButton->setAutoRaise( true );
820 normalSpeedButton->setText( "N" );
821 normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
823 CONNECT( normalSpeedButton, clicked(), this, resetRate() );
825 QVBoxLayout *speedControlLayout = new QVBoxLayout;
826 speedControlLayout->addWidget( speedSlider );
827 speedControlLayout->addWidget( normalSpeedButton );
828 setLayout( speedControlLayout );
831 SpeedControlWidget::~SpeedControlWidget()
834 #define RATE_SLIDER_MAXIMUM 3.0
835 #define RATE_SLIDER_MINIMUM 0.3
836 #define RATE_SLIDER_LENGTH 100.0
838 void SpeedControlWidget::updateControls( int rate )
840 if( speedSlider->isSliderDown() )
842 //We don't want to change anything if the user is using the slider
847 double speed = INPUT_RATE_DEFAULT / (double)rate;
849 if( rate >= INPUT_RATE_DEFAULT )
851 if( speed < RATE_SLIDER_MINIMUM )
853 sliderValue = speedSlider->minimum();
857 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
858 / ( 1.0 - RATE_SLIDER_MAXIMUM ) );
863 if( speed > RATE_SLIDER_MAXIMUM )
865 sliderValue = speedSlider->maximum();
869 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
870 / ( RATE_SLIDER_MAXIMUM - 1.0 ) );
874 //Block signals to avoid feedback loop
875 speedSlider->blockSignals( true );
876 speedSlider->setValue( sliderValue );
877 speedSlider->blockSignals( false );
880 void SpeedControlWidget::updateRate( int sliderValue )
884 if( sliderValue < 0.0 )
886 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
887 ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH );
891 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
892 ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH );
895 THEMIM->getIM()->setRate(rate);
898 void SpeedControlWidget::resetRate()
900 THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);