Commit 965c6422 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
parent 03cc7a2d
......@@ -29,6 +29,8 @@
#endif
#include "components/interface_widgets.hpp"
#include "dialogs_provider.hpp"
#include "util/customwidgets.hpp" // qtEventToVLCKey, QVLCStackedWidget
#include "menus.hpp" /* Popup menu on bgWidget */
......@@ -37,6 +39,7 @@
#include <QLabel>
#include <QToolButton>
#include <QPalette>
#include <QEvent>
#include <QResizeEvent>
#include <QDate>
#include <QMenu>
......@@ -70,14 +73,7 @@ private:
VideoWidget *owner;
public:
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,
* 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 );
......@@ -245,6 +242,32 @@ void VideoWidget::release( void )
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 );
msg_Dbg( p_intf, "Here: %i", i_vlckey );
return true;
}
}
return false;
}
/**********************************************************************
* Background Widget. Show a simple image background. Currently,
* it's album art if present or cone.
......
......@@ -73,7 +73,7 @@ private:
QWidget *reparentable;
QLayout *layout;
virtual bool eventFilter ( QObject * watched, QEvent * event );
signals:
void keyPressed( QKeyEvent * );
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