X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Finterface_widgets.cpp;h=1c740112259ddccb768cc85dba7370b6ec061258;hb=223419069363b3eab712cff2d0ac671a94d8fc65;hp=6402535db8ad09ea44f49f2e51f7b9ba71aa0fc3;hpb=4f541d3b05be7729e48a28e5daf8497102598bb8;p=vlc diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index 6402535db8..1c74011225 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -28,6 +28,8 @@ # include "config.h" #endif +#include + #include "dialogs_provider.hpp" #include "components/interface_widgets.hpp" #include "main_interface.hpp" @@ -35,7 +37,6 @@ #include "menus.hpp" #include "util/input_slider.hpp" #include "util/customwidgets.hpp" -#include #include #include @@ -47,11 +48,14 @@ #include #include #include + #ifdef Q_WS_X11 # include # include #endif +#include + /********************************************************************** * Video Widget. A simple frame on which video is drawn * This class handles resize issues @@ -60,11 +64,11 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i ) { /* Init */ - vlc_mutex_init( &lock ); - p_vout = NULL; + i_vout = 0; hide(); setMinimumSize( 16, 16 ); videoSize.rwidth() = -1; videoSize.rheight() = -1; + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); /* Black background is more coherent for a Video Widget IMVHO */ QPalette plt = palette(); @@ -74,10 +78,15 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i ) setAttribute( Qt::WA_PaintOnScreen, true ); /* The core can ask through a callback to show the video. */ - connect( this, SIGNAL(askVideoWidgetToShow()), this, SLOT(show()), Qt::BlockingQueuedConnection ); - - /* The core can ask through a callback to resize the video */ - // CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) ); +#if HAS_QT43 + connect( this, SIGNAL(askVideoWidgetToShow( unsigned int, unsigned int)), + this, SLOT(SetSizing(unsigned int, unsigned int )), + Qt::BlockingQueuedConnection ); +#else +#error This is broken. Fix it with a QEventLoop with a processEvents () + connect( this, SIGNAL(askVideoWidgetToShow( unsigned int, unsigned int)), + this, SLOT(SetSizing(unsigned int, unsigned int )) ); +#endif } void VideoWidget::paintEvent(QPaintEvent *ev) @@ -90,7 +99,9 @@ void VideoWidget::paintEvent(QPaintEvent *ev) VideoWidget::~VideoWidget() { - vlc_mutex_lock( &lock ); + vout_thread_t *p_vout = i_vout + ? (vout_thread_t *)vlc_object_get( i_vout ) : NULL; + if( p_vout ) { if( !p_intf->psz_switch_intf ) @@ -103,25 +114,24 @@ VideoWidget::~VideoWidget() if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS ) vout_Control( p_vout, VOUT_CLOSE ); } + vlc_object_release( p_vout ); } - vlc_mutex_unlock( &lock ); - vlc_mutex_destroy( &lock ); } /** * Request the video to avoid the conflicts **/ void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y, - unsigned int *pi_width, unsigned int *pi_height ) + unsigned int *pi_width, unsigned int *pi_height ) { msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y ); - emit askVideoWidgetToShow(); - if( p_vout ) + emit askVideoWidgetToShow( *pi_width, *pi_height ); + if( i_vout ) { msg_Dbg( p_intf, "embedded video already in use" ); return NULL; } - p_vout = p_nvout; + i_vout = p_nvout->i_object_id; msg_Dbg( p_intf, "embedded video ready (handle %p)", winId() ); return ( void* )winId(); } @@ -134,13 +144,14 @@ void VideoWidget::SetSizing( unsigned int w, unsigned int h ) msg_Dbg( p_intf, "Video is resizing to: %i %i", w, h ); videoSize.rwidth() = w; videoSize.rheight() = h; + if( isHidden() ) show(); updateGeometry(); // Needed for deinterlace } void VideoWidget::release( void *p_win ) { - msg_Dbg( p_intf, "Video is non needed anymore" ); - p_vout = NULL; + msg_Dbg( p_intf, "Video is not needed anymore" ); + i_vout = 0; videoSize.rwidth() = 0; videoSize.rheight() = 0; hide(); @@ -164,7 +175,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :QWidget( NULL ), p_intf( _p_i ) { /* We should use that one to take the more size it can */ -// setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); /* A dark background */ setAutoFillBackground( true ); @@ -194,8 +205,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) } BackgroundWidget::~BackgroundWidget() -{ -} +{} void BackgroundWidget::resizeEvent( QResizeEvent * event ) { @@ -241,7 +251,7 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) : layout->addItem( new QSpacerItem( 40,20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) ); + layout->addWidget( new QLabel( qtr( "Current visualization" ) ) ); current = new QLabel( qtr( "None" ) ); layout->addWidget( current ); @@ -254,8 +264,7 @@ VisualSelector::VisualSelector( intf_thread_t *_p_i ) : } VisualSelector::~VisualSelector() -{ -} +{} void VisualSelector::prev() { @@ -307,7 +316,7 @@ AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) : frameButton->setMaximumSize( QSize( 26, 26 ) ); frameButton->setIconSize( QSize( 20, 20 ) ); advLayout->addWidget( frameButton ); - BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by Frame" ), frame() ); + BUTTON_SET_ACT( frameButton, "Fr", qtr( "Frame by frame" ), frame() ); #endif recordButton = new QPushButton( "R" ); @@ -461,7 +470,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" ); BUTTON_SET_IMG( nextSectionButton, "", next.png, "" ); - BUTTON_SET_IMG( menuButton, "", previous.png, "" ); + BUTTON_SET_IMG( menuButton, "", previous.png, qtr( "Menu" ) ); discFrame->hide(); @@ -607,7 +616,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, /** extended Settings **/ extSettingsButton = new QPushButton; - BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ), + BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended settings" ), extSettings() ); setupSmallButton( extSettingsButton ); controlLayout->addWidget( extSettingsButton, 3, 12, Qt::AlignBottom ); @@ -721,11 +730,8 @@ void ControlsWidget::next() void ControlsWidget::setNavigation( int navigation ) { -#define HELP_MENU N_( "Menu" ) #define HELP_PCH N_( "Previous chapter" ) #define HELP_NCH N_( "Next chapter" ) -#define HELP_PTR N_( "Previous track" ) -#define HELP_NTR N_( "Next track" ) // 1 = chapter, 2 = title, 0 = no if( navigation == 0 ) @@ -872,7 +878,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, MainInterface *_p_mi, bool b_advControls, bool b_shiny ) : ControlsWidget( _p_i, _p_mi, b_advControls, b_shiny, true ), i_lastPosX( -1 ), i_lastPosY( -1 ), i_hideTimeout( 1 ), - b_mouseIsOver( false ) + b_mouseIsOver( false ), b_isFullscreen( false ) { setWindowFlags( Qt::ToolTip ); @@ -970,7 +976,11 @@ void FullscreenControllerWidget::slowHideFSC() } else { +#ifdef WIN32TRICK + if ( windowOpacity() > 0.0 && !fscHidden ) +#else if ( windowOpacity() > 0.0 ) +#endif { /* we should use 0.01 because of 100 pieces ^^^ but than it cannt be done in time */ @@ -1007,7 +1017,7 @@ void FullscreenControllerWidget::customEvent( QEvent *event ) { int type = event->type(); - if ( type == FullscreenControlShow_Type ) + if ( type == FullscreenControlShow_Type && b_isFullscreen ) { #ifdef WIN32TRICK // after quiting and going to fs, we need to call show() @@ -1144,7 +1154,8 @@ static int regMouseMoveCallback( vlc_object_t *vlc_object, const char *variable, if ( var_GetBool( p_vout, "fullscreen" ) && !b_registered ) { - p_fs->SetHideTimeout( var_GetInteger( p_vout, "mouse-hide-timeout" ) ); + p_fs->setHideTimeout( var_GetInteger( p_vout, "mouse-hide-timeout" ) ); + p_fs->setIsFullscreen( true ); var_AddCallback( p_vout, "mouse-moved", showFullscreenControllCallback, (void *) p_fs ); b_registered = true; @@ -1152,14 +1163,13 @@ static int regMouseMoveCallback( vlc_object_t *vlc_object, const char *variable, if ( !var_GetBool( p_vout, "fullscreen" ) && b_registered ) { + p_fs->setIsFullscreen( false ); + p_fs->hide(); var_DelCallback( p_vout, "mouse-moved", showFullscreenControllCallback, (void *) p_fs ); b_registered = false; } - if ( !var_GetBool( p_vout, "fullscreen" ) ) - p_fs->hide(); - return VLC_SUCCESS; } @@ -1201,22 +1211,24 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) : speedSlider->setOrientation( Qt::Vertical ); speedSlider->setTickPosition( QSlider::TicksRight ); - speedSlider->setRange( -100, 100 ); - speedSlider->setSingleStep( 10 ); - speedSlider->setPageStep( 20 ); - speedSlider->setTickInterval( 20 ); + speedSlider->setRange( -24, 24 ); + speedSlider->setSingleStep( 1 ); + speedSlider->setPageStep( 1 ); + speedSlider->setTickInterval( 12 ); CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) ); QToolButton *normalSpeedButton = new QToolButton( this ); normalSpeedButton->setMaximumSize( QSize( 26, 20 ) ); normalSpeedButton->setAutoRaise( true ); - normalSpeedButton->setText( "N" ); + normalSpeedButton->setText( "1x" ); normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) ); CONNECT( normalSpeedButton, clicked(), this, resetRate() ); QVBoxLayout *speedControlLayout = new QVBoxLayout; + speedControlLayout->setLayoutMargins( 4, 4, 4, 4, 4 ); + speedControlLayout->setSpacing( 4 ); speedControlLayout->addWidget( speedSlider ); speedControlLayout->addWidget( normalSpeedButton ); setLayout( speedControlLayout ); @@ -1230,10 +1242,6 @@ void SpeedControlWidget::setEnable( bool b_enable ) speedSlider->setEnabled( b_enable ); } -#define RATE_SLIDER_MAXIMUM 3.0 -#define RATE_SLIDER_MINIMUM 0.3 -#define RATE_SLIDER_LENGTH 100.0 - void SpeedControlWidget::updateControls( int rate ) { if( speedSlider->isSliderDown() ) @@ -1242,32 +1250,16 @@ void SpeedControlWidget::updateControls( int rate ) return; } - int sliderValue; - double speed = INPUT_RATE_DEFAULT / (double)rate; + double value = 12 * log( (double)INPUT_RATE_DEFAULT / rate ) / log( 2 ); + int sliderValue = (int) ( ( value > 0 ) ? value + .5 : value - .5 ); - if( rate >= INPUT_RATE_DEFAULT ) + if( sliderValue < speedSlider->minimum() ) { - if( speed < RATE_SLIDER_MINIMUM ) - { - sliderValue = speedSlider->minimum(); - } - else - { - sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH - / ( 1.0 - RATE_SLIDER_MAXIMUM ) ); - } + sliderValue = speedSlider->minimum(); } - else + else if( sliderValue > speedSlider->maximum() ) { - if( speed > RATE_SLIDER_MAXIMUM ) - { - sliderValue = speedSlider->maximum(); - } - else - { - sliderValue = (int)( ( speed - 1.0 ) * RATE_SLIDER_LENGTH - / ( RATE_SLIDER_MAXIMUM - 1.0 ) ); - } + sliderValue = speedSlider->maximum(); } //Block signals to avoid feedback loop @@ -1278,18 +1270,8 @@ void SpeedControlWidget::updateControls( int rate ) void SpeedControlWidget::updateRate( int sliderValue ) { - int rate; - - if( sliderValue < 0.0 ) - { - rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH / - ( sliderValue * ( 1.0 - RATE_SLIDER_MINIMUM ) + RATE_SLIDER_LENGTH )); - } - else - { - rate = (int)(INPUT_RATE_DEFAULT* RATE_SLIDER_LENGTH / - ( sliderValue * ( RATE_SLIDER_MAXIMUM - 1.0 ) + RATE_SLIDER_LENGTH )); - } + double speed = pow( 2, (double)sliderValue / 12 ); + int rate = INPUT_RATE_DEFAULT / speed; THEMIM->getIM()->setRate(rate); }