From: Clément Stenac Date: Sat, 16 Dec 2006 14:54:54 +0000 (+0000) Subject: Add video filters panel X-Git-Tag: 0.9.0-test0~8985 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=116f3a23ac8209172ad78363ebd7aeff0c83a231;p=vlc Add video filters panel Fix size of preference tree items --- diff --git a/include/vlc_intf_strings.h b/include/vlc_intf_strings.h index 4f2d9e9fbe..7236864c97 100644 --- a/include/vlc_intf_strings.h +++ b/include/vlc_intf_strings.h @@ -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 diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index ae88d4b9a7..cd0687fbe7 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -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 \ diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp index d525f4c2a8..8a9a803e5e 100644 --- a/modules/gui/qt4/components/extended_panels.cpp +++ b/modules/gui/qt4/components/extended_panels.cpp @@ -26,15 +26,168 @@ #include #include #include +#include #include "components/extended_panels.hpp" +#include "dialogs/prefs_dialog.hpp" +#include "dialogs_provider.hpp" #include "qt4.hpp" #include "../../audio_filter/equalizer_presets.h" #include #include +#include #include +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(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 **********************************************************************/ diff --git a/modules/gui/qt4/components/extended_panels.hpp b/modules/gui/qt4/components/extended_panels.hpp index 819dbb0004..4c19651367 100644 --- a/modules/gui/qt4/components/extended_panels.hpp +++ b/modules/gui/qt4/components/extended_panels.hpp @@ -27,9 +27,27 @@ #include #include #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 diff --git a/modules/gui/qt4/components/preferences.cpp b/modules/gui/qt4/components/preferences.cpp index 4ed1a65d61..234b7900bc 100644 --- a/modules/gui/qt4/components/preferences.cpp +++ b/modules/gui/qt4/components/preferences.cpp @@ -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; diff --git a/modules/gui/qt4/components/preferences.hpp b/modules/gui/qt4/components/preferences.hpp index 3a24f25614..1c53e2e8b9 100644 --- a/modules/gui/qt4/components/preferences.hpp +++ b/modules/gui/qt4/components/preferences.hpp @@ -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; }; diff --git a/modules/gui/qt4/dialogs/extended.cpp b/modules/gui/qt4/dialogs/extended.cpp index 176559508a..d9cf2744b4 100644 --- a/modules/gui/qt4/dialogs/extended.cpp +++ b/modules/gui/qt4/dialogs/extended.cpp @@ -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() diff --git a/modules/gui/qt4/dialogs/prefs_dialog.cpp b/modules/gui/qt4/dialogs/prefs_dialog.cpp index 36f0c91d11..24a481001e 100644 --- a/modules/gui/qt4/dialogs/prefs_dialog.cpp +++ b/modules/gui/qt4/dialogs/prefs_dialog.cpp @@ -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(); + 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(); + 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(); + if( !strcmp( mod_data->psz_name, psz_module ) ) { + advanced_tree->setCurrentItem( module_item ); + } + } + } + } + show(); +} + void PrefsDialog::save() { if( small->isChecked() && simple_tree ) diff --git a/modules/gui/qt4/dialogs/prefs_dialog.hpp b/modules/gui/qt4/dialogs/prefs_dialog.hpp index 06ab224c8b..cc67f0a2a5 100644 --- a/modules/gui/qt4/dialogs/prefs_dialog.hpp +++ b/modules/gui/qt4/dialogs/prefs_dialog.hpp @@ -53,6 +53,8 @@ public: return instance; } virtual ~PrefsDialog() {}; + + void showModulePrefs( char* ); private: PrefsDialog( intf_thread_t * ); diff --git a/modules/gui/qt4/pixmaps/go-next.png b/modules/gui/qt4/pixmaps/go-next.png new file mode 100644 index 0000000000..6ef8de76e0 Binary files /dev/null and b/modules/gui/qt4/pixmaps/go-next.png differ diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp index 0da277fb40..18dc637656 100644 --- a/modules/gui/qt4/qt4.cpp +++ b/modules/gui/qt4/qt4.cpp @@ -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(); diff --git a/modules/gui/qt4/res.qrc b/modules/gui/qt4/res.qrc index 4be0fe36ab..0f39529040 100644 --- a/modules/gui/qt4/res.qrc +++ b/modules/gui/qt4/res.qrc @@ -7,6 +7,7 @@ pixmaps/next.png pixmaps/volume-low.png pixmaps/volume-high.png + pixmaps/go-next.png ../../../share/vlc128x128.png pixmaps/noart.png pixmaps/playlist_icon.png diff --git a/modules/gui/qt4/ui/video_effects.ui b/modules/gui/qt4/ui/video_effects.ui new file mode 100644 index 0000000000..fc05087c20 --- /dev/null +++ b/modules/gui/qt4/ui/video_effects.ui @@ -0,0 +1,381 @@ + + ExtVideoWidget + + + + 0 + 0 + 491 + 184 + + + + Form + + + + 9 + + + 6 + + + + + true + + + Image adjust + + + true + + + false + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Hue + + + + + + + Brightness + + + + + + + Saturation + + + + + + + Qt::Horizontal + + + + + + + Contrast + + + + + + + Gamma + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + + + + + Video effects + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + Waves + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Magnification + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Puzzle game + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Image wall + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Image clone + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Gradient + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Water effect + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Color detect + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + Color invert + + + + + + + + + + + + + + + + 0 + + + 6 + + + + + + + + + + + + +