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()
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,
......@@ -112,7 +112,7 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
p_vout = p_nvout;
setMinimumSize( 1,1 );
p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height );
widgetSize = QSize( *pi_width, *pi_height );
updateGeometry();
need_update = true;
return (void*)winId();
......@@ -128,7 +128,7 @@ void VideoWidget::Release( void *p_win )
p_vout = NULL;
if( config_GetInt( p_intf, "qt-always-video" ) == 0 )
{
p_intf->p_sys->p_mi->videoSize = QSize ( 1,1 );
widgetSize = QSize ( 1,1 );
updateGeometry();
need_update = true;
}
......@@ -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_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();
need_update = true;
i_ret = VLC_SUCCESS;
......@@ -219,6 +219,11 @@ int BackgroundWidget::CleanBackground()
return 0;
}
QSize BackgroundWidget::sizeHint() const
{
return widgetSize;
}
void BackgroundWidget::hasAudio()
{
/* We have video already, do nothing */
......@@ -240,3 +245,39 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e )
else
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 @@
class QLabel;
class QHBoxLayout;
class QColor;
/******************** Video Widget ****************/
class VideoWidget : public QFrame
{
Q_OBJECT
......@@ -43,14 +43,16 @@ public:
VideoWidget( intf_thread_t * );
virtual ~VideoWidget();
virtual QSize sizeHint() const;
void *Request( vout_thread_t *, int *, int *,
unsigned int *, unsigned int * );
void Release( void * );
int Control( void *, int, va_list );
int i_video_height, i_video_width;
vout_thread_t *p_vout;
QSize widgetSize;
virtual QSize sizeHint() const;
private:
QWidget *frame;
intf_thread_t *p_intf;
......@@ -59,12 +61,15 @@ private slots:
void update();
};
/******************** Background Widget ****************/
class BackgroundWidget : public QFrame
{
Q_OBJECT
public:
BackgroundWidget( intf_thread_t * );
virtual ~BackgroundWidget();
QSize widgetSize;
virtual QSize sizeHint() const;
private:
QPalette plt;
QLabel *label;
......@@ -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
......@@ -27,12 +27,15 @@
#include "util/qvlcframe.hpp"
#include "dialogs_provider.hpp"
#include "components/interface_widgets.hpp"
#include "dialogs/playlist.hpp"
#include "menus.hpp"
#include <QCloseEvent>
#include <assert.h>
#include <QPushButton>
#include <QStatusBar>
#include <QKeyEvent>
#include "menus.hpp"
#include <assert.h>
#include <vlc_keys.h>
#ifdef WIN32
......@@ -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 )
{
/* All UI stuff */
QWidget *main = new QWidget( this );
setCentralWidget( main );
settings = new QSettings( "VideoLAN", "VLC" );
settings->beginGroup( "MainWindow" );
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 );
/* 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 );
ui.hboxLayout->insertWidget( 0, slider );
ui.prevButton->setText( "" );
ui.nextButton->setText( "" );
ui.playButton->setText( "" );
......@@ -66,97 +118,83 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.nextButton->setIcon( QIcon( ":/pixmaps/next.png" ) );
ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
ui.stopButton->setIcon( QIcon( ":/pixmaps/stop.png" ) );
/* Volume */
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
ui.volumeSlider->setMaximum( 100 );
ui.playlistButton->setText( "" );
ui.playlistButton->setIcon( QIcon( ":/pixmaps/volume-low.png" ) );
VolumeClickHandler *h = new VolumeClickHandler( this );
ui.volLowLabel->installEventFilter(h);
ui.volHighLabel->installEventFilter(h);
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 );
nameLabel = new QLabel( 0 );
statusBar()->addWidget( nameLabel, 4 );
statusBar()->addPermanentWidget( timeLabel, 1 );
/* Fetch configuration from settings and vlc config */
videoEmbeddedFlag = false;
if( config_GetInt( p_intf, "embedded-video" ) )
videoEmbeddedFlag = true;
playlistEmbeddedFlag = true;
/// \todo fetch playlist settings
resize ( PREF_W, PREF_H );
if( config_GetInt( p_intf, "embedded" ) )
if( videoEmbeddedFlag )
{
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" );
settings.beginGroup( "MainWindow" );
videoSize = settings.value( "videoSize", QSize( 200, 200 ) ).
toSize();
bgWidget = new BackgroundWidget( p_intf );
bgWidget->widgetSize = settings->value( "backgroundSize",
QSize( 200, 200 ) ).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 );
mainSize.setWidth( videoSize.width() + addSize.width() );
mainSize.setHeight( videoSize.height() + addSize.height() );
calculateInterfaceSize();
resize( mainSize );
/// \bug still needed ?
mainSize = size();
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" );
if( config_GetInt( p_intf, "qt-always-video" ) )
int width = 0, height = 0;
if( bgWidget->isVisible() )
{
QSettings s("VideoLAN", "VLC" );
s.beginGroup( "MainWindow" );
s.setValue( "videoSize", videoSize );
s.endGroup();
width += bgWidget->widgetSize.width();
height += bgWidget->widgetSize.height();
assert( !playlistWidget->isVisible() );
}
p_intf->b_interaction = VLC_FALSE;
var_DelCallback( p_intf, "interaction", InteractCallback, this );
if( playlistWidget->isVisible() )
{
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 )
{
videoSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() );
videoWidget->widgetSize.setHeight( e->size().height() - addSize.height() );
videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
p_intf->p_sys->p_video->updateGeometry() ;
}
......@@ -169,9 +207,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
if( e->modifiers()& Qt::ControlModifier ) i_vlck |= KEY_MODIFIER_CTRL;
if( e->modifiers()& Qt::MetaModifier ) i_vlck |= KEY_MODIFIER_META;
fprintf( stderr, "After modifiers %x\n", i_vlck );
bool found = false;
fprintf( stderr, "Qt %x\n", e->key() );
/* Look for some special keys */
#define HANDLE( qt, vk ) case Qt::qt : i_vlck |= vk; found = true;break
switch( e->key() )
......@@ -203,7 +239,6 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
HANDLE( Key_Delete, KEY_DELETE );
}
fprintf( stderr, "After keys %x\n", i_vlck );
if( !found )
{
/* Force lowercase */
......@@ -246,6 +281,36 @@ void MainInterface::next()
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 )
{
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
......
......@@ -28,13 +28,20 @@
#include "ui/main_interface.h"
#include "util/qvlcframe.hpp"
#include <QSize>
class QSettings;
class QCloseEvent;
class QKeyEvent;
class QLabel;
class InputManager;
class InputSlider;
class VideoWidget;
class BackgroundWidget;
class PlaylistWidget;
class VolumeClickHandler;
class MainInterface : public QVLCMW
{
Q_OBJECT;
......@@ -44,21 +51,33 @@ public:
void resizeEvent( QResizeEvent * );
QSize videoSize, addSize;
protected:
void closeEvent( QCloseEvent *);
Ui::MainInterfaceUI ui;
friend class VolumeClickHandler;
private:
QSettings *settings;
QSize mainSize, addSize;
void calculateInterfaceSize();
void handleMainUi( QSettings* );
virtual void keyPressEvent( QKeyEvent *);
VideoWidget *videoWidget;
InputManager *main_input_manager;
QLabel *timeLabel;
QLabel *nameLabel;
InputSlider *slider;
/// Main input associated to the playlist
input_thread_t *p_input;
/* All the stuff that goes in the main position */
VideoWidget *videoWidget;
BackgroundWidget *bgWidget;
PlaylistWidget *playlistWidget;
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:
void setStatus( int );
void setName( QString );
......@@ -68,6 +87,7 @@ private slots:
void stop();
void prev();
void next();
void playlist();
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