📄 extended_panels.cpp
字号:
/***************************************************************************** * extended_panels.cpp : Extended controls panels **************************************************************************** * Copyright (C) 2006-2007 the VideoLAN team * $Id$ * * Authors: Clément Stenac <zorglub@videolan.org> * Antoine Cellerier <dionoea .t videolan d@t 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. *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <QLabel>#include <QVariant>#include <QString>#include <QFont>#include <QGridLayout>#include <QSignalMapper>#include <QComboBox>#include "components/extended_panels.hpp"#include "dialogs/preferences.hpp"#include "dialogs_provider.hpp"#include "qt4.hpp"#include "input_manager.hpp"#include <vlc_aout.h>#include <vlc_intf_strings.h>#include <vlc_vout.h>#include <vlc_osd.h>#if 0class 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;};#endifQString ModuleFromWidgetName( QObject *obj ){ return obj->objectName().replace( "Enable","" );}QString OptionFromWidgetName( QObject *obj ){ /* Gruik ? ... nah */ QString option = obj->objectName().replace( "Slider", "" ) .replace( "Combo" , "" ) .replace( "Dial" , "" ) .replace( "Check" , "" ) .replace( "Spin" , "" ) .replace( "Text" , "" ); for( char a = 'A'; a <= 'Z'; a++ ) { option = option.replace( QString( a ), QString( '-' ) + QString( a + 'a' - 'A' ) ); } return option;}ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : p_intf( _p_intf ){ ui.setupUi( _parent ); p_vout = NULL;#define SETUP_VFILTER( widget ) \ { \ vlc_object_t *p_obj = ( vlc_object_t * ) \ vlc_object_find_name( p_intf->p_libvlc, \ #widget, \ FIND_CHILD ); \ QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \ QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \ if( p_obj ) \ { \ vlc_object_release( p_obj ); \ if( checkbox ) checkbox->setChecked( true ); \ else groupbox->setChecked( true ); \ } \ else \ { \ if( checkbox ) checkbox->setChecked( false ); \ else groupbox->setChecked( false ); \ } \ } \ CONNECT( ui.widget##Enable, clicked(), this, updateFilters() );#define SETUP_VFILTER_OPTION( widget, signal ) \ initComboBoxItems( ui.widget ); \ setWidgetValue( ui.widget ); \ CONNECT( ui.widget, signal, this, updateFilterOptions() ); SETUP_VFILTER( adjust ) SETUP_VFILTER_OPTION( hueSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( contrastSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( brightnessSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( saturationSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( gammaSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( brightnessThresholdCheck, stateChanged( int ) ) SETUP_VFILTER( extract ) SETUP_VFILTER_OPTION( extractComponentText, textChanged( QString ) ) SETUP_VFILTER( colorthres ) SETUP_VFILTER_OPTION( colorthresColorText, textChanged( QString ) ) SETUP_VFILTER_OPTION( colorthresSaturationthresSlider, valueChanged( int ) ) SETUP_VFILTER_OPTION( colorthresSimilaritythresSlider, valueChanged( int ) ) SETUP_VFILTER( invert ) SETUP_VFILTER( gradient ) SETUP_VFILTER_OPTION( gradientModeCombo, currentIndexChanged( QString ) ) SETUP_VFILTER_OPTION( gradientTypeCheck, stateChanged( int ) ) SETUP_VFILTER_OPTION( gradientCartoonCheck, stateChanged( int ) ) SETUP_VFILTER( motionblur ) SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged( int ) ) SETUP_VFILTER( motiondetect ) SETUP_VFILTER( noise ) SETUP_VFILTER( psychedelic ) SETUP_VFILTER( sharpen ) SETUP_VFILTER_OPTION( sharpenSigmaSlider, valueChanged( int ) ) SETUP_VFILTER( ripple ) SETUP_VFILTER( wave ) SETUP_VFILTER( transform ) SETUP_VFILTER_OPTION( transformTypeCombo, currentIndexChanged( QString ) ) SETUP_VFILTER( rotate ) SETUP_VFILTER_OPTION( rotateAngleDial, valueChanged( int ) ) ui.rotateAngleDial->setWrapping( true ); ui.rotateAngleDial->setNotchesVisible( true ); SETUP_VFILTER( puzzle ) SETUP_VFILTER_OPTION( puzzleRowsSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( puzzleColsSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( puzzleBlackSlotCheck, stateChanged( int ) ) SETUP_VFILTER( magnify ) SETUP_VFILTER( clone ) SETUP_VFILTER_OPTION( cloneCountSpin, valueChanged( int ) ) SETUP_VFILTER( wall ) SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) ) SETUP_VFILTER( panoramix ) SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) ) SETUP_VFILTER( erase ) SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() ) SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) ) SETUP_VFILTER( marq ) SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( QString ) ) SETUP_VFILTER_OPTION( marqPositionCombo, currentIndexChanged( QString ) ) SETUP_VFILTER( logo ) SETUP_VFILTER_OPTION( logoFileText, editingFinished() ) SETUP_VFILTER_OPTION( logoYSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( logoXSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( logoTransparencySlider, valueChanged( int ) )#undef SETUP_VFILTER#undef SETUP_VFILTER_OPTION CONNECT( ui.cropTopPx, valueChanged( int ), this, cropChange() ); CONNECT( ui.cropBotPx, valueChanged( int ), this, cropChange() ); CONNECT( ui.cropLeftPx, valueChanged( int ), this, cropChange() ); CONNECT( ui.cropRightPx, valueChanged( int ), this, cropChange() ); CONNECT( ui.topBotCropSync, toggled( bool ), ui.cropBotPx, setDisabled( bool ) ); CONNECT( ui.leftRightCropSync, toggled( bool ), ui.cropRightPx, setDisabled( bool ) );}ExtVideo::~ExtVideo(){}void ExtVideo::cropChange(){ if( THEMIM->getInput() ) { p_vout = ( vout_thread_t * )vlc_object_find( THEMIM->getInput(), VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout ) { var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() ); var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() ); var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() ); var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() ); } vlc_object_release( p_vout ); }}void ExtVideo::clean(){ ui.cropTopPx->setValue( 0 ); ui.cropBotPx->setValue( 0 ); ui.cropLeftPx->setValue( 0 ); ui.cropRightPx->setValue( 0 );}void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add ){ char *psz_parser, *psz_string; const char *psz_filter_type; module_t *p_obj = module_Find( p_intf, psz_name ); if( !p_obj ) { msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name ); return; } if( module_IsCapable( p_obj, "video filter2" ) ) { psz_filter_type = "video-filter"; } else if( module_IsCapable( p_obj, "video filter" ) ) { psz_filter_type = "vout-filter"; } else if( module_IsCapable( p_obj, "sub filter" ) ) { psz_filter_type = "sub-filter"; } else { module_Put( p_obj ); msg_Err( p_intf, "Unknown video filter type." ); return; } module_Put( p_obj ); psz_string = config_GetPsz( p_intf, psz_filter_type ); if( !psz_string ) psz_string = strdup( "" ); psz_parser = strstr( psz_string, psz_name ); if( b_add ) { if( !psz_parser ) { psz_parser = psz_string; if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s", psz_string, psz_name ) == -1 ) { free( psz_parser ); return; } free( psz_parser ); } else { return; } } else { if( psz_parser ) { if( *( psz_parser + strlen( psz_name ) ) == ':' ) { memmove( psz_parser, psz_parser + strlen( psz_name ) + 1, strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 ); } else { *psz_parser = '\0'; } /* Remove trailing : : */ if( strlen( psz_string ) > 0 && *( 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, psz_filter_type, psz_string ); if( !strcmp( psz_filter_type, "video-filter" ) ) ui.videoFilterText->setText( psz_string ); else if( !strcmp( psz_filter_type, "vout-filter" ) ) ui.voutFilterText->setText( psz_string ); else if( !strcmp( psz_filter_type, "sub-filter" ) ) ui.subpictureFilterText->setText( psz_string ); /* Try to set on the fly */ if( THEMIM->getInput() ) p_vout = ( vout_thread_t * )vlc_object_find( THEMIM->getInput(), VLC_OBJECT_VOUT, FIND_CHILD ); /* If you have stopped the video, p_vout is still at its old value */ else p_vout = NULL; if( p_vout ) { if( !strcmp( psz_filter_type, "sub-filter" ) ) var_SetString( p_vout->p_spu, psz_filter_type, psz_string ); else var_SetString( p_vout, psz_filter_type, psz_string ); vlc_object_release( p_vout ); } free( psz_string );}void ExtVideo::updateFilters(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -