Commit c26bdee6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4: Simplified/fixed qt4 fullscreen implementation

This is a merge+manual adaptations of numerous commits on Qt4

(cherry picked from commit 99b7cf3c3f0d554bf3175082a32722e78bb0f4e8)
(cherry picked from commit 7e26f748884c337eeafdd55c403c5ebce7e90f80)
(cherry picked from commit 8abd25d4f52c23e6c19f40740e3aaafc385c0e73)
(cherry picked from commit a736053c00778ca35f8653713517558e1e710aea)
(cherry picked from commit 312d9c3fc4dee049bf25288d7a3f519003c817b4)
(cherry picked from commit 6fac93217a965a843046e4c0c814cc161a4e0cc8)
(cherry picked from commit df261c30a4ec89baee1c7b3a1152b846d0bc80a7)
(cherry picked from commit a70095543572745dca9b9ef1c776ed751e76d936)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 42bd98c6
...@@ -51,31 +51,13 @@ ...@@ -51,31 +51,13 @@
#include <QBitmap> #include <QBitmap>
#ifdef Q_WS_X11 #ifdef Q_WS_X11
# include <X11/Xlib.h> # include <X11/Xlib.h>
# include <qx11info_x11.h> # include <qx11info_x11.h>
static void videoSync( void )
{
/* Make sure the X server has processed all requests.
* This protects other threads using distinct connections from getting
* the video widget window in an inconsistent states. */
XSync( QX11Info::display(), False );
}
#else
# define videoSync() (void)0
#endif #endif
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
class ReparentableWidget : public QWidget
{
private:
VideoWidget *owner;
public:
ReparentableWidget( VideoWidget *owner ) : owner( owner )
{}
};
/********************************************************************** /**********************************************************************
* Video Widget. A simple frame on which video is drawn * Video Widget. A simple frame on which video is drawn
* This class handles resize issues * This class handles resize issues
...@@ -84,7 +66,6 @@ public: ...@@ -84,7 +66,6 @@ public:
VideoWidget::VideoWidget( intf_thread_t *_p_i ) VideoWidget::VideoWidget( intf_thread_t *_p_i )
: QFrame( NULL ) : QFrame( NULL )
, p_intf( _p_i ) , p_intf( _p_i )
, reparentable( NULL )
{ {
/* Set the policy to expand in both directions */ /* Set the policy to expand in both directions */
// setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); // setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
...@@ -92,12 +73,23 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) ...@@ -92,12 +73,23 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i )
layout = new QHBoxLayout( this ); layout = new QHBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 ); layout->setContentsMargins( 0, 0, 0, 0 );
setLayout( layout ); setLayout( layout );
stable = NULL;
} }
VideoWidget::~VideoWidget() VideoWidget::~VideoWidget()
{ {
/* Ensure we are not leaking the video output. This would crash. */ /* Ensure we are not leaking the video output. This would crash. */
assert( reparentable == NULL ); assert( !stable );
}
void VideoWidget::sync( void )
{
#ifdef Q_WS_X11
/* Make sure the X server has processed all requests.
* This protects other threads using distinct connections from getting
* the video widget window in an inconsistent states. */
XSync( QX11Info::display(), False );
#endif
} }
/** /**
...@@ -109,7 +101,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -109,7 +101,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
{ {
msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y ); msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
if( reparentable != NULL ) if( stable )
{ {
msg_Dbg( p_intf, "embedded video already in use" ); msg_Dbg( p_intf, "embedded video already in use" );
return NULL; return NULL;
...@@ -120,20 +112,10 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -120,20 +112,10 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
*pi_height = size().height(); *pi_height = size().height();
} }
/* The Qt4 UI needs a fixed a widget ("this"), so that the parent layout is
* not messed up when we the video is reparented. Hence, we create an extra
* reparentable widget, that will be within the VideoWidget in windowed
* mode, and within the root window (NULL parent) in full-screen mode.
*/
reparentable = new ReparentableWidget( this );
reparentable->installEventFilter(this );
QLayout *innerLayout = new QHBoxLayout( reparentable );
innerLayout->setContentsMargins( 0, 0, 0, 0 );
/* The owner of the video window needs a stable handle (WinId). Reparenting /* The owner of the video window needs a stable handle (WinId). Reparenting
* in Qt4-X11 changes the WinId of the widget, so we need to create another * in Qt4-X11 changes the WinId of the widget, so we need to create another
* dummy widget that stays within the reparentable widget. */ * dummy widget that stays within the reparentable widget. */
QWidget *stable = new QWidget(); stable = new QWidget();
QPalette plt = palette(); QPalette plt = palette();
plt.setColor( QPalette::Window, Qt::black ); plt.setColor( QPalette::Window, Qt::black );
stable->setPalette( plt ); stable->setPalette( plt );
...@@ -147,9 +129,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -147,9 +129,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
stable->setAttribute( Qt::WA_PaintOnScreen, true ); stable->setAttribute( Qt::WA_PaintOnScreen, true );
#endif #endif
innerLayout->addWidget( stable ); layout->addWidget( stable );
layout->addWidget( reparentable );
#ifdef Q_WS_X11 #ifdef Q_WS_X11
/* HACK: Only one X11 client can subscribe to mouse button press events. /* HACK: Only one X11 client can subscribe to mouse button press events.
...@@ -163,7 +143,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -163,7 +143,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask); attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
XSelectInput( dpy, w, attr.your_event_mask ); XSelectInput( dpy, w, attr.your_event_mask );
#endif #endif
videoSync(); sync();
#ifndef NDEBUG #ifndef NDEBUG
msg_Dbg( p_intf, "embedded video ready (handle %p)", msg_Dbg( p_intf, "embedded video ready (handle %p)",
(void *)stable->winId() ); (void *)stable->winId() );
...@@ -176,8 +156,6 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -176,8 +156,6 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
Parent has to care about resizing itself */ Parent has to care about resizing itself */
void VideoWidget::SetSizing( unsigned int w, unsigned int h ) void VideoWidget::SetSizing( unsigned int w, unsigned int h )
{ {
if (reparentable->windowState() & Qt::WindowFullScreen )
return;
if( !isVisible() ) show(); if( !isVisible() ) show();
resize( w, h ); resize( w, h );
emit sizeChanged( w, h ); emit sizeChanged( w, h );
...@@ -188,96 +166,22 @@ void VideoWidget::SetSizing( unsigned int w, unsigned int h ) ...@@ -188,96 +166,22 @@ void VideoWidget::SetSizing( unsigned int w, unsigned int h )
*/ */
if( size().width() == w && size().height() == h ) if( size().width() == w && size().height() == h )
updateGeometry(); updateGeometry();
videoSync(); sync();
}
void VideoWidget::SetFullScreen( bool b_fs )
{
const Qt::WindowStates curstate = reparentable->windowState();
Qt::WindowStates newstate = curstate;
Qt::WindowFlags newflags = reparentable->windowFlags();
if( b_fs )
{
newstate |= Qt::WindowFullScreen;
newflags |= Qt::WindowStaysOnTopHint;
}
else
{
newstate &= ~Qt::WindowFullScreen;
newflags &= ~Qt::WindowStaysOnTopHint;
}
if( newstate == curstate )
return; /* no changes needed */
if( b_fs )
{ /* Go full-screen */
int numscreen = var_InheritInteger( p_intf, "qt-fullscreen-screennumber" );
/* if user hasn't defined screennumber, or screennumber that is bigger
* than current number of screens, take screennumber where current interface
* is
*/
if( numscreen == -1 || numscreen > QApplication::desktop()->numScreens() )
numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
/* To be sure window is on proper-screen in xinerama */
if( !screenres.contains( reparentable->pos() ) )
{
msg_Dbg( p_intf, "Moving video to correct screen");
reparentable->move( QPoint( screenres.x(), screenres.y() ) );
}
reparentable->setParent( NULL, newflags );
reparentable->setWindowState( newstate );
reparentable->show();
}
else
{ /* Go windowed */
reparentable->setWindowFlags( newflags );
reparentable->setWindowState( newstate );
layout->addWidget( reparentable );
}
videoSync();
} }
void VideoWidget::release( void ) void VideoWidget::release( void )
{ {
msg_Dbg( p_intf, "Video is not needed anymore" ); msg_Dbg( p_intf, "Video is not needed anymore" );
//layout->removeWidget( reparentable );
reparentable->deleteLater(); assert( stable );
reparentable = NULL; layout->removeWidget( stable );
stable->deleteLater();
stable = NULL;
updateGeometry(); updateGeometry();
hide(); hide();
} }
#undef KeyPress
bool VideoWidget::eventFilter(QObject *obj, QEvent *event)
{
if( obj == reparentable )
{
if (event->type() == QEvent::Close)
{
THEDP->quit();
return true;
}
else if( event->type() == QEvent::KeyPress )
{
emit keyPressed( static_cast<QKeyEvent *>(event) );
return true;
}
else if( event->type() == QEvent::Wheel )
{
int i_vlckey = qtWheelEventToVLCKey( static_cast<QWheelEvent *>(event) );
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
return true;
}
}
return false;
}
/********************************************************************** /**********************************************************************
* Background Widget. Show a simple image background. Currently, * Background Widget. Show a simple image background. Currently,
* it's album art if present or cone. * it's album art if present or cone.
......
...@@ -46,14 +46,11 @@ class QPixmap; ...@@ -46,14 +46,11 @@ class QPixmap;
class QHBoxLayout; class QHBoxLayout;
class QMenu; class QMenu;
class QSlider; class QSlider;
class ReparentableWidget;
/******************** Video Widget ****************/ /******************** Video Widget ****************/
class VideoWidget : public QFrame class VideoWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
friend class ReparentableWidget;
public: public:
VideoWidget( intf_thread_t * ); VideoWidget( intf_thread_t * );
virtual ~VideoWidget(); virtual ~VideoWidget();
...@@ -61,6 +58,7 @@ public: ...@@ -61,6 +58,7 @@ public:
WId request( int *, int *, unsigned int *, unsigned int *, bool ); WId request( int *, int *, unsigned int *, unsigned int *, bool );
void release( void ); void release( void );
int control( void *, int, va_list ); int control( void *, int, va_list );
void sync( void );
protected: protected:
virtual QPaintEngine *paintEngine() const virtual QPaintEngine *paintEngine() const
...@@ -71,16 +69,13 @@ protected: ...@@ -71,16 +69,13 @@ protected:
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
QWidget *reparentable; QWidget *stable;
QLayout *layout; QLayout *layout;
virtual bool eventFilter ( QObject * watched, QEvent * event );
signals: signals:
void keyPressed( QKeyEvent * );
void sizeChanged( int, int ); void sizeChanged( int, int );
public slots: public slots:
void SetSizing( unsigned int, unsigned int ); void SetSizing( unsigned int, unsigned int );
void SetFullScreen( bool );
}; };
/******************** Background Widget ****************/ /******************** Background Widget ****************/
......
...@@ -110,7 +110,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -110,7 +110,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
b_autoresize = var_InheritBool( p_intf, "qt-video-autoresize" ); b_autoresize = var_InheritBool( p_intf, "qt-video-autoresize" );
/* Are we in the enhanced always-video mode or not ? */ /* Are we in the enhanced always-video mode or not ? */
i_visualmode = var_InheritBool( p_intf, "qt-minimal-view" ); b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" );
/* Do we want anoying popups or not */ /* Do we want anoying popups or not */
b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" ); b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" );
...@@ -198,26 +198,27 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -198,26 +198,27 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* END CONNECTS ON IM */ /* END CONNECTS ON IM */
/* VideoWidget connects for asynchronous calls */ /* VideoWidget connects for asynchronous calls */
b_videoFullScreen = false;
b_videoOnTop = false;
connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)), connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)),
this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)), this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)),
Qt::BlockingQueuedConnection ); Qt::BlockingQueuedConnection );
connect( this, SIGNAL(askReleaseVideo( void )), connect( this, SIGNAL(askReleaseVideo( void )),
this, SLOT(releaseVideoSlot( void )), this, SLOT(releaseVideoSlot( void )),
Qt::BlockingQueuedConnection ); Qt::BlockingQueuedConnection );
CONNECT( this, askVideoOnTop(bool), this, setVideoOnTop(bool));
if( videoWidget ) if( videoWidget )
{ {
if( b_autoresize ) if( b_autoresize )
{ {
CONNECT( this, askVideoToResize( unsigned int, unsigned int ), CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
videoWidget, SetSizing( unsigned int, unsigned int ) ); this, setVideoSize( unsigned int, unsigned int ) );
CONNECT( videoWidget, sizeChanged( int, int ), CONNECT( videoWidget, sizeChanged( int, int ),
this, resizeStack( int, int ) ); this, resizeStack( int, int ) );
} }
CONNECT( this, askVideoSetFullScreen( bool ), CONNECT( this, askVideoSetFullScreen( bool ),
videoWidget, SetFullScreen( bool ) ); this, setVideoFullScreen( bool ) );
CONNECT( videoWidget, keyPressed( QKeyEvent * ),
this, handleKeyPress( QKeyEvent * ) );
} }
CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() ); CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
...@@ -243,6 +244,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -243,6 +244,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
QVLCTools::restoreWidgetPosition( settings, this, QSize(400, 100) ); QVLCTools::restoreWidgetPosition( settings, this, QSize(400, 100) );
settings->endGroup(); settings->endGroup();
b_interfaceFullScreen = isFullScreen();
/* Final sizing and showing */ /* Final sizing and showing */
setVisible( !b_hideAfterCreation ); setVisible( !b_hideAfterCreation );
...@@ -250,7 +253,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -250,7 +253,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
menuBar()->sizeHint().width() ) + 30 ); menuBar()->sizeHint().width() ) + 30 );
/* Switch to minimal view if needed, must be called after the show() */ /* Switch to minimal view if needed, must be called after the show() */
if( i_visualmode ) if( b_minimalView )
toggleMinimalView( true ); toggleMinimalView( true );
} }
...@@ -531,21 +534,6 @@ void MainInterface::toggleFSC() ...@@ -531,21 +534,6 @@ void MainInterface::toggleFSC()
* Video Handling * Video Handling
****************************************************************************/ ****************************************************************************/
/* This event is used to deal with the fullscreen and always on top
issue conflict (bug in wx) */
class SetVideoOnTopQtEvent : public QEvent
{
public:
SetVideoOnTopQtEvent( bool _onTop ) :
QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
{}
bool OnTop() const { return onTop; }
private:
bool onTop;
};
/** /**
* NOTE: * NOTE:
* You must not change the state of this object or other Qt4 UI objects, * You must not change the state of this object or other Qt4 UI objects,
...@@ -588,13 +576,14 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -588,13 +576,14 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
void MainInterface::releaseVideo( void ) void MainInterface::releaseVideo( void )
{ {
emit askReleaseVideo(); emit askReleaseVideo();
QApplication::postEvent( this, new SetVideoOnTopQtEvent( false ) );
} }
/* Function that is CONNECTED to the previous emit */ /* Function that is CONNECTED to the previous emit */
void MainInterface::releaseVideoSlot( void ) void MainInterface::releaseVideoSlot( void )
{ {
videoWidget->release(); videoWidget->release();
setVideoOnTop( false );
setVideoFullScreen( false );
if( stackCentralW->currentWidget() == videoWidget ) if( stackCentralW->currentWidget() == videoWidget )
restoreStackOldWidget(); restoreStackOldWidget();
...@@ -603,6 +592,66 @@ void MainInterface::releaseVideoSlot( void ) ...@@ -603,6 +592,66 @@ void MainInterface::releaseVideoSlot( void )
stackCentralOldWidget = bgWidget; stackCentralOldWidget = bgWidget;
} }
void MainInterface::setVideoSize( unsigned int w, unsigned int h )
{
if( !isFullScreen() && !isMaximized() )
videoWidget->SetSizing( w, h );
}
void MainInterface::setVideoFullScreen( bool fs )
{
b_videoFullScreen = fs;
if( fs )
{
int numscreen = var_InheritInteger( p_intf, "qt-fullscreen-screennumber" );
/* if user hasn't defined screennumber, or screennumber that is bigger
* than current number of screens, take screennumber where current interface
* is
*/
if( numscreen == -1 || numscreen > QApplication::desktop()->numScreens() )
numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
/* To be sure window is on proper-screen in xinerama */
if( !screenres.contains( pos() ) )
{
msg_Dbg( p_intf, "Moving video to correct screen");
move( QPoint( screenres.x(), screenres.y() ) );
}
setMinimalView( true );
setInterfaceFullScreen( true );
}
else
{
/* TODO do we want to restore screen and position ? (when
* qt-fullscreen-screennumber is forced) */
setMinimalView( b_minimalView );
setInterfaceFullScreen( b_interfaceFullScreen );
}
videoWidget->sync();
}
/* Slot to change the video always-on-top flag.
* Emit askVideoOnTop() to invoke this from other thread. */
void MainInterface::setVideoOnTop( bool on_top )
{
b_videoOnTop = on_top;
Qt::WindowFlags oldflags = windowFlags(), newflags;
if( b_videoOnTop )
newflags = oldflags | Qt::WindowStaysOnTopHint;
else
newflags = oldflags & ~Qt::WindowStaysOnTopHint;
if( newflags != oldflags )
{
setWindowFlags( newflags );
show(); /* necessary to apply window flags */
}
}
/* Asynchronous call from WindowControl function */ /* Asynchronous call from WindowControl function */
int MainInterface::controlVideo( int i_query, va_list args ) int MainInterface::controlVideo( int i_query, va_list args )
{ {
...@@ -612,8 +661,7 @@ int MainInterface::controlVideo( int i_query, va_list args ) ...@@ -612,8 +661,7 @@ int MainInterface::controlVideo( int i_query, va_list args )
{ {
unsigned int i_width = va_arg( args, unsigned int ); unsigned int i_width = va_arg( args, unsigned int );
unsigned int i_height = va_arg( args, unsigned int ); unsigned int i_height = va_arg( args, unsigned int );
if( isFullScreen() || isMaximized() )
showNormal();
emit askVideoToResize( i_width, i_height ); emit askVideoToResize( i_width, i_height );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -621,12 +669,14 @@ int MainInterface::controlVideo( int i_query, va_list args ) ...@@ -621,12 +669,14 @@ int MainInterface::controlVideo( int i_query, va_list args )
{ {
unsigned i_arg = va_arg( args, unsigned ); unsigned i_arg = va_arg( args, unsigned );
unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE; unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
QApplication::postEvent( this, new SetVideoOnTopQtEvent( on_top ) );
emit askVideoOnTop( on_top != 0 );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
case VOUT_WINDOW_SET_FULLSCREEN: case VOUT_WINDOW_SET_FULLSCREEN:
{ {
bool b_fs = va_arg( args, int ); bool b_fs = va_arg( args, int );
emit askVideoSetFullScreen( b_fs ); emit askVideoSetFullScreen( b_fs );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -726,12 +776,20 @@ void MainInterface::dockPlaylist( bool p_docked ) ...@@ -726,12 +776,20 @@ void MainInterface::dockPlaylist( bool p_docked )
playlistVisible = true; playlistVisible = true;
} }
void MainInterface::setMinimalView( bool b_minimal )
{
menuBar()->setVisible( !b_minimal );
controls->setVisible( !b_minimal );
statusBar()->setVisible( !b_minimal );
inputC->setVisible( !b_minimal );
}
/* /*
If b_switch is false, then we are normalView If b_minimal is false, then we are normalView
*/ */
void MainInterface::toggleMinimalView( bool b_switch ) void MainInterface::toggleMinimalView( bool b_minimal )
{ {
if( i_visualmode == 0 && b_autoresize ) /* Normal mode */ if( !b_minimalView && b_autoresize ) /* Normal mode */
{ {
if( stackCentralW->currentWidget() == bgWidget ) if( stackCentralW->currentWidget() == bgWidget )
{ {
...@@ -741,13 +799,11 @@ void MainInterface::toggleMinimalView( bool b_switch ) ...@@ -741,13 +799,11 @@ void MainInterface::toggleMinimalView( bool b_switch )
} }
} }
} }
b_minimalView = b_minimal;
if( !b_videoFullScreen )
setMinimalView( b_minimalView );
menuBar()->setVisible( !b_switch ); emit minimalViewToggled( b_minimalView );
controls->setVisible( !b_switch );
statusBar()->setVisible( !b_switch );
inputC->setVisible( !b_switch );
emit minimalViewToggled( b_switch );
} }
/* toggling advanced controls buttons */ /* toggling advanced controls buttons */
...@@ -1035,19 +1091,6 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event) ...@@ -1035,19 +1091,6 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
/************************************************************************ /************************************************************************
* Events stuff * Events stuff
************************************************************************/ ************************************************************************/
void MainInterface::customEvent( QEvent *event )
{
if ( event->type() == (int)SetVideoOnTopEvent_Type )
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
if( p_event->OnTop() )
setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
else
setWindowFlags( windowFlags() & ~Qt::WindowStaysOnTopHint );
show(); /* necessary to apply window flags */
}
}
void MainInterface::keyPressEvent( QKeyEvent *e ) void MainInterface::keyPressEvent( QKeyEvent *e )
{ {
handleKeyPress( e ); handleKeyPress( e );
...@@ -1055,10 +1098,9 @@ void MainInterface::keyPressEvent( QKeyEvent *e ) ...@@ -1055,10 +1098,9 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
void MainInterface::handleKeyPress( QKeyEvent *e ) void MainInterface::handleKeyPress( QKeyEvent *e )
{ {
if( ( e->modifiers() & Qt::ControlModifier ) && ( e->key() == Qt::Key_H ) if( ( e->modifiers() & Qt::ControlModifier ) && ( e->key() == Qt::Key_H ) )
&& !menuBar()->isVisible() )
{ {
toggleMinimalView( false ); toggleMinimalView( !b_minimalView );
e->accept(); e->accept();
} }
...@@ -1086,18 +1128,19 @@ void MainInterface::closeEvent( QCloseEvent *e ) ...@@ -1086,18 +1128,19 @@ void MainInterface::closeEvent( QCloseEvent *e )
THEDP->quit(); THEDP->quit();
} }
void MainInterface::toggleFullScreen() void MainInterface::setInterfaceFullScreen( bool fs )
{ {
if( isFullScreen() ) if( fs )
{
showNormal();
emit fullscreenInterfaceToggled( false );
}
else
{
showFullScreen(); showFullScreen();
emit fullscreenInterfaceToggled( true ); else
} showNormal();
}
void MainInterface::toggleInterfaceFullScreen()
{
b_interfaceFullScreen = !b_interfaceFullScreen;
if( !b_videoFullScreen )
setInterfaceFullScreen( b_interfaceFullScreen );
emit fullscreenInterfaceToggled( b_interfaceFullScreen );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -86,6 +86,7 @@ public: ...@@ -86,6 +86,7 @@ public:
#endif #endif
int getControlsVisibilityStatus(); int getControlsVisibilityStatus();
bool isPlDocked() { return ( b_plDocked != false ); } bool isPlDocked() { return ( b_plDocked != false ); }
bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
protected: protected:
void dropEventPlay( QDropEvent *, bool); void dropEventPlay( QDropEvent *, bool);
...@@ -97,7 +98,6 @@ protected: ...@@ -97,7 +98,6 @@ protected:
virtual void dragMoveEvent( QDragMoveEvent * ); virtual void dragMoveEvent( QDragMoveEvent * );
virtual void dragLeaveEvent( QDragLeaveEvent * ); virtual void dragLeaveEvent( QDragLeaveEvent * );
virtual void closeEvent( QCloseEvent *); virtual void closeEvent( QCloseEvent *);
virtual void customEvent( QEvent *);
virtual void keyPressEvent( QKeyEvent *); virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * ); virtual void wheelEvent( QWheelEvent * );
...@@ -117,6 +117,10 @@ private: ...@@ -117,6 +117,10 @@ private:
void showVideo(); void showVideo();
void restoreStackOldWidget(); void restoreStackOldWidget();
/* */
void setMinimalView( bool );
void setInterfaceFullScreen( bool );
/* */ /* */
QSettings *settings; QSettings *settings;
#ifndef HAVE_MAEMO #ifndef HAVE_MAEMO
...@@ -151,8 +155,11 @@ private: ...@@ -151,8 +155,11 @@ private:
bool b_notificationEnabled; /// Systray Notifications bool b_notificationEnabled; /// Systray Notifications
bool b_autoresize; ///< persistent resizeable window bool b_autoresize; ///< persistent resizeable window
bool b_videoEmbedded; ///< Want an external Video Window bool b_videoEmbedded; ///< Want an external Video Window
bool b_videoFullScreen; ///< --fullscreen
bool b_videoOnTop; ///< --video-on-top
bool b_hideAfterCreation; bool b_hideAfterCreation;
int i_visualmode; ///< Visual Mode bool b_minimalView; ///< Minimal video
bool b_interfaceFullScreen;
/* States */ /* States */
bool playlistVisible; ///< Is the playlist visible ? bool playlistVisible; ///< Is the playlist visible ?
...@@ -176,7 +183,7 @@ public slots: ...@@ -176,7 +183,7 @@ public slots:
void toggleUpdateSystrayMenu(); void toggleUpdateSystrayMenu();
#endif #endif
void toggleAdvancedButtons(); void toggleAdvancedButtons();
void toggleFullScreen(); void toggleInterfaceFullScreen();
void toggleFSC(); void toggleFSC();
void popupMenu( const QPoint& ); void popupMenu( const QPoint& );
...@@ -209,12 +216,15 @@ private slots: ...@@ -209,12 +216,15 @@ private slots:
void resizeStack( int w, int h ) { void resizeStack( int w, int h ) {
if( !isFullScreen() && !isMaximized() ) if( !isFullScreen() && !isMaximized() )
if( i_visualmode == 1 ) resize( w, h ); /* Oh yes, it shouldn't if( b_minimalView ) resize( w, h ); /* Oh yes, it shouldn't
be possible that size() - stackCentralW->size() < 0 be possible that size() - stackCentralW->size() < 0
since stackCentralW is contained in the QMW... */ since stackCentralW is contained in the QMW... */
else resize( size() - stackCentralW->size() + QSize( w, h ) ); else resize( size() - stackCentralW->size() + QSize( w, h ) );
debug(); } debug(); }
void setVideoSize( unsigned int, unsigned int );
void setVideoFullScreen( bool );
void setVideoOnTop( bool );
signals: signals:
void askGetVideo( WId *p_id, int *pi_x, int *pi_y, void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
...@@ -222,6 +232,7 @@ signals: ...@@ -222,6 +232,7 @@ signals:
void askReleaseVideo( ); void askReleaseVideo( );
void askVideoToResize( unsigned int, unsigned int ); void askVideoToResize( unsigned int, unsigned int );
void askVideoSetFullScreen( bool ); void askVideoSetFullScreen( bool );
void askVideoOnTop( bool );
void minimalViewToggled( bool ); void minimalViewToggled( bool );
void fullscreenInterfaceToggled( bool ); void fullscreenInterfaceToggled( bool );
......
...@@ -465,9 +465,9 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface ...@@ -465,9 +465,9 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface
/* FullScreen View */ /* FullScreen View */
action = menu->addAction( qtr( "&Fullscreen Interface" ), mi, action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
SLOT( toggleFullScreen() ), QString( "F11" ) ); SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
action->setCheckable( true ); action->setCheckable( true );
action->setChecked( mi->isFullScreen() ); action->setChecked( mi->isInterfaceFullScreen() );
CONNECT( mi, fullscreenInterfaceToggled( bool ), CONNECT( mi, fullscreenInterfaceToggled( bool ),
action, setChecked( bool ) ); action, setChecked( bool ) );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment