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, update( QString ) );
185 BackgroundWidget::~BackgroundWidget()
189 void BackgroundWidget::update( QString url )
193 if( QDate::currentDate().dayOfYear() >= 354 )
194 label->setPixmap( QPixmap( ":/vlc128-christmas.png" ) );
196 label->setPixmap( QPixmap( ":/vlc128.png" ) );
201 label->setPixmap( QPixmap( url ) );
202 msg_Dbg( p_intf, "changing input b_need_update done ");
206 void BackgroundWidget::contextMenuEvent( QContextMenuEvent *event )
208 QVLCMenu::PopupMenu( p_intf, true );
211 /**********************************************************************
212 * Visualization selector panel
213 **********************************************************************/
214 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
215 QFrame( NULL ), p_intf( _p_i )
217 QHBoxLayout *layout = new QHBoxLayout( this );
218 layout->setMargin( 0 );
219 QPushButton *prevButton = new QPushButton( "Prev" );
220 QPushButton *nextButton = new QPushButton( "Next" );
221 layout->addWidget( prevButton );
222 layout->addWidget( nextButton );
224 layout->addItem( new QSpacerItem( 40,20,
225 QSizePolicy::Expanding, QSizePolicy::Minimum ) );
226 layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
228 current = new QLabel( qtr( "None" ) );
229 layout->addWidget( current );
231 BUTTONACT( prevButton, prev() );
232 BUTTONACT( nextButton, next() );
235 setMaximumHeight( 35 );
238 VisualSelector::~VisualSelector()
242 void VisualSelector::prev()
244 char *psz_new = aout_VisualPrev( p_intf );
247 current->setText( qfu( psz_new ) );
252 void VisualSelector::next()
254 char *psz_new = aout_VisualNext( p_intf );
257 current->setText( qfu( psz_new ) );
262 /**********************************************************************
264 **********************************************************************/
266 #define setupSmallButton( aButton ){ \
267 aButton->setMaximumSize( QSize( 26, 26 ) ); \
268 aButton->setMinimumSize( QSize( 26, 26 ) ); \
269 aButton->setIconSize( QSize( 20, 20 ) ); }
271 AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
272 QFrame( NULL ), p_intf( _p_i )
274 QHBoxLayout *advLayout = new QHBoxLayout( this );
275 advLayout->setMargin( 0 );
276 advLayout->setSpacing( 0 );
279 ABButton = new QPushButton( "AB" );
280 ABButton->setMaximumSize( QSize( 26, 26 ) );
281 ABButton->setIconSize( QSize( 20, 20 ) );
282 advLayout->addWidget( ABButton );
283 BUTTON_SET_ACT( ABButton, "AB", qtr( "A to B" ), fromAtoB() );
285 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
286 this, AtoBLoop( float, int, int ) );
288 frameButton = new QPushButton( "Fr" );
289 frameButton->setMaximumSize( QSize( 26, 26 ) );
290 frameButton->setIconSize( QSize( 20, 20 ) );
291 advLayout->addWidget( frameButton );
292 BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() );
295 recordButton = new QPushButton( "R" );
296 recordButton->setMaximumSize( QSize( 26, 26 ) );
297 recordButton->setIconSize( QSize( 20, 20 ) );
298 advLayout->addWidget( recordButton );
299 BUTTON_SET_ACT_I( recordButton, "", record_16px.png,
300 qtr( "Record" ), record() );
302 /* Snapshot Button */
303 snapshotButton = new QPushButton( "S" );
304 snapshotButton->setMaximumSize( QSize( 26, 26 ) );
305 snapshotButton->setIconSize( QSize( 20, 20 ) );
306 advLayout->addWidget( snapshotButton );
307 BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
310 AdvControlsWidget::~AdvControlsWidget()
313 void AdvControlsWidget::enableInput( bool enable )
315 ABButton->setEnabled( enable );
316 recordButton->setEnabled( enable );
319 void AdvControlsWidget::enableVideo( bool enable )
321 snapshotButton->setEnabled( enable );
323 frameButton->setEnabled( enable );
327 void AdvControlsWidget::snapshot()
329 vout_thread_t *p_vout =
330 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
331 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
334 /* Function called when the button is clicked() */
335 void AdvControlsWidget::fromAtoB()
339 timeA = var_GetTime( THEMIM->getInput(), "time" );
340 ABButton->setText( "A->..." );
345 timeB = var_GetTime( THEMIM->getInput(), "time" );
346 var_SetTime( THEMIM->getInput(), "time" , timeA );
347 ABButton->setText( "A<=>B" );
352 ABButton->setText( "AB" );
355 /* Function called regularly when in an AtoB loop */
356 void AdvControlsWidget::AtoBLoop( float f_pos, int i_time, int i_length )
360 if( i_time >= (int)(timeB/1000000) )
361 var_SetTime( THEMIM->getInput(), "time" , timeA );
365 /* FIXME Record function */
366 void AdvControlsWidget::record(){}
369 //FIXME Frame by frame function
370 void AdvControlsWidget::frame(){}
373 /*****************************
374 * DA Control Widget !
375 *****************************/
376 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
377 MainInterface *_p_mi,
380 QFrame( NULL ), p_intf( _p_i )
382 controlLayout = new QGridLayout( this );
383 controlLayout->setSpacing( 0 );
385 controlLayout->setContentsMargins( 9, 6, 9, 6 );
387 controlLayout->setMargin( 6 );
390 setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
392 /** The main Slider **/
393 slider = new InputSlider( Qt::Horizontal, NULL );
394 controlLayout->addWidget( slider, 0, 1, 1, 16 );
395 /* Update the position when the IM has changed */
396 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
397 slider, setPosition( float, int, int ) );
398 /* And update the IM, when the position has changed */
399 CONNECT( slider, sliderDragged( float ),
400 THEMIM->getIM(), sliderUpdate( float ) );
402 /** Slower and faster Buttons **/
403 slowerButton = new QToolButton;
404 slowerButton->setAutoRaise( true );
405 slowerButton->setMaximumSize( QSize( 26, 20 ) );
407 BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
408 controlLayout->addWidget( slowerButton, 0, 0 );
410 fasterButton = new QToolButton;
411 fasterButton->setAutoRaise( true );
412 fasterButton->setMaximumSize( QSize( 26, 20 ) );
414 BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
415 controlLayout->addWidget( fasterButton, 0, 17 );
417 /* advanced Controls handling */
418 b_advancedVisible = b_advControls;
420 advControls = new AdvControlsWidget( p_intf );
421 controlLayout->addWidget( advControls, 1, 3, 2, 4, Qt::AlignBottom );
422 if( !b_advancedVisible ) advControls->hide();
424 /** Disc and Menus handling */
425 discFrame = new QWidget( this );
427 QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
428 discLayout->setSpacing( 0 );
429 discLayout->setMargin( 0 );
431 prevSectionButton = new QPushButton( discFrame );
432 setupSmallButton( prevSectionButton );
433 discLayout->addWidget( prevSectionButton );
435 menuButton = new QPushButton( discFrame );
436 setupSmallButton( menuButton );
437 discLayout->addWidget( menuButton );
439 nextSectionButton = new QPushButton( discFrame );
440 setupSmallButton( nextSectionButton );
441 discLayout->addWidget( nextSectionButton );
443 controlLayout->addWidget( discFrame, 1, 10, 2, 3, Qt::AlignBottom );
445 BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
446 BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
447 BUTTON_SET_IMG( menuButton, "", previous.png, "" );
451 /* Change the navigation button display when the IM navigation changes */
452 CONNECT( THEMIM->getIM(), navigationChanged( int ),
453 this, setNavigation( int ) );
454 /* Changes the IM navigation when triggered on the nav buttons */
455 CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
457 CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
459 CONNECT( menuButton, clicked(), THEMIM->getIM(),
463 * TODO: Merge with upper menu in a StackLayout
466 telexFrame = new QWidget( this );
467 QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
468 telexLayout->setSpacing( 0 );
469 telexLayout->setMargin( 0 );
471 QToolButton *telexOn = new QToolButton;
472 telexOn->setText( qtr( "On" ) );
473 setupSmallButton( telexOn );
474 telexLayout->addWidget( telexOn );
476 QToolButton *telexTransparent = new QToolButton;
477 telexTransparent->setText( qtr( "Transparent" ) );
478 setupSmallButton( telexTransparent );
479 telexLayout->addWidget( telexTransparent );
481 QSpinBox *telexPage = new QSpinBox;
482 telexPage->setRange( 0, 999 );
483 telexPage->setValue( 100 );
484 telexPage->setAlignment( Qt::AlignRight );
485 telexLayout->addWidget( telexPage );
487 controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
490 CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
491 telexGotoPage( int ) );
492 CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
493 telexToggle( bool ) );
494 CONNECT( telexTransparent, clicked( bool ),
495 THEMIM->getIM(), telexSetTransparency( bool ) );
496 CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
497 telexFrame, setVisible( bool ) );
501 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
502 sizePolicy.setHorizontalStretch( 0 );
503 sizePolicy.setVerticalStretch( 0 );
506 playButton = new QPushButton;
507 playButton->setSizePolicy( sizePolicy );
508 playButton->setMaximumSize( QSize( 36, 36 ) );
509 playButton->setMinimumSize( QSize( 36, 36 ) );
510 playButton->setIconSize( QSize( 30, 30 ) );
512 controlLayout->addWidget( playButton, 2, 0, 2, 2 );
514 controlLayout->setColumnMinimumWidth( 2, 20 );
515 controlLayout->setColumnStretch( 2, 0 );
517 /** Prev + Stop + Next Block **/
518 QHBoxLayout *controlButLayout = new QHBoxLayout;
519 controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */
522 QPushButton *prevButton = new QPushButton;
523 prevButton->setSizePolicy( sizePolicy );
524 setupSmallButton( prevButton );
526 controlButLayout->addWidget( prevButton );
529 QPushButton *stopButton = new QPushButton;
530 stopButton->setSizePolicy( sizePolicy );
531 setupSmallButton( stopButton );
533 controlButLayout->addWidget( stopButton );
536 QPushButton *nextButton = new QPushButton;
537 nextButton->setSizePolicy( sizePolicy );
538 setupSmallButton( nextButton );
540 controlButLayout->addWidget( nextButton );
542 /* Add this block to the main layout */
543 controlLayout->addLayout( controlButLayout, 3, 3, 1, 3 );
545 BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
546 BUTTON_SET_ACT_I( prevButton, "" , previous.png,
547 qtr( "Previous" ), prev() );
548 BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
549 BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
551 controlLayout->setColumnMinimumWidth( 7, 20 );
552 controlLayout->setColumnStretch( 7, 0 );
553 controlLayout->setColumnStretch( 8, 0 );
554 controlLayout->setColumnStretch( 9, 0 );
557 * Other first Line buttons
559 /** Fullscreen/Visualisation **/
560 fullscreenButton = new QPushButton( "F" );
561 BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
562 setupSmallButton( fullscreenButton );
563 controlLayout->addWidget( fullscreenButton, 3, 10, Qt::AlignBottom );
565 /** Playlist Button **/
566 playlistButton = new QPushButton;
567 setupSmallButton( playlistButton );
568 controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
569 BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
570 CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
572 /** extended Settings **/
573 QPushButton *extSettingsButton = new QPushButton( "F" );
574 BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
576 setupSmallButton( extSettingsButton );
577 controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom );
579 controlLayout->setColumnStretch( 13, 0 );
580 controlLayout->setColumnMinimumWidth( 13, 24 );
581 controlLayout->setColumnStretch( 14, 5 );
584 VolumeClickHandler *hVolLabel = new VolumeClickHandler( p_intf, this );
586 volMuteLabel = new QLabel;
587 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
588 volMuteLabel->setToolTip( qtr( "Mute" ) );
589 volMuteLabel->installEventFilter( hVolLabel );
590 controlLayout->addWidget( volMuteLabel, 3, 15, Qt::AlignBottom );
594 volumeSlider = new SoundSlider( this,
595 config_GetInt( p_intf, "volume-step" ),
596 config_GetInt( p_intf, "qt-volume-complete" ) );
600 volumeSlider = new QSlider( this );
601 volumeSlider->setOrientation( Qt::Horizontal );
603 volumeSlider->setMaximumSize( QSize( 200, 40 ) );
604 volumeSlider->setMinimumSize( QSize( 106, 30 ) );
605 volumeSlider->setFocusPolicy( Qt::NoFocus );
606 controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom );
608 /* Set the volume from the config */
609 volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
610 VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
612 /* Volume control connection */
613 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
614 CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
616 CONNECT( THEMIM->getIM(), statusChanged( int ), this, updateInput() );
621 ControlsWidget::~ControlsWidget()
624 void ControlsWidget::stop()
629 void ControlsWidget::play()
631 if( THEPL->current.i_size == 0 )
633 /* The playlist is empty, open a file requester */
634 THEDP->openFileDialog();
638 THEMIM->togglePlayPause();
641 void ControlsWidget::prev()
646 void ControlsWidget::next()
651 void ControlsWidget::setNavigation( int navigation )
653 #define HELP_MENU N_( "Menu" )
654 #define HELP_PCH N_( "Previous chapter" )
655 #define HELP_NCH N_( "Next chapter" )
656 #define HELP_PTR N_( "Previous track" )
657 #define HELP_NTR N_( "Next track" )
659 // 1 = chapter, 2 = title, 0 = no
660 if( navigation == 0 )
663 } else if( navigation == 1 ) {
664 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
665 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
669 prevSectionButton->setToolTip( qfu( HELP_PCH ) );
670 nextSectionButton->setToolTip( qfu( HELP_NCH ) );
676 static bool b_my_volume;
677 void ControlsWidget::updateVolume( int i_sliderVolume )
681 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
682 aout_VolumeSet( p_intf, i_res );
684 if( i_sliderVolume == 0 )
685 volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) );
686 else if( i_sliderVolume < VOLUME_MAX / 3 )
687 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
688 else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
689 volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
690 else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
693 void ControlsWidget::updateVolume()
696 audio_volume_t i_volume;
697 aout_VolumeGet( p_intf, &i_volume );
698 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
699 int i_gauge = volumeSlider->value();
701 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
704 volumeSlider->setValue( i_volume );
709 void ControlsWidget::updateInput()
711 /* Activate the interface buttons according to the presence of the input */
712 enableInput( THEMIM->getIM()->hasInput() );
713 enableVideo( THEMIM->getIM()->hasVideo() );
716 void ControlsWidget::setStatus( int status )
718 if( status == PLAYING_S ) // Playing
719 playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
721 playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
726 * This functions toggle the fullscreen mode
727 * If there is no video, it should first activate Visualisations...
728 * This has also to be fixed in enableVideo()
730 void ControlsWidget::fullscreen()
732 vout_thread_t *p_vout =
733 (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
736 var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) );
737 vlc_object_release( p_vout );
741 void ControlsWidget::extSettings()
743 THEDP->extendedDialog();
746 void ControlsWidget::slower()
748 THEMIM->getIM()->slower();
751 void ControlsWidget::faster()
753 THEMIM->getIM()->faster();
756 void ControlsWidget::enableInput( bool enable )
758 slowerButton->setEnabled( enable );
759 slider->setEnabled( enable );
760 fasterButton->setEnabled( enable );
762 /* Advanced Buttons too */
763 advControls->enableInput( enable );
766 void ControlsWidget::enableVideo( bool enable )
768 // TODO Later make the fullscreenButton toggle Visualisation and so on.
769 fullscreenButton->setEnabled( enable );
771 /* Advanced Buttons too */
772 advControls->enableVideo( enable );
775 void ControlsWidget::toggleAdvanced()
777 if( !VISIBLE( advControls ) )
780 b_advancedVisible = true;
785 b_advancedVisible = false;
787 emit advancedControlsToggled( b_advancedVisible );
791 /**********************************************************************
792 * Speed control widget
793 **********************************************************************/
794 SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :
795 QFrame( NULL ), p_intf( _p_i )
797 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
798 sizePolicy.setHorizontalStretch( 0 );
799 sizePolicy.setVerticalStretch( 0 );
801 speedSlider = new QSlider;
802 speedSlider->setSizePolicy( sizePolicy );
803 speedSlider->setMaximumSize( QSize( 80, 200 ) );
804 speedSlider->setOrientation( Qt::Vertical );
805 speedSlider->setTickPosition( QSlider::TicksRight );
807 speedSlider->setRange( -100, 100 );
808 speedSlider->setSingleStep( 10 );
809 speedSlider->setPageStep( 20 );
810 speedSlider->setTickInterval( 20 );
812 CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
814 QToolButton *normalSpeedButton = new QToolButton( this );
815 normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
816 normalSpeedButton->setAutoRaise( true );
817 normalSpeedButton->setText( "N" );
818 normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
820 CONNECT( normalSpeedButton, clicked(), this, resetRate() );
822 QVBoxLayout *speedControlLayout = new QVBoxLayout;
823 speedControlLayout->addWidget( speedSlider );
824 speedControlLayout->addWidget( normalSpeedButton );
825 setLayout( speedControlLayout );
828 SpeedControlWidget::~SpeedControlWidget()
831 void SpeedControlWidget::mouseDoubleClickEvent( QMouseEvent * event )
836 #define RATE_SLIDER_MAXIMUM 3.0
837 #define RATE_SLIDER_MINIMUM 0.3
838 #define RATE_SLIDER_LENGTH 100.0
840 void SpeedControlWidget::updateControls( int rate )
842 if( speedSlider->isSliderDown() )
844 //We don't want to change anything if the user is using the slider
849 double speed = INPUT_RATE_DEFAULT / (double)rate;
851 if( rate >= INPUT_RATE_DEFAULT )
853 if( speed < RATE_SLIDER_MINIMUM )
855 sliderValue = speedSlider->minimum();
859 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
860 / ( 1.0 - RATE_SLIDER_MAXIMUM ) );
865 if( speed > RATE_SLIDER_MAXIMUM )
867 sliderValue = speedSlider->maximum();
871 sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH
872 / ( RATE_SLIDER_MAXIMUM - 1.0 ) );
876 //Block signals to avoid feedback loop
877 speedSlider->blockSignals( true );
878 speedSlider->setValue( sliderValue );
879 speedSlider->blockSignals( false );
882 void SpeedControlWidget::updateRate( int sliderValue )
886 if( sliderValue < 0.0 )
888 rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
889 ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH ));
893 rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH /
894 ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH ));
897 THEMIM->getIM()->setRate(rate);
900 void SpeedControlWidget::resetRate()
902 THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);