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>
40 #include <QVBoxLayout>
42 #include <QtAlgorithms>
46 #define ICON_HEIGHT 64
47 #define BUTTON_HEIGHT 74
49 /*********************************************************************
50 * The List of categories
51 *********************************************************************/
52 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
53 QWidget( _parent ), p_intf( _p_intf )
55 QVBoxLayout *layout = new QVBoxLayout();
57 QButtonGroup *buttonGroup = new QButtonGroup( this );
58 buttonGroup->setExclusive ( true );
59 CONNECT( buttonGroup, buttonClicked ( int ),
60 this, switchPanel( int ) );
62 #define ADD_CATEGORY( button, label, icon, numb ) \
63 QToolButton * button = new QToolButton( this ); \
64 button->setIcon( QIcon( ":/pixmaps/prefs/" #icon ) ); \
65 button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \
66 button->setText( label ); \
67 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
68 button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \
69 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
70 button->setAutoRaise( true ); \
71 button->setCheckable( true ); \
72 buttonGroup->addButton( button, numb ); \
73 layout->addWidget( button );
75 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
76 spref_cone_Interface_64.png, 0 );
77 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
78 ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
79 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
80 spref_cone_Subtitles_64.png, 3 );
81 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
82 spref_cone_Input_64.png, 4 );
83 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
85 SPrefsInterface->setChecked( true );
86 layout->setMargin( 0 );
87 layout->setSpacing( 1 );
89 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
94 void SPrefsCatList::switchPanel( int i )
96 emit currentItemChanged( i );
99 /*********************************************************************
101 *********************************************************************/
102 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
103 int _number ) : QWidget( _parent ), p_intf( _p_intf )
105 module_config_t *p_config;
106 ConfigControl *control;
109 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
110 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
113 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
114 p_config, label, ui.qcontrol, false ); \
115 controls.append( control ); \
118 #define CONFIG_GENERIC2( option, type, label, qcontrol ) \
119 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
122 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
123 p_config, label, qcontrol, false ); \
124 controls.append( control ); \
128 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
129 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
132 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
133 p_config, label, ui.qcontrol ); \
134 controls.append( control ); \
137 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
138 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
141 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
142 p_config, label, qcontrol, qbutton, \
144 controls.append( control ); \
147 #define START_SPREFS_CAT( name , label ) \
148 case SPrefs ## name: \
150 Ui::SPrefs ## name ui; \
151 ui.setupUi( panel ); \
152 panel_label->setText( label );
154 #define END_SPREFS_CAT \
158 QVBoxLayout *panel_layout = new QVBoxLayout();
159 QWidget *panel = new QWidget();
160 panel_layout->setMargin( 3 );
163 QLabel *panel_label = new QLabel;
164 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
165 labelFont.setPointSize( labelFont.pointSize() + 6 );
166 labelFont.setFamily( "Verdana" );
167 panel_label->setFont( labelFont );
170 QFrame *title_line = new QFrame;
171 title_line->setFrameShape(QFrame::HLine);
172 title_line->setFrameShadow(QFrame::Sunken);
174 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
175 italicFont.setItalic( true );
179 /******************************
180 * VIDEO Panel Implementation *
181 ******************************/
182 START_SPREFS_CAT( Video , qtr("General Video Settings") );
183 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
185 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
186 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
187 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
188 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
189 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
190 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
193 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
194 CONFIG_GENERIC( "directx-device", StringList, NULL,
196 CONFIG_GENERIC( "directx-hw-yuv", Bool, NULL, hwYUVBox );
198 ui.directXBox->setVisible( false );
199 ui.hwYUVBox->setVisible( false );
202 CONFIG_GENERIC( "deinterlace-mode", StringList, NULL, deinterlaceBox );
203 CONFIG_GENERIC( "aspect-ratio", String, NULL, arLine );
205 CONFIG_GENERIC_FILE( "snapshot-path", Directory, NULL,
206 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
207 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
208 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
209 snapshotsSequentialNumbering );
210 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
214 /******************************
215 * AUDIO Panel Implementation *
216 ******************************/
217 START_SPREFS_CAT( Audio, qtr("General Audio Settings") );
219 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
221 #define audioCommon( name ) \
222 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
223 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
224 name ## Layout->setMargin( 0 ); \
225 name ## Layout->setSpacing( 0 ); \
226 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
227 name ## Label->setMinimumSize(QSize(100, 0)); \
228 name ## Layout->addWidget( name ## Label ); \
230 #define audioControl( name) \
231 audioCommon( name ) \
232 QComboBox * name ## Device = new QComboBox( name ## Control ); \
233 name ## Layout->addWidget( name ## Device ); \
234 name ## Label->setBuddy( name ## Device ); \
235 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
237 #define audioControl2( name) \
238 audioCommon( name ) \
239 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
240 name ## Layout->addWidget( name ## Device ); \
241 name ## Label->setBuddy( name ## Device ); \
242 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
243 name ## Layout->addWidget( name ## Browse ); \
244 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
246 /* hide if necessary */
247 ui.lastfm_user_edit->hide();
248 ui.lastfm_user_label->hide();
249 ui.lastfm_pass_edit->hide();
250 ui.lastfm_pass_label->hide();
252 /* Build if necessary */
253 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
255 audioControl( DirectX );
256 optionWidgets.append( DirectXControl );
257 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
258 DirectXLabel, DirectXDevice );
260 if( module_exists( "alsa" ) )
262 audioControl( alsa );
263 optionWidgets.append( alsaControl );
265 CONFIG_GENERIC2( "alsa-audio-device" , StringList , alsaLabel,
269 optionWidgets.append( NULL );
270 if( module_exists( "oss" ) )
272 audioControl2( OSS );
273 optionWidgets.append( OSSControl );
274 CONFIG_GENERIC_FILE( "oss-audio-device" , File , OSSLabel, OSSDevice,
278 optionWidgets.append( NULL );
281 /* General Audio Options */
282 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
284 CONNECT( ui.defaultVolume, valueChanged( int ),
285 this, updateAudioVolume( int ) );
287 CONFIG_GENERIC( "audio-language" , String , NULL,
288 preferredAudioLanguage );
290 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
291 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, saveVolBox );
292 CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
295 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
297 CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
299 /* Audio Output Specifics */
300 CONFIG_GENERIC( "aout", Module, NULL, outputModule );
302 CONNECT( ui.outputModule, currentIndexChanged( int ),
303 this, updateAudioOptions( int ) );
305 /* File output exists on all platforms */
306 CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
307 ui.fileName, ui.fileBrowseButton );
309 optionWidgets.append( ui.fileControl );
310 optionWidgets.append( ui.outputModule );
311 optionWidgets.append( ui.volNormBox );
312 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
313 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
314 optionWidgets.append( ui.volumeValue );
315 optionWidgets.append( ui.headphoneEffect );
316 updateAudioOptions( ui.outputModule->currentIndex() );
319 if( module_exists( "audioscrobbler" ) )
321 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
323 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
326 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
327 ui.lastfm->setChecked( true );
329 ui.lastfm->setChecked( false );
330 CONNECT( ui.lastfm, stateChanged( int ), this ,
331 lastfm_Changed( int ) );
337 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
338 setEnabled( bool ) );
340 char* psz = config_GetPsz( p_intf, "audio-filter" );
341 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
344 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
345 ui.volNormBox->setChecked( b_enabled );
346 ui.volNormSpin->setEnabled( b_enabled );
348 b_enabled = ( qs_filter.contains( "headphone" ) );
349 ui.headphoneEffect->setChecked( b_enabled );
352 updateAudioVolume( ui.defaultVolume->value() ); // First time init
356 /* Input and Codecs Panel Implementation */
357 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
361 ui.DVDDevice->setToolTip(
362 qtr( "If this property is blank, different values\n"
363 "for DVD, VCD, and CDDA are set.\n"
364 "You can define a unique one or configure them \n"
365 "individually in the advanced preferences." ) );
366 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
367 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
368 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
369 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
370 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
371 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
373 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
375 free( psz_cddadiscpath );
376 free( psz_dvddiscpath );
377 free( psz_vcddiscpath );
380 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
381 CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
382 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
383 CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
384 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
386 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
388 ui.systemCodecBox->hide();
390 optionWidgets.append( ui.DVDDevice );
391 optionWidgets.append( ui.cachingCombo );
394 /* Add the things to the ComboBox */
395 #define addToCachingBox( str, cachingNumber ) \
396 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
397 addToCachingBox( N_("Custom"), CachingCustom );
398 addToCachingBox( N_("Lowest latency"), CachingLowest );
399 addToCachingBox( N_("Low latency"), CachingLow );
400 addToCachingBox( N_("Normal"), CachingNormal );
401 addToCachingBox( N_("High latency"), CachingHigh );
402 addToCachingBox( N_("Higher latency"), CachingHigher );
404 #define TestCaC( name ) \
405 b_cache_equal = b_cache_equal && \
406 ( i_cache == config_GetInt( p_intf, name ) )
408 #define TestCaCi( name, int ) \
409 b_cache_equal = b_cache_equal && \
410 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
411 /* Select the accurate value of the ComboBox */
412 bool b_cache_equal = true;
413 int i_cache = config_GetInt( p_intf, "file-caching");
415 TestCaC( "udp-caching" );
416 if (module_exists ("dvdread"))
417 TestCaC( "dvdread-caching" );
418 if (module_exists ("dvdnav"))
419 TestCaC( "dvdnav-caching" );
420 TestCaC( "tcp-caching" );
421 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
422 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
424 TestCaC( "dshow-caching" );
426 if (module_exists ("v4l"))
427 TestCaC( "v4l-caching" );
428 if (module_exists ("access_jack"))
429 TestCaC( "jack-input-caching" );
430 if (module_exists ("v4l2"))
431 TestCaC( "v4l2-caching" );
432 if (module_exists ("pvr"))
433 TestCaC( "pvr-caching" );
435 TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
436 TestCaCi( "http-caching", 4 );
437 if (module_exists ("access_realrtsp"))
438 TestCaCi( "realrtsp-caching", 10 );
439 TestCaCi( "mms-caching", 19 );
440 if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
441 ui.cachingCombo->findData( QVariant( i_cache ) ) );
447 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
448 ui.defaultLabel->setFont( italicFont );
449 ui.skinsLabel->setFont( italicFont );
452 CONFIG_GENERIC( "language", StringList, NULL, language );
453 BUTTONACT( ui.assoButton, assoDialog() );
456 ui.languageLabel->hide();
458 ui.assoButton->hide();
462 char *psz_intf = config_GetPsz( p_intf, "intf" );
465 if( strstr( psz_intf, "skin" ) )
466 ui.skins->setChecked( true );
467 else if( strstr( psz_intf, "qt" ) )
468 ui.qt4->setChecked( true );
472 optionWidgets.append( ui.skins );
473 optionWidgets.append( ui.qt4 );
475 CONFIG_GENERIC( "qt-display-mode", IntegerList, NULL,
477 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
478 CONFIG_GENERIC( "qt-fs-controller", Bool, NULL, fsController );
479 CONFIG_GENERIC( "qt-system-tray", Bool, NULL, systrayBox );
480 CONFIG_GENERIC_FILE( "skins2-last", File, NULL, ui.fileSkin,
483 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
488 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
489 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
491 CONNECT( ui.updatesBox, toggled( bool ),
492 ui.updatesDays, setEnabled( bool ) );
494 ui.updatesBox->hide();
495 ui.updatesDays->hide();
497 /* ONE INSTANCE options */
498 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
499 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
500 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
501 EnqueueOneInterfaceMode );
503 ui.OneInterfaceBox->hide();
505 /* RECENTLY PLAYED options */
506 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
507 ui.recentlyPlayedFilters, setEnabled( bool ) );
508 ui.recentlyPlayedFilters->setEnabled( false );
509 CONFIG_GENERIC( "qt-recentplay", Bool, NULL, saveRecentlyPlayed );
510 CONFIG_GENERIC( "qt-recentplay-filter", String, NULL,
511 recentlyPlayedFilters );
515 START_SPREFS_CAT( Subtitles, qtr("Subtitles & On Screen Display Settings") );
516 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
517 CONFIG_GENERIC( "video-title-show", Bool, NULL, OSDTitleBox);
520 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
521 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
522 CONFIG_GENERIC_FILE( "freetype-font", File, NULL, ui.font,
524 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
525 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
527 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
528 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, NULL, subsPosition );
534 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
536 QGridLayout *gLayout = new QGridLayout;
537 panel->setLayout( gLayout );
540 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
541 this, gLayout, line );
543 panel_label->setText( qtr( "Configure Hotkeys" ) );
544 controls.append( control );
550 panel_layout->addWidget( panel_label );
551 panel_layout->addWidget( title_line );
552 panel_layout->addWidget( panel );
553 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
555 setLayout( panel_layout );
558 void SPrefsPanel::updateAudioOptions( int number)
560 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
561 ->itemData( number ).toString();
563 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
565 /* optionWidgets[ossW] can be NULL */
566 if( optionWidgets[ossW] )
567 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
568 /* optionWidgets[alsaW] can be NULL */
569 if( optionWidgets[alsaW] )
570 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
572 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
576 SPrefsPanel::~SPrefsPanel()
578 qDeleteAll( controls ); controls.clear();
581 void SPrefsPanel::updateAudioVolume( int volume )
583 qobject_cast<QSpinBox *>(optionWidgets[volLW])
584 ->setValue( volume * 100 / 256 );
588 /* Function called from the main Preferences dialog on each SPrefs Panel */
589 void SPrefsPanel::apply()
591 /* Generic save for ever panel */
592 QList<ConfigControl *>::Iterator i;
593 for( i = controls.begin() ; i != controls.end() ; i++ )
595 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
596 c->doApply( p_intf );
601 case SPrefsInputAndCodecs:
603 /* Device default selection */
604 const char *psz_devicepath =
605 qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
606 if( !EMPTY_STR( psz_devicepath ) )
608 config_PutPsz( p_intf, "dvd", psz_devicepath );
609 config_PutPsz( p_intf, "vcd", psz_devicepath );
610 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
613 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
614 #define CaC( name ) CaCi( name, 1 )
616 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
617 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
620 CaC( "udp-caching" );
621 if (module_exists ("dvdread" ))
622 CaC( "dvdread-caching" );
623 if (module_exists ("dvdnav" ))
624 CaC( "dvdnav-caching" );
625 CaC( "tcp-caching" ); CaC( "vcd-caching" );
626 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
627 CaC( "screen-caching" );
628 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
629 CaCi( "http-caching", 2 );
630 if (module_exists ("access_realrtsp" ))
631 CaCi( "realrtsp-caching", 10 );
632 CaCi( "mms-caching", 10 );
634 CaC( "dshow-caching" );
636 if (module_exists ( "v4l" ))
637 CaC( "v4l-caching" );
638 if (module_exists ( "access_jack" ))
639 CaC( "jack-input-caching" );
640 if (module_exists ( "v4l2" ))
641 CaC( "v4l2-caching" );
642 if (module_exists ( "pvr" ))
643 CaC( "pvr-caching" );
645 //CaCi( "dv-caching" ) too short...
651 case SPrefsInterface:
653 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
654 config_PutPsz( p_intf, "intf", "skins2" );
655 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
656 config_PutPsz( p_intf, "intf", "qt" );
663 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
664 if( b_checked && !qs_filter.contains( "volnorm" ) )
665 qs_filter.append( "volnorm" );
666 if( !b_checked && qs_filter.contains( "volnorm" ) )
667 qs_filter.removeAll( "volnorm" );
670 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
672 if( b_checked && !qs_filter.contains( "headphone" ) )
673 qs_filter.append( "headphone" );
674 if( !b_checked && qs_filter.contains( "headphone" ) )
675 qs_filter.removeAll( "headphone" );
677 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
683 void SPrefsPanel::clean()
686 void SPrefsPanel::lastfm_Changed( int i_state )
688 if( i_state == Qt::Checked )
689 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
690 else if( i_state == Qt::Unchecked )
691 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
695 #include <QDialogButtonBox>
696 #include <QHeaderView>
697 #include "util/registry.hpp"
699 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
700 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
703 const char* psz_VLC = "VLC";
704 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
706 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
708 current->setCheckState( 0, Qt::Checked );
713 current->setCheckState( 0, Qt::Unchecked );
716 listAsso.append( current );
720 void SPrefsPanel::assoDialog()
722 QDialog *d = new QDialog( this );
723 QGridLayout *assoLayout = new QGridLayout( d );
725 QTreeWidget *filetypeList = new QTreeWidget;
726 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
727 filetypeList->header()->hide();
729 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
731 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
732 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
733 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
735 filetypeList->addTopLevelItem( audioType );
736 filetypeList->addTopLevelItem( videoType );
737 filetypeList->addTopLevelItem( otherType );
739 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
740 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
741 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
743 QTreeWidgetItem *currentItem;
746 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
747 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
748 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
750 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
751 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
752 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
753 aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
754 audioType->setCheckState( 0, ( i_temp > 0 ) ?
755 ( ( i_temp == audioType->childCount() ) ?
756 Qt::Checked : Qt::PartiallyChecked )
760 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
761 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
762 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
763 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
764 aTv( ".mts" ); aTv( ".mxf" );
765 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
766 aTv( ".vob" ); aTv( ".wmv" );
767 videoType->setCheckState( 0, ( i_temp > 0 ) ?
768 ( ( i_temp == audioType->childCount() ) ?
769 Qt::Checked : Qt::PartiallyChecked )
773 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
775 otherType->setCheckState( 0, ( i_temp > 0 ) ?
776 ( ( i_temp == audioType->childCount() ) ?
777 Qt::Checked : Qt::PartiallyChecked )
780 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
781 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
782 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
783 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
784 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
786 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
788 CONNECT( closeButton, clicked(), this, saveAsso() );
789 CONNECT( clearButton, clicked(), d, reject() );
790 d->resize( 300, 400 );
797 void addAsso( QVLCRegistry *qvReg, char *psz_ext )
799 std::string s_path( "VLC" ); s_path += psz_ext;
800 std::string s_path2 = s_path;
802 /* Save a backup if already assigned */
803 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
805 if( psz_value && strlen( psz_value ) > 0 )
806 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
809 /* Put a "link" to VLC.EXT as default */
810 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
812 /* Create the needed Key if they weren't done in the installer */
813 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
815 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
816 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
817 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
819 /* Get the installer path */
820 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
821 std::string str_temp; str_temp.assign(
822 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
824 if( str_temp.size() )
826 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
827 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
829 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
830 "", str_temp.append(",0").c_str() );
836 void delAsso( QVLCRegistry *qvReg, char *psz_ext )
838 char psz_VLC[] = "VLC";
839 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
841 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
844 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
846 qvReg->WriteRegistryString( psz_ext, "", psz_value );
848 qvReg->DeleteKey( psz_ext, "VLC.backup" );
852 void SPrefsPanel::saveAsso()
854 QVLCRegistry * qvReg;
855 for( int i = 0; i < listAsso.size(); i ++ )
857 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
858 if( listAsso[i]->checkState( 0 ) > 0 )
860 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
864 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
868 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();