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>
43 #include <QtAlgorithms>
47 #define ICON_HEIGHT 64
48 #define BUTTON_HEIGHT 74
50 /*********************************************************************
51 * The List of categories
52 *********************************************************************/
53 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
54 QWidget( _parent ), p_intf( _p_intf )
56 QVBoxLayout *layout = new QVBoxLayout();
58 QButtonGroup *buttonGroup = new QButtonGroup( this );
59 buttonGroup->setExclusive ( true );
60 CONNECT( buttonGroup, buttonClicked ( int ),
61 this, switchPanel( int ) );
63 #define ADD_CATEGORY( button, label, icon, numb ) \
64 QToolButton * button = new QToolButton( this ); \
65 button->setIcon( QIcon( ":/pixmaps/prefs/" #icon ) ); \
66 button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \
67 button->setText( label ); \
68 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
69 button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \
70 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
71 button->setAutoRaise( true ); \
72 button->setCheckable( true ); \
73 buttonGroup->addButton( button, numb ); \
74 layout->addWidget( button );
76 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
77 spref_cone_Interface_64.png, 0 );
78 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
79 ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
80 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
81 spref_cone_Subtitles_64.png, 3 );
82 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
83 spref_cone_Input_64.png, 4 );
84 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
86 SPrefsInterface->setChecked( true );
87 layout->setMargin( 0 );
88 layout->setSpacing( 1 );
90 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
95 void SPrefsCatList::switchPanel( int i )
97 emit currentItemChanged( i );
100 /*********************************************************************
102 *********************************************************************/
103 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
104 int _number ) : QWidget( _parent ), p_intf( _p_intf )
106 module_config_t *p_config;
107 ConfigControl *control;
110 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
111 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
114 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
115 p_config, label, ui.qcontrol, false ); \
116 controls.append( control ); \
119 #define CONFIG_GENERIC2( option, type, label, qcontrol ) \
120 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
123 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
124 p_config, label, qcontrol, false ); \
125 controls.append( control ); \
129 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
130 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
133 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
134 p_config, label, ui.qcontrol ); \
135 controls.append( control ); \
138 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
139 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
142 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
143 p_config, label, qcontrol, qbutton, \
145 controls.append( control ); \
148 #define START_SPREFS_CAT( name , label ) \
149 case SPrefs ## name: \
151 Ui::SPrefs ## name ui; \
152 ui.setupUi( panel ); \
153 panel_label->setText( label );
155 #define END_SPREFS_CAT \
159 QVBoxLayout *panel_layout = new QVBoxLayout();
160 QWidget *panel = new QWidget();
161 panel_layout->setMargin( 3 );
164 QLabel *panel_label = new QLabel;
165 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
166 labelFont.setPointSize( labelFont.pointSize() + 6 );
167 labelFont.setFamily( "Verdana" );
168 panel_label->setFont( labelFont );
171 QFrame *title_line = new QFrame;
172 title_line->setFrameShape(QFrame::HLine);
173 title_line->setFrameShadow(QFrame::Sunken);
175 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
176 italicFont.setItalic( true );
180 /******************************
181 * VIDEO Panel Implementation *
182 ******************************/
183 START_SPREFS_CAT( Video , qtr("General Video Settings") );
184 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
186 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
187 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
188 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
189 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
190 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
191 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
194 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
195 CONFIG_GENERIC( "directx-device", StringList, NULL,
198 ui.directXBox->setVisible( false );
201 CONFIG_GENERIC_FILE( "snapshot-path", Directory, NULL,
202 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
203 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
204 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
205 snapshotsSequentialNumbering );
206 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
210 /******************************
211 * AUDIO Panel Implementation *
212 ******************************/
213 START_SPREFS_CAT( Audio, qtr("General Audio Settings") );
215 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
217 #define audioCommon( name ) \
218 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
219 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
220 name ## Layout->setMargin( 0 ); \
221 name ## Layout->setSpacing( 0 ); \
222 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
223 name ## Label->setMinimumSize(QSize(100, 0)); \
224 name ## Layout->addWidget( name ## Label ); \
226 #define audioControl( name) \
227 audioCommon( name ) \
228 QComboBox * name ## Device = new QComboBox( name ## Control ); \
229 name ## Layout->addWidget( name ## Device ); \
230 name ## Label->setBuddy( name ## Device ); \
231 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
233 #define audioControl2( name) \
234 audioCommon( name ) \
235 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
236 name ## Layout->addWidget( name ## Device ); \
237 name ## Label->setBuddy( name ## Device ); \
238 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
239 name ## Layout->addWidget( name ## Browse ); \
240 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
242 /* hide if necessary */
243 ui.lastfm_user_edit->hide();
244 ui.lastfm_user_label->hide();
245 ui.lastfm_pass_edit->hide();
246 ui.lastfm_pass_label->hide();
248 /* Build if necessary */
249 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
251 audioControl( DirectX );
252 optionWidgets.append( DirectXControl );
253 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
254 DirectXLabel, DirectXDevice );
256 if( module_Exists( p_intf, "alsa" ) )
258 audioControl( alsa );
259 optionWidgets.append( alsaControl );
261 CONFIG_GENERIC2( "alsadev" , StringList , alsaLabel,
265 optionWidgets.append( NULL );
266 if( module_Exists( p_intf, "oss" ) )
268 audioControl2( OSS );
269 optionWidgets.append( OSSControl );
270 CONFIG_GENERIC_FILE( "dspdev" , File , OSSLabel, OSSDevice,
274 optionWidgets.append( NULL );
277 /* General Audio Options */
278 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
280 CONNECT( ui.defaultVolume, valueChanged( int ),
281 this, updateAudioVolume( int ) );
283 CONFIG_GENERIC( "audio-language" , String , NULL,
284 preferredAudioLanguage );
286 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
287 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, saveVolBox );
288 CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
291 CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
293 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
295 CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
297 /* Audio Output Specifics */
298 CONFIG_GENERIC( "aout", Module, NULL, outputModule );
300 CONNECT( ui.outputModule, currentIndexChanged( int ),
301 this, updateAudioOptions( int ) );
303 /* File output exists on all platforms */
304 CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
305 ui.fileName, ui.fileBrowseButton );
307 optionWidgets.append( ui.fileControl );
308 optionWidgets.append( ui.outputModule );
309 optionWidgets.append( ui.volNormBox );
310 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
312 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
314 optionWidgets.append( ui.volumeValue );
315 updateAudioOptions( ui.outputModule->currentIndex() );
318 if( module_Exists( p_intf, "audioscrobbler" ) )
320 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
322 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
325 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
326 ui.lastfm->setChecked( true );
328 ui.lastfm->setChecked( false );
329 CONNECT( ui.lastfm, stateChanged( int ), this ,
330 lastfm_Changed( int ) );
337 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
338 setEnabled( bool ) );
339 char* psz = config_GetPsz( p_intf, "audio-filter" );
340 qs_filter = qfu( psz );
342 bool b_normalizer = ( qs_filter.contains( "volnorm" ) );
344 ui.volNormBox->setChecked( b_normalizer );
345 ui.volNormSpin->setEnabled( b_normalizer );
349 updateAudioVolume( ui.defaultVolume->value() ); // First time init
353 /* Input and Codecs Panel Implementation */
354 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
358 ui.DVDDevice->setToolTip(
359 qtr( "If this property is blank, different values\n"
360 "for DVD, VCD, and CDDA are set.\n"
361 "You can define a unique one or configure them \n"
362 "individually in the advanced preferences." ) );
363 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
364 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
365 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
366 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
367 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
368 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
370 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
372 free( psz_cddadiscpath );
373 free( psz_dvddiscpath );
374 free( psz_vcddiscpath );
377 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
378 CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
379 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
380 CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
381 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
383 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
385 ui.systemCodecBox->hide();
388 char* psz = config_GetPsz( p_intf, "access-filter" );
389 qs_filter = qfu( psz );
391 ui.timeshiftBox->setChecked( qs_filter.contains( "timeshift" ) );
392 ui.dumpBox->setChecked( qs_filter.contains( "dump" ) );
393 ui.recordBox->setChecked( qs_filter.contains( "record" ) );
394 ui.bandwidthBox->setChecked( qs_filter.contains( "bandwidth" ) );
396 optionWidgets.append( ui.recordBox );
397 optionWidgets.append( ui.dumpBox );
398 optionWidgets.append( ui.bandwidthBox );
399 optionWidgets.append( ui.timeshiftBox );
400 optionWidgets.append( ui.DVDDevice );
401 optionWidgets.append( ui.cachingCombo );
404 /* Add the things to the ComboBox */
405 #define addToCachingBox( str, cachingNumber ) \
406 ui.cachingCombo->addItem( str, QVariant( cachingNumber ) );
407 addToCachingBox( "Custom", CachingCustom );
408 addToCachingBox( "Lowest latency", CachingLowest );
409 addToCachingBox( "Low latency", CachingLow );
410 addToCachingBox( "Normal", CachingNormal );
411 addToCachingBox( "High latency", CachingHigh );
412 addToCachingBox( "Higher latency", CachingHigher );
414 #define TestCaC( name ) \
415 b_cache_equal = b_cache_equal && \
416 ( i_cache == config_GetInt( p_intf, name ) )
418 #define TestCaCi( name, int ) \
419 b_cache_equal = b_cache_equal && \
420 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
421 /* Select the accurate value of the ComboBox */
422 bool b_cache_equal = true;
423 int i_cache = config_GetInt( p_intf, "file-caching");
425 TestCaC( "udp-caching" );
426 if (module_Exists (p_intf, "dvdread"))
427 TestCaC( "dvdread-caching" );
428 if (module_Exists (p_intf, "dvdnav"))
429 TestCaC( "dvdnav-caching" );
430 TestCaC( "tcp-caching" );
431 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
432 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
434 TestCaC( "dshow-caching" );
436 if (module_Exists (p_intf, "v4l"))
437 TestCaC( "v4l-caching" );
438 if (module_Exists (p_intf, "access_jack"))
439 TestCaC( "jack-input-caching" );
440 if (module_Exists (p_intf, "v4l2"))
441 TestCaC( "v4l2-caching" );
442 if (module_Exists (p_intf, "pvr"))
443 TestCaC( "pvr-caching" );
445 TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
446 TestCaCi( "http-caching", 4 );
447 if (module_Exists (p_intf, "access_realrtsp"))
448 TestCaCi( "realrtsp-caching", 10 );
449 TestCaCi( "mms-caching", 19 );
450 if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
451 ui.cachingCombo->findData( QVariant( i_cache ) ) );
457 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
458 ui.defaultLabel->setFont( italicFont );
459 ui.skinsLabel->setFont( italicFont );
462 CONFIG_GENERIC( "language", StringList, NULL, language );
463 BUTTONACT( ui.assoButton, assoDialog() );
466 ui.languageLabel->hide();
468 ui.assoButton->hide();
472 char *psz_intf = config_GetPsz( p_intf, "intf" );
475 if( strstr( psz_intf, "skin" ) )
476 ui.skins->setChecked( true );
477 else if( strstr( psz_intf, "qt" ) )
478 ui.qt4->setChecked( true );
482 optionWidgets.append( ui.skins );
483 optionWidgets.append( ui.qt4 );
485 CONFIG_GENERIC( "qt-display-mode", IntegerList, NULL,
487 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
488 CONFIG_GENERIC( "qt-fs-controller", Bool, NULL, fsController );
489 CONFIG_GENERIC_FILE( "skins2-last", File, NULL, ui.fileSkin,
492 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
497 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
498 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
500 CONNECT( ui.updatesBox, toggled( bool ),
501 ui.updatesDays, setEnabled( bool ) );
503 ui.updatesBox->hide();
504 ui.updatesDays->hide();
506 /* ONE INSTANCE options */
507 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
508 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
509 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
510 EnqueueOneInterfaceMode );
512 ui.OneInterfaceBox->hide();
516 START_SPREFS_CAT( Subtitles, qtr("Subtitles & On Screen Display Settings") );
517 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
519 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
520 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
521 CONFIG_GENERIC_FILE( "freetype-font", File, NULL, ui.font,
523 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
524 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
526 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
532 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
534 QGridLayout *gLayout = new QGridLayout;
535 panel->setLayout( gLayout );
538 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
539 this, gLayout, line );
541 panel_label->setText( qtr( "Configure Hotkeys" ) );
542 controls.append( control );
548 panel_layout->addWidget( panel_label );
549 panel_layout->addWidget( title_line );
550 panel_layout->addWidget( panel );
551 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
553 setLayout( panel_layout );
556 void SPrefsPanel::updateAudioOptions( int number)
558 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
559 ->itemData( number ).toString();
561 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
563 /* optionWidgets[ossW] can be NULL */
564 if( optionWidgets[ossW] )
565 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
566 /* optionWidgets[alsaW] can be NULL */
567 if( optionWidgets[alsaW] )
568 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
570 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
574 SPrefsPanel::~SPrefsPanel()
576 qDeleteAll( controls ); controls.clear();
579 void SPrefsPanel::updateAudioVolume( int volume )
581 qobject_cast<QSpinBox *>(optionWidgets[volLW])
582 ->setValue( volume * 100 / 256 );
586 /* Function called from the main Preferences dialog on each SPrefs Panel */
587 void SPrefsPanel::apply()
589 /* Generic save for ever panel */
590 QList<ConfigControl *>::Iterator i;
591 for( i = controls.begin() ; i != controls.end() ; i++ )
593 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
594 c->doApply( p_intf );
599 case SPrefsInputAndCodecs:
601 /* Device default selection */
602 char *psz_devicepath =
603 qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
604 if( !EMPTY_STR( psz_devicepath ) )
606 config_PutPsz( p_intf, "dvd", psz_devicepath );
607 config_PutPsz( p_intf, "vcd", psz_devicepath );
608 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
612 #define saveBox( name, box ) {\
613 if( box->isChecked() ) { \
615 qs_filter.append( name ); \
618 else qs_filter.append( ":" ).append( name ); \
623 saveBox( "record", qobject_cast<QCheckBox *>(optionWidgets[recordChB]) );
624 saveBox( "dump", qobject_cast<QCheckBox *>(optionWidgets[dumpChB]) );
625 saveBox( "timeshift", qobject_cast<QCheckBox *>(optionWidgets[timeshiftChB]) );
626 saveBox( "bandwidth", qobject_cast<QCheckBox *>(optionWidgets[bandwidthChB] ) );
627 config_PutPsz( p_intf, "access-filter", qtu( qs_filter ) );
629 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
630 #define CaC( name ) CaCi( name, 1 )
632 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
633 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
636 CaC( "udp-caching" );
637 if (module_Exists (p_intf, "dvdread" ))
638 CaC( "dvdread-caching" );
639 if (module_Exists (p_intf, "dvdnav" ))
640 CaC( "dvdnav-caching" );
641 CaC( "tcp-caching" ); CaC( "vcd-caching" );
642 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
643 CaC( "screen-caching" );
644 CaCi( "rtsp-caching", 4 ); CaCi( "ftp-caching", 2 );
645 CaCi( "http-caching", 4 );
646 if (module_Exists (p_intf, "access_realrtsp" ))
647 CaCi( "realrtsp-caching", 10 );
648 CaCi( "mms-caching", 19 );
650 CaC( "dshow-caching" );
652 if (module_Exists (p_intf, "v4l" ))
653 CaC( "v4l-caching" );
654 if (module_Exists (p_intf, "access_jack" ))
655 CaC( "jack-input-caching" );
656 if (module_Exists (p_intf, "v4l2" ))
657 CaC( "v4l2-caching" );
658 if (module_Exists (p_intf, "pvr" ))
659 CaC( "pvr-caching" );
661 //CaCi( "dv-caching" ) too short...
667 case SPrefsInterface:
669 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
670 config_PutPsz( p_intf, "intf", "skins2" );
671 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
672 config_PutPsz( p_intf, "intf", "qt4" );
679 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
680 if( qs_filter.isEmpty() )
682 /* the psz_filter is already empty, so we just append it needed */
683 if( b_normChecked ) qs_filter = "volnorm";
687 if( qs_filter.contains( "volnorm" ) )
689 /* The qs_filter not empty and contains "volnorm"
690 that we have to remove */
694 qs_filter.remove( "volnorm:" );
695 qs_filter.remove( ":volnorm" );
696 qs_filter.remove( "volnorm" );
699 else /* qs_filter not empty, but doesn't have volnorm inside */
700 if( b_normChecked ) qs_filter.append( ":volnorm" );
702 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter ) );
708 void SPrefsPanel::clean()
711 void SPrefsPanel::lastfm_Changed( int i_state )
713 if( i_state == Qt::Checked )
714 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
715 else if( i_state == Qt::Unchecked )
716 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
720 #include <QDialogButtonBox>
721 #include <QHeaderView>
722 #include "util/registry.hpp"
724 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
725 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
728 const char* psz_VLC = "VLC";
729 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
731 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
733 current->setCheckState( 0, Qt::Checked );
738 current->setCheckState( 0, Qt::Unchecked );
741 listAsso.append( current );
745 void SPrefsPanel::assoDialog()
747 QDialog *d = new QDialog( this );
748 QGridLayout *assoLayout = new QGridLayout( d );
750 QTreeWidget *filetypeList = new QTreeWidget;
751 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
752 filetypeList->header()->hide();
754 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
756 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
757 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
758 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
760 filetypeList->addTopLevelItem( audioType );
761 filetypeList->addTopLevelItem( videoType );
762 filetypeList->addTopLevelItem( otherType );
764 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
765 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
766 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
768 QTreeWidgetItem *currentItem;
771 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
772 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
773 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
775 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
776 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
777 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".ogg" ); aTa( ".spx" ); aTa( ".wav" );
778 aTa( ".wma" ); aTa( ".xm" );
779 audioType->setCheckState( 0, ( i_temp > 0 ) ?
780 ( ( i_temp == audioType->childCount() ) ?
781 Qt::Checked : Qt::PartiallyChecked )
785 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
786 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m4v" ); aTv( ".mkv" );
787 aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
788 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
789 aTv( ".mxf" ); aTv( ".ogm" ); aTv( ".ps" ); aTv( ".ts" );
790 aTv( ".vob" ); aTv( ".wmv" );
791 videoType->setCheckState( 0, ( i_temp > 0 ) ?
792 ( ( i_temp == audioType->childCount() ) ?
793 Qt::Checked : Qt::PartiallyChecked )
797 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
799 otherType->setCheckState( 0, ( i_temp > 0 ) ?
800 ( ( i_temp == audioType->childCount() ) ?
801 Qt::Checked : Qt::PartiallyChecked )
804 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
805 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
806 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
807 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
808 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
810 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
812 CONNECT( closeButton, clicked(), this, saveAsso() );
813 CONNECT( clearButton, clicked(), d, reject() );
814 d->resize( 300, 400 );
821 void addAsso( QVLCRegistry *qvReg, char *psz_ext )
823 std::string s_path( "VLC" ); s_path += psz_ext;
824 std::string s_path2 = s_path;
826 /* Save a backup if already assigned */
827 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
829 if( psz_value && strlen( psz_value ) > 0 )
830 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
833 /* Put a "link" to VLC.EXT as default */
834 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
836 /* Create the needed Key if they weren't done in the installer */
837 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
839 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
840 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
841 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
843 /* Get the installer path */
844 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
845 std::string str_temp; str_temp.assign(
846 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
848 if( str_temp.size() )
850 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
851 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
853 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
854 "", str_temp.append(",0").c_str() );
860 void delAsso( QVLCRegistry *qvReg, char *psz_ext )
862 char psz_VLC[] = "VLC";
863 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
865 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
868 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
870 qvReg->WriteRegistryString( psz_ext, "", psz_value );
872 qvReg->DeleteKey( psz_ext, "VLC.backup" );
876 void SPrefsPanel::saveAsso()
878 QVLCRegistry * qvReg;
879 for( int i = 0; i < listAsso.size(); i ++ )
881 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
882 if( listAsso[i]->checkState( 0 ) > 0 )
884 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
888 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
892 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();