1
1
/*****************************************************************************
2
2
* simple_preferences.cpp : "Simple preferences"
3
3
****************************************************************************
4
* Copyright (C) 2006-2008 the VideoLAN team
5
* $Id: 1abba1987896262ce37bc8a88c877c7818936296 $
4
* Copyright (C) 2006-2010 the VideoLAN team
5
* $Id: 9780ff80ede829c3db42baf7006815a3ab1caabe $
7
7
* Authors: Clément Stenac <zorglub@videolan.org>
8
8
* Antoine Cellerier <dionoea@videolan.org>
68
72
#define ADD_CATEGORY( button, label, icon, numb ) \
69
73
QToolButton * button = new QToolButton( this ); \
70
button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
74
button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
71
75
button->setText( label ); \
76
button->setToolTip( label + qtr("Preferences") ); \
72
77
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
73
78
button->setIconSize( QSize( icon_height, icon_height ) ); \
74
79
button->resize( icon_height + 6 , icon_height + 6 ); \
137
142
control = new BoolConfigControl( VLC_OBJECT(p_intf), \
138
p_config, NULL, ui.qcontrol, false ); \
143
p_config, NULL, ui.qcontrol ); \
139
144
controls.append( control ); \
141
146
else { ui.qcontrol->setEnabled( false ); }
216
220
CONFIG_BOOL( "overlay", overlay );
217
221
CONFIG_BOOL( "video-on-top", alwaysOnTop );
218
222
CONFIG_BOOL( "video-deco", windowDecorations );
219
CONFIG_BOOL( "skip-frames", skipFrames );
220
223
CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
222
CONFIG_BOOL( "video-wallpaper", wallpaperMode );
224
226
CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
225
227
dXdisplayDevice );
226
228
CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
229
CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
228
231
ui.directXBox->setVisible( false );
229
232
ui.hwYUVBox->setVisible( false );
236
CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
237
CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
240
ui.kvaBox->setVisible( false );
232
243
CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
233
244
CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
234
245
CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
266
277
QComboBox * name ## Device = new QComboBox( name ## Control ); \
267
278
name ## Layout->addWidget( name ## Device ); \
268
279
name ## Label->setBuddy( name ## Device ); \
280
name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
269
281
outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
271
283
#define audioControl2( name) \
284
296
optionWidgets.append( DirectXControl );
285
297
CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
286
298
DirectXLabel, DirectXDevice );
299
#elif defined( __OS2__ )
301
optionWidgets.append( kaiControl );
302
CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
288
305
if( module_exists( "alsa" ) )
290
307
audioControl( alsa );
291
308
optionWidgets.append( alsaControl );
293
309
CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
419
436
if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
420
437
!strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
422
ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
439
ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
424
441
free( psz_cddadiscpath );
425
442
free( psz_dvddiscpath );
426
443
free( psz_vcddiscpath );
428
CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
429
ui.DVDDevice, ui.DVDBrowse );
446
QStringList DVDDeviceComboBoxStringList = QStringList();
447
DVDDeviceComboBoxStringList
448
<< "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
449
ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
450
.entryList( DVDDeviceComboBoxStringList, QDir::System )
451
.replaceInStrings( QRegExp("^"), "/dev/" )
454
CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
455
DVDDeviceComboBox->lineEdit() );
430
456
CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
431
457
ui.recordPath, ui.recordBrowse );
433
CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
435
459
CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
436
460
CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
458
482
ui.systemCodecBox->hide();
460
optionWidgets.append( ui.DVDDevice );
484
optionWidgets.append( ui.DVDDeviceComboBox );
461
485
optionWidgets.append( ui.cachingCombo );
462
486
CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
487
CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
488
CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
489
CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
490
CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
491
CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
465
494
/* Add the things to the ComboBox */
473
502
addToCachingBox( N_("Higher latency"), CachingHigher );
474
503
#undef addToCachingBox
476
#define TestCaC( name ) \
505
#define TestCaC( name, factor ) \
477
506
b_cache_equal = b_cache_equal && \
478
( i_cache == config_GetInt( p_intf, name ) )
480
#define TestCaCi( name, int ) \
481
b_cache_equal = b_cache_equal && \
482
( ( i_cache * int ) == config_GetInt( p_intf, name ) )
507
( i_cache * factor == config_GetInt( p_intf, name ) );
483
508
/* Select the accurate value of the ComboBox */
484
509
bool b_cache_equal = true;
485
int i_cache = config_GetInt( p_intf, "file-caching");
510
int i_cache = config_GetInt( p_intf, "file-caching" );
487
TestCaC( "udp-caching" );
488
if (module_exists ("dvdread"))
489
TestCaC( "dvdread-caching" );
490
if (module_exists ("dvdnav"))
491
TestCaC( "dvdnav-caching" );
492
TestCaC( "tcp-caching" );
493
TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
494
TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
496
TestCaC( "dshow-caching" );
498
if (module_exists ("v4l"))
499
TestCaC( "v4l-caching" );
500
if (module_exists ("access_jack"))
501
TestCaC( "jack-input-caching" );
502
if (module_exists ("v4l2"))
503
TestCaC( "v4l2-caching" );
504
if (module_exists ("pvr"))
505
TestCaC( "pvr-caching" );
507
if (module_exists ("livedotcom"))
508
TestCaCi( "rtsp-caching", 4 );
509
TestCaCi( "ftp-caching", 2 );
510
TestCaCi( "http-caching", 2 );
511
if (module_exists ("access_realrtsp"))
512
TestCaCi( "realrtsp-caching", 10 );
513
TestCaCi( "mms-caching", 10 );
512
TestCaC( "network-caching", 10/3 );
513
TestCaC( "disc-caching", 1);
514
TestCaC( "live-caching", 1 );
514
515
if( b_cache_equal == 1 )
515
516
ui.cachingCombo->setCurrentIndex(
516
517
ui.cachingCombo->findData( QVariant( i_cache ) ) );
551
558
optionWidgets.append( ui.skins );
552
559
optionWidgets.append( ui.qt4 );
553
#if !defined(NDEBUG) || !defined( WIN32)
554
561
ui.stylesCombo->addItem( qtr("System's default") );
555
562
ui.stylesCombo->addItems( QStyleFactory::keys() );
556
563
ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
557
564
getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
558
565
ui.stylesCombo->insertSeparator( 1 );
566
if ( ui.stylesCombo->currentIndex() < 0 )
567
ui.stylesCombo->setCurrentIndex( 0 ); /* default */
560
569
CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
561
570
optionWidgets.append( ui.stylesCombo );
563
572
ui.stylesCombo->hide();
573
ui.stylesLabel->hide();
564
574
optionWidgets.append( NULL );
567
ui.skins_zone->setEnabled( ui.skins->isChecked() );
568
CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
570
ui.native_zone->setEnabled( ui.qt4->isChecked() );
571
CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
576
radioGroup = new QButtonGroup(this);
577
radioGroup->addButton( ui.qt4, 0 );
578
radioGroup->addButton( ui.skins, 1 );
579
CONNECT( radioGroup, buttonClicked( int ),
580
ui.styleStackedWidget, setCurrentIndex( int ) );
581
ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
573
583
CONNECT( ui.minimalviewBox, toggled( bool ),
574
584
ui.mainPreview, setNormalPreview( bool ) );
577
587
ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
579
589
CONFIG_BOOL( "embedded-video", embedVideo );
590
CONFIG_BOOL( "qt-video-autoresize", resizingBox );
591
CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
592
ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
580
594
CONFIG_BOOL( "qt-fs-controller", fsController );
581
595
CONFIG_BOOL( "qt-system-tray", systrayBox );
582
596
CONFIG_BOOL( "qt-notification", sysPop );
597
CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) );
598
ui.sysPop->setEnabled( ui.systrayBox->isChecked() );
600
CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
601
CONFIG_BOOL( "playlist-tree", treePlaylist );
602
CONFIG_BOOL( "play-and-pause", playPauseBox );
583
603
CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
584
604
ui.fileSkin, ui.skinBrowse );
585
CONFIG_BOOL( "qt-video-autoresize", resizingBox );
587
606
CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
624
642
qtr("Subtitles & On Screen Display Settings") );
625
643
CONFIG_BOOL( "osd", OSDBox);
626
644
CONFIG_BOOL( "video-title-show", OSDTitleBox);
645
CONFIG_GENERIC( "video-title-position", IntegerList,
646
ui.OSDTitlePosLabel, OSDTitlePos );
629
648
CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
631
650
CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
632
651
preferredLanguage );
653
CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
654
ui.fontSizeLabel, fontSize );
633
656
CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
634
CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
657
CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
636
CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
637
ui.fontSizeLabel, fontSize );
638
CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
659
CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
660
ui.fontEffectLabel, effect );
661
CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
640
664
CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
666
ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
667
ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
668
optionWidgets.append( ui.shadowCheck );
669
optionWidgets.append( ui.backgroundCheck );
644
673
case SPrefsHotkeys:
744
775
void SPrefsPanel::apply()
746
777
/* Generic save for ever panel */
747
QList<ConfigControl *>::Iterator i;
748
for( i = controls.begin() ; i != controls.end() ; i++ )
778
QList<ConfigControl *>::const_iterator i;
779
for( i = controls.begin() ; i != controls.end() ; ++i )
750
781
ConfigControl *c = qobject_cast<ConfigControl *>(*i);
751
c->doApply( p_intf );
756
787
case SPrefsInputAndCodecs:
758
789
/* Device default selection */
759
char *psz_devicepath =
760
strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
761
if( !EMPTY_STR( psz_devicepath ) )
790
QByteArray devicepath =
791
qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
792
if( devicepath.size() > 0 )
763
config_PutPsz( p_intf, "dvd", psz_devicepath );
764
config_PutPsz( p_intf, "vcd", psz_devicepath );
765
config_PutPsz( p_intf, "cd-audio", psz_devicepath );
766
free( psz_devicepath );
794
config_PutPsz( p_intf, "dvd", devicepath );
795
config_PutPsz( p_intf, "vcd", devicepath );
796
config_PutPsz( p_intf, "cd-audio", devicepath );
769
#define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
770
#define CaC( name ) CaCi( name, 1 )
799
#define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
772
801
QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
773
802
int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
774
803
if( i_comboValue )
776
CaC( "udp-caching" );
777
if (module_exists ("dvdread" ))
778
CaC( "dvdread-caching" );
779
if (module_exists ("dvdnav" ))
780
CaC( "dvdnav-caching" );
781
CaC( "tcp-caching" ); CaC( "vcd-caching" );
782
CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
783
CaC( "screen-caching" ); CaC( "bd-caching" );
784
CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
785
CaCi( "http-caching", 2 );
786
if (module_exists ("access_realrtsp" ))
787
CaCi( "realrtsp-caching", 10 );
788
CaCi( "mms-caching", 10 );
790
CaC( "dshow-caching" );
792
if (module_exists ( "v4l" ))
793
CaC( "v4l-caching" );
794
if (module_exists ( "access_jack" ))
795
CaC( "jack-input-caching" );
796
if (module_exists ( "v4l2" ))
797
CaC( "v4l2-caching" );
798
if (module_exists ( "pvr" ))
799
CaC( "pvr-caching" );
801
//CaCi( "dv-caching" ) too short...
805
CaC( "file-caching", 1 );
806
CaC( "network-caching", 10/3 );
807
CaC( "disc-caching", 1 );
808
CaC( "live-caching", 1 );
826
832
qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
827
if( b_checked && !qs_filter.contains( "volnorm" ) )
828
qs_filter.append( "volnorm" );
829
if( !b_checked && qs_filter.contains( "volnorm" ) )
830
qs_filter.removeAll( "volnorm" );
833
if( b_checked && !qs_filter.contains( "normvol" ) )
834
qs_filter.append( "normvol" );
835
if( !b_checked && qs_filter.contains( "normvol" ) )
836
qs_filter.removeAll( "normvol" );
833
839
qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
840
846
config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
849
case SPrefsSubtitles:
851
bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
852
if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
853
config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
855
else if (!b_checked ) {
856
config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
859
b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
860
if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
861
config_PutInt( p_intf, "freetype-background-opacity", 128 );
863
else if (!b_checked ) {
864
config_PutInt( p_intf, "freetype-background-opacity", 0 );
863
888
QWidgetList::iterator it = widgets.begin();
864
889
while( it != widgets.end() ) {
895
void SPrefsPanel::configML()
898
MLConfDialog *mld = new MLConfDialog( this, p_intf );
871
905
#include <QDialogButtonBox>
872
#include <QHeaderView>
873
906
#include "util/registry.hpp"
876
908
bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
877
909
QTreeWidgetItem* parent, QVLCRegistry *qvReg )
880
912
const char* psz_VLC = "VLC";
881
913
current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
883
if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
915
if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
885
917
current->setCheckState( 0, Qt::Checked );
902
934
if( S_OK == CoCreateInstance( &clsid_IApplication2,
903
935
NULL, CLSCTX_INPROC_SERVER,
904
&IID_IApplicationAssociationRegistrationUI,
936
IID_IApplicationAssociationRegistrationUI,
905
937
(void **)&p_appassoc) )
907
939
if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
934
967
videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
935
968
otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
937
QTreeWidgetItem *currentItem;
970
QTreeWidgetItem *currentItem = NULL;
940
973
#define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
955
988
aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
956
989
aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
957
990
aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
958
aTv( ".mts" ); aTv( ".mxf" );
991
aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
959
992
aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
960
993
aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
961
994
videoType->setCheckState( 0, ( i_temp > 0 ) ?
995
1028
void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
997
std::string s_path( "VLC" ); s_path += psz_ext;
998
std::string s_path2 = s_path;
1030
QString s_path( "VLC" ); s_path += psz_ext;
1031
QString s_path2 = s_path;
1000
1033
/* Save a backup if already assigned */
1001
1034
char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1003
if( psz_value && strlen( psz_value ) > 0 )
1036
if( !EMPTY_STR(psz_value) )
1004
1037
qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1005
1038
delete psz_value;
1007
1040
/* Put a "link" to VLC.EXT as default */
1008
qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1041
qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1010
1043
/* Create the needed Key if they weren't done in the installer */
1011
if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1044
if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1013
qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1014
qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1015
qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1046
qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1047
qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1048
qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1017
1050
/* Get the installer path */
1018
1051
QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1019
std::string str_temp; str_temp.assign(
1020
qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1052
QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1022
1054
if( str_temp.size() )
1024
qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1025
"", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1056
qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1057
"", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1027
qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1028
"", str_temp.append(",0").c_str() );
1059
qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1060
"", qtu( str_temp.append(",0") ) );
1034
1066
void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1036
1068
char psz_VLC[] = "VLC";
1037
char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1069
char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1039
1071
if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )