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 *), this, update( input_thread_t * ) );
166 BackgroundWidget::~BackgroundWidget()
171 void BackgroundWidget::update( input_thread_t *p_input )
173 if( !p_input || p_input->b_dead )
175 if( QDate::currentDate().dayOfYear() >= 354 )
176 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
178 label->setPixmap( QPixmap( ":/vlc128.png" ) );
183 vlc_object_yield( p_input );
184 char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
185 vlc_object_release( p_input );
186 QString url = qfu( psz_arturl );
187 QString arturl = url.replace( "file://",QString("" ) );
188 if( arturl.isNull() )
190 if( QDate::currentDate().dayOfYear() >= 354 )
191 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
193 label->setPixmap( QPixmap( ":/vlc128.png" ) );
197 label->setPixmap( QPixmap( arturl ) );
198 msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
203 QSize BackgroundWidget::sizeHint() const
205 return label->size();
208 void BackgroundWidget::resizeEvent( QResizeEvent *e )
210 if( e->size().height() < MAX_BG_SIZE -1 )
212 label->setMaximumWidth( e->size().height() );
213 label->setMaximumHeight( e->size().width() );
217 label->setMaximumHeight( MAX_BG_SIZE );
218 label->setMaximumWidth( MAX_BG_SIZE );
222 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
224 QVLCMenu::PopupMenu( p_intf, true );
227 /**********************************************************************
228 * Visualization selector panel
229 **********************************************************************/
230 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
231 QFrame( NULL ), p_intf( _p_i )
233 QHBoxLayout *layout = new QHBoxLayout( this );
234 layout->setMargin( 0 );
235 QPushButton *prevButton = new QPushButton( "Prev" );
236 QPushButton *nextButton = new QPushButton( "Next" );
237 layout->addWidget( prevButton );
238 layout->addWidget( nextButton );
240 layout->addItem( new QSpacerItem( 40,20,
241 QSizePolicy::Expanding, QSizePolicy::Minimum ) );
242 layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
244 current = new QLabel( qtr( "None" ) );
245 layout->addWidget( current );
247 BUTTONACT( prevButton, prev() );
248 BUTTONACT( nextButton, next() );
251 setMaximumHeight( 35 );
254 VisualSelector::~VisualSelector()
258 void VisualSelector::prev()
260 char *psz_new = aout_VisualPrev( p_intf );
263 current->setText( qfu( psz_new ) );
268 void VisualSelector::next()
270 char *psz_new = aout_VisualNext( p_intf );
273 current->setText( qfu( psz_new ) );
278 /**********************************************************************
280 **********************************************************************/
282 #define setupSmallButton( aButton ){ \
283 aButton->setMaximumSize( QSize( 26, 26 ) ); \
284 aButton->setMinimumSize( QSize( 26, 26 ) ); \
285 aButton->setIconSize( QSize( 20, 20 ) ); }
287 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
288 QFrame( NULL ), p_intf( _p_i )
290 QHBoxLayout *advLayout = new QHBoxLayout( this );
291 advLayout->setMargin( 0 );
292 advLayout->setSpacing( 0 );
295 ABButton = new QPushButton( "AB" );
296 ABButton->setMaximumSize( QSize( 26, 26 ) );
297 ABButton->setIconSize( QSize( 20, 20 ) );
298 advLayout->addWidget( ABButton );
299 BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
301 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
302 this, AtoBLoop( float, int, int ) );
304 frameButton = new QPushButton( "Fr" );
305 frameButton->setMaximumSize( QSize( 26, 26 ) );
306 frameButton->setIconSize( QSize( 20, 20 ) );
307 advLayout->addWidget( frameButton );
308 BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
310 recordButton = new QPushButton( "R" );
311 recordButton->setMaximumSize( QSize( 26, 26 ) );
312 recordButton->setIconSize( QSize( 20, 20 ) );
313 advLayout->addWidget( recordButton );
314 BUTTON_SET_ACT_I( recordButton, "", record_16px.png,
315 qtr( "Record" ), record() );
317 /* Snapshot Button */
318 snapshotButton = new QPushButton( "S" );
319 snapshotButton->setMaximumSize( QSize( 26, 26 ) );
320 snapshotButton->setIconSize( QSize( 20, 20 ) );
321 advLayout->addWidget( snapshotButton );
322 BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
325 AdvControlsWidget::~AdvControlsWidget()
328 void AdvControlsWidget::enableInput( bool enable )
330 ABButton->setEnabled( enable );
331 recordButton->setEnabled( enable );
334 void AdvControlsWidget::enableVideo( bool enable )
336 snapshotButton->setEnabled( enable );
337 frameButton->setEnabled( enable );
340 void AdvControlsWidget::snapshot()
342 vout_thread_t *p_vout =
343 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
344 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
347 /* Function called when the button is clicked() */
348 void AdvControlsWidget::fromAtoB()
352 timeA = var_GetTime( THEMIM->getInput(), "time" );
353 ABButton->setText( "A->..." );
358 timeB = var_GetTime( THEMIM->getInput(), "time" );
359 var_SetTime( THEMIM->getInput(), "time" , timeA );
360 ABButton->setText( "A<=>B" );
365 ABButton->setText( "AB" );
368 /* Function called regularly when in an AtoB loop */
369 void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
373 if( i_time >= (int)(timeB/1000000) )
374 var_SetTime( THEMIM->getInput(), "time" , timeA );
378 /* FIXME Record function */
379 void AdvControlsWidget::record(){}
381 //FIXME Frame by frame function
382 void AdvControlsWidget::frame(){}
384 /*****************************
385 * DA Control Widget !
386 *****************************/
387 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
388 MainInterface *_p_mi,
391 QFrame( NULL ), p_intf( _p_i )
393 controlLayout = new QGridLayout( this );
394 controlLayout->setSpacing( 0 );
396 controlLayout->setContentsMargins( 9, 6, 9, 6 );
398 controlLayout->setMargin( 6 );
401 setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
403 /** The main Slider **/
404 slider = new InputSlider( Qt::Horizontal, NULL );
405 controlLayout->addWidget( slider, 0, 1, 1, 16 );
406 /* Update the position when the IM has changed */
407 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
408 slider, setPosition( float, int, int ) );
409 /* And update the IM, when the position has changed */
410 CONNECT( slider, sliderDragged( float ),
411 THEMIM->getIM(), sliderUpdate( float ) );
413 /** Slower and faster Buttons **/
414 slowerButton = new QToolButton;
415 slowerButton->setAutoRaise( true );
416 slowerButton->setMaximumSize( QSize( 26, 20 ) );
418 BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
419 controlLayout->addWidget( slowerButton, 0, 0 );
421 fasterButton = new QToolButton;
422 fasterButton->setAutoRaise( true );
423 fasterButton->setMaximumSize( QSize( 26, 20 ) );
425 BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
426 controlLayout->addWidget( fasterButton, 0, 17 );
428 /* advanced Controls handling */
429 b_advancedVisible = b_advControls;
431 advControls = new AdvControlsWidget( p_intf );
432 controlLayout->addWidget( advControls, 1, 3, 2, 4, Qt::AlignBottom );
433 if( !b_advancedVisible ) advControls->hide();
435 /** Disc and Menus handling */
436 discFrame = new QWidget( this );
438 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
439 discLayout->setSpacing( 0 );
440 discLayout->setMargin( 0 );
442 prevSectionButton = new QPushButton( discFrame );
443 setupSmallButton( prevSectionButton );
444 discLayout->addWidget( prevSectionButton );
446 menuButton = new QPushButton( discFrame );
447 setupSmallButton( menuButton );
448 discLayout->addWidget( menuButton );
450 nextSectionButton = new QPushButton( discFrame );
451 setupSmallButton( nextSectionButton );
452 discLayout->addWidget( nextSectionButton );
454 controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
456 BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
457 BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
458 BUTTON_SET_IMG( menuButton, "", previous.png, "" );
462 /* Change the navigation button display when the IM navigation changes */
463 CONNECT( THEMIM->getIM(), navigationChanged( int ),
464 this, setNavigation( int ) );
465 /* Changes the IM navigation when triggered on the nav buttons */
466 CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
468 CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
470 CONNECT( menuButton, clicked(), THEMIM->getIM(),
474 * TODO: Merge with upper menu in a StackLayout
477 telexFrame = new QWidget( this );
478 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
479 telexLayout->setSpacing( 0 );
480 telexLayout->setMargin( 0 );
482 QToolButton *telexOn = new QToolButton;
483 telexOn->setText( qtr( "On" ) );
484 setupSmallButton( telexOn );
485 telexLayout->addWidget( telexOn );
487 QToolButton *telexTransparent = new QToolButton;
488 telexTransparent->setText( qtr( "Transparent" ) );
489 setupSmallButton( telexTransparent );
490 telexLayout->addWidget( telexTransparent );
492 QSpinBox *telexPage = new QSpinBox;
493 telexPage->setRange( 0, 999 );
494 telexPage->setValue( 100 );
495 telexPage->setAlignment( Qt::AlignRight );
496 telexLayout->addWidget( telexPage );
498 controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
501 CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
502 telexGotoPage( int ) );
503 CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
504 telexToggle( bool ) );
505 CONNECT( telexTransparent, clicked( bool ),
506 THEMIM->getIM(), telexSetTransparency( bool ) );
507 CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
508 telexFrame, setVisible( bool ) );
512 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
513 sizePolicy.setHorizontalStretch( 0 );
514 sizePolicy.setVerticalStretch( 0 );
517 playButton = new QPushButton;
518 playButton->setSizePolicy( sizePolicy );
519 playButton->setMaximumSize( QSize( 36, 36 ) );
520 playButton->setMinimumSize( QSize( 36, 36 ) );
521 playButton->setIconSize( QSize( 30, 30 ) );
523 controlLayout->addWidget( playButton, 2, 0, 2, 2 );
525 controlLayout->setColumnMinimumWidth( 2, 20 );
526 controlLayout->setColumnStretch( 2, 0 );
528 /** Prev + Stop + Next Block **/
529 QHBoxLayout *controlButLayout = new QHBoxLayout;
530 controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
533 QPushButton *prevButton = new QPushButton;
534 prevButton->setSizePolicy( sizePolicy );
535 setupSmallButton( prevButton );
537 controlButLayout->addWidget( prevButton );
540 QPushButton *stopButton = new QPushButton;
541 stopButton->setSizePolicy( sizePolicy );
542 setupSmallButton( stopButton );
544 controlButLayout->addWidget( stopButton );
547 QPushButton *nextButton = new QPushButton;
548 nextButton->setSizePolicy( sizePolicy );
549 setupSmallButton( nextButton );
551 controlButLayout->addWidget( nextButton );
553 /* Add this block to the main layout */
554 controlLayout->addLayout( controlButLayout, 3, 3, 1, 3, Qt::AlignBottom );
556 BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
557 BUTTON_SET_ACT_I( prevButton, "" , previous.png,
558 qtr( "Previous" ), prev() );
559 BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
560 BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
562 controlLayout->setColumnMinimumWidth( 7, 20 );
563 controlLayout->setColumnStretch( 7, 0 );
564 controlLayout->setColumnStretch( 8, 0 );
565 controlLayout->setColumnStretch( 9, 0 );
568 * Other first Line buttons
570 /** Fullscreen/Visualisation **/
571 fullscreenButton = new QPushButton( "F" );
572 BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
573 setupSmallButton( fullscreenButton );
574 controlLayout->addWidget( fullscreenButton, 3, 10, Qt::AlignBottom );
576 /** Playlist Button **/
577 playlistButton = new QPushButton;
578 setupSmallButton( playlistButton );
579 controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
580 BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
581 CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
583 /** extended Settings **/
584 QPushButton *extSettingsButton = new QPushButton( "F" );
585 BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
587 setupSmallButton( extSettingsButton );
588 controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom );
590 controlLayout->setColumnStretch( 13, 0 );
591 controlLayout->setColumnMinimumWidth( 13, 24 );
592 controlLayout->setColumnStretch( 14, 5 );
595 VolumeClickHandler *hVolLabel = new VolumeClickHandler( p_intf, this );
597 volMuteLabel = new QLabel;
598 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
599 volMuteLabel->setToolTip( qtr( "Mute" ) );
600 volMuteLabel->installEventFilter( hVolLabel );
601 controlLayout->addWidget( volMuteLabel, 3, 15, Qt::AlignBottom );
605 volumeSlider = new SoundSlider( this,
606 config_GetInt( p_intf, "volume-step" ),
607 config_GetInt( p_intf, "qt-volume-complete" ) );
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 /* Volume control connection */
624 //resize( QSize( 300, 60 ) );
625 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
626 msg_Dbg( p_intf, "controls size: %i - %i", size().width(), size().height() );
629 ControlsWidget::~ControlsWidget()
633 QSize ControlsWidget::sizeHint() const
635 return QSize( 300, 50 );
639 void ControlsWidget::stop()
644 void ControlsWidget::play()
646 if( THEPL->current.i_size == 0 )
648 /* The playlist is empty, open a file requester */
649 THEDP->openFileDialog();
653 THEMIM->togglePlayPause();
656 void ControlsWidget::prev()
661 void ControlsWidget::next()
666 void ControlsWidget::setNavigation( int navigation )
668 #define HELP_MENU N_( "Menu" )
669 #define HELP_PCH N_( "Previous chapter" )
670 #define HELP_NCH N_( "Next chapter" )
671 #define HELP_PTR N_( "Previous track" )
672 #define HELP_NTR N_( "Next track" )
674 // 1 = chapter, 2 = title, 0 = no
675 if( navigation == 0 )
678 } else if( navigation == 1 ) {
679 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
680 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
684 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
685 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
691 static bool b_my_volume;
692 void ControlsWidget::updateVolume( int i_sliderVolume )
696 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
697 aout_VolumeSet( p_intf, i_res );
699 if( i_sliderVolume == 0 )
700 volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
701 else if( i_sliderVolume < VOLUME_MAX / 2 )
702 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
703 else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
706 void ControlsWidget::updateOnTimer()
709 audio_volume_t i_volume;
710 aout_VolumeGet( p_intf, &i_volume );
711 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
712 int i_gauge = volumeSlider->value();
714 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
717 volumeSlider->setValue( i_volume );
721 /* Activate the interface buttons according to the presence of the input */
722 enableInput( THEMIM->getIM()->hasInput() );
723 //enableVideo( THEMIM->getIM()->hasVideo() );
727 void ControlsWidget::setStatus( int status )
729 if( status == PLAYING_S ) // Playing
730 playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
732 playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
737 * This functions toggle the fullscreen mode
738 * If there is no video, it should first activate Visualisations...
739 * This has also to be fixed in enableVideo()
741 void ControlsWidget::fullscreen()
743 vout_thread_t *p_vout =
744 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
747 var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
748 vlc_object_release( p_vout );
752 void ControlsWidget::extSettings()
754 THEDP->extendedDialog();
757 void ControlsWidget::slower()
759 THEMIM->getIM()->slower();
762 void ControlsWidget::faster()
764 THEMIM->getIM()->faster();
767 void ControlsWidget::enableInput( bool enable )
769 slowerButton->setEnabled( enable );
770 slider->setEnabled( enable );
771 fasterButton->setEnabled( enable );
773 /* Advanced Buttons too */
774 advControls->enableInput( enable );
777 void ControlsWidget::enableVideo( bool enable )
779 // TODO Later make the fullscreenButton toggle Visualisation and so on.
780 fullscreenButton->setEnabled( enable );
782 /* Advanced Buttons too */
783 advControls->enableVideo( enable );
786 void ControlsWidget::toggleAdvanced()
788 if( !VISIBLE( advControls ) )
791 b_advancedVisible = true;
796 b_advancedVisible = false;
798 emit advancedControlsToggled( b_advancedVisible );
802 /**********************************************************************
803 * Speed control widget
804 **********************************************************************/
805 SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :
806 QFrame( NULL ), p_intf( _p_i )
808 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
809 sizePolicy.setHorizontalStretch( 0 );
810 sizePolicy.setVerticalStretch( 0 );
812 speedSlider = new QSlider;
813 speedSlider->setSizePolicy( sizePolicy );
814 speedSlider->setMaximumSize( QSize( 80, 200 ) );
815 speedSlider->setOrientation( Qt::Vertical );
816 speedSlider->setTickPosition( QSlider::TicksRight );
818 speedSlider->setRange( -100, 100 );
819 speedSlider->setSingleStep( 10 );
820 speedSlider->setPageStep( 20 );
821 speedSlider->setTickInterval( 20 );
823 CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
825 QToolButton *normalSpeedButton = new QToolButton( this );
826 normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
827 normalSpeedButton->setAutoRaise( true );
828 normalSpeedButton->setText( "N" );
829 normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
831 CONNECT( normalSpeedButton, clicked(), this, resetRate() );
833 QVBoxLayout *speedControlLayout = new QVBoxLayout;
834 speedControlLayout->addWidget( speedSlider );
835 speedControlLayout->addWidget( normalSpeedButton );
836 setLayout( speedControlLayout );
839 SpeedControlWidget::~SpeedControlWidget()
842 #define RATE_SLIDER_MAXIMUM 3.0
843 #define RATE_SLIDER_MINIMUM 0.3
844 #define RATE_SLIDER_LENGTH 100.0
846 void SpeedControlWidget::updateControls( int rate )
848 if( speedSlider->isSliderDown() )
850 //We don't want to change anything if the user is using the slider
855 double speed = INPUT_RATE_DEFAULT / (double)rate;
857 if( rate >= INPUT_RATE_DEFAULT )
859 if( speed < RATE_SLIDER_MINIMUM )
861 sliderValue = speedSlider->minimum();
865 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
866 / ( 1.0 - RATE_SLIDER_MAXIMUM ) );
871 if( speed > RATE_SLIDER_MAXIMUM )
873 sliderValue = speedSlider->maximum();
877 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
878 / ( RATE_SLIDER_MAXIMUM - 1.0 ) );
882 //Block signals to avoid feedback loop
883 speedSlider->blockSignals( true );
884 speedSlider->setValue( sliderValue );
885 speedSlider->blockSignals( false );
888 void SpeedControlWidget::updateRate( int sliderValue )
892 if( sliderValue < 0.0 )
894 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
895 ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH );
899 rate = INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
900 ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH );
903 THEMIM->getIM()->setRate(rate);
906 void SpeedControlWidget::resetRate()
908 THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);