#include <QPalette>
#include <QResizeEvent>
#include <QDate>
+#ifdef Q_WS_X11
+# include <X11/Xlib.h>
+# include <qx11info_x11.h>
+#endif
+
+#include <math.h>
/**********************************************************************
* Video Widget. A simple frame on which video is drawn
* This class handles resize issues
**********************************************************************/
-static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
- unsigned int *, unsigned int * );
-static void DoRelease( intf_thread_t *, void * );
-static int DoControl( intf_thread_t *, void *, int, va_list );
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();
plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
setPalette( plt );
+ setAttribute( Qt::WA_PaintOnScreen, true );
+
+ /* The core can ask through a callback to show the video. */
+#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
+
+
+}
- /* The core can ask through a callback to show the video */
- CONNECT( this, askVideoWidgetToShow(), this, show() );
- /* The core can ask through a callback to resize the video */
- // CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) );
+void VideoWidget::paintEvent(QPaintEvent *ev)
+{
+ QFrame::paintEvent(ev);
+#ifdef Q_WS_X11
+ XFlush( QX11Info::display() );
+#endif
}
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 )
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 );
}
/**
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();
}
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();
: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 );
controlLayout = new QGridLayout( );
controlLayout->setSpacing( 0 );
-#if QT43
- controlLayout->setContentsMargins( 9, 6, 9, 6 );
-#else
- controlLayout->setMargin( 6 );
-#endif
+ controlLayout->setLayoutMargins( 7, 5, 7, 3, 6 );
if( !b_fsCreation )
setLayout( controlLayout );
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();
sectionNext() );
CONNECT( menuButton, clicked(), THEMIM->getIM(),
sectionMenu() );
+
/**
* Telextext QFrame
* TODO: Merge with upper menu in a StackLayout
**/
-#ifdef ZVBI_COMPILED
telexFrame = new QWidget( this );
QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
telexLayout->setSpacing( 0 );
telexLayout->setMargin( 0 );
- QToolButton *telexOn = new QToolButton;
- telexOn->setText( qtr( "On" ) );
+ telexOn = new QPushButton;
setupSmallButton( telexOn );
telexLayout->addWidget( telexOn );
- QToolButton *telexTransparent = new QToolButton;
- telexTransparent->setText( qtr( "Transparent" ) );
+ telexTransparent = new QPushButton;
setupSmallButton( telexTransparent );
telexLayout->addWidget( telexTransparent );
+ b_telexTransparent = false;
- QSpinBox *telexPage = new QSpinBox;
+ telexPage = new QSpinBox;
telexPage->setRange( 0, 999 );
telexPage->setValue( 100 );
telexPage->setAccelerated( true );
telexPage->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
telexLayout->addWidget( telexPage );
- controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
- telexFrame->hide();
+ if( !b_fsCreation )
+ controlLayout->addWidget( telexFrame, 1, 10, 2, 4, Qt::AlignBottom );
+ telexFrame->hide(); /* default hidden */
CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
telexGotoPage( int ) );
+ CONNECT( THEMIM->getIM(), setNewTelexPage( int ),
+ telexPage, setValue( int ) );
+
+ BUTTON_SET_IMG( telexOn, "", tv.png, qtr( "Teletext on" ) );
+
+ CONNECT( telexOn, clicked(), THEMIM->getIM(),
+ telexToggleButtons() );
CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
telexToggle( bool ) );
+ CONNECT( THEMIM->getIM(), toggleTelexButtons(),
+ this, toggleTeletext() );
+ b_telexEnabled = false;
+ telexTransparent->setEnabled( false );
+ telexPage->setEnabled( false );
+
+ BUTTON_SET_IMG( telexTransparent, "", tvtelx.png, qtr( "Teletext" ) );
CONNECT( telexTransparent, clicked( bool ),
- THEMIM->getIM(), telexSetTransparency( bool ) );
+ THEMIM->getIM(), telexSetTransparency() );
+ CONNECT( THEMIM->getIM(), toggleTelexTransparency(),
+ this, toggleTeletextTransparency() );
CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
telexFrame, setVisible( bool ) );
-#endif
/** Play Buttons **/
QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
ControlsWidget::~ControlsWidget()
{}
+void ControlsWidget::toggleTeletext()
+{
+ bool b_enabled = THEMIM->teletextState();
+ if( b_telexEnabled )
+ {
+ telexTransparent->setEnabled( false );
+ telexPage->setEnabled( false );
+ b_telexEnabled = false;
+ }
+ else if( b_enabled )
+ {
+ telexTransparent->setEnabled( true );
+ telexPage->setEnabled( true );
+ b_telexEnabled = true;
+ }
+}
+
+void ControlsWidget::toggleTeletextTransparency()
+{
+ if( b_telexTransparent )
+ {
+ telexTransparent->setIcon( QIcon( ":/pixmaps/tvtelx.png" ) );
+ telexTransparent->setToolTip( qtr( "Teletext" ) );
+ b_telexTransparent = false;
+ }
+ else
+ {
+ telexTransparent->setIcon( QIcon( ":/pixmaps/tvtelx-transparent.png" ) );
+ telexTransparent->setToolTip( qtr( "Transparent" ) );
+ b_telexTransparent = true;
+ }
+}
+
void ControlsWidget::stop()
{
THEMIM->stop();
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 )
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 );
QGridLayout *fsLayout = new QGridLayout( this );
controlLayout->setSpacing( 0 );
- #if QT43
- controlLayout->setContentsMargins( 5, 1, 5, 1 );
- #else
- controlLayout->setMargin( 5 );
- #endif
+ controlLayout->setLayoutMargins( 5, 1, 5, 1, 5 );
fsLayout->addWidget( slowerButton, 0, 0 );
slider->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum);
fsLayout->addWidget( discFrame, 1, 4 );
- #ifdef ZVBI_COMPILED
fsLayout->addWidget( telexFrame, 1, 5 );
- #endif
fsLayout->addWidget( advControls, 1, 6, Qt::AlignVCenter );
}
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 */
{
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()
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;
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;
- p_fs->hide();
}
return VLC_SUCCESS;
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 );
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() )
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
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);
}