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

Qt: Correctly close the player when alt+f4 is pressed

even when in fullscreen. Close #3602
(cherry picked from commit 965c64221f5d91443e9ee2993b758beb132d00d5)
(cherry picked from commit 308b6e6d8eab5bb2b4cfb8208f4504f54534273c)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent ab8e1532
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#endif #endif
#include "components/interface_widgets.hpp" #include "components/interface_widgets.hpp"
#include "dialogs_provider.hpp"
#include "util/customwidgets.hpp" // qtEventToVLCKey, QVLCStackedWidget
#include "menus.hpp" /* Popup menu on bgWidget */ #include "menus.hpp" /* Popup menu on bgWidget */
...@@ -37,6 +39,7 @@ ...@@ -37,6 +39,7 @@
#include <QLabel> #include <QLabel>
#include <QToolButton> #include <QToolButton>
#include <QPalette> #include <QPalette>
#include <QEvent>
#include <QResizeEvent> #include <QResizeEvent>
#include <QDate> #include <QDate>
#include <QMenu> #include <QMenu>
...@@ -70,14 +73,7 @@ private: ...@@ -70,14 +73,7 @@ private:
VideoWidget *owner; VideoWidget *owner;
public: public:
ReparentableWidget( VideoWidget *owner ) : owner( owner ) ReparentableWidget( VideoWidget *owner ) : owner( owner )
{ {}
}
protected:
void keyPressEvent( QKeyEvent *e )
{
emit owner->keyPressed( e );
}
}; };
/********************************************************************** /**********************************************************************
...@@ -130,6 +126,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y, ...@@ -130,6 +126,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
* mode, and within the root window (NULL parent) in full-screen mode. * mode, and within the root window (NULL parent) in full-screen mode.
*/ */
reparentable = new ReparentableWidget( this ); reparentable = new ReparentableWidget( this );
reparentable->installEventFilter(this );
QLayout *innerLayout = new QHBoxLayout( reparentable ); QLayout *innerLayout = new QHBoxLayout( reparentable );
innerLayout->setContentsMargins( 0, 0, 0, 0 ); innerLayout->setContentsMargins( 0, 0, 0, 0 );
...@@ -245,6 +242,25 @@ void VideoWidget::release( void ) ...@@ -245,6 +242,25 @@ void VideoWidget::release( void )
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;
}
}
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.
......
...@@ -73,7 +73,7 @@ private: ...@@ -73,7 +73,7 @@ private:
QWidget *reparentable; QWidget *reparentable;
QLayout *layout; QLayout *layout;
virtual bool eventFilter ( QObject * watched, QEvent * event );
signals: signals:
void keyPressed( QKeyEvent * ); void keyPressed( QKeyEvent * );
void sizeChanged( int, int ); void sizeChanged( int, int );
......
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