X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fcontroller.cpp;h=af1da21c16c43c663f5e27d0660b4bed3f036203;hb=fce3f85b6fa118a8212ec90b1a6d9469a6556197;hp=fc5d56d3c03c5fe682fa32abfc94548503e67f3e;hpb=f2851a7b132ecc92fad01f5d89418fd912f62cd5;p=vlc diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp index fc5d56d3c0..af1da21c16 100644 --- a/modules/gui/qt4/components/controller.cpp +++ b/modules/gui/qt4/components/controller.cpp @@ -1,12 +1,10 @@ /***************************************************************************** * Controller.cpp : Controller for the main interface **************************************************************************** - * Copyright ( C ) 2006-2008 the VideoLAN team + * Copyright (C) 2006-2008 the VideoLAN team * $Id$ * - * Authors: Clément Stenac - * Jean-Baptiste Kempf - * Rafaël Carré + * Authors: Jean-Baptiste Kempf * Ilkka Ollakka * * This program is free software; you can redistribute it and/or modify @@ -35,8 +33,9 @@ #include "components/controller_widget.hpp" #include "components/interface_widgets.hpp" -#include "dialogs_provider.hpp" +#include "dialogs_provider.hpp" /* Opening Dialogs */ #include "input_manager.hpp" +#include "actions_manager.hpp" #include "util/input_slider.hpp" /* InputSlider */ #include "util/customwidgets.hpp" /* qEventToKey */ @@ -64,7 +63,8 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent ) /* Main action provider */ toolbarActionsMapper = new QSignalMapper( this ); - CONNECT( toolbarActionsMapper, mapped( int ), this, doAction( int ) ); + CONNECT( toolbarActionsMapper, mapped( int ), + ActionsManager::getInstance( p_intf ), doAction( int ) ); CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) ); } @@ -79,6 +79,9 @@ void AbstractController::setStatus( int status ) emit inputIsRecordable( b_hasInput && var_GetBool( THEMIM->getInput(), "can-record" ) ); + + emit inputIsTrickPlayable( b_hasInput && + var_GetBool( THEMIM->getInput(), "can-rewind" ) ); } /* Generic button setup */ @@ -96,7 +99,7 @@ void AbstractController::setupButton( QAbstractButton *aButton ) /* Open the generic config line for the toolbar, parse it * and create the widgets accordingly */ -void AbstractController::parseAndCreate( QString config, +void AbstractController::parseAndCreate( const QString& config, QBoxLayout *controlLayout ) { QStringList list = config.split( ";", QString::SkipEmptyParts ) ; @@ -163,7 +166,7 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout, CONNECT_MAP( a ); \ SET_MAPPING( a, b ); #define BUTTON_SET_BAR( a_button ) \ - a_button->setToolTip( tooltipL[button] ); \ + a_button->setToolTip( qtr( tooltipL[button] ) ); \ a_button->setIcon( QIcon( iconL[button] ) ); #define BUTTON_SET_BAR2( button, image, tooltip ) \ button->setToolTip( tooltip ); \ @@ -184,6 +187,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) bool b_flat = options & WIDGET_FLAT; bool b_big = options & WIDGET_BIG; bool b_shiny = options & WIDGET_SHINY; + bool b_special = false; QWidget *widget = NULL; switch( button ) @@ -307,12 +311,16 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) CONNECT_MAP_SET( recordButton, RECORD_ACTION ); BUTTON_SET_BAR( recordButton ); ENABLE_ON_INPUT( recordButton ); + recordButton->setCheckable( true ); + CONNECT( THEMIM->getIM(), recordingStateChanged( bool ), + recordButton, setChecked( bool ) ); widget = recordButton; } break; case ATOB_BUTTON: { AtoB_Button *ABButton = new AtoB_Button; setupButton( ABButton ); + ABButton->setShortcut( qtr("Shift+L") ); BUTTON_SET_BAR( ABButton ); ENABLE_ON_INPUT( ABButton ); CONNECT_MAP_SET( ABButton, ATOB_ACTION ); @@ -341,9 +349,11 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) widget = telexFrame(); widget->hide(); break; + case VOLUME_SPECIAL: + b_special = true; case VOLUME: { - SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny ); + SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny, b_special ); widget = snd; } break; @@ -374,7 +384,11 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) setupButton( reverseButton ); CONNECT_MAP_SET( reverseButton, REVERSE_ACTION ); BUTTON_SET_BAR( reverseButton ); - ENABLE_ON_INPUT( reverseButton ); + reverseButton->setCheckable( true ); + /* You should, of COURSE change this to the correct event, + when/if we have one, that tells us if trickplay is possible . */ + CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) ); + reverseButton->setVisible( false ); widget = reverseButton; } break; @@ -396,6 +410,14 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) widget = skipFwButton; } break; + case QUIT_BUTTON: { + QToolButton *quitButton = new QToolButton; + setupButton( quitButton ); + CONNECT_MAP_SET( quitButton, QUIT_ACTION ); + BUTTON_SET_BAR( quitButton ); + widget = quitButton; + } + break; default: msg_Warn( p_intf, "This should not happen %i", button ); break; @@ -404,25 +426,41 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) /* Customize Buttons */ if( b_flat || b_big ) { - QToolButton *tmpButton = qobject_cast(widget); - if( tmpButton ) + QFrame *frame = qobject_cast(widget); + if( frame ) { - if( b_flat ) - tmpButton->setAutoRaise( b_flat ); - if( b_big ) - { - tmpButton->setFixedSize( QSize( 32, 32 ) ); - tmpButton->setIconSize( QSize( 26, 26 ) ); - } + QList allTButtons = frame->findChildren(); + for( int i = 0; i < allTButtons.size(); i++ ) + applyAttributes( allTButtons[i], b_flat, b_big ); + } + else + { + QToolButton *tmpButton = qobject_cast(widget); + if( tmpButton ) + applyAttributes( tmpButton, b_flat, b_big ); } } return widget; } -QWidget *AbstractController::discFrame() +void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, bool b_big ) +{ + if( tmpButton ) + { + if( b_flat ) + tmpButton->setAutoRaise( b_flat ); + if( b_big ) + { + tmpButton->setFixedSize( QSize( 32, 32 ) ); + tmpButton->setIconSize( QSize( 26, 26 ) ); + } + } +} + +QFrame *AbstractController::discFrame() { /** Disc and Menus handling */ - QWidget *discFrame = new QWidget( this ); + QFrame *discFrame = new QFrame( this ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); @@ -457,54 +495,58 @@ QWidget *AbstractController::discFrame() sectionNext() ); CONNECT( menuButton, clicked(), THEMIM->getIM(), sectionMenu() ); + connect( THEMIM->getIM(), SIGNAL( titleChanged( bool ) ), + this, SIGNAL( sizeChanged() ) ); return discFrame; } -QWidget *AbstractController::telexFrame() +QFrame *AbstractController::telexFrame() { /** * Telextext QFrame **/ - TeletextController *telexFrame = new TeletextController; + QFrame *telexFrame = new QFrame; QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); CONNECT( THEMIM->getIM(), teletextPossible( bool ), telexFrame, setVisible( bool ) ); + connect( THEMIM->getIM(), SIGNAL( teletextPossible( bool ) ), + this, SIGNAL( sizeChanged() ) ); /* On/Off button */ QToolButton *telexOn = new QToolButton; - telexFrame->telexOn = telexOn; setupButton( telexOn ); BUTTON_SET_BAR2( telexOn, tv, qtr( "Teletext Activation" ) ); + telexOn->setEnabled( false ); + telexOn->setCheckable( true ); + telexLayout->addWidget( telexOn ); /* Teletext Activation and set */ CONNECT( telexOn, clicked( bool ), THEMIM->getIM(), activateTeletext( bool ) ); - CONNECT( THEMIM->getIM(), teletextActivated( bool ), - telexFrame, enableTeletextButtons( bool ) ); - + CONNECT( THEMIM->getIM(), teletextPossible( bool ), + telexOn, setEnabled( bool ) ); /* Transparency button */ QToolButton *telexTransparent = new QToolButton; - telexFrame->telexTransparent = telexTransparent; setupButton( telexTransparent ); BUTTON_SET_BAR2( telexTransparent, tvtelx, qtr( "Toggle Transparency " ) ); telexTransparent->setEnabled( false ); + telexTransparent->setCheckable( true ); telexLayout->addWidget( telexTransparent ); /* Transparency change and set */ CONNECT( telexTransparent, clicked( bool ), THEMIM->getIM(), telexSetTransparency( bool ) ); CONNECT( THEMIM->getIM(), teletextTransparencyActivated( bool ), - telexFrame, toggleTeletextTransparency( bool ) ); + telexTransparent, setChecked( bool ) ); /* Page setting */ - QSpinBox *telexPage = new QSpinBox; - telexFrame->telexPage = telexPage; + QSpinBox *telexPage = new QSpinBox( telexFrame ); telexPage->setRange( 0, 999 ); telexPage->setValue( 100 ); telexPage->setAccelerated( true ); @@ -520,6 +562,9 @@ QWidget *AbstractController::telexFrame() CONNECT( THEMIM->getIM(), newTelexPageSet( int ), telexPage, setValue( int ) ); + CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexPage, setEnabled( bool ) ); + CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexTransparent, setEnabled( bool ) ); + CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexOn, setChecked( bool ) ); return telexFrame; } #undef CONNECT_MAP @@ -529,163 +574,6 @@ QWidget *AbstractController::telexFrame() #undef ENABLE_ON_VIDEO #undef ENABLE_ON_INPUT -//* Actions */ -void AbstractController::doAction( int id_action ) -{ - switch( id_action ) - { - case PLAY_ACTION: - play(); break; - case PREVIOUS_ACTION: - prev(); break; - case NEXT_ACTION: - next(); break; - case STOP_ACTION: - stop(); break; - case SLOWER_ACTION: - slower(); break; - case FASTER_ACTION: - faster(); break; - case FULLSCREEN_ACTION: - fullscreen(); break; - case EXTENDED_ACTION: - extSettings(); break; - case PLAYLIST_ACTION: - playlist(); break; - case SNAPSHOT_ACTION: - snapshot(); break; - case RECORD_ACTION: - record(); break; - case ATOB_ACTION: - THEMIM->getIM()->setAtoB(); break; - case FRAME_ACTION: - frame(); break; - case REVERSE_ACTION: - reverse(); break; - case SKIP_BACK_ACTION: - var_SetInteger( p_intf->p_libvlc, "key-pressed", - ACTIONID_JUMP_BACKWARD_SHORT ); - break; - case SKIP_FW_ACTION: - var_SetInteger( p_intf->p_libvlc, "key-pressed", - ACTIONID_JUMP_FORWARD_SHORT ); - break; - default: - msg_Dbg( p_intf, "Action: %i", id_action ); - break; - } -} - -void AbstractController::stop() -{ - THEMIM->stop(); -} - -void AbstractController::play() -{ - if( THEPL->current.i_size == 0 ) - { - /* The playlist is empty, open a file requester */ - THEDP->openFileDialog(); - return; - } - THEMIM->togglePlayPause(); -} - -void AbstractController::prev() -{ - THEMIM->prev(); -} - -void AbstractController::next() -{ - THEMIM->next(); -} - -/** - * TODO - * This functions toggle the fullscreen mode - * If there is no video, it should first activate Visualisations... - * This has also to be fixed in enableVideo() - */ -void AbstractController::fullscreen() -{ - vout_thread_t *p_vout = - (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); - if( p_vout) - { - var_SetBool( p_vout, "fullscreen", !var_GetBool( p_vout, "fullscreen" ) ); - vlc_object_release( p_vout ); - } -} - -void AbstractController::snapshot() -{ - vout_thread_t *p_vout = - (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); - if( p_vout ) - { - vout_Control( p_vout, VOUT_SNAPSHOT ); - vlc_object_release( p_vout ); - } -} - -void AbstractController::extSettings() -{ - THEDP->extendedDialog(); -} - -void AbstractController::reverse() -{ - THEMIM->getIM()->reverse(); -} - -void AbstractController::slower() -{ - THEMIM->getIM()->slower(); -} - -void AbstractController::faster() -{ - THEMIM->getIM()->faster(); -} - -void AbstractController::playlist() -{ - if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->togglePlaylist(); -} - -void AbstractController::record() -{ - input_thread_t *p_input = THEMIM->getInput(); - if( p_input ) - { - /* This method won't work fine if the stream can't be cut anywhere */ - const bool b_recording = var_GetBool( p_input, "record" ); - var_SetBool( p_input, "record", !b_recording ); -#if 0 - else - { - /* 'record' access-filter is not loaded, we open Save dialog */ - input_item_t *p_item = input_GetItem( p_input ); - if( !p_item ) - return; - - char *psz = input_item_GetURI( p_item ); - if( psz ) - THEDP->streamingDialog( NULL, psz, true ); - } -#endif - } -} - -void AbstractController::frame() -{ - input_thread_t *p_input = THEMIM->getInput(); - if( p_input ) - var_SetVoid( p_input, "frame-next" ); -} - #include /***************************** * DA Control Widget ! @@ -706,23 +594,14 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, QHBoxLayout *controlLayout1 = new QHBoxLayout; controlLayout1->setSpacing( 0 ); - QString line1 = getSettings()->value( "MainWindow/MainToolbar1", - "64;36;37;38;65").toString(); + QString line1 = getSettings()->value( "MainToolbar1", MAIN_TB1_DEFAULT ) + .toString(); parseAndCreate( line1, controlLayout1 ); - /* QString line2 = QString( "%1-2;%2;%3;%4;%5;%6;%6;%7;%8;%9;%6;%10;%11-4") - .arg( PLAY_BUTTON ) .arg( WIDGET_SPACER ) - .arg( PREVIOUS_BUTTON ) .arg( STOP_BUTTON ) - .arg( NEXT_BUTTON ) .arg( WIDGET_SPACER ) - .arg( FULLSCREEN_BUTTON ) .arg( PLAYLIST_BUTTON ) - .arg( EXTENDED_BUTTON ) .arg( WIDGET_SPACER_EXTEND ) - .arg( VOLUME ); - msg_Dbg( p_intf, "%s", qtu( line2 )); */ - QHBoxLayout *controlLayout2 = new QHBoxLayout; controlLayout2->setSpacing( 0 ); - QString line2 = getSettings()->value( "MainWindow/MainToolbar2", - "0-2;64;3;1;4;64;7;10;9;65;34-4" ).toString(); + QString line2 = getSettings()->value( "MainToolbar2", MAIN_TB2_DEFAULT ) + .toString(); parseAndCreate( line2, controlLayout2 ); if( !b_advancedVisible && advControls ) advControls->hide(); @@ -758,13 +637,8 @@ AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i, QWidget *_parent ) : controlLayout->setMargin( 0 ); controlLayout->setSpacing( 0 ); - /* QString line = QString( "%1;%2;%3").arg( RECORD_BUTTON ) - .arg( SNAPSHOT_BUTTON ) - .arg( ATOB_BUTTON ) - .arg( FRAME_BUTTON ); */ - - QString line = getSettings()->value( "MainWindow/AdvToolbar", - "12;11;13;14" ).toString(); + QString line = getSettings()->value( "AdvToolbar", ADV_TB_DEFAULT ) + .toString(); parseAndCreate( line, controlLayout ); } @@ -775,12 +649,7 @@ InputControlsWidget::InputControlsWidget( intf_thread_t *_p_i, QWidget *_parent controlLayout->setMargin( 0 ); controlLayout->setSpacing( 0 ); - /* QString line = QString( "%1-%2;%3;%4-%2") - .arg( SLOWER_BUTTON ).arg( WIDGET_FLAT ) - .arg( INPUT_SLIDER ) - .arg( FASTER_BUTTON ); */ - QString line = getSettings()->value( "MainWindow/InputToolbar", - "5-1;33;6-1" ).toString(); + QString line = getSettings()->value( "InputToolbar", INPT_TB_DEFAULT ).toString(); parseAndCreate( line, controlLayout ); } /********************************************************************** @@ -800,9 +669,10 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i ) #endif b_fullscreen = false; i_hide_timeout = 1; - p_vout = NULL; i_screennumber = -1; + vout.clear(); + setWindowFlags( Qt::ToolTip ); setMinimumWidth( 600 ); @@ -810,30 +680,17 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i ) setFrameStyle( QFrame::Sunken ); setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); - controlLayout = new QHBoxLayout( this ); - controlLayout->setLayoutMargins( 5, 2, 5, 2, 5 ); + QVBoxLayout *controlLayout2 = new QVBoxLayout( this ); + controlLayout2->setLayoutMargins( 4, 6, 4, 2, 5 ); /* First line */ InputControlsWidget *inputC = new InputControlsWidget( p_intf, this ); - controlLayout->addWidget( inputC ); - - /* Second line */ -/* QString line = QString( "%1-2;%2;%3;%4;%5;%2;%6;%2;%7;%2;%8;%9;%10-4") - .arg( PLAY_BUTTON ) - .arg( WIDGET_SPACER ) - .arg( PREVIOUS_BUTTON ) - .arg( STOP_BUTTON ) - .arg( NEXT_BUTTON ) - .arg( MENU_BUTTONS ) - .arg( TELETEXT_BUTTONS ) - .arg( DEFULLSCREEN_BUTTON ) - .arg( WIDGET_SPACER_EXTEND ) - .arg( TIME_LABEL ) - .arg( VOLUME ); */ - - QString line = getSettings()->value( "MainWindow/FSCtoolbar", - "0-2;64;3;1;4;64;36;64;37;64;8;65;35-4;34" ).toString(); + controlLayout2->addWidget( inputC ); + + controlLayout = new QHBoxLayout; + QString line = getSettings()->value( "MainWindow/FSCtoolbar", FSC_TB_DEFAULT ).toString(); parseAndCreate( line, controlLayout ); + controlLayout2->addLayout( controlLayout ); /* hiding timer */ p_hideTimer = new QTimer( this ); @@ -856,32 +713,56 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i ) #endif vlc_mutex_init_recursive( &lock ); + + CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), + this, setVoutList( vout_thread_t **, int ) ); + + /* First Move */ + QPoint pos1 = getSettings()->value( "FullScreen/pos" ).toPoint(); + int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi ); + if( QApplication::desktop()->screenGeometry( number ).contains( pos1, true ) ) + { + move( pos1 ); + i_screennumber = number; + screenRes = QApplication::desktop()->screenGeometry(number); + } + else + { + centerFSC( number ); + } + } FullscreenControllerWidget::~FullscreenControllerWidget() { getSettings()->setValue( "FullScreen/pos", pos() ); - detachVout(); + setVoutList( NULL, 0 ); vlc_mutex_destroy( &lock ); } +void FullscreenControllerWidget::centerFSC( int number ) +{ + screenRes = QApplication::desktop()->screenGeometry(number); + /* screen has changed, calculate new position */ + QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (width() / 2), + screenRes.y() + screenRes.height() - height()); + move( pos ); + i_screennumber = number; +} + /** * Show fullscreen controller */ void FullscreenControllerWidget::showFSC() { adjustSize(); - /* center down */ + int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi ); - if( number != i_screennumber ) + + if( number != i_screennumber || + screenRes != QApplication::desktop()->screenGeometry(number) ) { - msg_Dbg( p_intf, "Calculation fullscreen controllers center"); - /* screen has changed, calculate new position */ - QRect screenRes = QApplication::desktop()->screenGeometry(number); - QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (width() / 2), - screenRes.y() + screenRes.height() - height()); - move( pos ); - i_screennumber = number; + centerFSC( number ); } #ifdef WIN32TRICK // after quiting and going to fs, we need to call show() @@ -985,6 +866,7 @@ void FullscreenControllerWidget::customEvent( QEvent *event ) b_fs = b_fullscreen; vlc_mutex_unlock( &lock ); if( b_fs ) + { #ifdef WIN32TRICK if( b_fscHidden ) #else @@ -996,6 +878,7 @@ void FullscreenControllerWidget::customEvent( QEvent *event ) } else hideFSC(); + } break; case FullscreenControlShow_Type: vlc_mutex_lock( &lock ); @@ -1016,6 +899,8 @@ void FullscreenControllerWidget::customEvent( QEvent *event ) if( !b_mouse_over ) // Only if the mouse is not over FSC planHideFSC(); break; + default: + break; } } @@ -1025,8 +910,11 @@ void FullscreenControllerWidget::customEvent( QEvent *event ) */ void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event ) { - if ( event->buttons() == Qt::LeftButton ) + if( event->buttons() == Qt::LeftButton ) { + if( i_mouse_last_x == -1 || i_mouse_last_y == -1 ) + return; + int i_moveX = event->globalX() - i_mouse_last_x; int i_moveY = event->globalY() - i_mouse_last_y; @@ -1047,6 +935,12 @@ void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event ) i_mouse_last_y = event->globalY(); } +void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event ) +{ + i_mouse_last_x = -1; + i_mouse_last_y = -1; +} + /** * On mouse go above FSC */ @@ -1058,6 +952,7 @@ void FullscreenControllerWidget::enterEvent( QEvent *event ) #if HAVE_TRANSPARENCY p_slowHideTimer->stop(); #endif + event->accept(); } /** @@ -1068,6 +963,7 @@ void FullscreenControllerWidget::leaveEvent( QEvent *event ) planHideFSC(); b_mouse_over = false; + event->accept(); } /** @@ -1093,11 +989,11 @@ static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object vlc_value_t new_val, void *data ) { vout_thread_t *p_vout = (vout_thread_t *) vlc_object; + msg_Dbg( p_vout, "Qt4: Fullscreen state changed" ); FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data; - p_fs->fullscreenChanged( p_vout, new_val.b_bool, - var_GetInteger( p_vout, "mouse-hide-timeout" ) ); + p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) ); return VLC_SUCCESS; } @@ -1106,92 +1002,83 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const vlc_value_t old_val, vlc_value_t new_val, void *data ) { + vout_thread_t *p_vout = (vout_thread_t *)vlc_object; FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data; - int i_mousex, i_mousey; - bool b_toShow = false; - /* Get the value from the Vout - Trust the vout more than Qt */ - i_mousex = var_GetInteger( p_fs->p_vout, "mouse-x" ); - i_mousey = var_GetInteger( p_fs->p_vout, "mouse-y" ); + const int i_mousex = var_GetInteger( p_vout, "mouse-x" ); + const int i_mousey = var_GetInteger( p_vout, "mouse-y" ); - /* First time */ - if( p_fs->i_mouse_last_move_x == -1 || p_fs->i_mouse_last_move_y == -1 ) - { - p_fs->i_mouse_last_move_x = i_mousex; - p_fs->i_mouse_last_move_y = i_mousey; - b_toShow = true; - } - /* All other times */ - else - { - /* Trigger only if move > 3 px dans une direction */ - if( abs( p_fs->i_mouse_last_move_x - i_mousex ) > 2 || - abs( p_fs->i_mouse_last_move_y - i_mousey ) > 2 ) - { - b_toShow = true; - p_fs->i_mouse_last_move_x = i_mousex; - p_fs->i_mouse_last_move_y = i_mousey; - } - } - - if( b_toShow ) - { - /* Show event */ - IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 ); - QApplication::postEvent( p_fs, static_cast(eShow) ); - - /* Plan hide event */ - IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 ); - QApplication::postEvent( p_fs, static_cast(eHide) ); - } + p_fs->mouseChanged( p_vout, i_mousex, i_mousey ); return VLC_SUCCESS; } /** - * It is called when video start + * It is call to update the list of vout handled by the fullscreen controller */ -void FullscreenControllerWidget::attachVout( vout_thread_t *p_nvout ) +void FullscreenControllerWidget::setVoutList( vout_thread_t **pp_vout, int i_vout ) { - assert( p_nvout && !p_vout ); + QList del; + QList add; - p_vout = p_nvout; + QList set; - msg_Dbg( p_vout, "Qt FS: Attaching Vout" ); - vlc_mutex_lock( &lock ); + /* */ + for( int i = 0; i < i_vout; i++ ) + set += pp_vout[i]; - var_AddCallback( p_vout, "fullscreen", - FullscreenControllerWidgetFullscreenChanged, this ); - /* I miss a add and fire */ - fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ), - var_GetInteger( p_vout, "mouse-hide-timeout" ) ); + /* Vout to remove */ + vlc_mutex_lock( &lock ); + foreach( vout_thread_t *p_vout, vout ) + { + if( !set.contains( p_vout ) ) + del += p_vout; + } vlc_mutex_unlock( &lock ); -} -/** - * It is called after turn off video. - */ -void FullscreenControllerWidget::detachVout() -{ - if( p_vout ) + foreach( vout_thread_t *p_vout, del ) { - msg_Dbg( p_vout, "Qt FS: Detaching Vout" ); var_DelCallback( p_vout, "fullscreen", - FullscreenControllerWidgetFullscreenChanged, this ); + FullscreenControllerWidgetFullscreenChanged, this ); vlc_mutex_lock( &lock ); fullscreenChanged( p_vout, false, 0 ); + vout.removeAll( p_vout ); vlc_mutex_unlock( &lock ); - p_vout = NULL; + + vlc_object_release( VLC_OBJECT(p_vout) ); } -} + /* Vout to track */ + vlc_mutex_lock( &lock ); + foreach( vout_thread_t *p_vout, set ) + { + if( !vout.contains( p_vout ) ) + add += p_vout; + } + vlc_mutex_unlock( &lock ); + + foreach( vout_thread_t *p_vout, add ) + { + vlc_object_hold( VLC_OBJECT(p_vout) ); + + vlc_mutex_lock( &lock ); + vout.append( p_vout ); + var_AddCallback( p_vout, "fullscreen", + FullscreenControllerWidgetFullscreenChanged, this ); + /* I miss a add and fire */ + fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ), + var_GetInteger( p_vout, "mouse-hide-timeout" ) ); + vlc_mutex_unlock( &lock ); + } +} /** * Register and unregister callback for mouse moving */ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout, bool b_fs, int i_timeout ) { + /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */ msg_Dbg( p_vout, "Qt: Entering Fullscreen" ); vlc_mutex_lock( &lock ); @@ -1213,8 +1100,39 @@ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout, /* Force fs hidding */ IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 ); - QApplication::postEvent( this, static_cast(eHide) ); + QApplication::postEvent( this, eHide ); } vlc_mutex_unlock( &lock ); } +/** + * Mouse change callback (show/hide the controller on mouse movement) + */ +void FullscreenControllerWidget::mouseChanged( vout_thread_t *p_vout, int i_mousex, int i_mousey ) +{ + bool b_toShow; + + /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */ + + b_toShow = false; + if( ( i_mouse_last_move_x == -1 || i_mouse_last_move_y == -1 ) || + ( abs( i_mouse_last_move_x - i_mousex ) > 2 || + abs( i_mouse_last_move_y - i_mousey ) > 2 ) ) + { + i_mouse_last_move_x = i_mousex; + i_mouse_last_move_y = i_mousey; + b_toShow = true; + } + + if( b_toShow ) + { + /* Show event */ + IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 ); + QApplication::postEvent( this, eShow ); + + /* Plan hide event */ + IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 ); + QApplication::postEvent( this, eHide ); + } +} +