Commit 8a473ffa authored by Clément Stenac's avatar Clément Stenac

Improve embedded video output

Skeleton for interaction
Fix window settings save
parent 3ebf4f30
......@@ -11,7 +11,8 @@
AUTOMAKE_OPTIONS = subdir-objects
TOUI = ui/input_stats ui/main_interface ui/file_open
TOUI = ui/input_stats ui/main_interface ui/file_open \
ui/okcanceldialog
UIH = $(TOUI:%=%.h)
TOMOC = main_interface \
......@@ -21,11 +22,13 @@ TOMOC = main_interface \
dialogs/playlist \
dialogs/prefs_dialog \
dialogs/streaminfo \
dialogs/interaction \
components/infopanels \
components/preferences_widgets \
components/preferences \
components/open \
components/playlist/panels \
components/video_widget \
util/input_slider
MOCCPP = $(TOMOC:%=%.moc.cpp)
......@@ -37,11 +40,13 @@ nodist_SOURCES_qt4 = \
dialogs/playlist.moc.cpp \
dialogs/streaminfo.moc.cpp \
dialogs/prefs_dialog.moc.cpp \
dialogs/interaction.moc.cpp \
components/infopanels.moc.cpp \
components/preferences_widgets.moc.cpp \
components/preferences.moc.cpp \
components/open.moc.cpp \
components/playlist/panels.moc.cpp \
components/video_widget.moc.cpp \
util/input_slider.moc.cpp \
resources.cpp
......@@ -72,6 +77,7 @@ SOURCES_qt4 = qt4.cpp \
dialogs/playlist.cpp \
dialogs/prefs_dialog.cpp \
dialogs/streaminfo.cpp \
dialogs/interaction.cpp \
components/infopanels.cpp \
components/preferences_widgets.cpp \
components/preferences.cpp \
......@@ -91,6 +97,7 @@ EXTRA_DIST += \
dialogs/playlist.hpp \
dialogs/streaminfo.hpp \
dialogs/prefs_dialog.hpp \
dialogs/interaction.cpp \
components/infopanels.hpp \
components/preferences_widgets.hpp \
components/preferences.hpp \
......@@ -99,6 +106,9 @@ EXTRA_DIST += \
components/video_widget.hpp \
util/input_slider.hpp \
ui/input_stats.ui \
ui/file_open.ui \
ui/main_interface.ui \
ui/okcanceldialog.ui \
pixmaps/advanced.xpm \
pixmaps/audio.xpm \
pixmaps/codec.xpm \
......
......@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "dialogs_provider.hpp"
#include <vlc/vout.h>
#include "qt4.hpp"
#include "components/video_widget.hpp"
......@@ -30,9 +31,10 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
unsigned int *, unsigned int * );
static void DoRelease( intf_thread_t *, void * );
static int DoControl( intf_thread_t *, void *, int, va_list );
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QWidget( NULL ),
bool need_update;
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ),
p_intf( _p_i )
{
vlc_mutex_init( p_intf, &lock );
......@@ -43,8 +45,23 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QWidget( NULL ),
p_intf->p_sys->p_video = this;
p_vout = NULL;
i_video_width = i_video_height = 1;
setFrameStyle(QFrame::Panel | QFrame::Raised);
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT( update() ) );
need_update = false;
}
void VideoWidget::update()
{
if( need_update )
{
p_intf->p_sys->p_mi->resize( p_intf->p_sys->p_mi->sizeHint() );
need_update = false;
}
}
VideoWidget::~VideoWidget()
......@@ -72,7 +89,7 @@ VideoWidget::~VideoWidget()
QSize VideoWidget::sizeHint() const
{
return QSize( i_video_width, i_video_height );
return p_intf->p_sys->p_mi->videoSize;
}
static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
......@@ -97,19 +114,21 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
p_intf->p_sys->p_mi->maximumSize().width(),
p_intf->p_sys->p_mi->maximumSize().height() );
i_video_width = *pi_width;
i_video_height = *pi_height;
setMinimumSize( 1,1 );
p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height );
updateGeometry();
p_intf->p_sys->p_mi->setMinimumSize(
p_intf->p_sys->p_mi->i_saved_width,
p_intf->p_sys->p_mi->i_saved_height );
p_intf->p_sys->p_mi->resize( p_intf->p_sys->p_mi->sizeHint() );
fprintf( stderr, "[After update] MI constraints %ix%i -> %ix%i\n",
need_update = true;
fprintf( stderr, "[After update] MI constraints %ix%i -> %ix%i - Fr %ix%i -> %ix%i (hint %ix%i)\n",
p_intf->p_sys->p_mi->minimumSize().width(),
p_intf->p_sys->p_mi->minimumSize().height(),
p_intf->p_sys->p_mi->maximumSize().width(),
p_intf->p_sys->p_mi->maximumSize().height() );
p_intf->p_sys->p_mi->maximumSize().height(),
minimumSize().width(),
minimumSize().height(),
maximumSize().width(),
maximumSize().height(),
sizeHint().width(),sizeHint().height()
);
return (void*)winId();
}
......@@ -121,7 +140,10 @@ static void DoRelease( intf_thread_t *p_intf, void *p_win )
void VideoWidget::Release( void *p_win )
{
i_video_height = i_video_width = 1;
if( !config_GetInt( p_intf, "qt-always-video" ) );
{
p_intf->p_sys->p_mi->videoSize = QSize ( 1,1 );
}
fprintf( stderr, "[Before R update] MI constraints %ix%i -> %ix%i\n",
p_intf->p_sys->p_mi->minimumSize().width(),
p_intf->p_sys->p_mi->minimumSize().height(),
......@@ -129,8 +151,11 @@ void VideoWidget::Release( void *p_win )
p_intf->p_sys->p_mi->maximumSize().height() );
updateGeometry();
p_intf->p_sys->p_mi->setMinimumSize( p_intf->p_sys->p_mi->sizeHint() );
p_intf->p_sys->p_mi->resize( p_intf->p_sys->p_mi->sizeHint() );
// p_intf->p_sys->p_mi->setMinimumSize( 500,
// p_intf->p_sys->p_mi->addSize.height() );
if( !config_GetIntf( p_intf, "qt-always-video" ) )
need_update = true;
fprintf( stderr, "[After R update] MI constraints %ix%i -> %ix%i\n",
p_intf->p_sys->p_mi->minimumSize().width(),
......
......@@ -27,9 +27,11 @@
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <QWidget>
#include <QFrame>
class VideoWidget : public QWidget
class VideoWidget : public QFrame
{
Q_OBJECT
public:
VideoWidget( intf_thread_t *);
virtual ~VideoWidget();
......@@ -41,12 +43,13 @@ public:
void Release( void * );
int Control( void *, int, va_list );
int i_video_height, i_video_width;
vout_thread_t *p_vout;
private:
QWidget *frame;
intf_thread_t *p_intf;
vout_thread_t *p_vout;
vlc_mutex_t lock;
private slots:
void update();
};
#endif
/*****************************************************************************
* interaction.cpp : Interaction stuff
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include "dialogs/interaction.hpp"
#include <vlc/intf.h>
InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
interaction_dialog_t *_p_dialog ) :
p_intf( _p_intf), p_dialog( _p_dialog )
{
if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
uiOkCancel = new Ui::OKCancelDialog;
uiOkCancel->setupUi( this );
uiOkCancel->description->setText( p_dialog->psz_description );
connect( uiOkCancel->okButton, SIGNAL( clicked() ),
this, SLOT( OK() ) );
connect( uiOkCancel->cancelButton, SIGNAL( clicked() ),
this, SLOT( cancel() ) );
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
}
else
msg_Err( p_intf, "unknown dialog type" );
}
void InteractionDialog::Update()
{
}
InteractionDialog::~InteractionDialog()
{
}
void InteractionDialog::OK()
{
Finish( DIALOG_OK_YES, NULL, NULL );
}
void InteractionDialog::cancel()
{
Finish( DIALOG_CANCELLED, NULL, NULL );
}
void InteractionDialog::Finish( int i_ret, QString *r1, QString *r2 )
{
vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
p_dialog->i_status = ANSWERED_DIALOG;
p_dialog->i_return = i_ret;
hide();
vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
}
/*****************************************************************************
* interaction.hpp : Interaction dialogs
****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#ifndef _INTERACTION_H_
#define _INTERACTION_H_
#include <vlc/vlc.h>
#include <vlc_interaction.h>
#include <ui/okcanceldialog.h>
class InteractionDialog : public QWidget
{
Q_OBJECT
public:
InteractionDialog( intf_thread_t *, interaction_dialog_t * );
virtual ~InteractionDialog();
void Update();
private:
intf_thread_t *p_intf;
interaction_dialog_t *p_dialog;
Ui::OKCancelDialog *uiOkCancel;
void Finish( int, QString *, QString * );
private slots:
void OK();
void cancel();
};
#endif
......@@ -20,9 +20,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include "dialogs_provider.hpp"
#include "qt4.hpp"
#include <QEvent>
#include "dialogs_provider.hpp"
#include "dialogs/playlist.hpp"
#include "dialogs/prefs_dialog.hpp"
#include "dialogs/streaminfo.hpp"
......@@ -33,8 +33,8 @@ DialogsProvider* DialogsProvider::instance = NULL;
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
QObject( NULL ), p_intf( _p_intf )
{
idle_timer = new QTimer( this );
// idle_timer->start( 0 );
// idle_timer = new QTimer( this );
// idle_timer->start( 0 );
fixed_timer = new QTimer( this );
fixed_timer->start( 150 /* milliseconds */ );
......@@ -69,12 +69,13 @@ void DialogsProvider::customEvent( QEvent *event )
popupMenu( de->i_dialog ); break;
case INTF_DIALOG_FILEINFO:
streaminfoDialog(); break;
case INTF_DIALOG_VLM:
case INTF_DIALOG_INTERACTION:
doInteraction( de->p_arg ); break;
case INTF_DIALOG_VLM:
case INTF_DIALOG_BOOKMARKS:
case INTF_DIALOG_WIZARD:
default:
fprintf( stderr, "Unimplemented dialog\n");
msg_Warn( p_intf, "unimplemented dialog\n" );
}
}
}
......@@ -88,6 +89,36 @@ void DialogsProvider::openDialog( int i_dialog )
{
}
void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
{
InteractionDialog *qdialog;
interaction_dialog_t *p_dialog = p_arg->p_dialog;
switch( p_dialog->i_action )
{
case INTERACT_NEW:
qdialog = new InteractionDialog( p_intf, p_dialog );
p_dialog->p_private = (void*)qdialog;
qdialog->show();
break;
case INTERACT_UPDATE:
qdialog = (InteractionDialog*)(p_dialog->p_private);
if( qdialog)
qdialog->Update();
break;
case INTERACT_HIDE:
qdialog = (InteractionDialog*)(p_dialog->p_private);
if( qdialog )
qdialog->hide();
p_dialog->i_status = HIDDEN_DIALOG;
break;
case INTERACT_DESTROY:
qdialog = (InteractionDialog*)(p_dialog->p_private);
delete qdialog;
p_dialog->i_status = DESTROYED_DIALOG;
break;
}
}
void DialogsProvider::streaminfoDialog()
{
StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
......
......@@ -27,6 +27,8 @@
#include <QTimer>
#include <QApplication>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "dialogs/interaction.hpp"
class QEvent;
......@@ -57,6 +59,7 @@ public slots:
void messagesDialog();
void openDialog( int );
void popupMenu( int );
void doInteraction( intf_dialog_args_t * );
};
......
......@@ -31,6 +31,9 @@
#include <assert.h>
#include <QPushButton>
static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void *);
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{
/* All UI stuff */
......@@ -54,16 +57,43 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
//QVLCMenu::createMenuBar();
resize (500, 131 );
fprintf( stderr, "Before creating the video widget, size is %ix%i\n", size().width(), size().height() );
// if( config_GetInt( p_intf, "embedded" ) )
{
videoWidget = new VideoWidget( p_intf );
videoWidget->resize( 1,1 );
if( config_GetInt( p_intf, "qt-always-video" ) )
{
QSettings settings( "VideoLAN", "VLC" );
settings.beginGroup( "MainWindow" );
videoSize = settings.value( "videoSize", QSize( 200, 200 ) ).
toSize();
}
else
videoSize = QSize( 1,1 );
videoWidget->resize( videoSize );
ui.vboxLayout->insertWidget( 0, videoWidget );
}
fprintf( stderr, "Margin : %i\n",ui.vboxLayout->margin() );
readSettings( "MainWindow" );
readSettings( "MainWindow" , QSize( 500, 131) );
addSize = QSize( ui.vboxLayout->margin() * 2, 131 );
if( config_GetInt( p_intf, "qt-always-video" ) )
mainSize = videoSize + addSize;
else
mainSize = QSize( 500,131 );
resize( 500,131 );
resize( mainSize );
mainSize = size();
//QVLCMenu::createMenuBar();
fprintf( stderr, "Size is %ix%i - Video %ix%i\n", mainSize.width(), mainSize.height(), videoSize.width(), videoSize.height() );
fprintf( stderr, "Additional size around video %ix%i", addSize.width(), addSize.height() );
setMinimumSize( 500, addSize.height() );
/* Init input manager */
MainInputManager::getInstance( p_intf );
......@@ -91,17 +121,39 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
connect( ui.playlistButton, SLOT(clicked() ),
DialogsProvider::getInstance( p_intf ), SLOT( playlistDialog() ) );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this );
p_intf->b_interaction = VLC_TRUE;
}
MainInterface::~MainInterface()
{
writeSettings( "MainWindow" );
if( config_GetInt( p_intf, "qt-always-video" ) )
{
QSettings s("VideoLAN", "VLC" );
s.beginGroup( "MainWindow" );
s.setValue( "videoSize", videoSize );
s.endGroup();
}
p_intf->b_interaction = VLC_FALSE;
var_DelCallback( p_intf, "interaction", InteractCallback, this );
}
QSize MainInterface::sizeHint() const
void MainInterface::resizeEvent( QResizeEvent *e )
{
int i_width = __MAX( i_saved_width, p_intf->p_sys->p_video->i_video_width );
return QSize( i_width, i_saved_height +
p_intf->p_sys->p_video->i_video_height );
fprintf( stderr, "Resized to %ix%i\n", e->size().width(), e->size().height() );
fprintf( stderr, "MI constraints %ix%i -> %ix%i\n",
p_intf->p_sys->p_mi->minimumSize().width(),
p_intf->p_sys->p_mi->minimumSize().height(),
p_intf->p_sys->p_mi->maximumSize().width(),
p_intf->p_sys->p_mi->maximumSize().height() );
videoSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() );
p_intf->p_sys->p_video->updateGeometry() ;
}
void MainInterface::stop()
......@@ -144,3 +196,17 @@ void MainInterface::closeEvent( QCloseEvent *e )
hide();
p_intf->b_die = VLC_TRUE;
}
static int InteractCallback( vlc_object_t *p_this,
const char *psz_var, vlc_value_t old_val,
vlc_value_t new_val, void *param )
{
intf_dialog_args_t *p_arg = new intf_dialog_args_t;
p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
MainInterface *p_interface = (MainInterface*)param;
DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
QApplication::postEvent( DialogsProvider::getInstance( NULL ),
static_cast<QEvent*>(event) );
return VLC_SUCCESS;
}
......@@ -39,9 +39,9 @@ public:
MainInterface( intf_thread_t *);
virtual ~MainInterface();
virtual QSize sizeHint() const;
void resizeEvent( QResizeEvent * );
int i_saved_width, i_saved_height;
QSize videoSize, addSize;
protected:
void closeEvent( QCloseEvent *);
......
......@@ -52,6 +52,7 @@ vlc_module_begin();
add_submodule();
set_description( "Dialogs provider" );
set_capability( "dialogs provider", 51 );
add_bool( "qt-always-video", VLC_FALSE, NULL, "", "", VLC_TRUE );
set_callbacks( OpenDialogs, Close );
vlc_module_end();
......@@ -140,6 +141,7 @@ static void Init( intf_thread_t *p_intf )
app->setQuitOnLastWindowClosed( false );
app->exec();
delete p_intf->p_sys->p_mi;
}
/*****************************************************************************
......
......@@ -4,14 +4,14 @@
<exportmacro></exportmacro>
<class>MainInterfaceUI</class>
<widget class="QWidget" name="MainInterfaceUI" >
<property name="geometry" >
<!-- <property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<height>80</height>
</rect>
</property>
</property> -->
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
......
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>OKCancelDialog</class>
<widget class="QWidget" name="OKCancelDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>122</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="description" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
......@@ -75,6 +75,7 @@ protected:
}
void writeSettings( QString name )
{
fprintf( stderr, "save\n" );
QSettings settings( "VideoLAN", "VLC" );
settings.beginGroup( name );
settings.setValue ("size", size() );
......@@ -100,8 +101,16 @@ protected:
QSettings settings( "VideoLAN", "VLC" );
settings.beginGroup( name );
mainSize = settings.value( "size", defSize ).toSize();
resize( mainSize );
move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
QPoint npos = settings.value( "pos", QPoint( 0,0 ) ).toPoint();
if( npos.x() > 0 )
move( npos );
settings.endGroup();
}
void readSettings( QString name )
{
QSettings settings( "VideoLAN", "VLC" );
settings.beginGroup( name );
mainSize = settings.value( "size", QSize( 0,0 ) ).toSize();
settings.endGroup();
}
void writeSettings( QString name )
......
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