#include <QDate>
#include <QMenu>
#include <QWidgetAction>
+#include <QDesktopWidget>
#ifdef Q_WS_X11
# include <X11/Xlib.h>
#include <math.h>
+class ReparentableWidget : public QWidget
+{
+private:
+ VideoWidget *owner;
+public:
+ ReparentableWidget( VideoWidget *owner ) : owner( owner )
+ {
+ }
+
+protected:
+ void keyPressEvent( QKeyEvent *e )
+ {
+ emit owner->keyPressed( e );
+ }
+};
+
/**********************************************************************
* Video Widget. A simple frame on which video is drawn
* This class handles resize issues
* reparentable widget, that will be within the VideoWidget in windowed
* mode, and within the root window (NULL parent) in full-screen mode.
*/
- reparentable = new QWidget();
+ reparentable = new ReparentableWidget( this );
QLayout *innerLayout = new QHBoxLayout( reparentable );
innerLayout->setContentsMargins( 0, 0, 0, 0 );
reparentable->setLayout( innerLayout );
layout->addWidget( reparentable );
+#ifdef Q_WS_X11
+ /* HACK: Only one X11 client can subscribe to mouse button press events.
+ * VLC currently handles those in the video display.
+ * Force Qt4 to unsubscribe from mouse press and release events. */
+ Display *dpy = QX11Info::display();
+ Window w = stable->winId();
+ XWindowAttributes attr;
+
+ XGetWindowAttributes( dpy, w, &attr );
+ attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
+ XSelectInput( dpy, w, attr.your_event_mask );
+#endif
videoSync();
#ifndef NDEBUG
msg_Dbg( p_intf, "embedded video ready (handle %p)",
Qt::WindowStates newstate = curstate;
Qt::WindowFlags newflags = reparentable->windowFlags();
+
if( b_fs )
{
newstate |= Qt::WindowFullScreen;
if( b_fs )
{ /* Go full-screen */
+ int numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
+ QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
+
reparentable->setWindowState( newstate );
reparentable->setParent( NULL );
reparentable->setWindowFlags( newflags );
+ /* 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->show();
}
else
label->setMaximumWidth( MAX_BG_SIZE );
label->setMinimumHeight( MIN_BG_SIZE );
label->setMinimumWidth( MIN_BG_SIZE );
+ label->setAlignment( Qt::AlignCenter );
if( QDate::currentDate().dayOfYear() >= 354 )
label->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
else
}
else
{
- label->setPixmap( QPixmap( url ) );
+ QPixmap pixmap( url );
+ if( pixmap.width() > label->maximumWidth() ||
+ pixmap.height() > label->maximumHeight() )
+ {
+ pixmap = pixmap.scaled( label->maximumWidth(),
+ label->maximumHeight(), Qt::KeepAspectRatio );
+ }
+
+ label->setPixmap( pixmap );
}
}
{
setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, askForUpdate() );
- CONNECT( THEMIM->getIM(), artChanged( QString ),
- this, showArtUpdate( const QString& ) );
setMinimumHeight( 128 );
setMinimumWidth( 128 );
setMaximumHeight( 128 );
setMaximumWidth( 128 );
- setScaledContents( true );
+ setScaledContents( false );
+ setAlignment( Qt::AlignCenter );
QList< QAction* > artActions = actions();
QAction *action = new QAction( qtr( "Download cover art" ), this );
QPixmap pix;
if( !url.isEmpty() && pix.load( url ) )
{
- setPixmap( pix );
+ pix = pix.scaled( maximumWidth(), maximumHeight(),
+ Qt::KeepAspectRatioByExpanding );
}
else
{
- setPixmap( QPixmap( ":/noart.png" ) );
+ pix = QPixmap( ":/noart.png" );
}
+ setPixmap( pix );
}
void CoverArtLabel::askForUpdate()