Commit 9906af38 authored by Clément Stenac's avatar Clément Stenac

Rework of the embedded stuff. This breaks everything :)

parent 3dda1153
...@@ -92,7 +92,7 @@ VideoWidget::~VideoWidget() ...@@ -92,7 +92,7 @@ VideoWidget::~VideoWidget()
QSize VideoWidget::sizeHint() const QSize VideoWidget::sizeHint() const
{ {
return p_intf->p_sys->p_mi->videoSize; return widgetSize;
} }
static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout, static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
...@@ -112,7 +112,7 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y, ...@@ -112,7 +112,7 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
p_vout = p_nvout; p_vout = p_nvout;
setMinimumSize( 1,1 ); setMinimumSize( 1,1 );
p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height ); widgetSize = QSize( *pi_width, *pi_height );
updateGeometry(); updateGeometry();
need_update = true; need_update = true;
return (void*)winId(); return (void*)winId();
...@@ -128,7 +128,7 @@ void VideoWidget::Release( void *p_win ) ...@@ -128,7 +128,7 @@ void VideoWidget::Release( void *p_win )
p_vout = NULL; p_vout = NULL;
if( config_GetInt( p_intf, "qt-always-video" ) == 0 ) if( config_GetInt( p_intf, "qt-always-video" ) == 0 )
{ {
p_intf->p_sys->p_mi->videoSize = QSize ( 1,1 ); widgetSize = QSize ( 1,1 );
updateGeometry(); updateGeometry();
need_update = true; need_update = true;
} }
...@@ -161,7 +161,7 @@ int VideoWidget::Control( void *p_window, int i_query, va_list args ) ...@@ -161,7 +161,7 @@ int VideoWidget::Control( void *p_window, int i_query, va_list args )
if( !i_width && p_vout ) i_width = p_vout->i_window_width; if( !i_width && p_vout ) i_width = p_vout->i_window_width;
if( !i_height && p_vout ) i_height = p_vout->i_window_height; if( !i_height && p_vout ) i_height = p_vout->i_window_height;
p_intf->p_sys->p_mi->videoSize = QSize( i_width, i_height ); widgetSize = QSize( i_width, i_height );
updateGeometry(); updateGeometry();
need_update = true; need_update = true;
i_ret = VLC_SUCCESS; i_ret = VLC_SUCCESS;
...@@ -219,6 +219,11 @@ int BackgroundWidget::CleanBackground() ...@@ -219,6 +219,11 @@ int BackgroundWidget::CleanBackground()
return 0; return 0;
} }
QSize BackgroundWidget::sizeHint() const
{
return widgetSize;
}
void BackgroundWidget::hasAudio() void BackgroundWidget::hasAudio()
{ {
/* We have video already, do nothing */ /* We have video already, do nothing */
...@@ -240,3 +245,39 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e ) ...@@ -240,3 +245,39 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e )
else else
label->setMaximumWidth( ICON_SIZE ); label->setMaximumWidth( ICON_SIZE );
} }
/**********************************************************************
* Playlist Widget. The embedded playlist
**********************************************************************/
#include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp"
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
p_intf( _p_intf )
{
selector = new PLSelector( this, p_intf, THEPL );
selector->setMaximumWidth( 130 );
playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
THEPL->p_local_category );
rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
p_intf, THEPL, p_root ) );
CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( selector, 0 );
layout->addWidget( rightPanel, 10 );
setLayout( layout );
}
PlaylistWidget::~PlaylistWidget()
{
}
QSize PlaylistWidget::sizeHint() const
{
return widgetSize;
}
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
class QLabel; class QLabel;
class QHBoxLayout; class QHBoxLayout;
class QColor;
/******************** Video Widget ****************/
class VideoWidget : public QFrame class VideoWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
...@@ -43,14 +43,16 @@ public: ...@@ -43,14 +43,16 @@ public:
VideoWidget( intf_thread_t * ); VideoWidget( intf_thread_t * );
virtual ~VideoWidget(); virtual ~VideoWidget();
virtual QSize sizeHint() const;
void *Request( vout_thread_t *, int *, int *, void *Request( vout_thread_t *, int *, int *,
unsigned int *, unsigned int * ); unsigned int *, unsigned int * );
void Release( void * ); void Release( void * );
int Control( void *, int, va_list ); int Control( void *, int, va_list );
int i_video_height, i_video_width; int i_video_height, i_video_width;
vout_thread_t *p_vout; vout_thread_t *p_vout;
QSize widgetSize;
virtual QSize sizeHint() const;
private: private:
QWidget *frame; QWidget *frame;
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -59,12 +61,15 @@ private slots: ...@@ -59,12 +61,15 @@ private slots:
void update(); void update();
}; };
/******************** Background Widget ****************/
class BackgroundWidget : public QFrame class BackgroundWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
BackgroundWidget( intf_thread_t * ); BackgroundWidget( intf_thread_t * );
virtual ~BackgroundWidget(); virtual ~BackgroundWidget();
QSize widgetSize;
virtual QSize sizeHint() const;
private: private:
QPalette plt; QPalette plt;
QLabel *label; QLabel *label;
...@@ -79,7 +84,24 @@ private slots: ...@@ -79,7 +84,24 @@ private slots:
}; };
/******************** Playlist Widget ****************/
#include <QModelIndex>
class QSignalMapper;
class PLSelector;
class PLPanel;
class PlaylistWidget : public QFrame
{
Q_OBJECT;
public:
PlaylistWidget( intf_thread_t * );
virtual ~PlaylistWidget();
QSize widgetSize;
virtual QSize sizeHint() const;
private:
PLSelector *selector;
PLPanel *rightPanel;
intf_thread_t *p_intf;
};
#endif #endif
...@@ -27,12 +27,15 @@ ...@@ -27,12 +27,15 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "components/interface_widgets.hpp" #include "components/interface_widgets.hpp"
#include "dialogs/playlist.hpp"
#include "menus.hpp"
#include <QCloseEvent> #include <QCloseEvent>
#include <assert.h>
#include <QPushButton> #include <QPushButton>
#include <QStatusBar> #include <QStatusBar>
#include <QKeyEvent> #include <QKeyEvent>
#include "menus.hpp"
#include <assert.h>
#include <vlc_keys.h> #include <vlc_keys.h>
#ifdef WIN32 #ifdef WIN32
...@@ -48,16 +51,65 @@ static int InteractCallback( vlc_object_t *, const char *, vlc_value_t, ...@@ -48,16 +51,65 @@ static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{ {
/* All UI stuff */ settings = new QSettings( "VideoLAN", "VLC" );
QWidget *main = new QWidget( this ); settings->beginGroup( "MainWindow" );
setCentralWidget( main );
setWindowTitle( QString::fromUtf8( _("VLC media player") ) ); setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
ui.setupUi( centralWidget() ); handleMainUi( settings );
QVLCMenu::createMenuBar( menuBar(), p_intf );
/* Status bar */
timeLabel = new QLabel( 0 );
nameLabel = new QLabel( 0 );
statusBar()->addWidget( nameLabel, 4 );
statusBar()->addPermanentWidget( timeLabel, 1 );
setFocusPolicy( Qt::StrongFocus ); setFocusPolicy( Qt::StrongFocus );
/* Init input manager */
MainInputManager::getInstance( p_intf );
ON_TIMEOUT( updateOnTimer() );
/* Volume control */
CONNECT( ui.volumeSlider, valueChanged(int), this, updateVolume(int) );
/* Connect the input manager to the GUI elements it manages */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
slider, setPosition( float,int, int ) );
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplay( float, int, int ) );
CONNECT( THEMIM->getIM(), nameChanged( QString ), this,setName( QString ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) );
/* Actions */
BUTTONACT( ui.playButton, play() );
BUTTONACT( ui.stopButton, stop() );
BUTTONACT( ui.nextButton, next() );
BUTTONACT( ui.prevButton, prev() );
BUTTONACT( ui.playlistButton, playlist() );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this );
p_intf->b_interaction = VLC_TRUE;
}
MainInterface::~MainInterface()
{
/// \todo Save everything
p_intf->b_interaction = VLC_FALSE;
var_DelCallback( p_intf, "interaction", InteractCallback, this );
}
void MainInterface::handleMainUi( QSettings *settings )
{
QWidget *main = new QWidget( this );
setCentralWidget( main );
ui.setupUi( centralWidget() );
slider = new InputSlider( Qt::Horizontal, NULL ); slider = new InputSlider( Qt::Horizontal, NULL );
ui.hboxLayout->insertWidget( 0, slider ); ui.hboxLayout->insertWidget( 0, slider );
ui.prevButton->setText( "" ); ui.prevButton->setText( "" );
ui.nextButton->setText( "" ); ui.nextButton->setText( "" );
ui.playButton->setText( "" ); ui.playButton->setText( "" );
...@@ -66,97 +118,83 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -66,97 +118,83 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.nextButton->setIcon( QIcon( ":/pixmaps/next.png" ) ); ui.nextButton->setIcon( QIcon( ":/pixmaps/next.png" ) );
ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) ); ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
ui.stopButton->setIcon( QIcon( ":/pixmaps/stop.png" ) ); ui.stopButton->setIcon( QIcon( ":/pixmaps/stop.png" ) );
/* Volume */
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) ); ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) ); ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
ui.volumeSlider->setMaximum( 100 ); ui.volumeSlider->setMaximum( 100 );
ui.playlistButton->setText( "" );
ui.playlistButton->setIcon( QIcon( ":/pixmaps/volume-low.png" ) );
VolumeClickHandler *h = new VolumeClickHandler( this ); VolumeClickHandler *h = new VolumeClickHandler( this );
ui.volLowLabel->installEventFilter(h); ui.volLowLabel->installEventFilter(h);
ui.volHighLabel->installEventFilter(h); ui.volHighLabel->installEventFilter(h);
ui.volumeSlider->setFocusPolicy( Qt::NoFocus ); ui.volumeSlider->setFocusPolicy( Qt::NoFocus );
QVLCMenu::createMenuBar( menuBar(), p_intf ); ui.playlistButton->setText( "" );
ui.playlistButton->setIcon( QIcon( ":/pixmaps/volume-low.png" ) );
timeLabel = new QLabel( 0 ); /* Fetch configuration from settings and vlc config */
nameLabel = new QLabel( 0 ); videoEmbeddedFlag = false;
statusBar()->addWidget( nameLabel, 4 ); if( config_GetInt( p_intf, "embedded-video" ) )
statusBar()->addPermanentWidget( timeLabel, 1 ); videoEmbeddedFlag = true;
playlistEmbeddedFlag = true;
/// \todo fetch playlist settings
resize ( PREF_W, PREF_H ); resize ( PREF_W, PREF_H );
if( config_GetInt( p_intf, "embedded" ) )
if( videoEmbeddedFlag )
{ {
videoWidget = new VideoWidget( p_intf ); videoWidget = new VideoWidget( p_intf );
if( config_GetInt( p_intf, "qt-always-video" ) ) videoWidget->widgetSize = QSize( 1, 1 );
videoWidget->resize( videoWidget->widgetSize );
ui.vboxLayout->insertWidget( 0, videoWidget );
if( config_GetInt( p_intf, "qt-always-video" ))
{ {
QSettings settings( "VideoLAN", "VLC" ); bgWidget = new BackgroundWidget( p_intf );
settings.beginGroup( "MainWindow" ); bgWidget->widgetSize = settings->value( "backgroundSize",
videoSize = settings.value( "videoSize", QSize( 200, 200 ) ). QSize( 200, 200 ) ).toSize();
toSize(); ui.vboxLayout->insertWidget( 0, bgWidget );
bgWidget->hide();
} }
else
videoSize = QSize( 1,1 );
videoWidget->resize( videoSize );
ui.vboxLayout->insertWidget( 0, videoWidget );
} }
readSettings( "MainWindow" );
// Size for fixed elements
addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H ); addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H );
mainSize.setWidth( videoSize.width() + addSize.width() );
mainSize.setHeight( videoSize.height() + addSize.height() ); calculateInterfaceSize();
resize( mainSize ); resize( mainSize );
/// \bug still needed ?
mainSize = size(); mainSize = size();
setMinimumSize( PREF_W, addSize.height() ); setMinimumSize( PREF_W, addSize.height() );
/* Init input manager */
MainInputManager::getInstance( p_intf );
ON_TIMEOUT( updateOnTimer() );
/* Volume control */
CONNECT( ui.volumeSlider, valueChanged(int), this, updateVolume(int) );
/* Connect the input manager to the GUI elements it manages */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
slider, setPosition( float,int, int ) );
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplay( float, int, int ) );
CONNECT( THEMIM->getIM(), nameChanged( QString ), this,setName( QString ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) );
/* Actions */
BUTTONACT( ui.playButton, play() );
BUTTONACT( ui.stopButton, stop() );
BUTTONACT( ui.nextButton, next() );
BUTTONACT( ui.prevButton, prev() );
CONNECT( ui.playlistButton, clicked(), THEDP, playlistDialog() );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this );
p_intf->b_interaction = VLC_TRUE;
} }
MainInterface::~MainInterface() void MainInterface::calculateInterfaceSize()
{ {
writeSettings( "MainWindow" ); int width = 0, height = 0;
if( config_GetInt( p_intf, "qt-always-video" ) ) if( bgWidget->isVisible() )
{ {
QSettings s("VideoLAN", "VLC" ); width += bgWidget->widgetSize.width();
s.beginGroup( "MainWindow" ); height += bgWidget->widgetSize.height();
s.setValue( "videoSize", videoSize ); assert( !playlistWidget->isVisible() );
s.endGroup();
} }
p_intf->b_interaction = VLC_FALSE; if( playlistWidget->isVisible() )
var_DelCallback( p_intf, "interaction", InteractCallback, this ); {
width += playlistWidget->widgetSize.width();
height += playlistWidget->widgetSize.height();
}
mainSize.setWidth( width + videoWidget->widgetSize.width() +
addSize.width() );
mainSize.setHeight( height + videoWidget->widgetSize.height() +
addSize.height() );
} }
void MainInterface::resizeEvent( QResizeEvent *e ) void MainInterface::resizeEvent( QResizeEvent *e )
{ {
videoSize.setHeight( e->size().height() - addSize.height() ); videoWidget->widgetSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() ); videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
p_intf->p_sys->p_video->updateGeometry() ; p_intf->p_sys->p_video->updateGeometry() ;
} }
...@@ -169,9 +207,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e ) ...@@ -169,9 +207,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
if( e->modifiers()& Qt::ControlModifier ) i_vlck |= KEY_MODIFIER_CTRL; if( e->modifiers()& Qt::ControlModifier ) i_vlck |= KEY_MODIFIER_CTRL;
if( e->modifiers()& Qt::MetaModifier ) i_vlck |= KEY_MODIFIER_META; if( e->modifiers()& Qt::MetaModifier ) i_vlck |= KEY_MODIFIER_META;
fprintf( stderr, "After modifiers %x\n", i_vlck );
bool found = false; bool found = false;
fprintf( stderr, "Qt %x\n", e->key() );
/* Look for some special keys */ /* Look for some special keys */
#define HANDLE( qt, vk ) case Qt::qt : i_vlck |= vk; found = true;break #define HANDLE( qt, vk ) case Qt::qt : i_vlck |= vk; found = true;break
switch( e->key() ) switch( e->key() )
...@@ -203,7 +239,6 @@ void MainInterface::keyPressEvent( QKeyEvent *e ) ...@@ -203,7 +239,6 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
HANDLE( Key_Delete, KEY_DELETE ); HANDLE( Key_Delete, KEY_DELETE );
} }
fprintf( stderr, "After keys %x\n", i_vlck );
if( !found ) if( !found )
{ {
/* Force lowercase */ /* Force lowercase */
...@@ -246,6 +281,36 @@ void MainInterface::next() ...@@ -246,6 +281,36 @@ void MainInterface::next()
playlist_Next( THEPL ); playlist_Next( THEPL );
} }
void MainInterface::playlist()
{
// Toggle the playlist dialog
if( !playlistEmbeddedFlag )
{
if( playlistWidget )
{
/// \todo Destroy it
}
THEDP->playlistDialog();
return;
}
if( !playlistWidget )
{
PlaylistDialog::killInstance();
playlistWidget = new PlaylistWidget( p_intf );
ui.vboxLayout->insertWidget( 0, playlistWidget );
playlistWidget->widgetSize = settings->value( "playlistSize",
QSize( 600, 300 ) ).toSize();
}
/// Todo, reset its size ?
if( playlistWidget->isVisible() ) playlistWidget->show();
else playlistWidget->hide();
calculateInterfaceSize();
resize( mainSize );
}
void MainInterface::setDisplay( float pos, int time, int length ) void MainInterface::setDisplay( float pos, int time, int length )
{ {
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE]; char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
......
...@@ -28,13 +28,20 @@ ...@@ -28,13 +28,20 @@
#include "ui/main_interface.h" #include "ui/main_interface.h"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include <QSize>
class QSettings;
class QCloseEvent; class QCloseEvent;
class QKeyEvent; class QKeyEvent;
class QLabel; class QLabel;
class InputManager; class InputManager;
class InputSlider; class InputSlider;
class VideoWidget; class VideoWidget;
class BackgroundWidget;
class PlaylistWidget;
class VolumeClickHandler; class VolumeClickHandler;
class MainInterface : public QVLCMW class MainInterface : public QVLCMW
{ {
Q_OBJECT; Q_OBJECT;
...@@ -44,21 +51,33 @@ public: ...@@ -44,21 +51,33 @@ public:
void resizeEvent( QResizeEvent * ); void resizeEvent( QResizeEvent * );
QSize videoSize, addSize;
protected: protected:
void closeEvent( QCloseEvent *); void closeEvent( QCloseEvent *);
Ui::MainInterfaceUI ui; Ui::MainInterfaceUI ui;
friend class VolumeClickHandler; friend class VolumeClickHandler;
private: private:
QSettings *settings;
QSize mainSize, addSize;
void calculateInterfaceSize();
void handleMainUi( QSettings* );
virtual void keyPressEvent( QKeyEvent *); virtual void keyPressEvent( QKeyEvent *);
VideoWidget *videoWidget;
InputManager *main_input_manager; /* All the stuff that goes in the main position */
QLabel *timeLabel; VideoWidget *videoWidget;
QLabel *nameLabel; BackgroundWidget *bgWidget;
InputSlider *slider; PlaylistWidget *playlistWidget;
/// Main input associated to the playlist
input_thread_t *p_input; bool playlistEmbeddedFlag;
bool videoEmbeddedFlag;
InputManager *main_input_manager;
InputSlider *slider;
input_thread_t *p_input; ///< Main input associated to the playlist
QLabel *timeLabel;
QLabel *nameLabel;
private slots: private slots:
void setStatus( int ); void setStatus( int );
void setName( QString ); void setName( QString );
...@@ -68,6 +87,7 @@ private slots: ...@@ -68,6 +87,7 @@ private slots:
void stop(); void stop();
void prev(); void prev();
void next(); void next();
void playlist();
void updateVolume( int sliderVolume ); void updateVolume( int sliderVolume );
}; };
......
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