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 ); \
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, ui.voutLabel, outputModule );
192 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
193 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
195 CONFIG_GENERIC( "directx-hw-yuv", Bool, NULL, hwYUVBox );
197 ui.directXBox->setVisible( false );
198 ui.hwYUVBox->setVisible( false );
201 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterLabel, deinterlaceBox );
202 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
204 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
205 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
206 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
207 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
208 snapshotsSequentialNumbering );
209 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
213 /******************************
214 * AUDIO Panel Implementation *
215 ******************************/
216 START_SPREFS_CAT( Audio, qtr("General Audio Settings") );
218 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
220 #define audioCommon( name ) \
221 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
222 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
223 name ## Layout->setMargin( 0 ); \
224 name ## Layout->setSpacing( 0 ); \
225 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
226 name ## Label->setMinimumSize(QSize(100, 0)); \
227 name ## Layout->addWidget( name ## Label ); \
229 #define audioControl( name) \
230 audioCommon( name ) \
231 QComboBox * name ## Device = new QComboBox( name ## Control ); \
232 name ## Layout->addWidget( name ## Device ); \
233 name ## Label->setBuddy( name ## Device ); \
234 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
236 #define audioControl2( name) \
237 audioCommon( name ) \
238 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
239 name ## Layout->addWidget( name ## Device ); \
240 name ## Label->setBuddy( name ## Device ); \
241 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
242 name ## Layout->addWidget( name ## Browse ); \
243 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
245 /* hide if necessary */
246 ui.lastfm_user_edit->hide();
247 ui.lastfm_user_label->hide();
248 ui.lastfm_pass_edit->hide();
249 ui.lastfm_pass_label->hide();
251 /* Build if necessary */
252 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
254 audioControl( DirectX );
255 optionWidgets.append( DirectXControl );
256 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
257 ui.DirectXLabel, DirectXDevice );
259 if( module_exists( "alsa" ) )
261 audioControl( alsa );
262 optionWidgets.append( alsaControl );
264 CONFIG_GENERIC2( "alsa-audio-device" , StringList, NULL,
268 optionWidgets.append( NULL );
269 if( module_exists( "oss" ) )
271 audioControl2( OSS );
272 optionWidgets.append( OSSControl );
273 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
277 optionWidgets.append( NULL );
280 /* General Audio Options */
281 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
283 CONNECT( ui.defaultVolume, valueChanged( int ),
284 this, updateAudioVolume( int ) );
286 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
287 preferredAudioLanguage );
289 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
290 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, saveVolBox );
291 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
294 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
296 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
299 /* Audio Output Specifics */
300 CONFIG_GENERIC( "aout", Module, ui.outputLabel, 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 ),
331 this, 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, ui.portLabel,
382 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
383 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
385 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
386 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
388 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
390 ui.systemCodecBox->hide();
392 optionWidgets.append( ui.DVDDevice );
393 optionWidgets.append( ui.cachingCombo );
396 /* Add the things to the ComboBox */
397 #define addToCachingBox( str, cachingNumber ) \
398 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
399 addToCachingBox( N_("Custom"), CachingCustom );
400 addToCachingBox( N_("Lowest latency"), CachingLowest );
401 addToCachingBox( N_("Low latency"), CachingLow );
402 addToCachingBox( N_("Normal"), CachingNormal );
403 addToCachingBox( N_("High latency"), CachingHigh );
404 addToCachingBox( N_("Higher latency"), CachingHigher );
406 #define TestCaC( name ) \
407 b_cache_equal = b_cache_equal && \
408 ( i_cache == config_GetInt( p_intf, name ) )
410 #define TestCaCi( name, int ) \
411 b_cache_equal = b_cache_equal && \
412 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
413 /* Select the accurate value of the ComboBox */
414 bool b_cache_equal = true;
415 int i_cache = config_GetInt( p_intf, "file-caching");
417 TestCaC( "udp-caching" );
418 if (module_exists ("dvdread"))
419 TestCaC( "dvdread-caching" );
420 if (module_exists ("dvdnav"))
421 TestCaC( "dvdnav-caching" );
422 TestCaC( "tcp-caching" );
423 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
424 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
426 TestCaC( "dshow-caching" );
428 if (module_exists ("v4l"))
429 TestCaC( "v4l-caching" );
430 if (module_exists ("access_jack"))
431 TestCaC( "jack-input-caching" );
432 if (module_exists ("v4l2"))
433 TestCaC( "v4l2-caching" );
434 if (module_exists ("pvr"))
435 TestCaC( "pvr-caching" );
437 TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
438 TestCaCi( "http-caching", 4 );
439 if (module_exists ("access_realrtsp"))
440 TestCaCi( "realrtsp-caching", 10 );
441 TestCaCi( "mms-caching", 19 );
442 if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
443 ui.cachingCombo->findData( QVariant( i_cache ) ) );
449 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
450 ui.defaultLabel->setFont( italicFont );
451 ui.skinsLabel->setFont( italicFont );
454 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
455 BUTTONACT( ui.assoButton, assoDialog() );
458 ui.languageLabel->hide();
460 ui.assoButton->hide();
464 char *psz_intf = config_GetPsz( p_intf, "intf" );
467 if( strstr( psz_intf, "skin" ) )
468 ui.skins->setChecked( true );
469 else if( strstr( psz_intf, "qt" ) )
470 ui.qt4->setChecked( true );
474 optionWidgets.append( ui.skins );
475 optionWidgets.append( ui.qt4 );
477 CONFIG_GENERIC( "qt-display-mode", IntegerList, ui.displayLabel,
479 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
480 CONFIG_GENERIC( "qt-fs-controller", Bool, NULL, fsController );
481 CONFIG_GENERIC( "qt-system-tray", Bool, NULL, systrayBox );
482 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
483 ui.fileSkin, ui.skinBrowse );
485 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
490 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
491 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
493 CONNECT( ui.updatesBox, toggled( bool ),
494 ui.updatesDays, setEnabled( bool ) );
496 ui.updatesBox->hide();
497 ui.updatesDays->hide();
499 /* ONE INSTANCE options */
500 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
501 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
502 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
503 EnqueueOneInterfaceMode );
505 ui.OneInterfaceBox->hide();
507 /* RECENTLY PLAYED options */
508 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
509 ui.recentlyPlayedFilters, setEnabled( bool ) );
510 ui.recentlyPlayedFilters->setEnabled( false );
511 CONFIG_GENERIC( "qt-recentplay", Bool, NULL, saveRecentlyPlayed );
512 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
513 recentlyPlayedFilters );
517 START_SPREFS_CAT( Subtitles,
518 qtr("Subtitles & On Screen Display Settings") );
519 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
520 CONFIG_GENERIC( "video-title-show", Bool, NULL, OSDTitleBox);
523 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
525 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
527 CONFIG_GENERIC_FILE( "freetype-font", File, ui.fontLabel, ui.font,
529 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
531 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
532 ui.fontSizeLabel, fontSize );
533 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
535 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
541 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
543 QGridLayout *gLayout = new QGridLayout;
544 panel->setLayout( gLayout );
547 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
548 this, gLayout, line );
550 panel_label->setText( qtr( "Configure Hotkeys" ) );
551 controls.append( control );
557 panel_layout->addWidget( panel_label );
558 panel_layout->addWidget( title_line );
559 panel_layout->addWidget( panel );
560 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
562 setLayout( panel_layout );
565 void SPrefsPanel::updateAudioOptions( int number)
567 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
568 ->itemData( number ).toString();
570 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
572 /* optionWidgets[ossW] can be NULL */
573 if( optionWidgets[ossW] )
574 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
575 /* optionWidgets[alsaW] can be NULL */
576 if( optionWidgets[alsaW] )
577 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
579 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
583 SPrefsPanel::~SPrefsPanel()
585 qDeleteAll( controls ); controls.clear();
588 void SPrefsPanel::updateAudioVolume( int volume )
590 qobject_cast<QSpinBox *>(optionWidgets[volLW])
591 ->setValue( volume * 100 / 256 );
595 /* Function called from the main Preferences dialog on each SPrefs Panel */
596 void SPrefsPanel::apply()
598 /* Generic save for ever panel */
599 QList<ConfigControl *>::Iterator i;
600 for( i = controls.begin() ; i != controls.end() ; i++ )
602 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
603 c->doApply( p_intf );
608 case SPrefsInputAndCodecs:
610 /* Device default selection */
611 const char *psz_devicepath =
612 qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
613 if( !EMPTY_STR( psz_devicepath ) )
615 config_PutPsz( p_intf, "dvd", psz_devicepath );
616 config_PutPsz( p_intf, "vcd", psz_devicepath );
617 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
620 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
621 #define CaC( name ) CaCi( name, 1 )
623 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
624 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
627 CaC( "udp-caching" );
628 if (module_exists ("dvdread" ))
629 CaC( "dvdread-caching" );
630 if (module_exists ("dvdnav" ))
631 CaC( "dvdnav-caching" );
632 CaC( "tcp-caching" ); CaC( "vcd-caching" );
633 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
634 CaC( "screen-caching" );
635 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
636 CaCi( "http-caching", 2 );
637 if (module_exists ("access_realrtsp" ))
638 CaCi( "realrtsp-caching", 10 );
639 CaCi( "mms-caching", 10 );
641 CaC( "dshow-caching" );
643 if (module_exists ( "v4l" ))
644 CaC( "v4l-caching" );
645 if (module_exists ( "access_jack" ))
646 CaC( "jack-input-caching" );
647 if (module_exists ( "v4l2" ))
648 CaC( "v4l2-caching" );
649 if (module_exists ( "pvr" ))
650 CaC( "pvr-caching" );
652 //CaCi( "dv-caching" ) too short...
658 case SPrefsInterface:
660 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
661 config_PutPsz( p_intf, "intf", "skins2" );
662 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
663 config_PutPsz( p_intf, "intf", "qt" );
670 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
671 if( b_checked && !qs_filter.contains( "volnorm" ) )
672 qs_filter.append( "volnorm" );
673 if( !b_checked && qs_filter.contains( "volnorm" ) )
674 qs_filter.removeAll( "volnorm" );
677 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
679 if( b_checked && !qs_filter.contains( "headphone" ) )
680 qs_filter.append( "headphone" );
681 if( !b_checked && qs_filter.contains( "headphone" ) )
682 qs_filter.removeAll( "headphone" );
684 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
690 void SPrefsPanel::clean()
693 void SPrefsPanel::lastfm_Changed( int i_state )
695 if( i_state == Qt::Checked )
696 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
697 else if( i_state == Qt::Unchecked )
698 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
702 #include <QDialogButtonBox>
703 #include <QHeaderView>
704 #include "util/registry.hpp"
706 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
707 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
710 const char* psz_VLC = "VLC";
711 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
713 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
715 current->setCheckState( 0, Qt::Checked );
720 current->setCheckState( 0, Qt::Unchecked );
723 listAsso.append( current );
727 void SPrefsPanel::assoDialog()
729 QDialog *d = new QDialog( this );
730 QGridLayout *assoLayout = new QGridLayout( d );
732 QTreeWidget *filetypeList = new QTreeWidget;
733 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
734 filetypeList->header()->hide();
736 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
738 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
739 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
740 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
742 filetypeList->addTopLevelItem( audioType );
743 filetypeList->addTopLevelItem( videoType );
744 filetypeList->addTopLevelItem( otherType );
746 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
747 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
748 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
750 QTreeWidgetItem *currentItem;
753 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
754 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
755 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
757 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
758 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
759 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
760 aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
761 audioType->setCheckState( 0, ( i_temp > 0 ) ?
762 ( ( i_temp == audioType->childCount() ) ?
763 Qt::Checked : Qt::PartiallyChecked )
767 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
768 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
769 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
770 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
771 aTv( ".mts" ); aTv( ".mxf" );
772 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
773 aTv( ".vob" ); aTv( ".wmv" );
774 videoType->setCheckState( 0, ( i_temp > 0 ) ?
775 ( ( i_temp == audioType->childCount() ) ?
776 Qt::Checked : Qt::PartiallyChecked )
780 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
782 otherType->setCheckState( 0, ( i_temp > 0 ) ?
783 ( ( i_temp == audioType->childCount() ) ?
784 Qt::Checked : Qt::PartiallyChecked )
787 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
788 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
789 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
790 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
791 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
793 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
795 CONNECT( closeButton, clicked(), this, saveAsso() );
796 CONNECT( clearButton, clicked(), d, reject() );
797 d->resize( 300, 400 );
804 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
806 std::string s_path( "VLC" ); s_path += psz_ext;
807 std::string s_path2 = s_path;
809 /* Save a backup if already assigned */
810 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
812 if( psz_value && strlen( psz_value ) > 0 )
813 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
816 /* Put a "link" to VLC.EXT as default */
817 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
819 /* Create the needed Key if they weren't done in the installer */
820 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
822 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
823 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
824 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
826 /* Get the installer path */
827 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
828 std::string str_temp; str_temp.assign(
829 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
831 if( str_temp.size() )
833 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
834 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
836 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
837 "", str_temp.append(",0").c_str() );
843 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
845 char psz_VLC[] = "VLC";
846 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
848 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
851 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
853 qvReg->WriteRegistryString( psz_ext, "", psz_value );
855 qvReg->DeleteKey( psz_ext, "VLC.backup" );
859 void SPrefsPanel::saveAsso()
861 QVLCRegistry * qvReg;
862 for( int i = 0; i < listAsso.size(); i ++ )
864 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
865 if( listAsso[i]->checkState( 0 ) > 0 )
867 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
871 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
875 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();