/*****************************************************************************
- * Controller.cpp : Controller for the main interface
+ * controller.cpp : Controller for the main interface
****************************************************************************
* Copyright (C) 2006-2009 the VideoLAN team
* $Id$
/* Open the generic config line for the toolbar, parse it
* and create the widgets accordingly */
void AbstractController::parseAndCreate( const QString& config,
- QBoxLayout *controlLayout )
+ QBoxLayout *newControlLayout )
{
QStringList list = config.split( ";", QString::SkipEmptyParts ) ;
for( int i = 0; i < list.count(); i++ )
buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
if( !ok )
{
- msg_Warn( p_intf, "Parsing error 2. Please report this." );
+ msg_Warn( p_intf, "Parsing error 2. Please, report this." );
continue;
}
{
msg_Warn( p_intf, "Parsing error 3. Please, report this." );
continue;
- } }
+ }
+ }
- createAndAddWidget( controlLayout, -1, i_type, i_option );
+ createAndAddWidget( newControlLayout, -1, i_type, i_option );
}
if( buttonGroupLayout )
{
- controlLayout->addLayout( buttonGroupLayout );
+ newControlLayout->addLayout( buttonGroupLayout );
buttonGroupLayout = NULL;
}
}
-void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
+void AbstractController::createAndAddWidget( QBoxLayout *controlLayout_,
int i_index,
buttonType_e i_type,
int i_option )
/* Close the current buttonGroup if we have a special widget or a spacer */
if( buttonGroupLayout && i_type > BUTTON_MAX )
{
- controlLayout->addLayout( buttonGroupLayout );
+ controlLayout_->addLayout( buttonGroupLayout );
buttonGroupLayout = NULL;
}
/* Special case for SPACERS, who aren't QWidgets */
if( i_type == WIDGET_SPACER )
{
- controlLayout->addSpacing( 12 );
+ controlLayout_->addSpacing( 12 );
}
else if( i_type == WIDGET_SPACER_EXTEND )
{
- controlLayout->addStretch( 12 );
+ controlLayout_->addStretch( 12 );
}
else
{
}
else /* Special widgets */
{
- controlLayout->addWidget( widg );
+ controlLayout_->addWidget( widg );
}
}
}
ENABLE_ON_VIDEO( FULLSCREENButton );
}
break;
+ case FULLWIDTH_BUTTON: {
+ NORMAL_BUTTON( FULLWIDTH );
+ }
+ break;
case EXTENDED_BUTTON:{
NORMAL_BUTTON( EXTENDED );
}
}
break;
case INPUT_SLIDER: {
- SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL );
+ SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL, !b_shiny );
SeekPoints *chapters = new SeekPoints( this, p_intf );
- CONNECT( THEMIM->getIM(), titleChanged( bool ), chapters, update() );
+ CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() );
slider->setChapters( chapters );
/* Update the position when the IM has changed */
THEMIM->getIM(), sliderUpdate( float ) );
CONNECT( THEMIM->getIM(), cachingChanged( float ),
slider, updateBuffering( float ) );
+ /* Give hint to disable slider's interactivity when useless */
+ CONNECT( THEMIM->getIM(), inputCanSeek( bool ),
+ slider, setSeekable( bool ) );
widget = slider;
}
break;
CONNECT_MAP_SET( play, PLAY_ACTION );
}
break;
+ case ASPECT_RATIO_COMBOBOX:
+ widget = new AspectRatioComboBox( p_intf );
+ widget->setMinimumHeight( 26 );
+ break;
+ case SPEED_LABEL:
+ widget = new SpeedLabel( p_intf, this );
+ break;
+ case TIME_LABEL_ELAPSED:
+ widget = new TimeLabel( p_intf, TimeLabel::Elapsed );
+ break;
+ case TIME_LABEL_REMAINING:
+ widget = new TimeLabel( p_intf, TimeLabel::Remaining );
+ break;
default:
msg_Warn( p_intf, "This should not happen %i", button );
break;
/* Change the navigation button display when the IM
navigation changes */
- CONNECT( THEMIM->getIM(), titleChanged( bool ),
- discFrame, setVisible( bool ) );
CONNECT( THEMIM->getIM(), chapterChanged( bool ),
+ discFrame, setVisible( bool ) );
+ CONNECT( THEMIM->getIM(), titleChanged( bool ),
menuButton, setVisible( bool ) );
/* Changes the IM navigation when triggered on the nav buttons */
CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
setStyleSheet( "background: red ");
#endif
setAttribute( Qt::WA_MacBrushedMetal);
- QVBoxLayout *controlLayout = new QVBoxLayout( this );
- controlLayout->setContentsMargins( 4, 1, 0, 0 );
+ controlLayout = new QVBoxLayout( this );
+ controlLayout->setContentsMargins( 3, 1, 0, 1 );
controlLayout->setSpacing( 0 );
QHBoxLayout *controlLayout1 = new QHBoxLayout;
controlLayout1->setSpacing( 0 ); controlLayout1->setMargin( 0 );
- QString line1 = getSettings()->value( "MainToolbar1", MAIN_TB1_DEFAULT )
+ QString line1 = getSettings()->value( "MainWindow/MainToolbar1", MAIN_TB1_DEFAULT )
.toString();
parseAndCreate( line1, controlLayout1 );
QHBoxLayout *controlLayout2 = new QHBoxLayout;
controlLayout2->setSpacing( 0 ); controlLayout2->setMargin( 0 );
- QString line2 = getSettings()->value( "MainToolbar2", MAIN_TB2_DEFAULT )
+ QString line2 = getSettings()->value( "MainWindow/MainToolbar2", MAIN_TB2_DEFAULT )
.toString();
parseAndCreate( line2, controlLayout2 );
#endif
- QString line = getSettings()->value( "AdvToolbar", ADV_TB_DEFAULT )
+ QString line = getSettings()->value( "MainWindow/AdvToolbar", ADV_TB_DEFAULT )
.toString();
parseAndCreate( line, controlLayout );
}
setStyleSheet( "background: green ");
#endif
- QString line = getSettings()->value( "InputToolbar", INPT_TB_DEFAULT ).toString();
+ QString line = getSettings()->value( "MainWindow/InputToolbar", INPT_TB_DEFAULT ).toString();
parseAndCreate( line, controlLayout );
}
/**********************************************************************
vout.clear();
setWindowFlags( Qt::ToolTip );
- setMinimumWidth( 600 );
+ setMinimumWidth( FSC_WIDTH );
+ setMinimumHeight( FSC_HEIGHT );
+ isWideFSC = false;
setFrameShape( QFrame::StyledPanel );
setFrameStyle( QFrame::Sunken );
this, setVoutList( vout_thread_t **, int ) );
/* First Move */
- QRect rect1 = getSettings()->value( "FullScreen/screen" ).toRect();
- QPoint pos1 = getSettings()->value( "FullScreen/pos" ).toPoint();
- int number = var_InheritInteger( p_intf, "qt-fullscreen-screennumber" );
- if( number == -1 || number > QApplication::desktop()->numScreens() )
- number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
-
- QRect rect = QApplication::desktop()->screenGeometry( number );
- if( rect == rect1 && rect.contains( pos1, true ) )
- {
- move( pos1 );
- i_screennumber = number;
- screenRes = QApplication::desktop()->screenGeometry(number);
- }
- else
- {
- centerFSC( number );
- }
-
+ previousPosition = getSettings()->value( "FullScreen/pos" ).toPoint();
+ screenRes = getSettings()->value( "FullScreen/screen" ).toRect();
+ isWideFSC = getSettings()->value( "FullScreen/wide" ).toBool();
+ i_screennumber = var_InheritInteger( p_intf, "qt-fullscreen-screennumber" );
}
FullscreenControllerWidget::~FullscreenControllerWidget()
{
- QPoint pos1 = pos();
- QRect rect1 = QApplication::desktop()->screenGeometry( pos1 );
- getSettings()->setValue( "FullScreen/pos", pos1 );
- getSettings()->setValue( "FullScreen/screen", rect1 );
+ getSettings()->setValue( "FullScreen/pos", previousPosition );
+ getSettings()->setValue( "FullScreen/screen", screenRes );
+ getSettings()->setValue( "FullScreen/wide", isWideFSC );
setVoutList( NULL, 0 );
vlc_mutex_destroy( &lock );
}
+void FullscreenControllerWidget::restoreFSC()
+{
+ if( !isWideFSC )
+ {
+ /* Restore half-bar and re-centre if needed */
+ setMinimumWidth( FSC_WIDTH );
+ adjustSize();
+
+ QRect currentRes = QApplication::desktop()->screenGeometry( targetScreen() );
+
+ if( currentRes == screenRes &&
+ QApplication::desktop()->screen()->geometry().contains( previousPosition, true ) )
+ {
+ /* Restore to the last known position */
+ move( previousPosition );
+ }
+ else
+ {
+ /* FSC is out of screen or screen resolution changed */
+ msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
+ centerFSC( targetScreen() );
+ screenRes = currentRes;
+ previousPosition = pos();
+ }
+ }
+ else
+ {
+ /* Dock at the bottom of the screen */
+ updateFullwidthGeometry( targetScreen() );
+ }
+
+#ifdef Q_WS_X11
+ // Tell kwin that we do not want a shadow around the fscontroller
+ setMask( QRegion( 0, 0, width(), height() ) );
+#endif
+}
+
void FullscreenControllerWidget::centerFSC( int number )
{
- screenRes = QApplication::desktop()->screenGeometry(number);
+ QRect currentRes = QApplication::desktop()->screenGeometry( number );
/* screen has changed, calculate new position */
- QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (sizeHint().width() / 2),
- screenRes.y() + screenRes.height() - sizeHint().height());
+ QPoint pos = QPoint( currentRes.x() + (currentRes.width() / 2) - (width() / 2),
+ currentRes.y() + currentRes.height() - height());
move( pos );
-
- i_screennumber = number;
}
/**
*/
void FullscreenControllerWidget::showFSC()
{
- adjustSize();
-
- int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
-
- if( number != i_screennumber ||
- screenRes != QApplication::desktop()->screenGeometry(number) )
- {
- centerFSC( number );
- msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
- }
+ restoreFSC();
#if HAVE_TRANSPARENCY
setWindowOpacity( f_opacity );
#endif
-#ifdef Q_WS_X11
- // Tell kwin that we do not want a shadow around the fscontroller
- setMask( QRegion( 0, 0, width(), height() ) );
-#endif
-
show();
}
#endif
}
+void FullscreenControllerWidget::updateFullwidthGeometry( int number )
+{
+ QRect screenGeometry = QApplication::desktop()->screenGeometry( number );
+ setMinimumWidth( screenGeometry.width() );
+ setGeometry( screenGeometry.x(), screenGeometry.y() + screenGeometry.height() - FSC_HEIGHT, screenGeometry.width(), FSC_HEIGHT );
+ adjustSize();
+}
+
+void FullscreenControllerWidget::toggleFullwidth()
+{
+ /* Toggle isWideFSC switch */
+ isWideFSC = !isWideFSC;
+
+ restoreFSC();
+}
+
+int FullscreenControllerWidget::targetScreen()
+{
+ if( i_screennumber == -1 || i_screennumber > QApplication::desktop()->numScreens() )
+ return QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
+ return i_screennumber;
+}
+
/**
* event handling
* events: show, hide, start timer for hiding
switch( (int)event->type() )
{
/* This is used when the 'i' hotkey is used, to force quick toggle */
- case FullscreenControlToggle_Type:
+ case IMEvent::FullscreenControlToggle:
vlc_mutex_lock( &lock );
b_fs = b_fullscreen;
vlc_mutex_unlock( &lock );
}
break;
/* Event called to Show the FSC on mouseChanged() */
- case FullscreenControlShow_Type:
+ case IMEvent::FullscreenControlShow:
vlc_mutex_lock( &lock );
b_fs = b_fullscreen;
vlc_mutex_unlock( &lock );
break;
/* Start the timer to hide later, called usually with above case */
- case FullscreenControlPlanHide_Type:
+ case IMEvent::FullscreenControlPlanHide:
if( !b_mouse_over ) // Only if the mouse is not over FSC
planHideFSC();
break;
/* Hide */
- case FullscreenControlHide_Type:
+ case IMEvent::FullscreenControlHide:
hideFSC();
break;
default:
*/
void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event )
{
+ if( isWideFSC ) return;
i_mouse_last_x = event->globalX();
i_mouse_last_y = event->globalY();
event->accept();
void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event )
{
+ if( isWideFSC ) return;
i_mouse_last_x = -1;
i_mouse_last_y = -1;
event->accept();
+
+ // Save the new FSC position
+ previousPosition = pos();
}
/**
vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
- msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
+ msg_Dbg( p_vout, "Qt: Fullscreen state changed" );
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );
FullscreenControllerWidgetMouseMoved, this );
/* Force fs hiding */
- IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );
+ IMEvent *eHide = new IMEvent( IMEvent::FullscreenControlHide, 0 );
QApplication::postEvent( this, eHide );
}
vlc_mutex_unlock( &lock );
if( b_toShow )
{
/* Show event */
- IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
+ IMEvent *eShow = new IMEvent( IMEvent::FullscreenControlShow, 0 );
QApplication::postEvent( this, eShow );
/* Plan hide event */
- IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
+ IMEvent *eHide = new IMEvent( IMEvent::FullscreenControlPlanHide, 0 );
QApplication::postEvent( this, eHide );
}
}