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 #define CONFIG_GENERIC2( 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, qcontrol, false ); \
135 controls.append( control ); \
139 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
140 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
143 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
144 p_config, label, ui.qcontrol ); \
145 controls.append( control ); \
148 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
149 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
152 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
153 p_config, label, qcontrol, qbutton ); \
154 controls.append( control ); \
157 #define START_SPREFS_CAT( name , label ) \
158 case SPrefs ## name: \
160 Ui::SPrefs ## name ui; \
161 ui.setupUi( panel ); \
162 panel_label->setText( label );
164 #define END_SPREFS_CAT \
168 QVBoxLayout *panel_layout = new QVBoxLayout();
169 QWidget *panel = new QWidget();
170 panel_layout->setMargin( 3 );
173 QLabel *panel_label = new QLabel;
174 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
175 labelFont.setPointSize( labelFont.pointSize() + 6 );
176 labelFont.setFamily( "Verdana" );
177 panel_label->setFont( labelFont );
180 QFrame *title_line = new QFrame;
181 title_line->setFrameShape(QFrame::HLine);
182 title_line->setFrameShadow(QFrame::Sunken);
184 QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
185 italicFont.setItalic( true );
189 /******************************
190 * VIDEO Panel Implementation *
191 ******************************/
192 START_SPREFS_CAT( Video , qtr("Video Settings") );
193 CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
195 CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
196 CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
197 CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
198 CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
199 CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
200 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
203 CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
204 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
206 CONFIG_GENERIC( "directx-hw-yuv", Bool, NULL, hwYUVBox );
208 ui.directXBox->setVisible( false );
209 ui.hwYUVBox->setVisible( false );
212 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
213 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
214 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
216 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
217 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
218 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
219 CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
220 snapshotsSequentialNumbering );
221 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
225 /******************************
226 * AUDIO Panel Implementation *
227 ******************************/
228 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
230 CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
231 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
232 CONNECT( ui.enableAudio, toggled( bool ),
233 ui.SPrefsAudio_zone, setEnabled( bool ) );
235 #define audioCommon( name ) \
236 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
237 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
238 name ## Layout->setMargin( 0 ); \
239 name ## Layout->setSpacing( 0 ); \
240 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
241 name ## Label->setMinimumSize(QSize(250, 0)); \
242 name ## Layout->addWidget( name ## Label ); \
244 #define audioControl( name) \
245 audioCommon( name ) \
246 QComboBox * name ## Device = new QComboBox( name ## Control ); \
247 name ## Layout->addWidget( name ## Device ); \
248 name ## Label->setBuddy( name ## Device ); \
249 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
251 #define audioControl2( name) \
252 audioCommon( name ) \
253 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
254 name ## Layout->addWidget( name ## Device ); \
255 name ## Label->setBuddy( name ## Device ); \
256 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
257 name ## Layout->addWidget( name ## Browse ); \
258 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
260 /* Build if necessary */
261 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
263 audioControl( DirectX );
264 optionWidgets.append( DirectXControl );
265 CONFIG_GENERIC2( "directx-audio-device", IntegerList,
266 NULL, DirectXDevice );
268 if( module_exists( "alsa" ) )
270 audioControl( alsa );
271 optionWidgets.append( alsaControl );
273 CONFIG_GENERIC2( "alsa-audio-device" , StringList, NULL,
277 optionWidgets.append( NULL );
278 if( module_exists( "oss" ) )
280 audioControl2( OSS );
281 optionWidgets.append( OSSControl );
282 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
286 optionWidgets.append( NULL );
294 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
296 CONNECT( ui.defaultVolume, valueChanged( int ),
297 this, updateAudioVolume( int ) );
299 CONFIG_GENERIC( "qt-autosave-volume", Bool, NULL, keepVolumeRadio );
300 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
301 CONNECT( ui.resetVolumeRadio, toggled( bool ),
302 ui.defaultVolume_zone, setEnabled( bool ) );
304 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
305 preferredAudioLanguage );
307 CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
308 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
311 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
313 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
315 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
318 /* Audio Output Specifics */
319 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
321 CONNECT( ui.outputModule, currentIndexChanged( int ),
322 this, updateAudioOptions( int ) );
324 /* File output exists on all platforms */
325 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
326 ui.fileName, ui.fileBrowseButton );
328 optionWidgets.append( ui.fileControl );
329 optionWidgets.append( ui.outputModule );
330 optionWidgets.append( ui.volNormBox );
331 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
332 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
333 optionWidgets.append( ui.volumeValue );
334 optionWidgets.append( ui.headphoneEffect );
335 optionWidgets.append( ui.spdifBox );
336 updateAudioOptions( ui.outputModule->currentIndex() );
339 if( module_exists( "audioscrobbler" ) )
341 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
343 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
346 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
347 ui.lastfm->setChecked( true );
349 ui.lastfm->setChecked( false );
351 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
353 CONNECT( ui.lastfm, toggled( bool ),
354 ui.lastfm_zone, setVisible( bool ) );
355 CONNECT( ui.lastfm, stateChanged( int ),
356 this, lastfm_Changed( int ) );
361 ui.lastfm_zone->hide();
365 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
366 setEnabled( bool ) );
368 char* psz = config_GetPsz( p_intf, "audio-filter" );
369 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
372 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
373 ui.volNormBox->setChecked( b_enabled );
374 ui.volNormSpin->setEnabled( b_enabled );
376 b_enabled = ( qs_filter.contains( "headphone" ) );
377 ui.headphoneEffect->setChecked( b_enabled );
380 updateAudioVolume( ui.defaultVolume->value() ); // First time init
384 /* Input and Codecs Panel Implementation */
385 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
389 ui.DVDDevice->setToolTip(
390 qtr( "If this property is blank, different values\n"
391 "for DVD, VCD, and CDDA are set.\n"
392 "You can define a unique one or configure them \n"
393 "individually in the advanced preferences." ) );
394 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
395 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
396 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
397 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
398 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
399 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
401 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
403 free( psz_cddadiscpath );
404 free( psz_dvddiscpath );
405 free( psz_vcddiscpath );
407 CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
408 ui.DVDDevice, ui.DVDBrowse );
409 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
410 ui.recordPath, ui.recordBrowse );
412 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
414 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
415 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
417 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
419 /* live555 module prefs */
420 CONFIG_GENERIC( "rtsp-tcp", Bool, NULL,
421 live555TransportRTSP_TCPRadio );
422 if ( !module_exists( "live555" ) )
424 ui.live555TransportRTSP_TCPRadio->hide();
425 ui.live555TransportHTTPRadio->hide();
426 ui.live555TransportLabel->hide();
429 CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
431 ui.systemCodecBox->hide();
432 ui.systemCodecLabel->hide();
434 optionWidgets.append( ui.DVDDevice );
435 optionWidgets.append( ui.cachingCombo );
436 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
439 /* Add the things to the ComboBox */
440 #define addToCachingBox( str, cachingNumber ) \
441 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
442 addToCachingBox( N_("Custom"), CachingCustom );
443 addToCachingBox( N_("Lowest latency"), CachingLowest );
444 addToCachingBox( N_("Low latency"), CachingLow );
445 addToCachingBox( N_("Normal"), CachingNormal );
446 addToCachingBox( N_("High latency"), CachingHigh );
447 addToCachingBox( N_("Higher latency"), CachingHigher );
448 #undef addToCachingBox
450 #define TestCaC( name ) \
451 b_cache_equal = b_cache_equal && \
452 ( i_cache == config_GetInt( p_intf, name ) )
454 #define TestCaCi( name, int ) \
455 b_cache_equal = b_cache_equal && \
456 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
457 /* Select the accurate value of the ComboBox */
458 bool b_cache_equal = true;
459 int i_cache = config_GetInt( p_intf, "file-caching");
461 TestCaC( "udp-caching" );
462 if (module_exists ("dvdread"))
463 TestCaC( "dvdread-caching" );
464 if (module_exists ("dvdnav"))
465 TestCaC( "dvdnav-caching" );
466 TestCaC( "tcp-caching" );
467 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
468 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
470 TestCaC( "dshow-caching" );
472 if (module_exists ("v4l"))
473 TestCaC( "v4l-caching" );
474 if (module_exists ("access_jack"))
475 TestCaC( "jack-input-caching" );
476 if (module_exists ("v4l2"))
477 TestCaC( "v4l2-caching" );
478 if (module_exists ("pvr"))
479 TestCaC( "pvr-caching" );
481 if (module_exists ("livedotcom"))
482 TestCaCi( "rtsp-caching", 4 );
483 TestCaCi( "ftp-caching", 2 );
484 TestCaCi( "http-caching", 4 );
485 if (module_exists ("access_realrtsp"))
486 TestCaCi( "realrtsp-caching", 10 );
487 TestCaCi( "mms-caching", 19 );
488 if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
489 ui.cachingCombo->findData( QVariant( i_cache ) ) );
497 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
498 // ui.defaultLabel->setFont( italicFont );
499 ui.skinsLabel->setText(
500 qtr( "This is VLC's skinnable interface. You can download other skins at" )
501 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
502 ui.skinsLabel->setFont( italicFont );
505 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
506 BUTTONACT( ui.assoButton, assoDialog() );
508 ui.languageBox->hide();
512 char *psz_intf = config_GetPsz( p_intf, "intf" );
515 if( strstr( psz_intf, "skin" ) )
516 ui.skins->setChecked( true );
519 ui.qt4->setChecked( true );
523 optionWidgets.append( ui.skins );
524 optionWidgets.append( ui.qt4 );
525 #if !defined(NDEBUG) || !defined( WIN32)
526 ui.stylesCombo->addItem( qtr("System's default") );
527 ui.stylesCombo->addItems( QStyleFactory::keys() );
528 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
529 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
530 ui.stylesCombo->insertSeparator( 1 );
532 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
533 optionWidgets.append( ui.stylesCombo );
535 ui.stylesCombo->hide();
536 optionWidgets.append( NULL );
539 ui.skins_zone->setEnabled( ui.skins->isChecked() );
540 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
542 ui.native_zone->setEnabled( ui.qt4->isChecked() );
543 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
545 InterfacePreviewWidget *preview = new InterfacePreviewWidget( this );
546 ( (QGridLayout *) ui.LooknfeelBox->layout() )->
547 addWidget( preview, 1, 0, 1, 2 );
548 CONNECT( ui.displayModeBox, currentIndexChanged( int ),
549 preview, setPreview( int ) );
550 InterfacePreviewWidget *skinspreview = new InterfacePreviewWidget( this );
551 skinspreview->setPreview(3); /* skins_preview resource index */
552 ( (QGridLayout *) ui.LooknfeelBox->layout() )->
553 addWidget( skinspreview, 7, 0, 1, 2 );
555 CONFIG_GENERIC( "qt-display-mode", IntegerList, ui.displayLabel,
557 CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
558 CONFIG_GENERIC( "qt-fs-controller", Bool, NULL, fsController );
559 CONFIG_GENERIC( "qt-system-tray", Bool, NULL, systrayBox );
560 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
561 ui.fileSkin, ui.skinBrowse );
562 CONFIG_GENERIC( "qt-video-autoresize", Bool, NULL, resizingBox );
564 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
569 CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
570 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
572 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
573 CONNECT( ui.updatesBox, toggled( bool ),
574 ui.updatesDays, setEnabled( bool ) );
576 ui.updatesBox->hide();
577 ui.updatesDays->hide();
579 /* ONE INSTANCE options */
580 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
581 CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
582 CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
583 EnqueueOneInterfaceMode );
584 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
585 CONNECT( ui.OneInterfaceMode, toggled( bool ),
586 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
588 ui.OneInterfaceBox->hide();
590 /* RECENTLY PLAYED options */
591 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
592 ui.recentlyPlayedFilters, setEnabled( bool ) );
593 ui.recentlyPlayedFilters->setEnabled( false );
594 CONFIG_GENERIC( "qt-recentplay", Bool, NULL, saveRecentlyPlayed );
595 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
596 recentlyPlayedFilters );
600 START_SPREFS_CAT( Subtitles,
601 qtr("Subtitles & On Screen Display Settings") );
602 CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
603 CONFIG_GENERIC( "video-title-show", Bool, NULL, OSDTitleBox);
606 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
608 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
610 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
611 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
613 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
614 ui.fontSizeLabel, fontSize );
615 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
617 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
623 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
625 QGridLayout *gLayout = new QGridLayout;
626 panel->setLayout( gLayout );
629 panel_label->setText( qtr( "Configure Hotkeys" ) );
630 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
631 this, gLayout, line );
632 controls.append( control );
636 QFrame *sepline = new QFrame;
637 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
638 gLayout->addWidget( sepline, line, 0, 1, -1 );
642 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
643 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
644 p_config, false, this, gLayout, line );
645 controls.append( control );
651 panel_layout->addWidget( panel_label );
652 panel_layout->addWidget( title_line );
656 QScrollArea *scroller= new QScrollArea;
657 scroller->setWidget( panel );
658 scroller->setWidgetResizable( true );
659 scroller->setFrameStyle( QFrame::NoFrame );
660 panel_layout->addWidget( scroller );
664 panel_layout->addWidget( panel );
665 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
668 setLayout( panel_layout );
670 #undef END_SPREFS_CAT
671 #undef START_SPREFS_CAT
672 #undef CONFIG_GENERIC_FILE
673 #undef CONFIG_GENERIC_NO_BOOL
674 #undef CONFIG_GENERIC2
675 #undef CONFIG_GENERIC
679 void SPrefsPanel::updateAudioOptions( int number)
681 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
682 ->itemData( number ).toString();
684 optionWidgets[directxW]->setVisible( ( value == "directx" ) );
686 /* optionWidgets[ossW] can be NULL */
687 if( optionWidgets[ossW] )
688 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
689 /* optionWidgets[alsaW] can be NULL */
690 if( optionWidgets[alsaW] )
691 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
693 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
694 optionWidgets[spdifChB]->setVisible( ( value != "aout_file"
695 && value != "dummy" ) );
699 SPrefsPanel::~SPrefsPanel()
701 qDeleteAll( controls ); controls.clear();
704 void SPrefsPanel::updateAudioVolume( int volume )
706 qobject_cast<QSpinBox *>(optionWidgets[volLW])
707 ->setValue( volume * 100 / 256 );
711 /* Function called from the main Preferences dialog on each SPrefs Panel */
712 void SPrefsPanel::apply()
714 /* Generic save for ever panel */
715 QList<ConfigControl *>::Iterator i;
716 for( i = controls.begin() ; i != controls.end() ; i++ )
718 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
719 c->doApply( p_intf );
724 case SPrefsInputAndCodecs:
726 /* Device default selection */
727 char *psz_devicepath =
728 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
729 if( !EMPTY_STR( psz_devicepath ) )
731 config_PutPsz( p_intf, "dvd", psz_devicepath );
732 config_PutPsz( p_intf, "vcd", psz_devicepath );
733 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
734 free( psz_devicepath );
737 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
738 #define CaC( name ) CaCi( name, 1 )
740 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
741 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
744 CaC( "udp-caching" );
745 if (module_exists ("dvdread" ))
746 CaC( "dvdread-caching" );
747 if (module_exists ("dvdnav" ))
748 CaC( "dvdnav-caching" );
749 CaC( "tcp-caching" ); CaC( "vcd-caching" );
750 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
751 CaC( "screen-caching" ); CaC( "bd-caching" );
752 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
753 CaCi( "http-caching", 2 );
754 if (module_exists ("access_realrtsp" ))
755 CaCi( "realrtsp-caching", 10 );
756 CaCi( "mms-caching", 10 );
758 CaC( "dshow-caching" );
760 if (module_exists ( "v4l" ))
761 CaC( "v4l-caching" );
762 if (module_exists ( "access_jack" ))
763 CaC( "jack-input-caching" );
764 if (module_exists ( "v4l2" ))
765 CaC( "v4l2-caching" );
766 if (module_exists ( "pvr" ))
767 CaC( "pvr-caching" );
769 //CaCi( "dv-caching" ) too short...
777 case SPrefsInterface:
779 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
780 config_PutPsz( p_intf, "intf", "skins2" );
781 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
782 config_PutPsz( p_intf, "intf", "qt" );
783 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
784 getSettings()->setValue( "MainWindow/QtStyle",
785 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
793 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
794 if( b_checked && !qs_filter.contains( "volnorm" ) )
795 qs_filter.append( "volnorm" );
796 if( !b_checked && qs_filter.contains( "volnorm" ) )
797 qs_filter.removeAll( "volnorm" );
800 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
802 if( b_checked && !qs_filter.contains( "headphone" ) )
803 qs_filter.append( "headphone" );
804 if( !b_checked && qs_filter.contains( "headphone" ) )
805 qs_filter.removeAll( "headphone" );
807 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
813 void SPrefsPanel::clean()
816 void SPrefsPanel::lastfm_Changed( int i_state )
818 if( i_state == Qt::Checked )
819 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
820 else if( i_state == Qt::Unchecked )
821 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
824 void SPrefsPanel::changeStyle( QString s_style )
826 QApplication::setStyle( s_style );
828 /* force refresh on all widgets */
829 QWidgetList widgets = QApplication::allWidgets();
830 QWidgetList::iterator it = widgets.begin();
831 while( it != widgets.end() ) {
838 #include <QDialogButtonBox>
839 #include <QHeaderView>
840 #include "util/registry.hpp"
843 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
844 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
847 const char* psz_VLC = "VLC";
848 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
850 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
852 current->setCheckState( 0, Qt::Checked );
857 current->setCheckState( 0, Qt::Unchecked );
860 listAsso.append( current );
864 void SPrefsPanel::assoDialog()
866 OSVERSIONINFO winVer;
867 winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
868 //Vista specific file associations
869 if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
871 LPAPPASSOCREGUI p_appassoc;
874 if( S_OK == CoCreateInstance( &clsid_IApplication2,
875 NULL, CLSCTX_INPROC_SERVER,
876 &IID_IApplicationAssociationRegistrationUI,
877 (void **)&p_appassoc) )
879 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
888 QDialog *d = new QDialog( this );
889 QGridLayout *assoLayout = new QGridLayout( d );
891 QTreeWidget *filetypeList = new QTreeWidget;
892 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
893 filetypeList->header()->hide();
895 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
897 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
898 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
899 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
901 filetypeList->addTopLevelItem( audioType );
902 filetypeList->addTopLevelItem( videoType );
903 filetypeList->addTopLevelItem( otherType );
905 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
906 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
907 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
909 QTreeWidgetItem *currentItem;
912 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
913 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
914 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
916 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
917 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
918 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
919 aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
920 audioType->setCheckState( 0, ( i_temp > 0 ) ?
921 ( ( i_temp == audioType->childCount() ) ?
922 Qt::Checked : Qt::PartiallyChecked )
926 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
927 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
928 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
929 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
930 aTv( ".mts" ); aTv( ".mxf" );
931 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
932 aTv( ".vob" ); aTv( ".wmv" );
933 videoType->setCheckState( 0, ( i_temp > 0 ) ?
934 ( ( i_temp == audioType->childCount() ) ?
935 Qt::Checked : Qt::PartiallyChecked )
939 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
941 otherType->setCheckState( 0, ( i_temp > 0 ) ?
942 ( ( i_temp == audioType->childCount() ) ?
943 Qt::Checked : Qt::PartiallyChecked )
950 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
951 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
952 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
953 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
954 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
956 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
958 CONNECT( closeButton, clicked(), this, saveAsso() );
959 CONNECT( clearButton, clicked(), d, reject() );
960 d->resize( 300, 400 );
967 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
969 std::string s_path( "VLC" ); s_path += psz_ext;
970 std::string s_path2 = s_path;
972 /* Save a backup if already assigned */
973 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
975 if( psz_value && strlen( psz_value ) > 0 )
976 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
979 /* Put a "link" to VLC.EXT as default */
980 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
982 /* Create the needed Key if they weren't done in the installer */
983 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
985 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
986 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
987 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
989 /* Get the installer path */
990 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
991 std::string str_temp; str_temp.assign(
992 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
994 if( str_temp.size() )
996 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
997 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
999 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1000 "", str_temp.append(",0").c_str() );
1006 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1008 char psz_VLC[] = "VLC";
1009 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1011 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1014 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1016 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1018 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1020 delete( psz_value );
1022 void SPrefsPanel::saveAsso()
1024 QVLCRegistry * qvReg;
1025 for( int i = 0; i < listAsso.size(); i ++ )
1027 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1028 if( listAsso[i]->checkState( 0 ) > 0 )
1030 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1034 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1038 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();