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, icon, numb ) \
73 QToolButton * button = new QToolButton( this ); \
74 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
75 button->setText( label ); \
76 button->setToolTip( label + qtr("Preferences") ); \
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"),
87 cone_interface_64, 0 );
88 ADD_CATEGORY( SPrefsAudio, qtr("Audio"),
90 ADD_CATEGORY( SPrefsVideo, qtr("Video"),
92 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
93 cone_subtitles_64, 3 );
94 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
96 ADD_CATEGORY( SPrefsHotkeys, qtr("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 );
225 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
227 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
229 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
231 ui.directXBox->setVisible( false );
232 ui.hwYUVBox->setVisible( false );
235 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
236 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
237 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
239 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
240 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
241 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
242 CONFIG_BOOL( "snapshot-sequential",
243 snapshotsSequentialNumbering );
244 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
248 /******************************
249 * AUDIO Panel Implementation *
250 ******************************/
251 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
253 CONFIG_BOOL( "audio", enableAudio );
254 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
255 CONNECT( ui.enableAudio, toggled( bool ),
256 ui.SPrefsAudio_zone, setEnabled( bool ) );
258 #define audioCommon( name ) \
259 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
260 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
261 name ## Layout->setMargin( 0 ); \
262 name ## Layout->setSpacing( 0 ); \
263 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
264 name ## Label->setMinimumSize(QSize(250, 0)); \
265 name ## Layout->addWidget( name ## Label ); \
267 #define audioControl( name) \
268 audioCommon( name ) \
269 QComboBox * name ## Device = new QComboBox( name ## Control ); \
270 name ## Layout->addWidget( name ## Device ); \
271 name ## Label->setBuddy( name ## Device ); \
272 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
273 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
275 #define audioControl2( name) \
276 audioCommon( name ) \
277 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
278 name ## Layout->addWidget( name ## Device ); \
279 name ## Label->setBuddy( name ## Device ); \
280 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
281 name ## Layout->addWidget( name ## Browse ); \
282 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
284 /* Build if necessary */
285 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
287 audioControl( DirectX );
288 optionWidgets.append( DirectXControl );
289 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
290 DirectXLabel, DirectXDevice );
292 if( module_exists( "alsa" ) )
294 audioControl( alsa );
295 optionWidgets.append( alsaControl );
296 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
300 optionWidgets.append( NULL );
301 if( module_exists( "oss" ) )
303 audioControl2( OSS );
304 optionWidgets.append( OSSControl );
305 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
309 optionWidgets.append( NULL );
317 ui.volumeValue->setMaximum( QT_VOLUME_MAX / QT_VOLUME_DEFAULT * 100 );
318 CONFIG_GENERIC_NO_BOOL( "qt-startvolume" , IntegerRangeSlider, NULL,
320 CONNECT( ui.defaultVolume, valueChanged( int ),
321 this, updateAudioVolume( int ) );
323 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
324 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
325 CONNECT( ui.resetVolumeRadio, toggled( bool ),
326 ui.defaultVolume_zone, setEnabled( bool ) );
328 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
329 preferredAudioLanguage );
331 CONFIG_BOOL( "spdif", spdifBox );
332 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
335 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
337 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
339 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
341 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
343 /* Audio Output Specifics */
344 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
346 CONNECT( ui.outputModule, currentIndexChanged( int ),
347 this, updateAudioOptions( int ) );
349 /* File output exists on all platforms */
350 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
351 ui.fileName, ui.fileBrowseButton );
353 optionWidgets.append( ui.fileControl );
354 optionWidgets.append( ui.outputModule );
355 optionWidgets.append( ui.volNormBox );
356 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
357 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
358 optionWidgets.append( ui.volumeValue );
359 optionWidgets.append( ui.headphoneEffect );
360 optionWidgets.append( ui.spdifBox );
361 updateAudioOptions( ui.outputModule->currentIndex() );
364 if( module_exists( "audioscrobbler" ) )
366 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
368 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
371 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
372 ui.lastfm->setChecked( true );
374 ui.lastfm->setChecked( false );
376 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
378 CONNECT( ui.lastfm, toggled( bool ),
379 ui.lastfm_zone, setVisible( bool ) );
380 CONNECT( ui.lastfm, stateChanged( int ),
381 this, lastfm_Changed( int ) );
386 ui.lastfm_zone->hide();
390 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
391 setEnabled( bool ) );
393 char* psz = config_GetPsz( p_intf, "audio-filter" );
394 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
397 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
398 ui.volNormBox->setChecked( b_enabled );
399 ui.volNormSpin->setEnabled( b_enabled );
401 b_enabled = ( qs_filter.contains( "headphone" ) );
402 ui.headphoneEffect->setChecked( b_enabled );
405 updateAudioVolume( ui.defaultVolume->value() ); // First time init
409 /* Input and Codecs Panel Implementation */
410 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
414 ui.DVDDeviceComboBox->setToolTip(
415 qtr( "If this property is blank, different values\n"
416 "for DVD, VCD, and CDDA are set.\n"
417 "You can define a unique one or configure them \n"
418 "individually in the advanced preferences." ) );
419 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
420 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
421 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
422 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
423 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
424 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
426 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
428 free( psz_cddadiscpath );
429 free( psz_dvddiscpath );
430 free( psz_vcddiscpath );
433 QStringList DVDDeviceComboBoxStringList = QStringList();
434 DVDDeviceComboBoxStringList
435 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
436 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
437 .entryList( DVDDeviceComboBoxStringList, QDir::System )
438 .replaceInStrings( QRegExp("^"), "/dev/" )
441 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
442 DVDDeviceComboBox->lineEdit() );
443 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
444 ui.recordPath, ui.recordBrowse );
446 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
447 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
449 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
451 /* live555 module prefs */
452 CONFIG_BOOL( "rtsp-tcp",
453 live555TransportRTSP_TCPRadio );
454 if ( !module_exists( "live555" ) )
456 ui.live555TransportRTSP_TCPRadio->hide();
457 ui.live555TransportHTTPRadio->hide();
458 ui.live555TransportLabel->hide();
460 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
462 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
463 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
465 ui.hwAccelBox->setEnabled( false );
467 FreeLibrary( hdxva2_dll );
469 ui.systemCodecBox->hide();
471 optionWidgets.append( ui.DVDDeviceComboBox );
472 optionWidgets.append( ui.cachingCombo );
473 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
474 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
475 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
476 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
477 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
480 /* Add the things to the ComboBox */
481 #define addToCachingBox( str, cachingNumber ) \
482 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
483 addToCachingBox( N_("Custom"), CachingCustom );
484 addToCachingBox( N_("Lowest latency"), CachingLowest );
485 addToCachingBox( N_("Low latency"), CachingLow );
486 addToCachingBox( N_("Normal"), CachingNormal );
487 addToCachingBox( N_("High latency"), CachingHigh );
488 addToCachingBox( N_("Higher latency"), CachingHigher );
489 #undef addToCachingBox
491 #define TestCaC( name ) \
492 b_cache_equal = b_cache_equal && \
493 ( i_cache == config_GetInt( p_intf, name ) )
495 #define TestCaCi( name, int ) \
496 b_cache_equal = b_cache_equal && \
497 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
498 /* Select the accurate value of the ComboBox */
499 bool b_cache_equal = true;
500 int i_cache = config_GetInt( p_intf, "file-caching");
502 TestCaC( "udp-caching" );
503 if (module_exists ("dvdread"))
504 TestCaC( "dvdread-caching" );
505 if (module_exists ("dvdnav"))
506 TestCaC( "dvdnav-caching" );
507 TestCaC( "tcp-caching" );
508 TestCaC( "cdda-caching" );
509 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
511 TestCaC( "dshow-caching" );
513 if (module_exists ("access_jack"))
514 TestCaC( "jack-input-caching" );
515 if (module_exists ("v4l2"))
516 TestCaC( "v4l2-caching" );
517 if (module_exists ("pvr"))
518 TestCaC( "pvr-caching" );
520 if (module_exists ("livedotcom"))
521 TestCaCi( "rtsp-caching", 4 );
522 TestCaCi( "ftp-caching", 2 );
523 TestCaCi( "http-caching", 2 );
524 if (module_exists ("access_realrtsp"))
525 TestCaCi( "realrtsp-caching", 10 );
526 TestCaCi( "mms-caching", 10 );
527 if( b_cache_equal == 1 )
528 ui.cachingCombo->setCurrentIndex(
529 ui.cachingCombo->findData( QVariant( i_cache ) ) );
537 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
538 // ui.defaultLabel->setFont( italicFont );
539 ui.skinsLabel->setText(
540 qtr( "This is VLC's skinnable interface. You can download other skins at" )
541 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
542 + qtr( "VLC skins website" )+ QString( "</a>." ) );
543 ui.skinsLabel->setFont( italicFont );
546 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
547 BUTTONACT( ui.assoButton, assoDialog() );
549 ui.languageBox->hide();
550 ui.assoButton->hide();
551 ui.assocLabel->hide();
554 BUTTONACT( ui.sqlMLbtn, configML() );
558 char *psz_intf = config_GetPsz( p_intf, "intf" );
561 if( strstr( psz_intf, "skin" ) )
562 ui.skins->setChecked( true );
565 ui.qt4->setChecked( true );
569 optionWidgets.append( ui.skins );
570 optionWidgets.append( ui.qt4 );
571 #if !defined(NDEBUG) || !defined( WIN32)
572 ui.stylesCombo->addItem( qtr("System's default") );
573 ui.stylesCombo->addItems( QStyleFactory::keys() );
574 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
575 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
576 ui.stylesCombo->insertSeparator( 1 );
578 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
579 optionWidgets.append( ui.stylesCombo );
581 ui.stylesCombo->hide();
582 optionWidgets.append( NULL );
584 radioGroup = new QButtonGroup(this);
585 radioGroup->addButton( ui.qt4, 0 );
586 radioGroup->addButton( ui.skins, 1 );
587 CONNECT( radioGroup, buttonClicked( int ),
588 ui.styleStackedWidget, setCurrentIndex( int ) );
589 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
591 CONNECT( ui.minimalviewBox, toggled( bool ),
592 ui.mainPreview, setNormalPreview( bool ) );
593 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
594 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
595 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
597 CONFIG_BOOL( "embedded-video", embedVideo );
598 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
599 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
600 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
602 CONFIG_BOOL( "qt-fs-controller", fsController );
603 CONFIG_BOOL( "qt-system-tray", systrayBox );
604 CONFIG_BOOL( "qt-notification", sysPop );
605 CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) );
606 ui.sysPop->setEnabled( ui.systrayBox->isChecked() );
608 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
609 CONFIG_BOOL( "playlist-tree", treePlaylist );
610 CONFIG_BOOL( "play-and-pause", playPauseBox );
611 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
612 ui.fileSkin, ui.skinBrowse );
614 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
619 CONFIG_BOOL( "qt-updates-notif", updatesBox );
620 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
622 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
623 CONNECT( ui.updatesBox, toggled( bool ),
624 ui.updatesDays, setEnabled( bool ) );
626 ui.updateNotifierZone->hide();
628 /* ONE INSTANCE options */
629 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
630 CONFIG_BOOL( "one-instance", OneInterfaceMode );
631 CONFIG_BOOL( "playlist-enqueue",
632 EnqueueOneInterfaceMode );
633 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
634 CONNECT( ui.OneInterfaceMode, toggled( bool ),
635 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
637 ui.OneInterfaceBox->hide();
639 /* RECENTLY PLAYED options */
640 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
641 ui.recentlyPlayedFilters, setEnabled( bool ) );
642 ui.recentlyPlayedFilters->setEnabled( false );
643 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
644 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
645 recentlyPlayedFilters );
649 START_SPREFS_CAT( Subtitles,
650 qtr("Subtitles & On Screen Display Settings") );
651 CONFIG_BOOL( "osd", OSDBox);
652 CONFIG_BOOL( "video-title-show", OSDTitleBox);
653 CONFIG_GENERIC( "video-title-position", IntegerList,
654 ui.OSDTitlePosLabel, OSDTitlePos );
656 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
658 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
660 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
661 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
663 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
664 ui.fontSizeLabel, fontSize );
665 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
667 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
673 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
675 QGridLayout *gLayout = new QGridLayout;
676 panel->setLayout( gLayout );
679 panel_label->setText( qtr( "Configure Hotkeys" ) );
680 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
681 this, gLayout, line );
682 controls.append( control );
686 QFrame *sepline = new QFrame;
687 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
688 gLayout->addWidget( sepline, line, 0, 1, -1 );
692 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
693 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
694 p_config, this, false, gLayout, line );
695 controls.append( control );
700 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
701 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this, gLayout, line );
702 controls.append( control );
709 panel_layout->addWidget( panel_label );
710 panel_layout->addWidget( title_line );
714 QScrollArea *scroller= new QScrollArea;
715 scroller->setWidget( panel );
716 scroller->setWidgetResizable( true );
717 scroller->setFrameStyle( QFrame::NoFrame );
718 panel_layout->addWidget( scroller );
722 panel_layout->addWidget( panel );
723 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
726 setLayout( panel_layout );
728 #undef END_SPREFS_CAT
729 #undef START_SPREFS_CAT
730 #undef CONFIG_GENERIC_FILE
731 #undef CONFIG_GENERIC_NO_BOOL
732 #undef CONFIG_GENERIC_NO_UI
733 #undef CONFIG_GENERIC
738 void SPrefsPanel::updateAudioOptions( int number)
740 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
741 ->itemData( number ).toString();
743 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
745 /* optionWidgets[ossW] can be NULL */
746 if( optionWidgets[ossW] )
747 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
748 /* optionWidgets[alsaW] can be NULL */
749 if( optionWidgets[alsaW] )
750 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
752 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
753 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
754 value == "aout_directx" || value == "waveout" ) );
758 SPrefsPanel::~SPrefsPanel()
760 qDeleteAll( controls ); controls.clear();
763 void SPrefsPanel::updateAudioVolume( int volume )
765 qobject_cast<QSpinBox *>(optionWidgets[volLW])
766 ->setValue( volume * 100 / QT_VOLUME_DEFAULT );
770 /* Function called from the main Preferences dialog on each SPrefs Panel */
771 void SPrefsPanel::apply()
773 /* Generic save for ever panel */
774 QList<ConfigControl *>::const_iterator i;
775 for( i = controls.begin() ; i != controls.end() ; ++i )
777 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
783 case SPrefsInputAndCodecs:
785 /* Device default selection */
786 QByteArray devicepath =
787 qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
788 if( devicepath.size() > 0 )
790 config_PutPsz( p_intf, "dvd", devicepath );
791 config_PutPsz( p_intf, "vcd", devicepath );
792 config_PutPsz( p_intf, "cd-audio", devicepath );
795 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
796 #define CaC( name ) CaCi( name, 1 )
798 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
799 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
802 CaC( "udp-caching" );
803 if (module_exists ("dvdread" ))
804 CaC( "dvdread-caching" );
805 if (module_exists ("dvdnav" ))
806 CaC( "dvdnav-caching" );
807 CaC( "tcp-caching" ); CaC( "vcd-caching" );
808 CaC( "cdda-caching" ); CaC( "file-caching" );
809 CaC( "screen-caching" ); CaC( "bd-caching" );
810 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
811 CaCi( "http-caching", 2 );
812 if (module_exists ("access_realrtsp" ))
813 CaCi( "realrtsp-caching", 10 );
814 CaCi( "mms-caching", 10 );
816 CaC( "dshow-caching" );
818 if (module_exists ( "access_jack" ))
819 CaC( "jack-input-caching" );
820 if (module_exists ( "v4l2" ))
821 CaC( "v4l2-caching" );
822 if (module_exists ( "pvr" ))
823 CaC( "pvr-caching" );
825 //CaCi( "dv-caching" ) too short...
833 case SPrefsInterface:
835 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
836 config_PutPsz( p_intf, "intf", "skins2,any" );
838 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
839 config_PutPsz( p_intf, "intf", "" );
840 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
841 getSettings()->setValue( "MainWindow/QtStyle",
842 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
850 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
851 if( b_checked && !qs_filter.contains( "volnorm" ) )
852 qs_filter.append( "volnorm" );
853 if( !b_checked && qs_filter.contains( "volnorm" ) )
854 qs_filter.removeAll( "volnorm" );
857 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
859 if( b_checked && !qs_filter.contains( "headphone" ) )
860 qs_filter.append( "headphone" );
861 if( !b_checked && qs_filter.contains( "headphone" ) )
862 qs_filter.removeAll( "headphone" );
864 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
870 void SPrefsPanel::clean()
873 void SPrefsPanel::lastfm_Changed( int i_state )
875 if( i_state == Qt::Checked )
876 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
877 else if( i_state == Qt::Unchecked )
878 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
881 void SPrefsPanel::changeStyle( QString s_style )
883 QApplication::setStyle( s_style );
885 /* force refresh on all widgets */
886 QWidgetList widgets = QApplication::allWidgets();
887 QWidgetList::iterator it = widgets.begin();
888 while( it != widgets.end() ) {
894 void SPrefsPanel::configML()
897 MLConfDialog *mld = new MLConfDialog( this, p_intf );
904 #include <QDialogButtonBox>
905 #include "util/registry.hpp"
907 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
908 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
911 const char* psz_VLC = "VLC";
912 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
914 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
916 current->setCheckState( 0, Qt::Checked );
921 current->setCheckState( 0, Qt::Unchecked );
924 listAsso.append( current );
928 void SPrefsPanel::assoDialog()
930 LPAPPASSOCREGUI p_appassoc;
933 if( S_OK == CoCreateInstance( &clsid_IApplication2,
934 NULL, CLSCTX_INPROC_SERVER,
935 &IID_IApplicationAssociationRegistrationUI,
936 (void **)&p_appassoc) )
938 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
947 QDialog *d = new QDialog( this );
948 QGridLayout *assoLayout = new QGridLayout( d );
950 QTreeWidget *filetypeList = new QTreeWidget;
951 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
952 filetypeList->header()->hide();
954 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
956 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
957 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
958 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
960 filetypeList->addTopLevelItem( audioType );
961 filetypeList->addTopLevelItem( videoType );
962 filetypeList->addTopLevelItem( otherType );
964 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
965 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
966 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
968 QTreeWidgetItem *currentItem = NULL;
971 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
972 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
973 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
975 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
976 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
977 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
978 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
979 audioType->setCheckState( 0, ( i_temp > 0 ) ?
980 ( ( i_temp == audioType->childCount() ) ?
981 Qt::Checked : Qt::PartiallyChecked )
985 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
986 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
987 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
988 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
989 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
990 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
991 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
992 videoType->setCheckState( 0, ( i_temp > 0 ) ?
993 ( ( i_temp == audioType->childCount() ) ?
994 Qt::Checked : Qt::PartiallyChecked )
998 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
999 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1000 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1001 ( ( i_temp == audioType->childCount() ) ?
1002 Qt::Checked : Qt::PartiallyChecked )
1009 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1010 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1011 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1012 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1013 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1015 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1017 CONNECT( closeButton, clicked(), this, saveAsso() );
1018 CONNECT( clearButton, clicked(), d, reject() );
1019 d->resize( 300, 400 );
1026 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1028 QString s_path( "VLC" ); s_path += psz_ext;
1029 QString s_path2 = s_path;
1031 /* Save a backup if already assigned */
1032 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1034 if( !EMPTY_STR(psz_value) )
1035 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1038 /* Put a "link" to VLC.EXT as default */
1039 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1041 /* Create the needed Key if they weren't done in the installer */
1042 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1044 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1045 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1046 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1048 /* Get the installer path */
1049 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1050 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1052 if( str_temp.size() )
1054 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1055 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1057 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1058 "", qtu( str_temp.append(",0") ) );
1064 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1066 char psz_VLC[] = "VLC";
1067 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1069 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1072 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1074 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1076 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1078 delete( psz_value );
1080 void SPrefsPanel::saveAsso()
1082 QVLCRegistry * qvReg = NULL;
1083 for( int i = 0; i < listAsso.size(); i ++ )
1085 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1086 if( listAsso[i]->checkState( 0 ) > 0 )
1088 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1092 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1096 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();