# include "config.h"
#endif
+#include "qt4.hpp"
#include "components/interface_widgets.hpp"
#include "dialogs_provider.hpp"
#include "util/customwidgets.hpp" // qtEventToVLCKey, QVLCStackedWidget
#include <QBitmap>
#ifdef Q_WS_X11
-# include <X11/Xlib.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
+# include <X11/Xlib.h>
+# include <qx11info_x11.h>
#endif
#include <math.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
* This class handles resize issues
**********************************************************************/
VideoWidget::VideoWidget( intf_thread_t *_p_i )
- : QFrame( NULL )
- , p_intf( _p_i )
- , reparentable( NULL )
+ : QFrame( NULL ) , p_intf( _p_i )
{
/* Set the policy to expand in both directions */
// setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
layout = new QHBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
- setLayout( layout );
+ stable = NULL;
+ show();
}
VideoWidget::~VideoWidget()
{
/* 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
}
/**
{
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" );
- return NULL;
+ return 0;
}
if( b_keep_size )
{
*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
* in Qt4-X11 changes the WinId of the widget, so we need to create another
* dummy widget that stays within the reparentable widget. */
- QWidget *stable = new QWidget();
+ stable = new QWidget();
QPalette plt = palette();
plt.setColor( QPalette::Window, Qt::black );
stable->setPalette( plt );
/* Indicates that the widget wants to draw directly onto the screen.
Widgets with this attribute set do not participate in composition
management */
+ /* This is currently disabled on X11 as it does not seem to improve
+ * performance, but causes the video widget to be transparent... */
+#ifndef Q_WS_X11
stable->setAttribute( Qt::WA_PaintOnScreen, true );
+#endif
- innerLayout->addWidget( stable );
-
- layout->addWidget( reparentable );
+ layout->addWidget( stable );
#ifdef Q_WS_X11
/* HACK: Only one X11 client can subscribe to mouse button press events.
attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
XSelectInput( dpy, w, attr.your_event_mask );
#endif
- videoSync();
+ sync();
#ifndef NDEBUG
msg_Dbg( p_intf, "embedded video ready (handle %p)",
(void *)stable->winId() );
Parent has to care about resizing itself */
void VideoWidget::SetSizing( unsigned int w, unsigned int h )
{
- if (reparentable->windowState() & Qt::WindowFullScreen )
- return;
- if( !isVisible() ) show();
resize( w, h );
emit sizeChanged( w, h );
/* Work-around a bug?misconception? that would happen when vout core resize
*/
if( size().width() == w && size().height() == h )
updateGeometry();
- videoSync();
-}
-
-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 );
-
- /* FIXME: inherit from the vout window, not the interface */
- char *title = var_InheritString( p_intf, "video-title" );
- reparentable->setWindowTitle( qfu(title ? title : _("Video")) );
- free( title );
-
- reparentable->show();
- }
- else
- { /* Go windowed */
- reparentable->setWindowFlags( newflags );
- reparentable->setWindowState( newstate );
- layout->addWidget( reparentable );
- }
- videoSync();
+ sync();
}
void VideoWidget::release( void )
{
msg_Dbg( p_intf, "Video is not needed anymore" );
- //layout->removeWidget( reparentable );
-
- reparentable->deleteLater();
- reparentable = NULL;
- updateGeometry();
- hide();
-}
-#undef KeyPress
-bool VideoWidget::eventFilter(QObject *obj, QEvent *event)
-{
- if( obj == reparentable )
+ if( stable )
{
- 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;
- }
+ layout->removeWidget( stable );
+ stable->deleteLater();
+ stable = NULL;
}
- return false;
+
+ updateGeometry();
}
/**********************************************************************
**********************************************************************/
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
- :QWidget( NULL ), p_intf( _p_i ), b_expandPixmap( false )
+ :QWidget( NULL ), p_intf( _p_i ), b_expandPixmap( false ), b_withart( true )
{
/* A dark background */
setAutoFillBackground( true );
}
else
{ /* Xmas joke */
- if( QDate::currentDate().dayOfYear() >= 354 )
- pixmapUrl = QString( ":/logo/vlc128-christmas.png" );
+ if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) )
+ pixmapUrl = QString( ":/logo/vlc128-xmas.png" );
else
pixmapUrl = QString( ":/logo/vlc128.png" );
}
void BackgroundWidget::paintEvent( QPaintEvent *e )
{
+ if ( !b_withart )
+ {
+ /* we just want background autofill */
+ QWidget::paintEvent( e );
+ return;
+ }
+
int i_maxwidth, i_maxheight;
QPixmap pixmap = QPixmap( pixmapUrl );
QPainter painter(this);
return;
}
- double value = 17 * log( rate ) / log( 2 );
+ double value = 17 * log( rate ) / log( 2. );
int sliderValue = (int) ( ( value > 0 ) ? value + .5 : value - .5 );
if( sliderValue < speedSlider->minimum() )
if( !url.isEmpty() && pix.load( url ) )
{
pix = pix.scaled( maximumWidth(), maximumHeight(),
- Qt::KeepAspectRatioByExpanding );
+ Qt::KeepAspectRatioByExpanding,
+ Qt::SmoothTransformation );
}
else
{