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>
41 #include <QScrollArea>
43 #include <QStyleFactory>
45 #include <QtAlgorithms>
47 #define ICON_HEIGHT 64
50 # include <vlc_windows_interfaces.h>
53 /*********************************************************************
54 * The List of categories
55 *********************************************************************/
56 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
57 QWidget( _parent ), p_intf( _p_intf )
59 QVBoxLayout *layout = new QVBoxLayout();
61 QButtonGroup *buttonGroup = new QButtonGroup( this );
62 buttonGroup->setExclusive ( true );
63 CONNECT( buttonGroup, buttonClicked ( int ),
64 this, switchPanel( int ) );
66 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
68 #define ADD_CATEGORY( button, label, icon, numb ) \
69 QToolButton * button = new QToolButton( this ); \
70 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
71 button->setText( label ); \
72 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
73 button->setIconSize( QSize( icon_height, icon_height ) ); \
74 button->resize( icon_height + 6 , icon_height + 6 ); \
75 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
76 button->setAutoRaise( true ); \
77 button->setCheckable( true ); \
78 buttonGroup->addButton( button, numb ); \
79 layout->addWidget( button );
81 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
82 cone_interface_64, 0 );
83 ADD_CATEGORY( SPrefsAudio, qtr("Audio"),
85 ADD_CATEGORY( SPrefsVideo, qtr("Video"),
87 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
88 cone_subtitles_64, 3 );
89 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
91 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"),
96 SPrefsInterface->setChecked( true );
97 layout->setMargin( 0 );
98 layout->setSpacing( 1 );
100 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
105 void SPrefsCatList::switchPanel( int i )
107 emit currentItemChanged( i );
110 /*********************************************************************
112 *********************************************************************/
113 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
114 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
116 module_config_t *p_config;
117 ConfigControl *control;
120 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
121 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
124 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
125 p_config, label, ui.qcontrol, false ); \
126 controls.append( control ); \
129 ui.qcontrol->setEnabled( false ); \
130 if( label ) label->setEnabled( false ); \
133 #define CONFIG_BOOL( option, qcontrol ) \
134 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
137 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
138 p_config, NULL, ui.qcontrol, false ); \
139 controls.append( control ); \
141 else { ui.qcontrol->setEnabled( false ); }
144 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
145 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
148 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
149 p_config, label, qcontrol, false ); \
150 controls.append( control ); \
153 QWidget *widget = label; \
154 qcontrol->setVisible( false ); \
155 if( widget ) widget->setEnabled( false ); \
159 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
160 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
163 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
164 p_config, label, ui.qcontrol ); \
165 controls.append( control ); \
168 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
169 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
172 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
173 p_config, label, qcontrol, qbutton ); \
174 controls.append( control ); \
177 #define START_SPREFS_CAT( name , label ) \
178 case SPrefs ## name: \
180 Ui::SPrefs ## name ui; \
181 ui.setupUi( panel ); \
182 panel_label->setText( label );
184 #define END_SPREFS_CAT \
188 QVBoxLayout *panel_layout = new QVBoxLayout();
189 QWidget *panel = new QWidget();
190 panel_layout->setMargin( 3 );
193 QLabel *panel_label = new QLabel;
194 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
195 labelFont.setPointSize( labelFont.pointSize() + 6 );
196 labelFont.setFamily( "Verdana" );
197 panel_label->setFont( labelFont );
200 QFrame *title_line = new QFrame;
201 title_line->setFrameShape(QFrame::HLine);
202 title_line->setFrameShadow(QFrame::Sunken);
204 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
205 italicFont.setItalic( true );
209 /******************************
210 * VIDEO Panel Implementation *
211 ******************************/
212 START_SPREFS_CAT( Video , qtr("Video Settings") );
213 CONFIG_BOOL( "video", enableVideo );
215 CONFIG_BOOL( "fullscreen", fullscreen );
216 CONFIG_BOOL( "overlay", overlay );
217 CONFIG_BOOL( "video-on-top", alwaysOnTop );
218 CONFIG_BOOL( "video-deco", windowDecorations );
219 CONFIG_BOOL( "skip-frames", skipFrames );
220 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
222 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
224 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
226 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
228 ui.directXBox->setVisible( false );
229 ui.hwYUVBox->setVisible( false );
232 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
233 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
234 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
236 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
237 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
238 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
239 CONFIG_BOOL( "snapshot-sequential",
240 snapshotsSequentialNumbering );
241 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
245 /******************************
246 * AUDIO Panel Implementation *
247 ******************************/
248 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
250 CONFIG_BOOL( "audio", enableAudio );
251 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
252 CONNECT( ui.enableAudio, toggled( bool ),
253 ui.SPrefsAudio_zone, setEnabled( bool ) );
255 #define audioCommon( name ) \
256 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
257 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
258 name ## Layout->setMargin( 0 ); \
259 name ## Layout->setSpacing( 0 ); \
260 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
261 name ## Label->setMinimumSize(QSize(250, 0)); \
262 name ## Layout->addWidget( name ## Label ); \
264 #define audioControl( name) \
265 audioCommon( name ) \
266 QComboBox * name ## Device = new QComboBox( name ## Control ); \
267 name ## Layout->addWidget( name ## Device ); \
268 name ## Label->setBuddy( name ## Device ); \
269 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
271 #define audioControl2( name) \
272 audioCommon( name ) \
273 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
274 name ## Layout->addWidget( name ## Device ); \
275 name ## Label->setBuddy( name ## Device ); \
276 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
277 name ## Layout->addWidget( name ## Browse ); \
278 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
280 /* Build if necessary */
281 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
283 audioControl( DirectX );
284 optionWidgets.append( DirectXControl );
285 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
286 DirectXLabel, DirectXDevice );
288 if( module_exists( "alsa" ) )
290 audioControl( alsa );
291 optionWidgets.append( alsaControl );
293 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
297 optionWidgets.append( NULL );
298 if( module_exists( "oss" ) )
300 audioControl2( OSS );
301 optionWidgets.append( OSSControl );
302 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
306 optionWidgets.append( NULL );
314 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
316 CONNECT( ui.defaultVolume, valueChanged( int ),
317 this, updateAudioVolume( int ) );
319 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
320 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
321 CONNECT( ui.resetVolumeRadio, toggled( bool ),
322 ui.defaultVolume_zone, setEnabled( bool ) );
324 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
325 preferredAudioLanguage );
327 CONFIG_BOOL( "spdif", spdifBox );
328 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
331 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
333 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
335 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
337 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
339 /* Audio Output Specifics */
340 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
342 CONNECT( ui.outputModule, currentIndexChanged( int ),
343 this, updateAudioOptions( int ) );
345 /* File output exists on all platforms */
346 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
347 ui.fileName, ui.fileBrowseButton );
349 optionWidgets.append( ui.fileControl );
350 optionWidgets.append( ui.outputModule );
351 optionWidgets.append( ui.volNormBox );
352 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
353 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
354 optionWidgets.append( ui.volumeValue );
355 optionWidgets.append( ui.headphoneEffect );
356 optionWidgets.append( ui.spdifBox );
357 updateAudioOptions( ui.outputModule->currentIndex() );
360 if( module_exists( "audioscrobbler" ) )
362 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
364 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
367 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
368 ui.lastfm->setChecked( true );
370 ui.lastfm->setChecked( false );
372 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
374 CONNECT( ui.lastfm, toggled( bool ),
375 ui.lastfm_zone, setVisible( bool ) );
376 CONNECT( ui.lastfm, stateChanged( int ),
377 this, lastfm_Changed( int ) );
382 ui.lastfm_zone->hide();
386 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
387 setEnabled( bool ) );
389 char* psz = config_GetPsz( p_intf, "audio-filter" );
390 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
393 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
394 ui.volNormBox->setChecked( b_enabled );
395 ui.volNormSpin->setEnabled( b_enabled );
397 b_enabled = ( qs_filter.contains( "headphone" ) );
398 ui.headphoneEffect->setChecked( b_enabled );
401 updateAudioVolume( ui.defaultVolume->value() ); // First time init
405 /* Input and Codecs Panel Implementation */
406 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
410 ui.DVDDevice->setToolTip(
411 qtr( "If this property is blank, different values\n"
412 "for DVD, VCD, and CDDA are set.\n"
413 "You can define a unique one or configure them \n"
414 "individually in the advanced preferences." ) );
415 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
416 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
417 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
418 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
419 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
420 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
422 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
424 free( psz_cddadiscpath );
425 free( psz_dvddiscpath );
426 free( psz_vcddiscpath );
428 CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
429 ui.DVDDevice, ui.DVDBrowse );
430 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
431 ui.recordPath, ui.recordBrowse );
433 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
435 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
436 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
438 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
440 /* live555 module prefs */
441 CONFIG_BOOL( "rtsp-tcp",
442 live555TransportRTSP_TCPRadio );
443 if ( !module_exists( "live555" ) )
445 ui.live555TransportRTSP_TCPRadio->hide();
446 ui.live555TransportHTTPRadio->hide();
447 ui.live555TransportLabel->hide();
450 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
452 ui.systemCodecBox->hide();
454 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
455 optionWidgets.append( ui.DVDDevice );
456 optionWidgets.append( ui.cachingCombo );
457 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
458 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
459 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
462 /* Add the things to the ComboBox */
463 #define addToCachingBox( str, cachingNumber ) \
464 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
465 addToCachingBox( N_("Custom"), CachingCustom );
466 addToCachingBox( N_("Lowest latency"), CachingLowest );
467 addToCachingBox( N_("Low latency"), CachingLow );
468 addToCachingBox( N_("Normal"), CachingNormal );
469 addToCachingBox( N_("High latency"), CachingHigh );
470 addToCachingBox( N_("Higher latency"), CachingHigher );
471 #undef addToCachingBox
473 #define TestCaC( name ) \
474 b_cache_equal = b_cache_equal && \
475 ( i_cache == config_GetInt( p_intf, name ) )
477 #define TestCaCi( name, int ) \
478 b_cache_equal = b_cache_equal && \
479 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
480 /* Select the accurate value of the ComboBox */
481 bool b_cache_equal = true;
482 int i_cache = config_GetInt( p_intf, "file-caching");
484 TestCaC( "udp-caching" );
485 if (module_exists ("dvdread"))
486 TestCaC( "dvdread-caching" );
487 if (module_exists ("dvdnav"))
488 TestCaC( "dvdnav-caching" );
489 TestCaC( "tcp-caching" );
490 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
491 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
493 TestCaC( "dshow-caching" );
495 if (module_exists ("v4l"))
496 TestCaC( "v4l-caching" );
497 if (module_exists ("access_jack"))
498 TestCaC( "jack-input-caching" );
499 if (module_exists ("v4l2"))
500 TestCaC( "v4l2-caching" );
501 if (module_exists ("pvr"))
502 TestCaC( "pvr-caching" );
504 if (module_exists ("livedotcom"))
505 TestCaCi( "rtsp-caching", 4 );
506 TestCaCi( "ftp-caching", 2 );
507 TestCaCi( "http-caching", 2 );
508 if (module_exists ("access_realrtsp"))
509 TestCaCi( "realrtsp-caching", 10 );
510 TestCaCi( "mms-caching", 10 );
511 if( b_cache_equal == 1 )
512 ui.cachingCombo->setCurrentIndex(
513 ui.cachingCombo->findData( QVariant( i_cache ) ) );
521 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
522 // ui.defaultLabel->setFont( italicFont );
523 ui.skinsLabel->setText(
524 qtr( "This is VLC's skinnable interface. You can download other skins at" )
525 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
526 ui.skinsLabel->setFont( italicFont );
529 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
530 BUTTONACT( ui.assoButton, assoDialog() );
532 ui.languageBox->hide();
536 char *psz_intf = config_GetPsz( p_intf, "intf" );
539 if( strstr( psz_intf, "skin" ) )
540 ui.skins->setChecked( true );
543 ui.qt4->setChecked( true );
547 optionWidgets.append( ui.skins );
548 optionWidgets.append( ui.qt4 );
549 #if !defined(NDEBUG) || !defined( WIN32)
550 ui.stylesCombo->addItem( qtr("System's default") );
551 ui.stylesCombo->addItems( QStyleFactory::keys() );
552 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
553 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
554 ui.stylesCombo->insertSeparator( 1 );
556 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
557 optionWidgets.append( ui.stylesCombo );
559 ui.stylesCombo->hide();
560 optionWidgets.append( NULL );
563 ui.skins_zone->setEnabled( ui.skins->isChecked() );
564 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
566 ui.native_zone->setEnabled( ui.qt4->isChecked() );
567 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
569 CONNECT( ui.minimalviewBox, toggled( bool ),
570 ui.mainPreview, setNormalPreview( bool ) );
571 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
572 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
573 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
575 CONFIG_BOOL( "embedded-video", embedVideo );
576 CONFIG_BOOL( "qt-fs-controller", fsController );
577 CONFIG_BOOL( "qt-system-tray", systrayBox );
578 CONFIG_BOOL( "qt-notification", sysPop );
579 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
580 ui.fileSkin, ui.skinBrowse );
581 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
583 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
588 CONFIG_BOOL( "qt-updates-notif", updatesBox );
589 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
591 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
592 CONNECT( ui.updatesBox, toggled( bool ),
593 ui.updatesDays, setEnabled( bool ) );
595 ui.updatesBox->hide();
596 ui.updatesDays->hide();
598 /* ONE INSTANCE options */
599 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
600 CONFIG_BOOL( "one-instance", OneInterfaceMode );
601 CONFIG_BOOL( "playlist-enqueue",
602 EnqueueOneInterfaceMode );
603 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
604 CONNECT( ui.OneInterfaceMode, toggled( bool ),
605 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
607 ui.OneInterfaceBox->hide();
609 /* RECENTLY PLAYED options */
610 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
611 ui.recentlyPlayedFilters, setEnabled( bool ) );
612 ui.recentlyPlayedFilters->setEnabled( false );
613 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
614 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
615 recentlyPlayedFilters );
619 START_SPREFS_CAT( Subtitles,
620 qtr("Subtitles & On Screen Display Settings") );
621 CONFIG_BOOL( "osd", OSDBox);
622 CONFIG_BOOL( "video-title-show", OSDTitleBox);
625 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
627 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
629 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
630 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
632 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
633 ui.fontSizeLabel, fontSize );
634 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
636 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
642 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
644 QGridLayout *gLayout = new QGridLayout;
645 panel->setLayout( gLayout );
648 panel_label->setText( qtr( "Configure Hotkeys" ) );
649 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
650 this, gLayout, line );
651 controls.append( control );
655 QFrame *sepline = new QFrame;
656 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
657 gLayout->addWidget( sepline, line, 0, 1, -1 );
661 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
662 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
663 p_config, false, this, gLayout, line );
664 controls.append( control );
670 panel_layout->addWidget( panel_label );
671 panel_layout->addWidget( title_line );
675 QScrollArea *scroller= new QScrollArea;
676 scroller->setWidget( panel );
677 scroller->setWidgetResizable( true );
678 scroller->setFrameStyle( QFrame::NoFrame );
679 panel_layout->addWidget( scroller );
683 panel_layout->addWidget( panel );
684 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
687 setLayout( panel_layout );
689 #undef END_SPREFS_CAT
690 #undef START_SPREFS_CAT
691 #undef CONFIG_GENERIC_FILE
692 #undef CONFIG_GENERIC_NO_BOOL
693 #undef CONFIG_GENERIC_NO_UI
694 #undef CONFIG_GENERIC
699 void SPrefsPanel::updateAudioOptions( int number)
701 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
702 ->itemData( number ).toString();
704 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
706 /* optionWidgets[ossW] can be NULL */
707 if( optionWidgets[ossW] )
708 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
709 /* optionWidgets[alsaW] can be NULL */
710 if( optionWidgets[alsaW] )
711 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
713 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
714 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
715 value == "aout_directx" || value == "waveout" ) );
719 SPrefsPanel::~SPrefsPanel()
721 qDeleteAll( controls ); controls.clear();
724 void SPrefsPanel::updateAudioVolume( int volume )
726 qobject_cast<QSpinBox *>(optionWidgets[volLW])
727 ->setValue( volume * 100 / 256 );
731 /* Function called from the main Preferences dialog on each SPrefs Panel */
732 void SPrefsPanel::apply()
734 /* Generic save for ever panel */
735 QList<ConfigControl *>::Iterator i;
736 for( i = controls.begin() ; i != controls.end() ; i++ )
738 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
739 c->doApply( p_intf );
744 case SPrefsInputAndCodecs:
746 /* Device default selection */
747 char *psz_devicepath =
748 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
749 if( !EMPTY_STR( psz_devicepath ) )
751 config_PutPsz( p_intf, "dvd", psz_devicepath );
752 config_PutPsz( p_intf, "vcd", psz_devicepath );
753 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
754 free( psz_devicepath );
757 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
758 #define CaC( name ) CaCi( name, 1 )
760 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
761 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
764 CaC( "udp-caching" );
765 if (module_exists ("dvdread" ))
766 CaC( "dvdread-caching" );
767 if (module_exists ("dvdnav" ))
768 CaC( "dvdnav-caching" );
769 CaC( "tcp-caching" ); CaC( "vcd-caching" );
770 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
771 CaC( "screen-caching" ); CaC( "bd-caching" );
772 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
773 CaCi( "http-caching", 2 );
774 if (module_exists ("access_realrtsp" ))
775 CaCi( "realrtsp-caching", 10 );
776 CaCi( "mms-caching", 10 );
778 CaC( "dshow-caching" );
780 if (module_exists ( "v4l" ))
781 CaC( "v4l-caching" );
782 if (module_exists ( "access_jack" ))
783 CaC( "jack-input-caching" );
784 if (module_exists ( "v4l2" ))
785 CaC( "v4l2-caching" );
786 if (module_exists ( "pvr" ))
787 CaC( "pvr-caching" );
789 //CaCi( "dv-caching" ) too short...
797 case SPrefsInterface:
799 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
800 config_PutPsz( p_intf, "intf", "skins2" );
801 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
802 config_PutPsz( p_intf, "intf", "qt" );
803 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
804 getSettings()->setValue( "MainWindow/QtStyle",
805 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
813 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
814 if( b_checked && !qs_filter.contains( "volnorm" ) )
815 qs_filter.append( "volnorm" );
816 if( !b_checked && qs_filter.contains( "volnorm" ) )
817 qs_filter.removeAll( "volnorm" );
820 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
822 if( b_checked && !qs_filter.contains( "headphone" ) )
823 qs_filter.append( "headphone" );
824 if( !b_checked && qs_filter.contains( "headphone" ) )
825 qs_filter.removeAll( "headphone" );
827 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
833 void SPrefsPanel::clean()
836 void SPrefsPanel::lastfm_Changed( int i_state )
838 if( i_state == Qt::Checked )
839 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
840 else if( i_state == Qt::Unchecked )
841 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
844 void SPrefsPanel::changeStyle( QString s_style )
846 QApplication::setStyle( s_style );
848 /* force refresh on all widgets */
849 QWidgetList widgets = QApplication::allWidgets();
850 QWidgetList::iterator it = widgets.begin();
851 while( it != widgets.end() ) {
858 #include <QDialogButtonBox>
859 #include <QHeaderView>
860 #include "util/registry.hpp"
863 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
864 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
867 const char* psz_VLC = "VLC";
868 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
870 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
872 current->setCheckState( 0, Qt::Checked );
877 current->setCheckState( 0, Qt::Unchecked );
880 listAsso.append( current );
884 void SPrefsPanel::assoDialog()
886 LPAPPASSOCREGUI p_appassoc;
889 if( S_OK == CoCreateInstance( &clsid_IApplication2,
890 NULL, CLSCTX_INPROC_SERVER,
891 &IID_IApplicationAssociationRegistrationUI,
892 (void **)&p_appassoc) )
894 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
903 QDialog *d = new QDialog( this );
904 QGridLayout *assoLayout = new QGridLayout( d );
906 QTreeWidget *filetypeList = new QTreeWidget;
907 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
908 filetypeList->header()->hide();
910 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
912 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
913 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
914 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
916 filetypeList->addTopLevelItem( audioType );
917 filetypeList->addTopLevelItem( videoType );
918 filetypeList->addTopLevelItem( otherType );
920 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
921 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
922 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
924 QTreeWidgetItem *currentItem;
927 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
928 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
929 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
931 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
932 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
933 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
934 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
935 audioType->setCheckState( 0, ( i_temp > 0 ) ?
936 ( ( i_temp == audioType->childCount() ) ?
937 Qt::Checked : Qt::PartiallyChecked )
941 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
942 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
943 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
944 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
945 aTv( ".mts" ); aTv( ".mxf" );
946 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
947 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
948 videoType->setCheckState( 0, ( i_temp > 0 ) ?
949 ( ( i_temp == audioType->childCount() ) ?
950 Qt::Checked : Qt::PartiallyChecked )
954 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
955 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
956 otherType->setCheckState( 0, ( i_temp > 0 ) ?
957 ( ( i_temp == audioType->childCount() ) ?
958 Qt::Checked : Qt::PartiallyChecked )
965 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
966 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
967 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
968 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
969 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
971 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
973 CONNECT( closeButton, clicked(), this, saveAsso() );
974 CONNECT( clearButton, clicked(), d, reject() );
975 d->resize( 300, 400 );
982 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
984 std::string s_path( "VLC" ); s_path += psz_ext;
985 std::string s_path2 = s_path;
987 /* Save a backup if already assigned */
988 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
990 if( psz_value && strlen( psz_value ) > 0 )
991 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
994 /* Put a "link" to VLC.EXT as default */
995 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
997 /* Create the needed Key if they weren't done in the installer */
998 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1000 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1001 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1002 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1004 /* Get the installer path */
1005 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1006 std::string str_temp; str_temp.assign(
1007 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1009 if( str_temp.size() )
1011 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1012 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1014 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1015 "", str_temp.append(",0").c_str() );
1021 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1023 char psz_VLC[] = "VLC";
1024 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1026 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1029 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1031 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1033 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1035 delete( psz_value );
1037 void SPrefsPanel::saveAsso()
1039 QVLCRegistry * qvReg;
1040 for( int i = 0; i < listAsso.size(); i ++ )
1042 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1043 if( listAsso[i]->checkState( 0 ) > 0 )
1045 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1049 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1053 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();