/*****************************************************************************
* interface_widgets.hpp : Custom widgets for the main interface
****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006-2008 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
# include "config.h"
#endif
-#include <vlc_common.h>
-#include <vlc_interface.h>
-#include <vlc_aout.h>
+#include "main_interface.hpp" /* Interface integration */
+#include "input_manager.hpp" /* Speed control */
-#include "qt4.hpp"
-#include "main_interface.hpp"
-#include "input_manager.hpp"
+#include "components/controller.hpp"
+#include "components/controller_widget.hpp"
#include <QWidget>
#include <QFrame>
-#include <QMutex>
-#include <QWaitCondition>
-
-#define VOLUME_MAX 200
-
-/* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
- done by trick with setting the opacity of window */
-#ifdef WIN32
- #define WIN32TRICK
-#endif
-
-/* to trying transparency with fullscreen controller on windows enable that */
-/* it can be enabled on-non windows systems,
- but it will be transparent only with composite manager */
-#ifndef WIN32
- #define HAVE_TRANSPARENCY 1
-#else
- #define HAVE_TRANSPARENCY 0
-#endif
-
-/* Default value of opacity for FS controller */
-#define DEFAULT_OPACITY 0.75
+#include <QLabel>
+#include <QMouseEvent>
class ResizeEvent;
-class QPalette;
class QPixmap;
-class QLabel;
class QHBoxLayout;
+class QMenu;
+class QSlider;
+class ReparentableWidget;
/******************** Video Widget ****************/
class VideoWidget : public QFrame
{
Q_OBJECT
-friend class MainInterface;
+friend class ReparentableWidget;
public:
VideoWidget( intf_thread_t * );
virtual ~VideoWidget();
- void *request( vout_thread_t *, int *, int *,
- unsigned int *, unsigned int * );
- void release( void * );
+ WId request( int *, int *, unsigned int *, unsigned int *, bool );
+ void release( void );
int control( void *, int, va_list );
- virtual QSize sizeHint() const;
+protected:
+ virtual QPaintEngine *paintEngine() const
+ {
+ return NULL;
+ }
+
private:
intf_thread_t *p_intf;
- vout_thread_t *p_vout;
- vlc_mutex_t lock;
- QSize videoSize;
- QMutex handleLock;
- QWaitCondition handleWait;
- bool handleReady;
+ QWidget *reparentable;
+ QLayout *layout;
signals:
- void askVideoWidgetToShow();
- //void askResize();
+ void keyPressed( QKeyEvent * );
+ void sizeChanged( int, int );
public slots:
void SetSizing( unsigned int, unsigned int );
-
-protected:
- virtual QPaintEngine *paintEngine() const
- {
- return NULL;
- }
-
- virtual void paintEvent(QPaintEvent *);
+ void SetFullScreen( bool );
};
/******************** Background Widget ****************/
Q_OBJECT
public:
BackgroundWidget( intf_thread_t * );
- virtual ~BackgroundWidget();
-
+ void setExpandstoHeight( bool b_expand ) { b_expandPixmap = b_expand; }
private:
- QPalette plt;
- QLabel *label;
+ QString pixmapUrl;
+ bool b_expandPixmap;
virtual void contextMenuEvent( QContextMenuEvent *event );
intf_thread_t *p_intf;
virtual void resizeEvent( QResizeEvent * event );
+protected:
+ void paintEvent( QPaintEvent *e );
+ static const int MARGIN = 5;
public slots:
void toggle(){ TOGGLEV( this ); }
- void updateArt( QString );
+ void updateArt( const QString& );
};
+#if 0
class VisualSelector : public QFrame
{
Q_OBJECT
void prev();
void next();
};
-
-/* Advanced Button Bar */
-class QPushButton;
-class AdvControlsWidget : public QFrame
-{
- Q_OBJECT
-public:
- AdvControlsWidget( intf_thread_t *);
- virtual ~AdvControlsWidget();
-
- void enableInput( bool );
- void enableVideo( bool );
-
-private:
- intf_thread_t *p_intf;
- QPushButton *recordButton, *ABButton;
- QPushButton *snapshotButton, *frameButton;
-
- mtime_t timeA, timeB;
-
-private slots:
- void snapshot();
-#if 0
- void frame();
#endif
- void fromAtoB();
- void record();
- void AtoBLoop( float, int, int );
-};
-
-/* Button Bar */
-class InputSlider;
-class QSlider;
-class QGridLayout;
-class VolumeClickHandler;
-class SoundSlider;
-class QAbstractSlider;
-class QToolButton;
-
-class ControlsWidget : public QFrame
-{
- Q_OBJECT
-public:
- /* p_intf, advanced control visible or not, blingbling or not */
- ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
- bool b_advControls, bool b_shiny, bool b_fsCreation = false);
- virtual ~ControlsWidget();
-
- QPushButton *playlistButton;
- void setStatus( int );
- void enableInput( bool );
- void enableVideo( bool );
-public slots:
- void setNavigation( int );
-protected:
- friend class MainInterface;
- friend class VolumeClickHandler;
-protected:
- intf_thread_t *p_intf;
- QWidget *discFrame;
- QWidget *telexFrame;
- QGridLayout *controlLayout;
- InputSlider *slider;
- QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
- QPushButton *playButton, *fullscreenButton, *extSettingsButton;
- QPushButton *telexTransparent;
- QSpinBox *telexPage;
- QToolButton *slowerButton, *fasterButton;
- QHBoxLayout *controlButLayout;
- AdvControlsWidget *advControls;
- QLabel *volMuteLabel;
- QAbstractSlider *volumeSlider;
- VolumeClickHandler *hVolLabel;
-
- bool b_advancedVisible;
- bool b_telexTransparent;
- bool b_telexEnabled;
-protected slots:
- void play();
- void stop();
- void prev();
- void next();
- void updateVolume( int );
- void updateVolume( void );
- void updateInput();
- void fullscreen();
- void extSettings();
- void faster();
- void slower();
- void toggleAdvanced();
- void toggleTeletext();
- void toggleTeletextTransparency();
-signals:
- void advancedControlsToggled( bool );
-};
-
-/***********************************
- * Fullscreen controller
- ***********************************/
-
-static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
- vlc_value_t new_val, void *data);
-
-static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
- vlc_value_t new_val, void *data);
-class FullscreenControllerWidget : public ControlsWidget
+class TimeLabel : public QLabel
{
Q_OBJECT
public:
- FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
- virtual ~FullscreenControllerWidget();
-
- void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
- void regFullscreenCallback( vout_thread_t *p_vout );
-
- bool isFSCHidden();
-
-public slots:
- void unregFullscreenCallback();
-
+ TimeLabel( intf_thread_t *_p_intf );
protected:
- friend class MainInterface;
- friend class VolumeClickHandler;
-
- virtual void mouseMoveEvent( QMouseEvent *event );
- virtual void mousePressEvent( QMouseEvent *event );
- virtual void enterEvent( QEvent *event );
- virtual void leaveEvent( QEvent *event );
- virtual void keyPressEvent( QKeyEvent *event );
-
-private slots:
- void hideFSControllerWidget();
- void slowHideFSC();
-
-private:
- QTimer *p_hideTimer;
-
-#if HAVE_TRANSPARENCY
- QTimer *p_slowHideTimer;
-#endif
-
- int i_lastPosX;
- int i_lastPosY;
- int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
- bool b_mouseIsOver;
-
-#ifdef WIN32TRICK
- bool fscHidden;
-#endif
-
- virtual void customEvent( QEvent *event );
-};
-
-
-
-class VolumeClickHandler : public QObject
-{
-public:
- VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
- {m = _m; p_intf = _p_intf; }
- virtual ~VolumeClickHandler() {};
- bool eventFilter( QObject *obj, QEvent *e )
- {
- if (e->type() == QEvent::MouseButtonPress )
- {
- aout_VolumeMute( p_intf, NULL );
- audio_volume_t i_volume;
- aout_VolumeGet( p_intf, &i_volume );
- m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
- return true;
- }
- return false;
- }
-private:
- ControlsWidget *m;
- intf_thread_t *p_intf;
-};
-
-#include <QLabel>
-#include <QMouseEvent>
-class TimeLabel : public QLabel
-{
- Q_OBJECT
- void mousePressEvent( QMouseEvent *event )
+ virtual void mousePressEvent( QMouseEvent *event )
{
- emit timeLabelClicked();
+ toggleTimeDisplay();
+ event->accept();
}
- void mouseDoubleClickEvent( QMouseEvent *event )
+ virtual void mouseDoubleClickEvent( QMouseEvent *event )
{
+ event->accept();
+ toggleTimeDisplay();
emit timeLabelDoubleClicked();
}
+private:
+ intf_thread_t *p_intf;
+ bool b_remainingTime;
+ int cachedLength;
+ QTimer *bufTimer;
+ float bufVal;
+ bool buffering;
+ bool showBuffering;
+ char psz_length[MSTRTIME_MAX_SIZE];
+ char psz_time[MSTRTIME_MAX_SIZE];
+ void toggleTimeDisplay();
+ void paintEvent( QPaintEvent* );
signals:
- void timeLabelClicked();
void timeLabelDoubleClicked();
+private slots:
+ void setDisplayPosition( float pos, int64_t time, int length );
+ void setDisplayPosition( float pos );
+ void updateBuffering( float );
+ void updateBuffering();
};
class SpeedLabel : public QLabel
{
Q_OBJECT
public:
- SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
- { p_intf = _p_intf; }
+ SpeedLabel( intf_thread_t *, QWidget * );
+ virtual ~SpeedLabel();
protected:
- virtual void mouseDoubleClickEvent ( QMouseEvent * event )
+ virtual void mousePressEvent ( QMouseEvent * event )
{
- THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
+ showSpeedMenu( event->pos() );
}
+private slots:
+ void showSpeedMenu( QPoint );
+ void setRate( float );
private:
intf_thread_t *p_intf;
+ QMenu *speedControlMenu;
+ SpeedControlWidget *speedControl;
};
/******************** Speed Control Widgets ****************/
{
Q_OBJECT
public:
- SpeedControlWidget( intf_thread_t *);
- virtual ~SpeedControlWidget();
- void updateControls( int );
+ SpeedControlWidget( intf_thread_t *, QWidget * );
+ void updateControls( float );
private:
intf_thread_t *p_intf;
QSlider *speedSlider;
+
public slots:
- void setEnable( bool );
+ void activateOnState();
+
private slots:
void updateRate( int );
void resetRate();
};
+class CoverArtLabel : public QLabel
+{
+ Q_OBJECT
+public:
+ CoverArtLabel( QWidget *parent, intf_thread_t * );
+ virtual ~CoverArtLabel();
+
+private:
+ intf_thread_t *p_intf;
+
+public slots:
+ void requestUpdate() { emit updateRequested(); }
+ void update( )
+ {
+ requestUpdate();
+ }
+ void showArtUpdate( const QString& );
+
+private slots:
+ void askForUpdate();
+
+signals:
+ void updateRequested();
+};
+
#endif