1 /*****************************************************************************
2 * simple_preferences.cpp : "Simple preferences"
3 ****************************************************************************
4 * Copyright (C) 2006-2007 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 *****************************************************************************/
29 #include "components/simple_preferences.hpp"
30 #include "components/preferences_widgets.hpp"
32 #include <vlc_config_cat.h>
33 #include <vlc_configuration.h>
37 #include <QToolButton>
38 #include <QButtonGroup>
40 #include <QVBoxLayout>
44 #define ICON_HEIGHT 64
45 #define BUTTON_HEIGHT 74
47 /*********************************************************************
48 * The List of categories
49 *********************************************************************/
50 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
51 QWidget( _parent ), p_intf( _p_intf )
53 QVBoxLayout *layout = new QVBoxLayout();
55 QButtonGroup *buttonGroup = new QButtonGroup( this );
56 buttonGroup->setExclusive ( true );
57 CONNECT( buttonGroup, buttonClicked ( int ),
58 this, switchPanel( int ) );
60 #define ADD_CATEGORY( button, label, icon, numb ) \
61 QToolButton * button = new QToolButton( this ); \
62 button->setIcon( QIcon( ":/pixmaps/" #icon ) ); \
63 button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) ); \
64 button->setText( label ); \
65 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
66 button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT); \
67 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
68 button->setAutoRaise( true ); \
69 button->setCheckable( true ); \
70 buttonGroup->addButton( button, numb ); \
71 layout->addWidget( button );
73 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
74 spref_cone_Interface_64.png, 0 );
75 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
76 ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
77 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles & OSD"),
78 spref_cone_Subtitles_64.png, 3 );
79 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
80 spref_cone_Input_64.png, 4 );
81 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
83 SPrefsInterface->setChecked( true );
84 layout->setMargin( 0 );
85 layout->setSpacing( 1 );
87 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
92 void SPrefsCatList::switchPanel( int i )
94 emit currentItemChanged( i );
97 /*********************************************************************
99 *********************************************************************/
100 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
101 int _number ) : QWidget( _parent ), p_intf( _p_intf )
103 module_config_t *p_config;
104 ConfigControl *control;
107 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
108 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
111 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
112 p_config, label, ui.qcontrol, false ); \
113 controls.append( control ); \
116 #define CONFIG_GENERIC2( option, type, label, qcontrol ) \
117 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
120 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
121 p_config, label, qcontrol, false ); \
122 controls.append( control ); \
126 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
127 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
130 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
131 p_config, label, ui.qcontrol ); \
132 controls.append( control ); \
135 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
136 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
139 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
140 p_config, label, qcontrol, qbutton, \
142 controls.append( control ); \
145 #define START_SPREFS_CAT( name , label ) \
146 case SPrefs ## name: \
148 Ui::SPrefs ## name ui; \
149 ui.setupUi( panel ); \
150 panel_label->setText( label );
152 #define END_SPREFS_CAT \
156 QVBoxLayout *panel_layout = new QVBoxLayout();
157 QWidget *panel = new QWidget();
158 panel_layout->setMargin( 3 );
161 QLabel *panel_label = new QLabel;
162 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
163 labelFont.setPointSize( labelFont.pointSize() + 6 );
164 labelFont.setFamily( "Verdana" );
165 panel_label->setFont( labelFont );
168 QFrame *title_line = new QFrame;
169 title_line->setFrameShape(QFrame::HLine);
170 title_line->setFrameShadow(QFrame::Sunken);
172 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
173 italicFont.setItalic( true );
177 /******************************
178 * VIDEO Panel Implementation *
179 ******************************/
180 START_SPREFS_CAT( Video , qtr("General video settings") );
181 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
183 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
184 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
185 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
186 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
187 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
188 CONFIG_GENERIC( "vout", Module, NULL, outputModule );
191 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
192 CONFIG_GENERIC( "directx-device", StringList, NULL,
195 ui.directXBox->setVisible( false );
198 CONFIG_GENERIC_FILE( "snapshot-path", Directory, NULL,
199 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
200 CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
201 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
202 snapshotsSequentialNumbering );
203 CONFIG_GENERIC( "snapshot-format", StringList, NULL,
207 /******************************
208 * AUDIO Panel Implementation *
209 ******************************/
210 START_SPREFS_CAT( Audio, qtr("General audio settings") );
212 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
214 #define audioCommon( name ) \
215 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
216 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
217 name ## Layout->setMargin( 0 ); \
218 name ## Layout->setSpacing( 0 ); \
219 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
220 name ## Label->setMinimumSize(QSize(100, 0)); \
221 name ## Layout->addWidget( name ## Label ); \
223 #define audioControl( name) \
224 audioCommon( name ) \
225 QComboBox * name ## Device = new QComboBox( name ## Control ); \
226 name ## Layout->addWidget( name ## Device ); \
227 name ## Label->setBuddy( name ## Device ); \
228 ui.outputAudioLayout->addWidget( name ## Control, ui.outputAudioLayout->rowCount(), 0, 1, -1 );
230 #define audioControl2( name) \
231 audioCommon( name ) \
232 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
233 name ## Layout->addWidget( name ## Device ); \
234 name ## Label->setBuddy( name ## Device ); \
235 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
236 name ## Layout->addWidget( name ## Browse ); \
237 ui.outputAudioLayout->addWidget( name ## Control, ui.outputAudioLayout->rowCount(), 0, 1, -1 );
239 /* hide if necessary */
240 ui.lastfm_user_edit->hide();
241 ui.lastfm_user_label->hide();
242 ui.lastfm_pass_edit->hide();
243 ui.lastfm_pass_label->hide();
245 /* Build if necessary */
247 audioControl( DirectX );
248 optionWidgets.append( DirectXControl );
249 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
250 DirectXLabel, DirectXDevice );
252 if( module_Exists( p_intf, "alsa" ) )
254 audioControl( alsa );
255 optionWidgets.append( alsaControl );
257 CONFIG_GENERIC2( "alsadev" , StringList , alsaLabel,
261 optionWidgets.append( NULL );
262 if( module_Exists( p_intf, "oss" ) )
264 audioControl2( OSS );
265 optionWidgets.append( OSSControl );
266 CONFIG_GENERIC_FILE( "dspdev" , File , OSSLabel, OSSDevice,
270 optionWidgets.append( NULL );
273 /* General Audio Options */
274 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
276 CONNECT( ui.defaultVolume, valueChanged( int ),
277 this, updateAudioVolume( int ) );
279 CONFIG_GENERIC( "audio-language" , String , NULL,
280 preferredAudioLanguage );
282 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
283 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, saveVolBox );
284 CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
287 CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
289 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
291 CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
293 /* Audio Output Specifics */
294 CONFIG_GENERIC( "aout", Module, NULL, outputModule );
296 CONNECT( ui.outputModule, currentIndexChanged( int ),
297 this, updateAudioOptions( int ) );
299 // File exists everywhere
300 CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
301 ui.fileName, ui.fileBrowseButton );
303 optionWidgets.append( ui.fileControl );
304 optionWidgets.append( ui.outputModule );
305 optionWidgets.append( ui.volNormBox );
306 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
308 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
310 optionWidgets.append( ui.volumeValue );
311 updateAudioOptions( ui.outputModule->currentIndex() );
314 if( module_Exists( p_intf, "audioscrobbler" ) )
316 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
318 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
321 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
322 ui.lastfm->setChecked( true );
324 ui.lastfm->setChecked( false );
325 CONNECT( ui.lastfm, stateChanged( int ), this ,
326 lastfm_Changed( int ) );
333 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
334 setEnabled( bool ) );
335 qs_filter = qfu( config_GetPsz( p_intf, "audio-filter" ) );
336 bool b_normalizer = ( qs_filter.contains( "volnorm" ) );
338 ui.volNormBox->setChecked( b_normalizer );
339 ui.volNormSpin->setEnabled( b_normalizer );
343 updateAudioVolume( ui.defaultVolume->value() ); // First time init
347 /* Input and Codecs Panel Implementation */
348 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs settings") );
352 ui.DVDDevice->setToolTip(
353 //TODO: make this sentence understandable
354 qtr( "If this property is blank, then you have\n"
355 "values for DVD, VCD, and CDDA.\n"
356 "You can define a unique one or set that in"
357 "the advanced preferences" ) );
358 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
359 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
360 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
361 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
362 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
363 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
365 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
367 delete psz_cddadiscpath; delete psz_dvddiscpath;
368 delete psz_vcddiscpath;
371 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
372 CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
373 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
374 CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
375 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
377 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
379 ui.systemCodecBox->hide();
382 qs_filter = qfu( config_GetPsz( p_intf, "access-filter" ) );
383 ui.timeshiftBox->setChecked( qs_filter.contains( "timeshift" ) );
384 ui.dumpBox->setChecked( qs_filter.contains( "dump" ) );
385 ui.recordBox->setChecked( qs_filter.contains( "record" ) );
386 ui.bandwidthBox->setChecked( qs_filter.contains( "bandwidth" ) );
388 optionWidgets.append( ui.recordBox );
389 optionWidgets.append( ui.dumpBox );
390 optionWidgets.append( ui.bandwidthBox );
391 optionWidgets.append( ui.timeshiftBox );
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( str, QVariant( cachingNumber ) );
399 addToCachingBox( "Custom", CachingCustom );
400 addToCachingBox( "Lowest latency", CachingLowest );
401 addToCachingBox( "Low latency", CachingLow );
402 addToCachingBox( "Normal", CachingNormal );
403 addToCachingBox( "High latency", CachingHigh );
404 addToCachingBox( "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 (p_intf, "dvdread"))
419 TestCaC( "dvdread-caching" );
420 if (module_Exists (p_intf, "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 (p_intf, "v4l"))
429 TestCaC( "v4l-caching" );
430 if (module_Exists (p_intf, "access_jack"))
431 TestCaC( "jack-input-caching" );
432 if (module_Exists (p_intf, "v4l2"))
433 TestCaC( "v4l2-caching" );
434 if (module_Exists (p_intf, "pvr"))
435 TestCaC( "pvr-caching" );
437 TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
438 TestCaCi( "http-caching", 4 );
439 if (module_Exists (p_intf, "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, NULL, 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, NULL,
479 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
480 CONFIG_GENERIC_FILE( "skins2-last", File, NULL, ui.fileSkin,
483 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
485 CONFIG_GENERIC( "fetch-meta", Bool, NULL, metaFetcher );
489 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
490 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
492 CONNECT( ui.updatesBox, toggled( bool ),
493 ui.updatesDays, setEnabled( bool ) );
495 ui.updatesBox->hide();
496 ui.updatesDays->hide();
498 /* ONE INSTANCE options */
499 #if defined( WIN32 ) || defined( HAVE_DBUS_3 ) || defined(__APPLE__)
500 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
501 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
502 EnqueueOneInterfaceMode );
504 ui.OneInterfaceBox->hide();
508 START_SPREFS_CAT( Subtitles, qtr("Subtitles & OSD settings") );
509 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
511 CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
512 CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
513 CONFIG_GENERIC_FILE( "freetype-font", File, NULL, ui.font,
515 CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
516 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
518 CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
524 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
526 QGridLayout *gLayout = new QGridLayout;
527 panel->setLayout( gLayout );
530 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
531 this, gLayout, line );
533 panel_label->setText( qtr( "Configure Hotkeys" ) );
534 controls.append( control );
540 panel_layout->addWidget( panel_label );
541 panel_layout->addWidget( title_line );
542 panel_layout->addWidget( panel );
543 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
545 setLayout( panel_layout );
548 void SPrefsPanel::updateAudioOptions( int number)
550 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
551 ->itemData( number ).toString();
553 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
555 /* optionWidgets[ossW] can be NULL */
556 if( optionWidgets[ossW] )
557 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
558 /* optionWidgets[alsaW] can be NULL */
559 if( optionWidgets[alsaW] )
560 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
562 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
565 void SPrefsPanel::updateAudioVolume( int volume )
567 qobject_cast<QSpinBox *>(optionWidgets[volLW])
568 ->setValue( volume * 100 / 256 );
572 /* Function called from the main Preferences dialog on each SPrefs Panel */
573 void SPrefsPanel::apply()
575 /* Generic save for ever panel */
576 QList<ConfigControl *>::Iterator i;
577 for( i = controls.begin() ; i != controls.end() ; i++ )
579 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
580 c->doApply( p_intf );
585 case SPrefsInputAndCodecs:
587 /* Device default selection */
588 char *psz_devicepath =
589 qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
590 if( !EMPTY_STR( psz_devicepath ) )
592 config_PutPsz( p_intf, "dvd", psz_devicepath );
593 config_PutPsz( p_intf, "vcd", psz_devicepath );
594 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
598 #define saveBox( name, box ) {\
599 if( box->isChecked() ) { \
601 qs_filter.append( name ); \
604 else qs_filter.append( ":" ).append( name ); \
609 saveBox( "record", qobject_cast<QCheckBox *>(optionWidgets[recordChB]) );
610 saveBox( "dump", qobject_cast<QCheckBox *>(optionWidgets[dumpChB]) );
611 saveBox( "timeshift", qobject_cast<QCheckBox *>(optionWidgets[timeshiftChB]) );
612 saveBox( "bandwidth", qobject_cast<QCheckBox *>(optionWidgets[bandwidthChB] ) );
613 config_PutPsz( p_intf, "access-filter", qtu( qs_filter ) );
615 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
616 #define CaC( name ) CaCi( name, 1 )
618 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
619 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
622 CaC( "udp-caching" );
623 if (module_Exists (p_intf, "dvdread" ))
624 CaC( "dvdread-caching" );
625 if (module_Exists (p_intf, "dvdnav" ))
626 CaC( "dvdnav-caching" );
627 CaC( "tcp-caching" ); CaC( "vcd-caching" );
628 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
629 CaC( "screen-caching" );
630 CaCi( "rtsp-caching", 4 ); CaCi( "ftp-caching", 2 );
631 CaCi( "http-caching", 4 );
632 if (module_Exists (p_intf, "access_realrtsp" ))
633 CaCi( "realrtsp-caching", 10 );
634 CaCi( "mms-caching", 19 );
636 CaC( "dshow-caching" );
638 if (module_Exists (p_intf, "v4l" ))
639 CaC( "v4l-caching" );
640 if (module_Exists (p_intf, "access_jack" ))
641 CaC( "jack-input-caching" );
642 if (module_Exists (p_intf, "v4l2" ))
643 CaC( "v4l2-caching" );
644 if (module_Exists (p_intf, "pvr" ))
645 CaC( "pvr-caching" );
647 //CaCi( "dv-caching" ) too short...
653 case SPrefsInterface:
655 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
656 config_PutPsz( p_intf, "intf", "skins2" );
657 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
658 config_PutPsz( p_intf, "intf", "qt4" );
665 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
666 if( qs_filter.isEmpty() )
668 /* the psz_filter is already empty, so we just append it needed */
669 if( b_normChecked ) qs_filter = "volnorm";
673 if( qs_filter.contains( "volnorm" ) )
675 /* The qs_filter not empty and contains "volnorm"
676 that we have to remove */
680 qs_filter.remove( "volnorm:" );
681 qs_filter.remove( ":volnorm" );
682 qs_filter.remove( "volnorm" );
685 else /* qs_filter not empty, but doesn't have volnorm inside */
686 if( b_normChecked ) qs_filter.append( ":volnorm" );
688 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter ) );
694 void SPrefsPanel::clean()
697 void SPrefsPanel::lastfm_Changed( int i_state )
699 if( i_state == Qt::Checked )
700 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
701 else if( i_state == Qt::Unchecked )
702 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
706 #include <QDialogButtonBox>
707 #include <QHeaderView>
708 #include "util/registry.hpp"
710 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
711 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
714 const char* psz_VLC = "VLC";
715 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
717 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
719 current->setCheckState( 0, Qt::Checked );
724 current->setCheckState( 0, Qt::Unchecked );
727 listAsso.append( current );
731 void SPrefsPanel::assoDialog()
733 QDialog *d = new QDialog( this );
734 QGridLayout *assoLayout = new QGridLayout( d );
736 QTreeWidget *filetypeList = new QTreeWidget;
737 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
738 filetypeList->header()->hide();
740 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
742 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
743 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
744 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
746 filetypeList->addTopLevelItem( audioType );
747 filetypeList->addTopLevelItem( videoType );
748 filetypeList->addTopLevelItem( otherType );
750 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
751 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
752 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
754 QTreeWidgetItem *currentItem;
757 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
758 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
759 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
761 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
762 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
763 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".ogg" ); aTa( ".spx" ); aTa( ".wav" );
764 aTa( ".wma" ); aTa( ".xm" );
765 audioType->setCheckState( 0, ( i_temp > 0 ) ?
766 ( ( i_temp == audioType->childCount() ) ?
767 Qt::Checked : Qt::PartiallyChecked )
771 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
772 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m4v" ); aTv( ".mkv" );
773 aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
774 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
775 aTv( ".mxf" ); aTv( ".ogm" ); aTv( ".ps" ); aTv( ".ts" );
776 aTv( ".vob" ); aTv( ".wmv" );
777 videoType->setCheckState( 0, ( i_temp > 0 ) ?
778 ( ( i_temp == audioType->childCount() ) ?
779 Qt::Checked : Qt::PartiallyChecked )
783 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
785 otherType->setCheckState( 0, ( i_temp > 0 ) ?
786 ( ( i_temp == audioType->childCount() ) ?
787 Qt::Checked : Qt::PartiallyChecked )
790 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
791 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
792 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
793 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
794 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
796 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
798 CONNECT( closeButton, clicked(), this, saveAsso() );
799 CONNECT( clearButton, clicked(), d, reject() );
800 d->resize( 300, 400 );
807 void addAsso( QVLCRegistry *qvReg, char *psz_ext )
809 std::string s_path( "VLC" ); s_path += psz_ext;
810 std::string s_path2 = s_path;
812 /* Save a backup if already assigned */
813 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
815 if( psz_value && strlen( psz_value ) > 0 )
816 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
819 /* Put a "link" to VLC.EXT as default */
820 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
822 /* Create the needed Key if they weren't done in the installer */
823 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
825 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
826 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
827 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
829 /* Get the installer path */
830 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
831 std::string str_temp; str_temp.assign(
832 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
834 if( str_temp.size() )
836 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
837 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
839 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
840 "", str_temp.append(",0").c_str() );
846 void delAsso( QVLCRegistry *qvReg, char *psz_ext )
848 char psz_VLC[] = "VLC";
849 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
851 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
854 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
856 qvReg->WriteRegistryString( psz_ext, "", psz_value );
858 qvReg->DeleteKey( psz_ext, "VLC.backup" );
862 void SPrefsPanel::saveAsso()
864 QVLCRegistry * qvReg;
865 for( int i = 0; i < listAsso.size(); i ++ )
867 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
868 if( listAsso[i]->checkState( 0 ) > 0 )
870 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
874 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
878 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();