Commit 116f3a23 authored by Clément Stenac's avatar Clément Stenac

Add video filters panel

Fix size of preference tree items
parent f17ac07e
......@@ -82,4 +82,33 @@
#define I_HIDDEN_ADV N_( "Some options are available but hidden. "\
"Check \"Advanced options\" to see them." )
/*************** Video filters **************/
#define I_CLONE N_("Image clone")
#define I_CLONE_TIP N_("Clone the image")
#define I_MAGNIFY N_("Magnification")
#define I_MAGNIFY_TIP N_("Magnify a part of the video. You can select " \
"which part of the image should be magnified." )
#define I_WAVE N_("Waves")
#define I_WAVE_TIP N_("\"Waves\" video distortion effect")
#define I_RIPPLE_TIP N_("\"Water surface\" video distortion effect")
#define I_INVERT_TIP N_("Image colors inversion")
#define I_WALL_TIP N_("Split the image to make an image wall")
#define I_PUZZLE_TIP N_("Create a \"puzzle game\" with the video.\n" \
"The video gets split in parts that you must sort.")
#define I_GRADIENT_TIP N_("\"Edge detection\" video distortion effect.\n" \
"Try changing the various settings for different effects" )
#define I_COLORTHRES_TIP N_("\"Color detection\" effect. The whole image " \
"will be turned to black and white, except the parts that "\
"are of the color that you select in the settings.")
#endif
......@@ -13,6 +13,7 @@ AUTOMAKE_OPTIONS = subdir-objects
TOUI = \
ui/equalizer \
ui/video_effects \
ui/open_file \
ui/open_disk \
ui/open_net \
......@@ -168,6 +169,7 @@ EXTRA_DIST += \
util/customwidgets.hpp \
util/qvlcframe.hpp \
ui/equalizer.ui \
ui/video_effects.ui \
ui/open_file.ui \
ui/open_disk.ui \
ui/open_net.ui \
......
......@@ -26,15 +26,168 @@
#include <QString>
#include <QFont>
#include <QGridLayout>
#include <QSignalMapper>
#include "components/extended_panels.hpp"
#include "dialogs/prefs_dialog.hpp"
#include "dialogs_provider.hpp"
#include "qt4.hpp"
#include "../../audio_filter/equalizer_presets.h"
#include <vlc_aout.h>
#include <vlc_intf_strings.h>
#include <vlc_vout.h>
#include <assert.h>
class ConfClickHandler : public QObject
{
public:
ConfClickHandler( intf_thread_t *_p_intf, ExtVideo *_e ) : QObject (_e) {
e = _e; p_intf = _p_intf;
}
virtual ~ConfClickHandler() {}
bool eventFilter( QObject *obj, QEvent *evt )
{
if( evt->type() == QEvent::MouseButtonPress )
{
e->gotoConf( obj );
return true;
}
return false;
}
private:
ExtVideo* e;
intf_thread_t *p_intf;
};
#define SETUP_VFILTER( widget, conf, tooltip, labtooltip ) \
ui.widget##Check->setToolTip( tooltip ); \
if (conf ) {\
ui.widget##Label->setToolTip( labtooltip ); \
ui.widget##Label->setPixmap( QPixmap(":/pixmaps/go-next.png") ); \
ui.widget##Label->installEventFilter(h); \
} \
CONNECT( ui.widget##Check, clicked(), this, updateFilters() ); \
ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf )
{
ConfClickHandler* h = new ConfClickHandler( p_intf, this );
ui.setupUi( this );
SETUP_VFILTER( clone, true, qtr(I_CLONE_TIP),
qtr("Configure the clone filter") );
SETUP_VFILTER( magnify, false, qtr(I_MAGNIFY_TIP),
qtr("Configure the magnification effect"));
SETUP_VFILTER( wave, false, qtr(I_WAVE_TIP),
qtr("Configure the waves effect"));
SETUP_VFILTER( ripple, false, qtr(I_RIPPLE_TIP),
qtr("Configure the \"water\" effect"));
SETUP_VFILTER( invert, false, qtr(I_INVERT_TIP),
qtr("Configure the color inversion effect"));
SETUP_VFILTER( puzzle, true, qtr(I_PUZZLE_TIP),
qtr("Configure the puzzle effect"));
SETUP_VFILTER( wall, true, qtr(I_WALL_TIP),
qtr("Configure the wall filter") );
SETUP_VFILTER( gradient, true, qtr(I_GRADIENT_TIP),
qtr("Configure the \"gradient\" effect"));
SETUP_VFILTER( colorthres, true, qtr(I_COLORTHRES_TIP),
qtr("Configure the color detection effect"));
}
ExtVideo::~ExtVideo()
{
}
static void ChangeVFiltersString( intf_thread_t *p_intf,
char *psz_name, vlc_bool_t b_add )
{
vout_thread_t *p_vout;
char *psz_parser, *psz_string;
psz_string = config_GetPsz( p_intf, "video-filter" );
if( !psz_string ) psz_string = strdup("");
psz_parser = strstr( psz_string, psz_name );
if( b_add )
{
if( !psz_parser )
{
psz_parser = psz_string;
asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
psz_string, psz_name );
free( psz_parser );
}
else
{
return;
}
}
else
{
if( psz_parser )
{
memmove( psz_parser, psz_parser + strlen(psz_name) +
(*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
strlen(psz_parser + strlen(psz_name)) + 1 );
/* Remove trailing : : */
if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
{
*(psz_string+strlen(psz_string ) -1 ) = '\0';
}
}
else
{
free( psz_string );
return;
}
}
/* Vout is not kept, so put that in the config */
config_PutPsz( p_intf, "video-filter", psz_string );
/* Try to set on the fly */
p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
var_SetString( p_vout, "video-filter", psz_string );
vlc_object_release( p_vout );
}
free( psz_string );
}
void ExtVideo::updateFilters()
{
QCheckBox* filter = qobject_cast<QCheckBox*>(sender());
QString module = filter->objectName().replace("Check", "");
ChangeVFiltersString( p_intf, qtu(module), filter->isChecked() );
}
void ExtVideo::gotoConf( QObject* src )
{
#define SHOWCONF(module) \
if( src->objectName().contains(module) ) \
{ \
PrefsDialog::getInstance( p_intf )->showModulePrefs( module ); \
return; \
}
SHOWCONF( "clone" );
SHOWCONF( "magnify" );
SHOWCONF( "wave" );
SHOWCONF( "ripple" );
SHOWCONF( "invert" );
SHOWCONF( "puzzle" );
SHOWCONF( "wall" );
SHOWCONF( "gradient" );
SHOWCONF( "colorthres" )
}
/**********************************************************************
* Equalizer
**********************************************************************/
......
......@@ -27,9 +27,27 @@
#include <vlc/vlc.h>
#include <vlc_aout.h>
#include "ui/equalizer.h"
#include "ui/video_effects.h"
#define BANDS 10
class QSignalMapper;
class ExtVideo: public QWidget
{
Q_OBJECT
public:
ExtVideo( intf_thread_t *, QWidget * );
virtual ~ExtVideo();
void gotoConf( QObject* );
private:
Ui::ExtVideoWidget ui;
QSignalMapper* filterMapper;
intf_thread_t *p_intf;
private slots:
void updateFilters( );
};
class Equalizer: public QWidget
{
Q_OBJECT
......
......@@ -62,9 +62,9 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
QTreeWidget( _parent ), p_intf( _p_intf )
{
setColumnCount( 1 );
setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
setAlternatingRowColors( true );
header()->hide();
setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
#define BI( a,b) QIcon a##_icon = QIcon( QPixmap( b##_xpm ))
BI( audio, audio );
......@@ -128,6 +128,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
current_item = new QTreeWidgetItem();
current_item->setText( 0, data->name );
current_item->setIcon( 0 , icon );
current_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
current_item->setData( 0, Qt::UserRole,
qVariantFromValue( data ) );
addTopLevelItem( current_item );
......@@ -209,7 +210,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
break;
}
if( !i_options ) continue; // Nothing to display
// Locate the category item;
......@@ -248,6 +248,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
PrefsItemData *module_data = new PrefsItemData();
module_data->b_submodule = p_module->b_submodule;
module_data->i_type = TYPE_MODULE;
module_data->psz_name = strdup( p_module->psz_object_name );
module_data->i_object_id = p_module->b_submodule ?
((module_t *)p_module->p_parent)->i_object_id :
p_module->i_object_id;
......
......@@ -44,13 +44,14 @@ class PrefsItemData : public QObject
{
public:
PrefsItemData()
{ panel = NULL; i_object_id = 0; i_subcat_id = -1; };
virtual ~PrefsItemData() {};
{ panel = NULL; i_object_id = 0; i_subcat_id = -1; psz_name = NULL; };
virtual ~PrefsItemData() { free( psz_name ); };
PrefsPanel *panel;
int i_object_id;
int i_subcat_id;
int i_type;
bool b_submodule;
char *psz_name;
QString name;
QString help;
};
......
......@@ -39,9 +39,12 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
l->addWidget( tab );
setWindowTitle( qtr( "Extended controls" ) );
Equalizer *foo = new Equalizer( p_intf, this );
tab->addTab( foo, qtr( "Eqqualizer" ) );
tab->addTab( foo, qtr( "Equalizer" ) );
ExtVideo *bar = new ExtVideo( p_intf, this );
tab->addTab( bar, qtr( "Video effects" ) );
}
ExtendedDialog::~ExtendedDialog()
......
......@@ -75,7 +75,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
setSmall();
QPushButton *save, *cancel;
QHBoxLayout *buttonsLayout = QVLCFrame::doButtons( this, NULL,
QHBoxLayout *buttonsLayout = QVLCFrame::doButtons( this, NULL,
&save, _("Save"),
&cancel, _("Cancel"),
NULL, NULL );
......@@ -179,6 +179,37 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
advanced_panel->show();
}
void PrefsDialog::showModulePrefs( char *psz_module )
{
setAll();
all->setChecked( true );
for( int i_cat_index = 0 ; i_cat_index < advanced_tree->topLevelItemCount();
i_cat_index++ )
{
QTreeWidgetItem *cat_item = advanced_tree->topLevelItem( i_cat_index );
PrefsItemData *data = cat_item->data( 0, Qt::UserRole ).
value<PrefsItemData *>();
for( int i_sc_index = 0; i_sc_index < cat_item->childCount();
i_sc_index++ )
{
QTreeWidgetItem *subcat_item = cat_item->child( i_sc_index );
PrefsItemData *sc_data = subcat_item->data(0, Qt::UserRole).
value<PrefsItemData *>();
for( int i_module = 0; i_module < subcat_item->childCount();
i_module++ )
{
QTreeWidgetItem *module_item = subcat_item->child( i_module );
PrefsItemData *mod_data = module_item->data(0, Qt::UserRole).
value<PrefsItemData *>();
if( !strcmp( mod_data->psz_name, psz_module ) ) {
advanced_tree->setCurrentItem( module_item );
}
}
}
}
show();
}
void PrefsDialog::save()
{
if( small->isChecked() && simple_tree )
......
......@@ -53,6 +53,8 @@ public:
return instance;
}
virtual ~PrefsDialog() {};
void showModulePrefs( char* );
private:
PrefsDialog( intf_thread_t * );
......
......@@ -74,6 +74,8 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_playlist = pl_Yield( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
p_intf->b_play = VLC_TRUE;
return VLC_SUCCESS;
}
......@@ -136,6 +138,12 @@ static void Init( intf_thread_t *p_intf )
if( p_intf->pf_show_dialog )
vlc_thread_ready( p_intf );
/* Start playing if needed */
if( !p_intf->pf_show_dialog && p_intf->b_play )
{
playlist_Control( THEPL, PLAYLIST_AUTOPLAY, VLC_FALSE );
}
app->setQuitOnLastWindowClosed( false );
app->exec();
MainInputManager::killInstance();
......
......@@ -7,6 +7,7 @@
<file>pixmaps/next.png</file>
<file>pixmaps/volume-low.png</file>
<file>pixmaps/volume-high.png</file>
<file>pixmaps/go-next.png</file>
<file alias="vlc128.png">../../../share/vlc128x128.png</file>
<file alias="noart.png">pixmaps/noart.png</file>
<file>pixmaps/playlist_icon.png</file>
......
<ui version="4.0" >
<class>ExtVideoWidget</class>
<widget class="QWidget" name="ExtVideoWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>184</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="adjustEnable" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="title" >
<string>Image adjust</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Hue</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Brightness</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Saturation</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSlider" name="hueSlider" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Contrast</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Gamma</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QSlider" name="constrastSlider" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSlider" name="brightnessSlider" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSlider" name="saturationSlider" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QSlider" name="gammaSlider" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Video effects</string>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="waveCheck" >
<property name="text" >
<string>Waves</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="waveLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="magnifyCheck" >
<property name="text" >
<string>Magnification</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="magnifyLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="puzzleCheck" >
<property name="text" >
<string>Puzzle game</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="puzzleLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="wallCheck" >
<property name="text" >
<string>Image wall</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="wallLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="cloneCheck" >
<property name="text" >
<string>Image clone</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cloneLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="gradientCheck" >
<property name="text" >
<string>Gradient</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gradientLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="rippleCheck" >
<property name="text" >
<string>Water effect</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rippleLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="colorthresCheck" >
<property name="text" >
<string>Color detect</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="colorthresLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" >
<layout class="QHBoxLayout" >