1 /*****************************************************************************
2 * simple_preferences.cpp : "Simple preferences"
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
9 * Jean-Baptiste Kempf <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include "components/simple_preferences.hpp"
31 #include "components/preferences_widgets.hpp"
33 #include <vlc_config_cat.h>
34 #include <vlc_configuration.h>
38 #include <QToolButton>
39 #include <QButtonGroup>
41 #include <QVBoxLayout>
45 #define ICON_HEIGHT 64
46 #define BUTTON_HEIGHT 74
48 /*********************************************************************
49 * The List of categories
50 *********************************************************************/
51 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
52 QWidget( _parent ), p_intf( _p_intf )
54 QVBoxLayout *layout = new QVBoxLayout();
56 QButtonGroup *buttonGroup = new QButtonGroup( this );
57 buttonGroup->setExclusive ( true );
58 CONNECT( buttonGroup, buttonClicked ( int ),
59 this, switchPanel( int ) );
61 #define ADD_CATEGORY( button, label, icon, numb ) \
62 QToolButton * button = new QToolButton( this ); \
63 button->setIcon( QIcon( ":/pixmaps/prefs/" #icon ) ); \
64 button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \
65 button->setText( label ); \
66 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
67 button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \
68 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
69 button->setAutoRaise( true ); \
70 button->setCheckable( true ); \
71 buttonGroup->addButton( button, numb ); \
72 layout->addWidget( button );
74 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
75 spref_cone_Interface_64.png, 0 );
76 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
77 ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
78 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
79 spref_cone_Subtitles_64.png, 3 );
80 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
81 spref_cone_Input_64.png, 4 );
82 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
84 SPrefsInterface->setChecked( true );
85 layout->setMargin( 0 );
86 layout->setSpacing( 1 );
88 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
93 void SPrefsCatList::switchPanel( int i )
95 emit currentItemChanged( i );
98 /*********************************************************************
100 *********************************************************************/
101 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
102 int _number ) : QWidget( _parent ), p_intf( _p_intf )
104 module_config_t *p_config;
105 ConfigControl *control;
108 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
109 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
112 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
113 p_config, label, ui.qcontrol, false ); \
114 controls.append( control ); \
117 #define CONFIG_GENERIC2( option, type, label, qcontrol ) \
118 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
121 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
122 p_config, label, qcontrol, false ); \
123 controls.append( control ); \
127 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
128 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
131 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
132 p_config, label, ui.qcontrol ); \
133 controls.append( control ); \
136 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
137 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
140 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
141 p_config, label, qcontrol, qbutton, \
143 controls.append( control ); \
146 #define START_SPREFS_CAT( name , label ) \
147 case SPrefs ## name: \
149 Ui::SPrefs ## name ui; \
150 ui.setupUi( panel ); \
151 panel_label->setText( label );
153 #define END_SPREFS_CAT \
157 QVBoxLayout *panel_layout = new QVBoxLayout();
158 QWidget *panel = new QWidget();
159 panel_layout->setMargin( 3 );
162 QLabel *panel_label = new QLabel;
163 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
164 labelFont.setPointSize( labelFont.pointSize() + 6 );
165 labelFont.setFamily( "Verdana" );
166 panel_label->setFont( labelFont );
169 QFrame *title_line = new QFrame;
170 title_line->setFrameShape(QFrame::HLine);
171 title_line->setFrameShadow(QFrame::Sunken);
173 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
174 italicFont.setItalic( true );
178 /******************************
179 * VIDEO Panel Implementation *
180 ******************************/
181 START_SPREFS_CAT( Video , qtr("General Video Settings") );
182 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
184 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
185 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
186 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
187 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
188 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
189 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
192 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
193 CONFIG_GENERIC( "directx-device", StringList, NULL,
196 ui.directXBox->setVisible( false );
199 CONFIG_GENERIC_FILE( "snapshot-path", Directory, NULL,
200 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
201 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
202 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
203 snapshotsSequentialNumbering );
204 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
208 /******************************
209 * AUDIO Panel Implementation *
210 ******************************/
211 START_SPREFS_CAT( Audio, qtr("General Audio Settings") );
213 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
215 #define audioCommon( name ) \
216 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
217 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
218 name ## Layout->setMargin( 0 ); \
219 name ## Layout->setSpacing( 0 ); \
220 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
221 name ## Label->setMinimumSize(QSize(100, 0)); \
222 name ## Layout->addWidget( name ## Label ); \
224 #define audioControl( name) \
225 audioCommon( name ) \
226 QComboBox * name ## Device = new QComboBox( name ## Control ); \
227 name ## Layout->addWidget( name ## Device ); \
228 name ## Label->setBuddy( name ## Device ); \
229 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
231 #define audioControl2( name) \
232 audioCommon( name ) \
233 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
234 name ## Layout->addWidget( name ## Device ); \
235 name ## Label->setBuddy( name ## Device ); \
236 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
237 name ## Layout->addWidget( name ## Browse ); \
238 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
240 /* hide if necessary */
241 ui.lastfm_user_edit->hide();
242 ui.lastfm_user_label->hide();
243 ui.lastfm_pass_edit->hide();
244 ui.lastfm_pass_label->hide();
246 /* Build if necessary */
247 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
249 audioControl( DirectX );
250 optionWidgets.append( DirectXControl );
251 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
252 DirectXLabel, DirectXDevice );
254 if( module_Exists( p_intf, "alsa" ) )
256 audioControl( alsa );
257 optionWidgets.append( alsaControl );
259 CONFIG_GENERIC2( "alsadev" , StringList , alsaLabel,
263 optionWidgets.append( NULL );
264 if( module_Exists( p_intf, "oss" ) )
266 audioControl2( OSS );
267 optionWidgets.append( OSSControl );
268 CONFIG_GENERIC_FILE( "dspdev" , File , OSSLabel, OSSDevice,
272 optionWidgets.append( NULL );
275 /* General Audio Options */
276 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
278 CONNECT( ui.defaultVolume, valueChanged( int ),
279 this, updateAudioVolume( int ) );
281 CONFIG_GENERIC( "audio-language" , String , NULL,
282 preferredAudioLanguage );
284 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
285 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, saveVolBox );
286 CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
289 CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
291 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
293 CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
295 /* Audio Output Specifics */
296 CONFIG_GENERIC( "aout", Module, NULL, outputModule );
298 CONNECT( ui.outputModule, currentIndexChanged( int ),
299 this, updateAudioOptions( int ) );
301 /* File output exists on all platforms */
302 CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
303 ui.fileName, ui.fileBrowseButton );
305 optionWidgets.append( ui.fileControl );
306 optionWidgets.append( ui.outputModule );
307 optionWidgets.append( ui.volNormBox );
308 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
310 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
312 optionWidgets.append( ui.volumeValue );
313 updateAudioOptions( ui.outputModule->currentIndex() );
316 if( module_Exists( p_intf, "audioscrobbler" ) )
318 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
320 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
323 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
324 ui.lastfm->setChecked( true );
326 ui.lastfm->setChecked( false );
327 CONNECT( ui.lastfm, stateChanged( int ), this ,
328 lastfm_Changed( int ) );
335 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
336 setEnabled( bool ) );
337 char* psz = config_GetPsz( p_intf, "audio-filter" );
338 qs_filter = qfu( psz );
340 bool b_normalizer = ( qs_filter.contains( "volnorm" ) );
342 ui.volNormBox->setChecked( b_normalizer );
343 ui.volNormSpin->setEnabled( b_normalizer );
347 updateAudioVolume( ui.defaultVolume->value() ); // First time init
351 /* Input and Codecs Panel Implementation */
352 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
356 ui.DVDDevice->setToolTip(
357 qtr( "If this property is blank, different values\n"
358 "for DVD, VCD, and CDDA are set.\n"
359 "You can define a unique one or configure them \n"
360 "individually in the advanced preferences." ) );
361 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
362 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
363 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
364 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
365 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
366 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
368 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
370 free( psz_cddadiscpath );
371 free( psz_dvddiscpath );
372 free( psz_vcddiscpath );
375 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
376 CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
377 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
378 CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
379 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
381 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
383 ui.systemCodecBox->hide();
386 char* psz = config_GetPsz( p_intf, "access-filter" );
387 qs_filter = qfu( psz );
389 ui.timeshiftBox->setChecked( qs_filter.contains( "timeshift" ) );
390 ui.dumpBox->setChecked( qs_filter.contains( "dump" ) );
391 ui.recordBox->setChecked( qs_filter.contains( "record" ) );
392 ui.bandwidthBox->setChecked( qs_filter.contains( "bandwidth" ) );
394 optionWidgets.append( ui.recordBox );
395 optionWidgets.append( ui.dumpBox );
396 optionWidgets.append( ui.bandwidthBox );
397 optionWidgets.append( ui.timeshiftBox );
398 optionWidgets.append( ui.DVDDevice );
399 optionWidgets.append( ui.cachingCombo );
402 /* Add the things to the ComboBox */
403 #define addToCachingBox( str, cachingNumber ) \
404 ui.cachingCombo->addItem( str, QVariant( cachingNumber ) );
405 addToCachingBox( "Custom", CachingCustom );
406 addToCachingBox( "Lowest latency", CachingLowest );
407 addToCachingBox( "Low latency", CachingLow );
408 addToCachingBox( "Normal", CachingNormal );
409 addToCachingBox( "High latency", CachingHigh );
410 addToCachingBox( "Higher latency", CachingHigher );
412 #define TestCaC( name ) \
413 b_cache_equal = b_cache_equal && \
414 ( i_cache == config_GetInt( p_intf, name ) )
416 #define TestCaCi( name, int ) \
417 b_cache_equal = b_cache_equal && \
418 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
419 /* Select the accurate value of the ComboBox */
420 bool b_cache_equal = true;
421 int i_cache = config_GetInt( p_intf, "file-caching");
423 TestCaC( "udp-caching" );
424 if (module_Exists (p_intf, "dvdread"))
425 TestCaC( "dvdread-caching" );
426 if (module_Exists (p_intf, "dvdnav"))
427 TestCaC( "dvdnav-caching" );
428 TestCaC( "tcp-caching" );
429 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
430 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
432 TestCaC( "dshow-caching" );
434 if (module_Exists (p_intf, "v4l"))
435 TestCaC( "v4l-caching" );
436 if (module_Exists (p_intf, "access_jack"))
437 TestCaC( "jack-input-caching" );
438 if (module_Exists (p_intf, "v4l2"))
439 TestCaC( "v4l2-caching" );
440 if (module_Exists (p_intf, "pvr"))
441 TestCaC( "pvr-caching" );
443 TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
444 TestCaCi( "http-caching", 4 );
445 if (module_Exists (p_intf, "access_realrtsp"))
446 TestCaCi( "realrtsp-caching", 10 );
447 TestCaCi( "mms-caching", 19 );
448 if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
449 ui.cachingCombo->findData( QVariant( i_cache ) ) );
455 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
456 ui.defaultLabel->setFont( italicFont );
457 ui.skinsLabel->setFont( italicFont );
460 CONFIG_GENERIC( "language", StringList, NULL, language );
461 BUTTONACT( ui.assoButton, assoDialog() );
464 ui.languageLabel->hide();
466 ui.assoButton->hide();
470 char *psz_intf = config_GetPsz( p_intf, "intf" );
473 if( strstr( psz_intf, "skin" ) )
474 ui.skins->setChecked( true );
475 else if( strstr( psz_intf, "qt" ) )
476 ui.qt4->setChecked( true );
480 optionWidgets.append( ui.skins );
481 optionWidgets.append( ui.qt4 );
483 CONFIG_GENERIC( "qt-display-mode", IntegerList, NULL,
485 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
486 CONFIG_GENERIC( "qt-fs-controller", Bool, NULL, fsController );
487 CONFIG_GENERIC_FILE( "skins2-last", File, NULL, ui.fileSkin,
490 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
495 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
496 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
498 CONNECT( ui.updatesBox, toggled( bool ),
499 ui.updatesDays, setEnabled( bool ) );
501 ui.updatesBox->hide();
502 ui.updatesDays->hide();
504 /* ONE INSTANCE options */
505 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
506 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
507 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
508 EnqueueOneInterfaceMode );
510 ui.OneInterfaceBox->hide();
514 START_SPREFS_CAT( Subtitles, qtr("Subtitles & On Screen Display Settings") );
515 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
517 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
518 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
519 CONFIG_GENERIC_FILE( "freetype-font", File, NULL, ui.font,
521 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
522 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
524 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
530 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
532 QGridLayout *gLayout = new QGridLayout;
533 panel->setLayout( gLayout );
536 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
537 this, gLayout, line );
539 panel_label->setText( qtr( "Configure Hotkeys" ) );
540 controls.append( control );
546 panel_layout->addWidget( panel_label );
547 panel_layout->addWidget( title_line );
548 panel_layout->addWidget( panel );
549 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
551 setLayout( panel_layout );
554 void SPrefsPanel::updateAudioOptions( int number)
556 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
557 ->itemData( number ).toString();
559 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
561 /* optionWidgets[ossW] can be NULL */
562 if( optionWidgets[ossW] )
563 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
564 /* optionWidgets[alsaW] can be NULL */
565 if( optionWidgets[alsaW] )
566 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
568 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
572 SPrefsPanel::~SPrefsPanel()
574 QList<ConfigControl *>::Iterator conf_it;
575 for( conf_it = controls.begin() ; conf_it != controls.end() ; conf_it++ )
577 ConfigControl *c = qobject_cast<ConfigControl *>(*conf_it);
583 void SPrefsPanel::updateAudioVolume( int volume )
585 qobject_cast<QSpinBox *>(optionWidgets[volLW])
586 ->setValue( volume * 100 / 256 );
590 /* Function called from the main Preferences dialog on each SPrefs Panel */
591 void SPrefsPanel::apply()
593 /* Generic save for ever panel */
594 QList<ConfigControl *>::Iterator i;
595 for( i = controls.begin() ; i != controls.end() ; i++ )
597 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
598 c->doApply( p_intf );
603 case SPrefsInputAndCodecs:
605 /* Device default selection */
606 char *psz_devicepath =
607 qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
608 if( !EMPTY_STR( psz_devicepath ) )
610 config_PutPsz( p_intf, "dvd", psz_devicepath );
611 config_PutPsz( p_intf, "vcd", psz_devicepath );
612 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
616 #define saveBox( name, box ) {\
617 if( box->isChecked() ) { \
619 qs_filter.append( name ); \
622 else qs_filter.append( ":" ).append( name ); \
627 saveBox( "record", qobject_cast<QCheckBox *>(optionWidgets[recordChB]) );
628 saveBox( "dump", qobject_cast<QCheckBox *>(optionWidgets[dumpChB]) );
629 saveBox( "timeshift", qobject_cast<QCheckBox *>(optionWidgets[timeshiftChB]) );
630 saveBox( "bandwidth", qobject_cast<QCheckBox *>(optionWidgets[bandwidthChB] ) );
631 config_PutPsz( p_intf, "access-filter", qtu( qs_filter ) );
633 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
634 #define CaC( name ) CaCi( name, 1 )
636 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
637 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
640 CaC( "udp-caching" );
641 if (module_Exists (p_intf, "dvdread" ))
642 CaC( "dvdread-caching" );
643 if (module_Exists (p_intf, "dvdnav" ))
644 CaC( "dvdnav-caching" );
645 CaC( "tcp-caching" ); CaC( "vcd-caching" );
646 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
647 CaC( "screen-caching" );
648 CaCi( "rtsp-caching", 4 ); CaCi( "ftp-caching", 2 );
649 CaCi( "http-caching", 4 );
650 if (module_Exists (p_intf, "access_realrtsp" ))
651 CaCi( "realrtsp-caching", 10 );
652 CaCi( "mms-caching", 19 );
654 CaC( "dshow-caching" );
656 if (module_Exists (p_intf, "v4l" ))
657 CaC( "v4l-caching" );
658 if (module_Exists (p_intf, "access_jack" ))
659 CaC( "jack-input-caching" );
660 if (module_Exists (p_intf, "v4l2" ))
661 CaC( "v4l2-caching" );
662 if (module_Exists (p_intf, "pvr" ))
663 CaC( "pvr-caching" );
665 //CaCi( "dv-caching" ) too short...
671 case SPrefsInterface:
673 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
674 config_PutPsz( p_intf, "intf", "skins2" );
675 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
676 config_PutPsz( p_intf, "intf", "qt4" );
683 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
684 if( qs_filter.isEmpty() )
686 /* the psz_filter is already empty, so we just append it needed */
687 if( b_normChecked ) qs_filter = "volnorm";
691 if( qs_filter.contains( "volnorm" ) )
693 /* The qs_filter not empty and contains "volnorm"
694 that we have to remove */
698 qs_filter.remove( "volnorm:" );
699 qs_filter.remove( ":volnorm" );
700 qs_filter.remove( "volnorm" );
703 else /* qs_filter not empty, but doesn't have volnorm inside */
704 if( b_normChecked ) qs_filter.append( ":volnorm" );
706 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter ) );
712 void SPrefsPanel::clean()
715 void SPrefsPanel::lastfm_Changed( int i_state )
717 if( i_state == Qt::Checked )
718 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
719 else if( i_state == Qt::Unchecked )
720 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
724 #include <QDialogButtonBox>
725 #include <QHeaderView>
726 #include "util/registry.hpp"
728 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
729 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
732 const char* psz_VLC = "VLC";
733 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
735 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
737 current->setCheckState( 0, Qt::Checked );
742 current->setCheckState( 0, Qt::Unchecked );
745 listAsso.append( current );
749 void SPrefsPanel::assoDialog()
751 QDialog *d = new QDialog( this );
752 QGridLayout *assoLayout = new QGridLayout( d );
754 QTreeWidget *filetypeList = new QTreeWidget;
755 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
756 filetypeList->header()->hide();
758 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
760 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
761 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
762 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
764 filetypeList->addTopLevelItem( audioType );
765 filetypeList->addTopLevelItem( videoType );
766 filetypeList->addTopLevelItem( otherType );
768 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
769 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
770 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
772 QTreeWidgetItem *currentItem;
775 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
776 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
777 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
779 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
780 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
781 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".ogg" ); aTa( ".spx" ); aTa( ".wav" );
782 aTa( ".wma" ); aTa( ".xm" );
783 audioType->setCheckState( 0, ( i_temp > 0 ) ?
784 ( ( i_temp == audioType->childCount() ) ?
785 Qt::Checked : Qt::PartiallyChecked )
789 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
790 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m4v" ); aTv( ".mkv" );
791 aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
792 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
793 aTv( ".mxf" ); aTv( ".ogm" ); aTv( ".ps" ); aTv( ".ts" );
794 aTv( ".vob" ); aTv( ".wmv" );
795 videoType->setCheckState( 0, ( i_temp > 0 ) ?
796 ( ( i_temp == audioType->childCount() ) ?
797 Qt::Checked : Qt::PartiallyChecked )
801 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
803 otherType->setCheckState( 0, ( i_temp > 0 ) ?
804 ( ( i_temp == audioType->childCount() ) ?
805 Qt::Checked : Qt::PartiallyChecked )
808 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
809 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
810 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
811 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
812 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
814 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
816 CONNECT( closeButton, clicked(), this, saveAsso() );
817 CONNECT( clearButton, clicked(), d, reject() );
818 d->resize( 300, 400 );
825 void addAsso( QVLCRegistry *qvReg, char *psz_ext )
827 std::string s_path( "VLC" ); s_path += psz_ext;
828 std::string s_path2 = s_path;
830 /* Save a backup if already assigned */
831 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
833 if( psz_value && strlen( psz_value ) > 0 )
834 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
837 /* Put a "link" to VLC.EXT as default */
838 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
840 /* Create the needed Key if they weren't done in the installer */
841 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
843 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
844 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
845 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
847 /* Get the installer path */
848 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
849 std::string str_temp; str_temp.assign(
850 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
852 if( str_temp.size() )
854 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
855 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
857 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
858 "", str_temp.append(",0").c_str() );
864 void delAsso( QVLCRegistry *qvReg, char *psz_ext )
866 char psz_VLC[] = "VLC";
867 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
869 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
872 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
874 qvReg->WriteRegistryString( psz_ext, "", psz_value );
876 qvReg->DeleteKey( psz_ext, "VLC.backup" );
880 void SPrefsPanel::saveAsso()
882 QVLCRegistry * qvReg;
883 for( int i = 0; i < listAsso.size(); i ++ )
885 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
886 if( listAsso[i]->checkState( 0 ) > 0 )
888 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
892 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
896 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();