/*****************************************************************************
* Controller.cpp : Controller for the main interface
****************************************************************************
- * Copyright (C) 2006-2008 the VideoLAN team
+ * Copyright (C) 2006-2009 the VideoLAN team
* $Id$
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
# include "config.h"
#endif
-#include <vlc_vout.h>
-#include <vlc_keys.h>
+#include <vlc_vout.h> /* vout_thread_t for FSC */
+/* Widgets */
#include "components/controller.hpp"
#include "components/controller_widget.hpp"
#include "components/interface_widgets.hpp"
+#include "util/buttons/DeckButtonsLayout.hpp"
+#include "util/buttons/BrowseButton.hpp"
+#include "util/buttons/RoundButton.hpp"
-#include "dialogs_provider.hpp" /* Opening Dialogs */
-#include "input_manager.hpp"
-#include "actions_manager.hpp"
+#include "dialogs_provider.hpp" /* Opening Dialogs */
+#include "actions_manager.hpp" /* *_ACTION */
-#include "util/input_slider.hpp" /* InputSlider */
-#include "util/customwidgets.hpp" /* qEventToKey */
+#include "util/input_slider.hpp" /* SeekSlider */
+#include "util/customwidgets.hpp" /* qEventToKey */
+
+#include "adapters/seekpoints.hpp"
-#include <QSpacerItem>
#include <QToolButton>
#include <QHBoxLayout>
+#include <QRegion>
#include <QSignalMapper>
#include <QTimer>
+//#define DEBUG_LAYOUT 1
+
/**********************************************************************
* TEH controls
**********************************************************************/
{
p_intf = _p_i;
advControls = NULL;
+ buttonGroupLayout = NULL;
/* Main action provider */
toolbarActionsMapper = new QSignalMapper( this );
CONNECT( toolbarActionsMapper, mapped( int ),
ActionsManager::getInstance( p_intf ), doAction( int ) );
- CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
+ CONNECT( THEMIM->getIM(), playingStatusChanged( int ), this, setStatus( int ) );
+
+ setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
}
/* Reemit some signals on status Change to activate some buttons */
QStringList list2 = list.at( i ).split( "-" );
if( list2.size() < 1 )
{
- msg_Warn( p_intf, "Parsing error. Report this" );
+ msg_Warn( p_intf, "Parsing error 1. Please, report this." );
continue;
}
buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
if( !ok )
{
- msg_Warn( p_intf, "Parsing error 0. Please report this" );
+ msg_Warn( p_intf, "Parsing error 2. Please report this." );
continue;
}
i_option = list2.at( 1 ).toInt( &ok );
if( !ok )
{
- msg_Warn( p_intf, "Parsing error 1. Please report this" );
+ msg_Warn( p_intf, "Parsing error 3. Please, report this." );
continue;
- }
- }
+ } }
createAndAddWidget( controlLayout, -1, i_type, i_option );
}
+
+ if( buttonGroupLayout )
+ {
+ controlLayout->addLayout( buttonGroupLayout );
+ buttonGroupLayout = NULL;
+ }
}
void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
buttonType_e i_type,
int i_option )
{
+ VLC_UNUSED( i_index ); // i_index should only be required for edition
+
+ /* Close the current buttonGroup if we have a special widget or a spacer */
+ if( buttonGroupLayout && i_type > BUTTON_MAX )
+ {
+ controlLayout->addLayout( buttonGroupLayout );
+ buttonGroupLayout = NULL;
+ }
+
/* Special case for SPACERS, who aren't QWidgets */
if( i_type == WIDGET_SPACER )
{
- controlLayout->insertSpacing( i_index, 16 );
- return;
+ controlLayout->addSpacing( 12 );
}
-
- if( i_type == WIDGET_SPACER_EXTEND )
+ else if( i_type == WIDGET_SPACER_EXTEND )
{
- controlLayout->insertStretch( i_index, 16 );
- return;
+ controlLayout->addStretch( 12 );
}
+ else
+ {
+ /* Create the widget */
+ QWidget *widg = createWidget( i_type, i_option );
+ if( !widg ) return;
- QWidget *widg = createWidget( i_type, i_option );
- if( !widg ) return;
+ /* Buttons */
+ if( i_type < BUTTON_MAX )
+ {
+ if( !buttonGroupLayout )
+ {
+ buttonGroupLayout = new QHBoxLayout;
- controlLayout->insertWidget( i_index, widg );
+ }
+ buttonGroupLayout->addWidget( widg );
+ }
+ else /* Special widgets */
+ {
+ controlLayout->addWidget( widg );
+ }
+ }
}
button->setToolTip( tooltip ); \
button->setIcon( QIcon( ":/"#image ) );
-
#define ENABLE_ON_VIDEO( a ) \
CONNECT( THEMIM->getIM(), voutChanged( bool ), a, setEnabled( bool ) ); \
a->setEnabled( THEMIM->getIM()->hasVideo() ); /* TODO: is this necessary? when input is started before the interface? */
CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \
a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
+#define NORMAL_BUTTON( name ) \
+ QToolButton * name ## Button = new QToolButton; \
+ setupButton( name ## Button ); \
+ CONNECT_MAP_SET( name ## Button, name ## _ACTION ); \
+ BUTTON_SET_BAR( name ## Button ); \
+ widget = name ## Button;
+
QWidget *AbstractController::createWidget( buttonType_e button, int options )
{
-
- bool b_flat = options & WIDGET_FLAT;
- bool b_big = options & WIDGET_BIG;
+ bool b_flat = options & WIDGET_FLAT;
+ bool b_big = options & WIDGET_BIG;
bool b_shiny = options & WIDGET_SHINY;
bool b_special = false;
BUTTON_SET_BAR( playButton );
CONNECT_MAP_SET( playButton, PLAY_ACTION );
CONNECT( this, inputPlaying( bool ),
- playButton, updateButton( bool ));
+ playButton, updateButtonIcons( bool ));
widget = playButton;
}
break;
case STOP_BUTTON:{
- QToolButton *stopButton = new QToolButton;
- setupButton( stopButton );
- CONNECT_MAP_SET( stopButton, STOP_ACTION );
- BUTTON_SET_BAR( stopButton );
- widget = stopButton;
+ NORMAL_BUTTON( STOP );
}
break;
case OPEN_BUTTON:{
- QToolButton *openButton = new QToolButton;
- setupButton( openButton );
- CONNECT_MAP_SET( openButton, OPEN_ACTION );
- BUTTON_SET_BAR( openButton );
- widget = openButton;
+ NORMAL_BUTTON( OPEN );
+ }
+ break;
+ case OPEN_SUB_BUTTON:{
+ NORMAL_BUTTON( OPEN_SUB );
}
break;
case PREVIOUS_BUTTON:{
- QToolButton *prevButton = new QToolButton;
- setupButton( prevButton );
- CONNECT_MAP_SET( prevButton, PREVIOUS_ACTION );
- BUTTON_SET_BAR( prevButton );
- widget = prevButton;
+ NORMAL_BUTTON( PREVIOUS );
}
break;
- case NEXT_BUTTON:
- {
- QToolButton *nextButton = new QToolButton;
- setupButton( nextButton );
- CONNECT_MAP_SET( nextButton, NEXT_ACTION );
- BUTTON_SET_BAR( nextButton );
- widget = nextButton;
+ case NEXT_BUTTON: {
+ NORMAL_BUTTON( NEXT );
}
break;
case SLOWER_BUTTON:{
- QToolButton *slowerButton = new QToolButton;
- setupButton( slowerButton );
- CONNECT_MAP_SET( slowerButton, SLOWER_ACTION );
- BUTTON_SET_BAR( slowerButton );
- ENABLE_ON_INPUT( slowerButton );
- widget = slowerButton;
+ NORMAL_BUTTON( SLOWER );
+ ENABLE_ON_INPUT( SLOWERButton );
}
break;
case FASTER_BUTTON:{
- QToolButton *fasterButton = new QToolButton;
- setupButton( fasterButton );
- CONNECT_MAP_SET( fasterButton, FASTER_ACTION );
- BUTTON_SET_BAR( fasterButton );
- ENABLE_ON_INPUT( fasterButton );
- widget = fasterButton;
+ NORMAL_BUTTON( FASTER );
+ ENABLE_ON_INPUT( FASTERButton );
}
break;
- case FRAME_BUTTON: {
- QToolButton *frameButton = new QToolButton;
- setupButton( frameButton );
- CONNECT_MAP_SET( frameButton, FRAME_ACTION );
- BUTTON_SET_BAR( frameButton );
- ENABLE_ON_VIDEO( frameButton );
- widget = frameButton;
+ case PREV_SLOW_BUTTON:{
+ QToolButtonExt *but = new QToolButtonExt;
+ setupButton( but );
+ BUTTON_SET_BAR( but );
+ CONNECT( but, shortClicked(), THEMIM, prev() );
+ CONNECT( but, longClicked(), THEAM, skipBackward() );
+ widget = but;
+ }
+ break;
+ case NEXT_FAST_BUTTON:{
+ QToolButtonExt *but = new QToolButtonExt;
+ setupButton( but );
+ BUTTON_SET_BAR( but );
+ CONNECT( but, shortClicked(), THEMIM, next() );
+ CONNECT( but, longClicked(), THEAM, skipForward() );
+ widget = but;
}
break;
- case FULLSCREEN_BUTTON:{
- QToolButton *fullscreenButton = new QToolButton;
- setupButton( fullscreenButton );
- CONNECT_MAP_SET( fullscreenButton, FULLSCREEN_ACTION );
- BUTTON_SET_BAR( fullscreenButton );
- ENABLE_ON_VIDEO( fullscreenButton );
- widget = fullscreenButton;
+ case FRAME_BUTTON: {
+ NORMAL_BUTTON( FRAME );
+ ENABLE_ON_VIDEO( FRAMEButton );
}
break;
- case DEFULLSCREEN_BUTTON:{
- QToolButton *fullscreenButton = new QToolButton;
- setupButton( fullscreenButton );
- CONNECT_MAP_SET( fullscreenButton, FULLSCREEN_ACTION );
- BUTTON_SET_BAR( fullscreenButton )
- ENABLE_ON_VIDEO( fullscreenButton );
- widget = fullscreenButton;
+ case FULLSCREEN_BUTTON:
+ case DEFULLSCREEN_BUTTON:
+ {
+ NORMAL_BUTTON( FULLSCREEN );
+ ENABLE_ON_VIDEO( FULLSCREENButton );
}
break;
case EXTENDED_BUTTON:{
- QToolButton *extSettingsButton = new QToolButton;
- setupButton( extSettingsButton );
- CONNECT_MAP_SET( extSettingsButton, EXTENDED_ACTION );
- BUTTON_SET_BAR( extSettingsButton )
- widget = extSettingsButton;
+ NORMAL_BUTTON( EXTENDED );
}
break;
case PLAYLIST_BUTTON:{
- QToolButton *playlistButton = new QToolButton;
- setupButton( playlistButton );
- CONNECT_MAP_SET( playlistButton, PLAYLIST_ACTION );
- BUTTON_SET_BAR( playlistButton );
- widget = playlistButton;
+ NORMAL_BUTTON( PLAYLIST );
}
break;
case SNAPSHOT_BUTTON:{
- QToolButton *snapshotButton = new QToolButton;
- setupButton( snapshotButton );
- CONNECT_MAP_SET( snapshotButton, SNAPSHOT_ACTION );
- BUTTON_SET_BAR( snapshotButton );
- ENABLE_ON_VIDEO( snapshotButton );
- widget = snapshotButton;
+ NORMAL_BUTTON( SNAPSHOT );
+ ENABLE_ON_VIDEO( SNAPSHOTButton );
}
break;
case RECORD_BUTTON:{
ENABLE_ON_INPUT( ABButton );
CONNECT_MAP_SET( ABButton, ATOB_ACTION );
CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool),
- ABButton, setIcons( bool, bool ) );
+ ABButton, updateButtonIcons( bool, bool ) );
widget = ABButton;
}
break;
case INPUT_SLIDER: {
- InputSlider *slider = new InputSlider( Qt::Horizontal, NULL );
+ SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL );
+ SeekPoints *chapters = new SeekPoints( this, p_intf );
+ CONNECT( THEMIM->getIM(), titleChanged( bool ), chapters, update() );
+ slider->setChapters( chapters );
/* Update the position when the IM has changed */
- CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
- slider, setPosition( float, int, int ) );
+ CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
+ slider, setPosition( float, int64_t, int ) );
/* And update the IM, when the position has changed */
CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) );
+ CONNECT( THEMIM->getIM(), cachingChanged( float ),
+ slider, updateBuffering( float ) );
widget = slider;
}
break;
}
break;
case SKIP_BACK_BUTTON: {
- QToolButton *skipBakButton = new QToolButton;
- setupButton( skipBakButton );
- CONNECT_MAP_SET( skipBakButton, SKIP_BACK_ACTION );
- BUTTON_SET_BAR( skipBakButton );
- ENABLE_ON_INPUT( skipBakButton );
- widget = skipBakButton;
+ NORMAL_BUTTON( SKIP_BACK );
+ ENABLE_ON_INPUT( SKIP_BACKButton );
}
break;
case SKIP_FW_BUTTON: {
- QToolButton *skipFwButton = new QToolButton;
- setupButton( skipFwButton );
- CONNECT_MAP_SET( skipFwButton, SKIP_FW_ACTION );
- BUTTON_SET_BAR( skipFwButton );
- ENABLE_ON_INPUT( skipFwButton );
- widget = skipFwButton;
+ NORMAL_BUTTON( SKIP_FW );
+ ENABLE_ON_INPUT( SKIP_FWButton );
}
break;
case QUIT_BUTTON: {
- QToolButton *quitButton = new QToolButton;
- setupButton( quitButton );
- CONNECT_MAP_SET( quitButton, QUIT_ACTION );
- BUTTON_SET_BAR( quitButton );
- widget = quitButton;
+ NORMAL_BUTTON( QUIT );
+ }
+ break;
+ case RANDOM_BUTTON: {
+ NORMAL_BUTTON( RANDOM );
+ RANDOMButton->setCheckable( true );
+ RANDOMButton->setChecked( var_GetBool( THEPL, "random" ) );
+ CONNECT( THEMIM, randomChanged( bool ),
+ RANDOMButton, setChecked( bool ) );
+ }
+ break;
+ case LOOP_BUTTON:{
+ LoopButton *loopButton = new LoopButton;
+ setupButton( loopButton );
+ loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) );
+ loopButton->setCheckable( true );
+ loopButton->updateButtonIcons( NORMAL );
+ CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateButtonIcons( int ) );
+ CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
+ widget = loopButton;
+ }
+ break;
+ case INFO_BUTTON: {
+ NORMAL_BUTTON( INFO );
+ }
+ break;
+ case PLAYBACK_BUTTONS:{
+ widget = new QWidget;
+ DeckButtonsLayout *layout = new DeckButtonsLayout( widget );
+ BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward );
+ BrowseButton *next = new BrowseButton( widget );
+ RoundButton *play = new RoundButton( widget );
+ layout->setBackwardButton( prev );
+ layout->setForwardButton( next );
+ layout->setRoundButton( play );
+ CONNECT_MAP_SET( prev, PREVIOUS_ACTION );
+ CONNECT_MAP_SET( next, NEXT_ACTION );
+ CONNECT_MAP_SET( play, PLAY_ACTION );
}
break;
default:
/* Customize Buttons */
if( b_flat || b_big )
{
- QToolButton *tmpButton = qobject_cast<QToolButton *>(widget);
- if( tmpButton )
+ QFrame *frame = qobject_cast<QFrame *>(widget);
+ if( frame )
{
- if( b_flat )
- tmpButton->setAutoRaise( b_flat );
- if( b_big )
- {
- tmpButton->setFixedSize( QSize( 32, 32 ) );
- tmpButton->setIconSize( QSize( 26, 26 ) );
- }
+ QList<QToolButton *> allTButtons = frame->findChildren<QToolButton *>();
+ for( int i = 0; i < allTButtons.size(); i++ )
+ applyAttributes( allTButtons[i], b_flat, b_big );
+ }
+ else
+ {
+ QToolButton *tmpButton = qobject_cast<QToolButton *>(widget);
+ if( tmpButton )
+ applyAttributes( tmpButton, b_flat, b_big );
}
}
return widget;
}
+#undef NORMAL_BUTTON
+
+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()
{
QToolButton *prevSectionButton = new QToolButton( discFrame );
setupButton( prevSectionButton );
- BUTTON_SET_BAR2( prevSectionButton, dvd_prev,
+ BUTTON_SET_BAR2( prevSectionButton, toolbar/dvd_prev,
qtr("Previous Chapter/Title" ) );
discLayout->addWidget( prevSectionButton );
QToolButton *menuButton = new QToolButton( discFrame );
setupButton( menuButton );
discLayout->addWidget( menuButton );
- BUTTON_SET_BAR2( menuButton, dvd_menu, qtr( "Menu" ) );
+ BUTTON_SET_BAR2( menuButton, toolbar/dvd_menu, qtr( "Menu" ) );
QToolButton *nextSectionButton = new QToolButton( discFrame );
setupButton( nextSectionButton );
discLayout->addWidget( nextSectionButton );
- BUTTON_SET_BAR2( nextSectionButton, dvd_next,
+ BUTTON_SET_BAR2( nextSectionButton, toolbar/dvd_next,
qtr("Next Chapter/Title" ) );
/* Change the navigation button display when the IM
sectionNext() );
CONNECT( menuButton, clicked(), THEMIM->getIM(),
sectionMenu() );
- connect( THEMIM->getIM(), SIGNAL( titleChanged( bool ) ),
- this, SIGNAL( sizeChanged() ) );
return discFrame;
}
/**
* Telextext QFrame
**/
- QFrame *telexFrame = new QFrame;
+ QFrame *telexFrame = new QFrame( this );
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;
setupButton( telexOn );
- BUTTON_SET_BAR2( telexOn, tv, qtr( "Teletext Activation" ) );
+ BUTTON_SET_BAR2( telexOn, toolbar/tv, qtr( "Teletext Activation" ) );
telexOn->setEnabled( false );
telexOn->setCheckable( true );
/* Transparency button */
QToolButton *telexTransparent = new QToolButton;
setupButton( telexTransparent );
- BUTTON_SET_BAR2( telexTransparent, tvtelx,
+ BUTTON_SET_BAR2( telexTransparent, toolbar/tvtelx,
qtr( "Toggle Transparency " ) );
telexTransparent->setEnabled( false );
telexTransparent->setCheckable( true );
#undef SET_MAPPING
#undef CONNECT_MAP_SET
#undef BUTTON_SET_BAR
+#undef BUTTON_SET_BAR2
#undef ENABLE_ON_VIDEO
#undef ENABLE_ON_INPUT
QWidget *_parent ) :
AbstractController( _p_i, _parent )
{
- setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Maximum );
-
/* advanced Controls handling */
b_advancedVisible = b_advControls;
+#if DEBUG_LAYOUT
+ setStyleSheet( "background: red ");
+#endif
+ setAttribute( Qt::WA_MacBrushedMetal);
QVBoxLayout *controlLayout = new QVBoxLayout( this );
- controlLayout->setLayoutMargins( 6, 4, 6, 2, 5 );
+ controlLayout->setContentsMargins( 4, 1, 0, 0 );
controlLayout->setSpacing( 0 );
QHBoxLayout *controlLayout1 = new QHBoxLayout;
- controlLayout1->setSpacing( 0 );
+ controlLayout1->setSpacing( 0 ); controlLayout1->setMargin( 0 );
QString line1 = getSettings()->value( "MainToolbar1", MAIN_TB1_DEFAULT )
.toString();
parseAndCreate( line1, controlLayout1 );
QHBoxLayout *controlLayout2 = new QHBoxLayout;
- controlLayout2->setSpacing( 0 );
+ controlLayout2->setSpacing( 0 ); controlLayout2->setMargin( 0 );
QString line2 = getSettings()->value( "MainToolbar2", MAIN_TB2_DEFAULT )
.toString();
parseAndCreate( line2, controlLayout2 );
+ grip = new QSizeGrip( this );
+ controlLayout2->addWidget( grip, 0, Qt::AlignBottom|Qt::AlignRight );
+
if( !b_advancedVisible && advControls ) advControls->hide();
controlLayout->addLayout( controlLayout1 );
controlLayout->addLayout( controlLayout2 );
}
-ControlsWidget::~ControlsWidget()
-{}
-
void ControlsWidget::toggleAdvanced()
{
if( !advControls ) return;
controlLayout = new QHBoxLayout( this );
controlLayout->setMargin( 0 );
controlLayout->setSpacing( 0 );
+#if DEBUG_LAYOUT
+ setStyleSheet( "background: orange ");
+#endif
+
QString line = getSettings()->value( "AdvToolbar", ADV_TB_DEFAULT )
.toString();
controlLayout = new QHBoxLayout( this );
controlLayout->setMargin( 0 );
controlLayout->setSpacing( 0 );
+#if DEBUG_LAYOUT
+ setStyleSheet( "background: green ");
+#endif
QString line = getSettings()->value( "InputToolbar", INPT_TB_DEFAULT ).toString();
parseAndCreate( line, controlLayout );
/**********************************************************************
* Fullscrenn control widget
**********************************************************************/
-FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i )
- : AbstractController( _p_i )
+FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWidget *_parent )
+ : AbstractController( _p_i, _parent )
{
i_mouse_last_x = -1;
i_mouse_last_y = -1;
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
QVBoxLayout *controlLayout2 = new QVBoxLayout( this );
- controlLayout2->setLayoutMargins( 5, 2, 5, 2, 5 );
+ controlLayout2->setContentsMargins( 4, 6, 4, 2 );
/* First line */
InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
/* hiding timer */
p_hideTimer = new QTimer( this );
- CONNECT( p_hideTimer, timeout(), this, hideFSC() );
p_hideTimer->setSingleShot( true );
+ CONNECT( p_hideTimer, timeout(), this, hideFSC() );
/* slow hiding timer */
#if HAVE_TRANSPARENCY
p_slowHideTimer = new QTimer( this );
CONNECT( p_slowHideTimer, timeout(), this, slowHideFSC() );
+ f_opacity = var_InheritFloat( p_intf, "qt-fs-opacity" );
#endif
- adjustSize (); /* need to get real width and height for moving */
+ vlc_mutex_init_recursive( &lock );
-#ifdef WIN32TRICK
- setWindowOpacity( 0.0 );
- b_fscHidden = true;
- adjustSize();
- show();
-#endif
+ DCONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
+ this, setVoutList( vout_thread_t **, int ) );
- vlc_mutex_init_recursive( &lock );
+ /* 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 );
+ }
- CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, setVoutList( vout_thread_t **, int ) );
}
FullscreenControllerWidget::~FullscreenControllerWidget()
{
- getSettings()->setValue( "FullScreen/pos", pos() );
+ QPoint pos1 = pos();
+ QRect rect1 = QApplication::desktop()->screenGeometry( pos1 );
+ getSettings()->setValue( "FullScreen/pos", pos1 );
+ getSettings()->setValue( "FullScreen/screen", rect1 );
+
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) - (sizeHint().width() / 2),
+ screenRes.y() + screenRes.height() - sizeHint().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 ||
screenRes != QApplication::desktop()->screenGeometry(number) )
{
- screenRes = QApplication::desktop()->screenGeometry(number);
- msg_Dbg( p_intf, "Calculation fullscreen controllers center");
- /* 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;
- }
-#ifdef WIN32TRICK
- // after quiting and going to fs, we need to call show()
- if( isHidden() )
- show();
- if( b_fscHidden )
- {
- b_fscHidden = false;
- setWindowOpacity( 1.0 );
+ centerFSC( number );
+ msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
}
-#else
- show();
-#endif
#if HAVE_TRANSPARENCY
- setWindowOpacity( DEFAULT_OPACITY );
+ setWindowOpacity( f_opacity );
#endif
-}
-/**
- * Hide fullscreen controller
- * FIXME: under windows it have to be done by moving out of screen
- * because hide() doesnt work
- */
-void FullscreenControllerWidget::hideFSC()
-{
-#ifdef WIN32TRICK
- b_fscHidden = true;
- setWindowOpacity( 0.0 ); // simulate hidding
-#else
- hide();
+#ifdef Q_WS_X11
+ // Tell kwin that we do not want a shadow around the fscontroller
+ setMask( QRegion( 0, 0, width(), height() ) );
#endif
+
+ show();
}
/**
}
else
{
-#ifdef WIN32TRICK
- if ( windowOpacity() > 0.0 && !b_fscHidden )
-#else
if ( windowOpacity() > 0.0 )
-#endif
{
/* we should use 0.01 because of 100 pieces ^^^
but than it cannt be done in time */
/**
* event handling
- * events: show, hide, start timer for hidding
+ * events: show, hide, start timer for hiding
*/
void FullscreenControllerWidget::customEvent( QEvent *event )
{
switch( event->type() )
{
+ /* This is used when the 'i' hotkey is used, to force quick toggle */
case FullscreenControlToggle_Type:
vlc_mutex_lock( &lock );
b_fs = b_fullscreen;
vlc_mutex_unlock( &lock );
+
if( b_fs )
{
-#ifdef WIN32TRICK
- if( b_fscHidden )
-#else
if( isHidden() )
-#endif
{
p_hideTimer->stop();
showFSC();
hideFSC();
}
break;
+ /* Event called to Show the FSC on mouseChanged() */
case FullscreenControlShow_Type:
vlc_mutex_lock( &lock );
b_fs = b_fullscreen;
vlc_mutex_unlock( &lock );
-#ifdef WIN32TRICK
- if( b_fs && b_fscHidden )
-#else
- if( b_fs && !isVisible() )
-#endif
+ if( b_fs )
showFSC();
+
break;
- case FullscreenControlHide_Type:
- hideFSC();
- break;
+ /* Start the timer to hide later, called usually with above case */
case FullscreenControlPlanHide_Type:
if( !b_mouse_over ) // Only if the mouse is not over FSC
planHideFSC();
break;
+ /* Hide */
+ case FullscreenControlHide_Type:
+ hideFSC();
+ break;
default:
break;
}
*/
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;
{
i_mouse_last_x = event->globalX();
i_mouse_last_y = event->globalY();
+ event->accept();
+}
+
+void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event )
+{
+ i_mouse_last_x = -1;
+ i_mouse_last_y = -1;
+ event->accept();
}
/**
p_hideTimer->stop();
#if HAVE_TRANSPARENCY
p_slowHideTimer->stop();
+ setWindowOpacity( f_opacity );
#endif
event->accept();
}
/**
* When you get pressed key, send it to video output
- * FIXME: clearing focus by clearFocus() to not getting
- * key press events didnt work
*/
void FullscreenControllerWidget::keyPressEvent( QKeyEvent *event )
{
- int i_vlck = qtEventToVLCKey( event );
- if( i_vlck > 0 )
- {
- var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
- event->accept();
- }
- else
- event->ignore();
+ emit keyPressed( event );
}
/* */
const char *variable, vlc_value_t old_val,
vlc_value_t new_val, void *data )
{
+ VLC_UNUSED( variable ); VLC_UNUSED( old_val );
+
vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
vlc_value_t old_val, vlc_value_t new_val,
void *data )
{
+ VLC_UNUSED( variable ); VLC_UNUSED( old_val );
+
vout_thread_t *p_vout = (vout_thread_t *)vlc_object;
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
/* Get the value from the Vout - Trust the vout more than Qt */
- const int i_mousex = var_GetInteger( p_vout, "mouse-x" );
- const int i_mousey = var_GetInteger( p_vout, "mouse-y" );
-
- p_fs->mouseChanged( p_vout, i_mousex, i_mousey );
+ p_fs->mouseChanged( p_vout, new_val.coords.x, new_val.coords.y );
return VLC_SUCCESS;
}
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 );
/* Entering fullscreen, register callback */
if( b_fs && !b_fullscreen )
{
+ msg_Dbg( p_vout, "Qt: Entering Fullscreen" );
b_fullscreen = true;
i_hide_timeout = i_timeout;
var_AddCallback( p_vout, "mouse-moved",
/* Quitting fullscreen, unregistering callback */
else if( !b_fs && b_fullscreen )
{
+ msg_Dbg( p_vout, "Qt: Quitting Fullscreen" );
b_fullscreen = false;
i_hide_timeout = i_timeout;
var_DelCallback( p_vout, "mouse-moved",
FullscreenControllerWidgetMouseMoved, this );
- /* Force fs hidding */
+ /* Force fs hiding */
IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );
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 )
+void FullscreenControllerWidget::mouseChanged( vout_thread_t *, int i_mousex, int i_mousey )
{
bool b_toShow;