1 /*****************************************************************************
2 * simple_preferences.cpp : "Simple preferences"
3 ****************************************************************************
4 * Copyright (C) 2006-2010 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"
32 #include "dialogs/ml_configuration.hpp"
34 #include <vlc_config_cat.h>
35 #include <vlc_configuration.h>
36 #include <vlc_aout_intf.h>
40 #include <QToolButton>
41 #include <QButtonGroup>
42 #include <QVBoxLayout>
43 #include <QScrollArea>
45 #include <QStyleFactory>
47 #include <QtAlgorithms>
50 #define ICON_HEIGHT 64
53 # include <vlc_windows_interfaces.h>
55 #include <vlc_modules.h>
57 /*********************************************************************
58 * The List of categories
59 *********************************************************************/
60 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
61 QWidget( _parent ), p_intf( _p_intf )
63 QVBoxLayout *layout = new QVBoxLayout();
65 QButtonGroup *buttonGroup = new QButtonGroup( this );
66 buttonGroup->setExclusive ( true );
67 CONNECT( buttonGroup, buttonClicked ( int ),
68 this, switchPanel( int ) );
70 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
72 #define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
73 QToolButton * button = new QToolButton( this ); \
74 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
75 button->setText( label ); \
76 button->setToolTip( ltooltip ); \
77 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
78 button->setIconSize( QSize( icon_height, icon_height ) ); \
79 button->resize( icon_height + 6 , icon_height + 6 ); \
80 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
81 button->setAutoRaise( true ); \
82 button->setCheckable( true ); \
83 buttonGroup->addButton( button, numb ); \
84 layout->addWidget( button );
86 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
87 cone_interface_64, 0 );
88 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
90 ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
92 ADD_CATEGORY( SPrefsSubtitles, SUBPIC_TITLE, qtr("Subtitles & On Screen Display Settings"),
93 cone_subtitles_64, 3 );
94 ADD_CATEGORY( SPrefsInputAndCodecs, INPUT_TITLE, qtr("Input & Codecs Settings"),
96 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
101 SPrefsInterface->setChecked( true );
102 layout->setMargin( 0 );
103 layout->setSpacing( 1 );
105 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
110 void SPrefsCatList::switchPanel( int i )
112 emit currentItemChanged( i );
115 /*********************************************************************
117 *********************************************************************/
118 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
119 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
121 module_config_t *p_config;
122 ConfigControl *control;
125 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
126 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
129 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
130 p_config, label, ui.qcontrol, false ); \
131 controls.append( control ); \
134 ui.qcontrol->setEnabled( false ); \
135 if( label ) label->setEnabled( false ); \
138 #define CONFIG_BOOL( option, qcontrol ) \
139 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
142 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
143 p_config, NULL, ui.qcontrol ); \
144 controls.append( control ); \
146 else { ui.qcontrol->setEnabled( false ); }
149 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
150 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
153 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
154 p_config, label, qcontrol, false ); \
155 controls.append( control ); \
158 QWidget *widget = label; \
159 qcontrol->setVisible( false ); \
160 if( widget ) widget->setEnabled( false ); \
164 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
165 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
168 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
169 p_config, label, ui.qcontrol ); \
170 controls.append( control ); \
173 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
174 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
177 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
178 p_config, label, qcontrol, qbutton ); \
179 controls.append( control ); \
182 #define START_SPREFS_CAT( name , label ) \
183 case SPrefs ## name: \
185 Ui::SPrefs ## name ui; \
186 ui.setupUi( panel ); \
187 panel_label->setText( label );
189 #define END_SPREFS_CAT \
193 QVBoxLayout *panel_layout = new QVBoxLayout();
194 QWidget *panel = new QWidget();
195 panel_layout->setMargin( 3 );
198 QLabel *panel_label = new QLabel;
199 QFont labelFont = QApplication::font();
200 labelFont.setPointSize( labelFont.pointSize() + 6 );
201 panel_label->setFont( labelFont );
204 QFrame *title_line = new QFrame;
205 title_line->setFrameShape(QFrame::HLine);
206 title_line->setFrameShadow(QFrame::Sunken);
208 QFont italicFont = QApplication::font();
209 italicFont.setItalic( true );
213 /******************************
214 * VIDEO Panel Implementation *
215 ******************************/
216 START_SPREFS_CAT( Video , qtr("Video Settings") );
217 CONFIG_BOOL( "video", enableVideo );
219 CONFIG_BOOL( "fullscreen", fullscreen );
220 CONFIG_BOOL( "overlay", overlay );
221 CONFIG_BOOL( "video-on-top", alwaysOnTop );
222 CONFIG_BOOL( "video-deco", windowDecorations );
223 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
226 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
228 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
229 CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
231 ui.directXBox->setVisible( false );
232 ui.hwYUVBox->setVisible( false );
236 CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
237 CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
240 ui.kvaBox->setVisible( false );
243 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
244 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
245 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
247 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
248 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
249 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
250 CONFIG_BOOL( "snapshot-sequential",
251 snapshotsSequentialNumbering );
252 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
256 /******************************
257 * AUDIO Panel Implementation *
258 ******************************/
259 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
261 CONFIG_BOOL( "audio", enableAudio );
262 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
263 CONNECT( ui.enableAudio, toggled( bool ),
264 ui.SPrefsAudio_zone, setEnabled( bool ) );
266 #define audioCommon( name ) \
267 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
268 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
269 name ## Layout->setMargin( 0 ); \
270 name ## Layout->setSpacing( 0 ); \
271 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
272 name ## Label->setMinimumSize(QSize(250, 0)); \
273 name ## Layout->addWidget( name ## Label ); \
275 #define audioControl( name) \
276 audioCommon( name ) \
277 QComboBox * name ## Device = new QComboBox( name ## Control ); \
278 name ## Layout->addWidget( name ## Device ); \
279 name ## Label->setBuddy( name ## Device ); \
280 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
281 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
283 #define audioControl2( name) \
284 audioCommon( name ) \
285 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
286 name ## Layout->addWidget( name ## Device ); \
287 name ## Label->setBuddy( name ## Device ); \
288 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
289 name ## Layout->addWidget( name ## Browse ); \
290 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
292 /* Build if necessary */
293 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
295 audioControl( DirectX );
296 optionWidgets.append( DirectXControl );
297 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
298 DirectXLabel, DirectXDevice );
299 #elif defined( __OS2__ )
301 optionWidgets.append( kaiControl );
302 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
305 if( module_exists( "alsa" ) )
307 audioControl( alsa );
308 optionWidgets.append( alsaControl );
309 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
313 optionWidgets.append( NULL );
314 if( module_exists( "oss" ) )
316 audioControl2( OSS );
317 optionWidgets.append( OSSControl );
318 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
322 optionWidgets.append( NULL );
330 ui.volumeValue->setMaximum( (AOUT_VOLUME_DEFAULT * 2) / AOUT_VOLUME_DEFAULT * 100 );
331 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
333 CONNECT( ui.defaultVolume, valueChanged( int ),
334 this, updateAudioVolume( int ) );
336 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
337 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
338 CONNECT( ui.resetVolumeRadio, toggled( bool ),
339 ui.defaultVolume_zone, setEnabled( bool ) );
341 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
342 preferredAudioLanguage );
344 CONFIG_BOOL( "spdif", spdifBox );
345 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
348 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
350 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
352 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
354 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
356 /* Audio Output Specifics */
357 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
359 CONNECT( ui.outputModule, currentIndexChanged( int ),
360 this, updateAudioOptions( int ) );
362 /* File output exists on all platforms */
363 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
364 ui.fileName, ui.fileBrowseButton );
366 optionWidgets.append( ui.fileControl );
367 optionWidgets.append( ui.outputModule );
368 optionWidgets.append( ui.volNormBox );
369 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
370 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
371 optionWidgets.append( ui.volumeValue );
372 optionWidgets.append( ui.headphoneEffect );
373 optionWidgets.append( ui.spdifBox );
374 updateAudioOptions( ui.outputModule->currentIndex() );
377 if( module_exists( "audioscrobbler" ) )
379 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
381 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
384 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
385 ui.lastfm->setChecked( true );
387 ui.lastfm->setChecked( false );
389 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
391 CONNECT( ui.lastfm, toggled( bool ),
392 ui.lastfm_zone, setVisible( bool ) );
393 CONNECT( ui.lastfm, stateChanged( int ),
394 this, lastfm_Changed( int ) );
399 ui.lastfm_zone->hide();
403 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
404 setEnabled( bool ) );
406 char* psz = config_GetPsz( p_intf, "audio-filter" );
407 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
410 bool b_enabled = ( qs_filter.contains( "normvol" ) );
411 ui.volNormBox->setChecked( b_enabled );
412 ui.volNormSpin->setEnabled( b_enabled );
414 b_enabled = ( qs_filter.contains( "headphone" ) );
415 ui.headphoneEffect->setChecked( b_enabled );
418 updateAudioVolume( ui.defaultVolume->value() ); // First time init
422 /* Input and Codecs Panel Implementation */
423 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
427 ui.DVDDeviceComboBox->setToolTip(
428 qtr( "If this property is blank, different values\n"
429 "for DVD, VCD, and CDDA are set.\n"
430 "You can define a unique one or configure them \n"
431 "individually in the advanced preferences." ) );
432 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
433 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
434 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
435 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
436 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
437 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
439 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
441 free( psz_cddadiscpath );
442 free( psz_dvddiscpath );
443 free( psz_vcddiscpath );
446 QStringList DVDDeviceComboBoxStringList = QStringList();
447 DVDDeviceComboBoxStringList
448 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
449 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
450 .entryList( DVDDeviceComboBoxStringList, QDir::System )
451 .replaceInStrings( QRegExp("^"), "/dev/" )
454 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
455 DVDDeviceComboBox->lineEdit() );
456 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
457 ui.recordPath, ui.recordBrowse );
459 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
460 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
462 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
464 /* live555 module prefs */
465 CONFIG_BOOL( "rtsp-tcp",
466 live555TransportRTSP_TCPRadio );
467 if ( !module_exists( "live555" ) )
469 ui.live555TransportRTSP_TCPRadio->hide();
470 ui.live555TransportHTTPRadio->hide();
471 ui.live555TransportLabel->hide();
473 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
475 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
476 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
478 ui.hwAccelBox->setEnabled( false );
480 FreeLibrary( hdxva2_dll );
482 ui.systemCodecBox->hide();
484 optionWidgets.append( ui.DVDDeviceComboBox );
485 optionWidgets.append( ui.cachingCombo );
486 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
487 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
488 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
489 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
490 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
491 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
494 /* Add the things to the ComboBox */
495 #define addToCachingBox( str, cachingNumber ) \
496 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
497 addToCachingBox( N_("Custom"), CachingCustom );
498 addToCachingBox( N_("Lowest latency"), CachingLowest );
499 addToCachingBox( N_("Low latency"), CachingLow );
500 addToCachingBox( N_("Normal"), CachingNormal );
501 addToCachingBox( N_("High latency"), CachingHigh );
502 addToCachingBox( N_("Higher latency"), CachingHigher );
503 #undef addToCachingBox
505 #define TestCaC( name, factor ) \
506 b_cache_equal = b_cache_equal && \
507 ( i_cache * factor == config_GetInt( p_intf, name ) );
508 /* Select the accurate value of the ComboBox */
509 bool b_cache_equal = true;
510 int i_cache = config_GetInt( p_intf, "file-caching" );
512 TestCaC( "network-caching", 10/3 );
513 TestCaC( "disc-caching", 1);
514 TestCaC( "live-caching", 1 );
515 if( b_cache_equal == 1 )
516 ui.cachingCombo->setCurrentIndex(
517 ui.cachingCombo->findData( QVariant( i_cache ) ) );
524 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
525 // ui.defaultLabel->setFont( italicFont );
526 ui.skinsLabel->setText(
527 qtr( "This is VLC's skinnable interface. You can download other skins at" )
528 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
529 + qtr( "VLC skins website" )+ QString( "</a>." ) );
530 ui.skinsLabel->setFont( italicFont );
533 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
534 BUTTONACT( ui.assoButton, assoDialog() );
536 ui.languageBox->hide();
537 ui.assoButton->hide();
538 ui.assocLabel->hide();
541 BUTTONACT( ui.sqlMLbtn, configML() );
547 char *psz_intf = config_GetPsz( p_intf, "intf" );
550 if( strstr( psz_intf, "skin" ) )
551 ui.skins->setChecked( true );
554 ui.qt4->setChecked( true );
558 optionWidgets.append( ui.skins );
559 optionWidgets.append( ui.qt4 );
561 ui.stylesCombo->addItem( qtr("System's default") );
562 ui.stylesCombo->addItems( QStyleFactory::keys() );
563 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
564 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
565 ui.stylesCombo->insertSeparator( 1 );
566 if ( ui.stylesCombo->currentIndex() < 0 )
567 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
569 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
570 optionWidgets.append( ui.stylesCombo );
572 ui.stylesCombo->hide();
573 ui.stylesLabel->hide();
574 optionWidgets.append( NULL );
576 radioGroup = new QButtonGroup(this);
577 radioGroup->addButton( ui.qt4, 0 );
578 radioGroup->addButton( ui.skins, 1 );
579 CONNECT( radioGroup, buttonClicked( int ),
580 ui.styleStackedWidget, setCurrentIndex( int ) );
581 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
583 CONNECT( ui.minimalviewBox, toggled( bool ),
584 ui.mainPreview, setNormalPreview( bool ) );
585 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
586 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
587 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
589 CONFIG_BOOL( "embedded-video", embedVideo );
590 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
591 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
592 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
594 CONFIG_BOOL( "qt-fs-controller", fsController );
595 CONFIG_BOOL( "qt-system-tray", systrayBox );
596 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
598 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
599 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
601 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
602 CONFIG_BOOL( "playlist-tree", treePlaylist );
603 CONFIG_BOOL( "play-and-pause", playPauseBox );
604 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
605 ui.fileSkin, ui.skinBrowse );
607 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
612 CONFIG_BOOL( "qt-updates-notif", updatesBox );
613 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
615 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
616 CONNECT( ui.updatesBox, toggled( bool ),
617 ui.updatesDays, setEnabled( bool ) );
619 ui.updateNotifierZone->hide();
621 /* ONE INSTANCE options */
622 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
623 CONFIG_BOOL( "one-instance", OneInterfaceMode );
624 CONFIG_BOOL( "playlist-enqueue",
625 EnqueueOneInterfaceMode );
626 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
627 CONNECT( ui.OneInterfaceMode, toggled( bool ),
628 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
630 ui.OneInterfaceBox->hide();
632 /* RECENTLY PLAYED options */
633 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
634 ui.recentlyPlayedFilters, setEnabled( bool ) );
635 ui.recentlyPlayedFilters->setEnabled( false );
636 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
637 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
638 recentlyPlayedFilters );
642 START_SPREFS_CAT( Subtitles,
643 qtr("Subtitles & On Screen Display Settings") );
644 CONFIG_BOOL( "osd", OSDBox);
645 CONFIG_BOOL( "video-title-show", OSDTitleBox);
646 CONFIG_GENERIC( "video-title-position", IntegerList,
647 ui.OSDTitlePosLabel, OSDTitlePos );
649 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
651 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
654 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
655 ui.fontSizeLabel, fontSize );
657 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
658 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
660 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
661 ui.fontEffectLabel, effect );
662 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
665 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
667 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
668 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
669 optionWidgets.append( ui.shadowCheck );
670 optionWidgets.append( ui.backgroundCheck );
676 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
678 QGridLayout *gLayout = new QGridLayout;
679 panel->setLayout( gLayout );
682 panel_label->setText( qtr( "Configure Hotkeys" ) );
683 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
684 control->insertIntoExistingGrid( gLayout, line );
685 controls.append( control );
689 QFrame *sepline = new QFrame;
690 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
691 gLayout->addWidget( sepline, line, 0, 1, -1 );
695 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
696 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
697 p_config, this, false );
698 control->insertIntoExistingGrid( gLayout, line );
699 controls.append( control );
704 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
705 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
706 control->insertIntoExistingGrid( gLayout, line );
707 controls.append( control );
714 panel_layout->addWidget( panel_label );
715 panel_layout->addWidget( title_line );
719 QScrollArea *scroller= new QScrollArea;
720 scroller->setWidget( panel );
721 scroller->setWidgetResizable( true );
722 scroller->setFrameStyle( QFrame::NoFrame );
723 panel_layout->addWidget( scroller );
727 panel_layout->addWidget( panel );
728 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
731 setLayout( panel_layout );
733 #undef END_SPREFS_CAT
734 #undef START_SPREFS_CAT
735 #undef CONFIG_GENERIC_FILE
736 #undef CONFIG_GENERIC_NO_BOOL
737 #undef CONFIG_GENERIC_NO_UI
738 #undef CONFIG_GENERIC
743 void SPrefsPanel::updateAudioOptions( int number)
745 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
746 ->itemData( number ).toString();
748 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
749 #elif defined( __OS2__ )
750 optionWidgets[kaiW]->setVisible( ( value == "kai" ) );
752 /* optionWidgets[ossW] can be NULL */
753 if( optionWidgets[ossW] )
754 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
755 /* optionWidgets[alsaW] can be NULL */
756 if( optionWidgets[alsaW] )
757 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
759 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
760 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
761 value == "aout_directx" || value == "waveout" ) );
765 SPrefsPanel::~SPrefsPanel()
767 qDeleteAll( controls ); controls.clear();
770 void SPrefsPanel::updateAudioVolume( int volume )
772 qobject_cast<QSpinBox *>(optionWidgets[volLW])
773 ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
777 /* Function called from the main Preferences dialog on each SPrefs Panel */
778 void SPrefsPanel::apply()
780 /* Generic save for ever panel */
781 QList<ConfigControl *>::const_iterator i;
782 for( i = controls.begin() ; i != controls.end() ; ++i )
784 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
790 case SPrefsInputAndCodecs:
792 /* Device default selection */
793 QByteArray devicepath =
794 qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
795 if( devicepath.size() > 0 )
797 config_PutPsz( p_intf, "dvd", devicepath );
798 config_PutPsz( p_intf, "vcd", devicepath );
799 config_PutPsz( p_intf, "cd-audio", devicepath );
802 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
804 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
805 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
808 CaC( "file-caching", 1 );
809 CaC( "network-caching", 10/3 );
810 CaC( "disc-caching", 1 );
811 CaC( "live-caching", 1 );
818 case SPrefsInterface:
820 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
821 config_PutPsz( p_intf, "intf", "skins2,any" );
823 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
824 config_PutPsz( p_intf, "intf", "" );
825 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
826 getSettings()->setValue( "MainWindow/QtStyle",
827 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
835 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
836 if( b_checked && !qs_filter.contains( "normvol" ) )
837 qs_filter.append( "normvol" );
838 if( !b_checked && qs_filter.contains( "normvol" ) )
839 qs_filter.removeAll( "normvol" );
842 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
844 if( b_checked && !qs_filter.contains( "headphone" ) )
845 qs_filter.append( "headphone" );
846 if( !b_checked && qs_filter.contains( "headphone" ) )
847 qs_filter.removeAll( "headphone" );
849 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
852 case SPrefsSubtitles:
854 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
855 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
856 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
858 else if (!b_checked ) {
859 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
862 b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
863 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
864 config_PutInt( p_intf, "freetype-background-opacity", 128 );
866 else if (!b_checked ) {
867 config_PutInt( p_intf, "freetype-background-opacity", 0 );
874 void SPrefsPanel::clean()
877 void SPrefsPanel::lastfm_Changed( int i_state )
879 if( i_state == Qt::Checked )
880 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
881 else if( i_state == Qt::Unchecked )
882 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
885 void SPrefsPanel::changeStyle( QString s_style )
887 QApplication::setStyle( s_style );
889 /* force refresh on all widgets */
890 QWidgetList widgets = QApplication::allWidgets();
891 QWidgetList::iterator it = widgets.begin();
892 while( it != widgets.end() ) {
898 void SPrefsPanel::configML()
901 MLConfDialog *mld = new MLConfDialog( this, p_intf );
908 #include <QDialogButtonBox>
909 #include "util/registry.hpp"
911 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
912 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
915 const char* psz_VLC = "VLC";
916 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
918 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
920 current->setCheckState( 0, Qt::Checked );
925 current->setCheckState( 0, Qt::Unchecked );
928 listAsso.append( current );
932 void SPrefsPanel::assoDialog()
934 IApplicationAssociationRegistrationUI *p_appassoc;
937 if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
938 NULL, CLSCTX_INPROC_SERVER,
939 IID_IApplicationAssociationRegistrationUI,
940 (void **)&p_appassoc) )
942 if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
951 QDialog *d = new QDialog( this );
952 d->setWindowTitle( qtr( "File associations" ) );
953 QGridLayout *assoLayout = new QGridLayout( d );
955 QTreeWidget *filetypeList = new QTreeWidget;
956 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
957 filetypeList->header()->hide();
959 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
961 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
962 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
963 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
965 filetypeList->addTopLevelItem( audioType );
966 filetypeList->addTopLevelItem( videoType );
967 filetypeList->addTopLevelItem( otherType );
969 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
970 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
971 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
973 QTreeWidgetItem *currentItem = NULL;
976 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
977 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
978 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
980 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
981 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
982 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
983 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
984 audioType->setCheckState( 0, ( i_temp > 0 ) ?
985 ( ( i_temp == audioType->childCount() ) ?
986 Qt::Checked : Qt::PartiallyChecked )
990 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
991 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
992 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
993 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
994 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
995 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
996 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
997 videoType->setCheckState( 0, ( i_temp > 0 ) ?
998 ( ( i_temp == audioType->childCount() ) ?
999 Qt::Checked : Qt::PartiallyChecked )
1003 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1004 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1005 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1006 ( ( i_temp == audioType->childCount() ) ?
1007 Qt::Checked : Qt::PartiallyChecked )
1014 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1015 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1016 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1017 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1018 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1020 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1022 CONNECT( closeButton, clicked(), this, saveAsso() );
1023 CONNECT( clearButton, clicked(), d, reject() );
1024 d->resize( 300, 400 );
1031 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1033 QString s_path( "VLC" ); s_path += psz_ext;
1034 QString s_path2 = s_path;
1036 /* Save a backup if already assigned */
1037 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1039 if( !EMPTY_STR(psz_value) )
1040 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1043 /* Put a "link" to VLC.EXT as default */
1044 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1046 /* Create the needed Key if they weren't done in the installer */
1047 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1049 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1050 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1051 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1053 /* Get the installer path */
1054 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1055 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1057 if( str_temp.size() )
1059 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1060 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1062 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1063 "", qtu( str_temp.append(",0") ) );
1069 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1071 char psz_VLC[] = "VLC";
1072 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1074 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1077 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1079 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1081 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1083 delete( psz_value );
1085 void SPrefsPanel::saveAsso()
1087 QVLCRegistry * qvReg = NULL;
1088 for( int i = 0; i < listAsso.size(); i ++ )
1090 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1091 if( listAsso[i]->checkState( 0 ) > 0 )
1093 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1097 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1101 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();