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"
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>
48 #define ICON_HEIGHT 64
51 # include <vlc_windows_interfaces.h>
53 #include <vlc_modules.h>
55 /*********************************************************************
56 * The List of categories
57 *********************************************************************/
58 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
59 QWidget( _parent ), p_intf( _p_intf )
61 QVBoxLayout *layout = new QVBoxLayout();
63 QButtonGroup *buttonGroup = new QButtonGroup( this );
64 buttonGroup->setExclusive ( true );
65 CONNECT( buttonGroup, buttonClicked ( int ),
66 this, switchPanel( int ) );
68 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
70 #define ADD_CATEGORY( button, label, icon, numb ) \
71 QToolButton * button = new QToolButton( this ); \
72 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
73 button->setText( label ); \
74 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
75 button->setIconSize( QSize( icon_height, icon_height ) ); \
76 button->resize( icon_height + 6 , icon_height + 6 ); \
77 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
78 button->setAutoRaise( true ); \
79 button->setCheckable( true ); \
80 buttonGroup->addButton( button, numb ); \
81 layout->addWidget( button );
83 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
84 cone_interface_64, 0 );
85 ADD_CATEGORY( SPrefsAudio, qtr("Audio"),
87 ADD_CATEGORY( SPrefsVideo, qtr("Video"),
89 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
90 cone_subtitles_64, 3 );
91 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
93 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"),
98 SPrefsInterface->setChecked( true );
99 layout->setMargin( 0 );
100 layout->setSpacing( 1 );
102 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
107 void SPrefsCatList::switchPanel( int i )
109 emit currentItemChanged( i );
112 /*********************************************************************
114 *********************************************************************/
115 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
116 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
118 module_config_t *p_config;
119 ConfigControl *control;
122 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
123 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
126 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
127 p_config, label, ui.qcontrol, false ); \
128 controls.append( control ); \
131 ui.qcontrol->setEnabled( false ); \
132 if( label ) label->setEnabled( false ); \
135 #define CONFIG_BOOL( option, qcontrol ) \
136 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
139 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
140 p_config, NULL, ui.qcontrol, false ); \
141 controls.append( control ); \
143 else { ui.qcontrol->setEnabled( false ); }
146 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
147 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
150 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
151 p_config, label, qcontrol, false ); \
152 controls.append( control ); \
155 QWidget *widget = label; \
156 qcontrol->setVisible( false ); \
157 if( widget ) widget->setEnabled( false ); \
161 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
162 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
165 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
166 p_config, label, ui.qcontrol ); \
167 controls.append( control ); \
170 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
171 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
174 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
175 p_config, label, qcontrol, qbutton ); \
176 controls.append( control ); \
179 #define START_SPREFS_CAT( name , label ) \
180 case SPrefs ## name: \
182 Ui::SPrefs ## name ui; \
183 ui.setupUi( panel ); \
184 panel_label->setText( label );
186 #define END_SPREFS_CAT \
190 QVBoxLayout *panel_layout = new QVBoxLayout();
191 QWidget *panel = new QWidget();
192 panel_layout->setMargin( 3 );
195 QLabel *panel_label = new QLabel;
196 QFont labelFont = QApplication::font();
197 labelFont.setPointSize( labelFont.pointSize() + 6 );
198 panel_label->setFont( labelFont );
201 QFrame *title_line = new QFrame;
202 title_line->setFrameShape(QFrame::HLine);
203 title_line->setFrameShadow(QFrame::Sunken);
205 QFont italicFont = QApplication::font();
206 italicFont.setItalic( true );
210 /******************************
211 * VIDEO Panel Implementation *
212 ******************************/
213 START_SPREFS_CAT( Video , qtr("Video Settings") );
214 CONFIG_BOOL( "video", enableVideo );
216 CONFIG_BOOL( "fullscreen", fullscreen );
217 CONFIG_BOOL( "overlay", overlay );
218 CONFIG_BOOL( "video-on-top", alwaysOnTop );
219 CONFIG_BOOL( "video-deco", windowDecorations );
220 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
222 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
224 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
226 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
228 ui.directXBox->setVisible( false );
229 ui.hwYUVBox->setVisible( false );
232 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
233 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
234 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
236 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
237 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
238 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
239 CONFIG_BOOL( "snapshot-sequential",
240 snapshotsSequentialNumbering );
241 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
245 /******************************
246 * AUDIO Panel Implementation *
247 ******************************/
248 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
250 CONFIG_BOOL( "audio", enableAudio );
251 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
252 CONNECT( ui.enableAudio, toggled( bool ),
253 ui.SPrefsAudio_zone, setEnabled( bool ) );
255 #define audioCommon( name ) \
256 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
257 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
258 name ## Layout->setMargin( 0 ); \
259 name ## Layout->setSpacing( 0 ); \
260 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
261 name ## Label->setMinimumSize(QSize(250, 0)); \
262 name ## Layout->addWidget( name ## Label ); \
264 #define audioControl( name) \
265 audioCommon( name ) \
266 QComboBox * name ## Device = new QComboBox( name ## Control ); \
267 name ## Layout->addWidget( name ## Device ); \
268 name ## Label->setBuddy( name ## Device ); \
269 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
270 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
272 #define audioControl2( name) \
273 audioCommon( name ) \
274 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
275 name ## Layout->addWidget( name ## Device ); \
276 name ## Label->setBuddy( name ## Device ); \
277 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
278 name ## Layout->addWidget( name ## Browse ); \
279 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
281 /* Build if necessary */
282 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
284 audioControl( DirectX );
285 optionWidgets.append( DirectXControl );
286 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
287 DirectXLabel, DirectXDevice );
289 if( module_exists( "alsa" ) )
291 audioControl( alsa );
292 optionWidgets.append( alsaControl );
293 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
297 optionWidgets.append( NULL );
298 if( module_exists( "oss" ) )
300 audioControl2( OSS );
301 optionWidgets.append( OSSControl );
302 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
306 optionWidgets.append( NULL );
314 ui.volumeValue->setMaximum( QT_VOLUME_MAX / QT_VOLUME_DEFAULT * 100 );
315 CONFIG_GENERIC_NO_BOOL( "qt-startvolume" , IntegerRangeSlider, NULL,
317 CONNECT( ui.defaultVolume, valueChanged( int ),
318 this, updateAudioVolume( int ) );
320 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
321 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
322 CONNECT( ui.resetVolumeRadio, toggled( bool ),
323 ui.defaultVolume_zone, setEnabled( bool ) );
325 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
326 preferredAudioLanguage );
328 CONFIG_BOOL( "spdif", spdifBox );
329 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
332 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
334 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
336 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
338 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
340 /* Audio Output Specifics */
341 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
343 CONNECT( ui.outputModule, currentIndexChanged( int ),
344 this, updateAudioOptions( int ) );
346 /* File output exists on all platforms */
347 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
348 ui.fileName, ui.fileBrowseButton );
350 optionWidgets.append( ui.fileControl );
351 optionWidgets.append( ui.outputModule );
352 optionWidgets.append( ui.volNormBox );
353 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
354 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
355 optionWidgets.append( ui.volumeValue );
356 optionWidgets.append( ui.headphoneEffect );
357 optionWidgets.append( ui.spdifBox );
358 updateAudioOptions( ui.outputModule->currentIndex() );
361 if( module_exists( "audioscrobbler" ) )
363 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
365 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
368 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
369 ui.lastfm->setChecked( true );
371 ui.lastfm->setChecked( false );
373 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
375 CONNECT( ui.lastfm, toggled( bool ),
376 ui.lastfm_zone, setVisible( bool ) );
377 CONNECT( ui.lastfm, stateChanged( int ),
378 this, lastfm_Changed( int ) );
383 ui.lastfm_zone->hide();
387 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
388 setEnabled( bool ) );
390 char* psz = config_GetPsz( p_intf, "audio-filter" );
391 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
394 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
395 ui.volNormBox->setChecked( b_enabled );
396 ui.volNormSpin->setEnabled( b_enabled );
398 b_enabled = ( qs_filter.contains( "headphone" ) );
399 ui.headphoneEffect->setChecked( b_enabled );
402 updateAudioVolume( ui.defaultVolume->value() ); // First time init
406 /* Input and Codecs Panel Implementation */
407 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
411 ui.DVDDeviceComboBox->setToolTip(
412 qtr( "If this property is blank, different values\n"
413 "for DVD, VCD, and CDDA are set.\n"
414 "You can define a unique one or configure them \n"
415 "individually in the advanced preferences." ) );
416 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
417 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
418 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
419 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
420 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
421 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
423 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
425 free( psz_cddadiscpath );
426 free( psz_dvddiscpath );
427 free( psz_vcddiscpath );
430 QStringList DVDDeviceComboBoxStringList = QStringList();
431 DVDDeviceComboBoxStringList
432 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
433 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
434 .entryList( DVDDeviceComboBoxStringList, QDir::System )
435 .replaceInStrings( QRegExp("^"), "/dev/" )
438 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
439 DVDDeviceComboBox->lineEdit() );
440 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
441 ui.recordPath, ui.recordBrowse );
443 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
444 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
446 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
448 /* live555 module prefs */
449 CONFIG_BOOL( "rtsp-tcp",
450 live555TransportRTSP_TCPRadio );
451 if ( !module_exists( "live555" ) )
453 ui.live555TransportRTSP_TCPRadio->hide();
454 ui.live555TransportHTTPRadio->hide();
455 ui.live555TransportLabel->hide();
457 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
459 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
460 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
462 ui.hwAccelBox->setEnabled( false );
464 FreeLibrary( hdxva2_dll );
466 ui.systemCodecBox->hide();
468 optionWidgets.append( ui.DVDDeviceComboBox );
469 optionWidgets.append( ui.cachingCombo );
470 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
471 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
472 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
473 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
474 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
477 /* Add the things to the ComboBox */
478 #define addToCachingBox( str, cachingNumber ) \
479 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
480 addToCachingBox( N_("Custom"), CachingCustom );
481 addToCachingBox( N_("Lowest latency"), CachingLowest );
482 addToCachingBox( N_("Low latency"), CachingLow );
483 addToCachingBox( N_("Normal"), CachingNormal );
484 addToCachingBox( N_("High latency"), CachingHigh );
485 addToCachingBox( N_("Higher latency"), CachingHigher );
486 #undef addToCachingBox
488 #define TestCaC( name ) \
489 b_cache_equal = b_cache_equal && \
490 ( i_cache == config_GetInt( p_intf, name ) )
492 #define TestCaCi( name, int ) \
493 b_cache_equal = b_cache_equal && \
494 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
495 /* Select the accurate value of the ComboBox */
496 bool b_cache_equal = true;
497 int i_cache = config_GetInt( p_intf, "file-caching");
499 TestCaC( "udp-caching" );
500 if (module_exists ("dvdread"))
501 TestCaC( "dvdread-caching" );
502 if (module_exists ("dvdnav"))
503 TestCaC( "dvdnav-caching" );
504 TestCaC( "tcp-caching" );
505 TestCaC( "cdda-caching" );
506 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
508 TestCaC( "dshow-caching" );
510 if (module_exists ("access_jack"))
511 TestCaC( "jack-input-caching" );
512 if (module_exists ("v4l2"))
513 TestCaC( "v4l2-caching" );
514 if (module_exists ("pvr"))
515 TestCaC( "pvr-caching" );
517 if (module_exists ("livedotcom"))
518 TestCaCi( "rtsp-caching", 4 );
519 TestCaCi( "ftp-caching", 2 );
520 TestCaCi( "http-caching", 2 );
521 if (module_exists ("access_realrtsp"))
522 TestCaCi( "realrtsp-caching", 10 );
523 TestCaCi( "mms-caching", 10 );
524 if( b_cache_equal == 1 )
525 ui.cachingCombo->setCurrentIndex(
526 ui.cachingCombo->findData( QVariant( i_cache ) ) );
534 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
535 // ui.defaultLabel->setFont( italicFont );
536 ui.skinsLabel->setText(
537 qtr( "This is VLC's skinnable interface. You can download other skins at" )
538 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
539 + qtr( "VLC skins website" )+ QString( "</a>." ) );
540 ui.skinsLabel->setFont( italicFont );
543 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
544 BUTTONACT( ui.assoButton, assoDialog() );
546 ui.languageBox->hide();
547 ui.assoButton->hide();
548 ui.assocLabel->hide();
551 char *psz_intf = config_GetPsz( p_intf, "intf" );
554 if( strstr( psz_intf, "skin" ) )
555 ui.skins->setChecked( true );
558 ui.qt4->setChecked( true );
562 optionWidgets.append( ui.skins );
563 optionWidgets.append( ui.qt4 );
564 #if !defined(NDEBUG) || !defined( WIN32)
565 ui.stylesCombo->addItem( qtr("System's default") );
566 ui.stylesCombo->addItems( QStyleFactory::keys() );
567 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
568 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
569 ui.stylesCombo->insertSeparator( 1 );
571 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
572 optionWidgets.append( ui.stylesCombo );
574 ui.stylesCombo->hide();
575 optionWidgets.append( NULL );
577 radioGroup = new QButtonGroup(this);
578 radioGroup->addButton( ui.qt4, 0 );
579 radioGroup->addButton( ui.skins, 1 );
580 CONNECT( radioGroup, buttonClicked( int ),
581 ui.styleStackedWidget, setCurrentIndex( int ) );
582 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
584 CONNECT( ui.minimalviewBox, toggled( bool ),
585 ui.mainPreview, setNormalPreview( bool ) );
586 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
587 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
588 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
590 CONFIG_BOOL( "embedded-video", embedVideo );
591 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
592 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
593 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
595 CONFIG_BOOL( "qt-fs-controller", fsController );
596 CONFIG_BOOL( "qt-system-tray", systrayBox );
597 CONFIG_BOOL( "qt-notification", sysPop );
598 CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) );
599 ui.sysPop->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,
653 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
654 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
656 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
657 ui.fontSizeLabel, fontSize );
658 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
660 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
666 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
668 QGridLayout *gLayout = new QGridLayout;
669 panel->setLayout( gLayout );
672 panel_label->setText( qtr( "Configure Hotkeys" ) );
673 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
674 this, gLayout, line );
675 controls.append( control );
679 QFrame *sepline = new QFrame;
680 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
681 gLayout->addWidget( sepline, line, 0, 1, -1 );
685 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
686 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
687 p_config, this, false, gLayout, line );
688 controls.append( control );
693 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
694 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this, gLayout, line );
695 controls.append( control );
702 panel_layout->addWidget( panel_label );
703 panel_layout->addWidget( title_line );
707 QScrollArea *scroller= new QScrollArea;
708 scroller->setWidget( panel );
709 scroller->setWidgetResizable( true );
710 scroller->setFrameStyle( QFrame::NoFrame );
711 panel_layout->addWidget( scroller );
715 panel_layout->addWidget( panel );
716 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
719 setLayout( panel_layout );
721 #undef END_SPREFS_CAT
722 #undef START_SPREFS_CAT
723 #undef CONFIG_GENERIC_FILE
724 #undef CONFIG_GENERIC_NO_BOOL
725 #undef CONFIG_GENERIC_NO_UI
726 #undef CONFIG_GENERIC
731 void SPrefsPanel::updateAudioOptions( int number)
733 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
734 ->itemData( number ).toString();
736 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
738 /* optionWidgets[ossW] can be NULL */
739 if( optionWidgets[ossW] )
740 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
741 /* optionWidgets[alsaW] can be NULL */
742 if( optionWidgets[alsaW] )
743 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
745 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
746 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
747 value == "aout_directx" || value == "waveout" ) );
751 SPrefsPanel::~SPrefsPanel()
753 qDeleteAll( controls ); controls.clear();
756 void SPrefsPanel::updateAudioVolume( int volume )
758 qobject_cast<QSpinBox *>(optionWidgets[volLW])
759 ->setValue( volume * 100 / QT_VOLUME_DEFAULT );
763 /* Function called from the main Preferences dialog on each SPrefs Panel */
764 void SPrefsPanel::apply()
766 /* Generic save for ever panel */
767 QList<ConfigControl *>::Iterator i;
768 for( i = controls.begin() ; i != controls.end() ; ++i )
770 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
776 case SPrefsInputAndCodecs:
778 /* Device default selection */
779 char *psz_devicepath =
780 strdup( qtu( qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText() ) );
781 if( !EMPTY_STR( psz_devicepath ) )
783 config_PutPsz( p_intf, "dvd", psz_devicepath );
784 config_PutPsz( p_intf, "vcd", psz_devicepath );
785 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
786 free( psz_devicepath );
789 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
790 #define CaC( name ) CaCi( name, 1 )
792 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
793 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
796 CaC( "udp-caching" );
797 if (module_exists ("dvdread" ))
798 CaC( "dvdread-caching" );
799 if (module_exists ("dvdnav" ))
800 CaC( "dvdnav-caching" );
801 CaC( "tcp-caching" ); CaC( "vcd-caching" );
802 CaC( "cdda-caching" ); CaC( "file-caching" );
803 CaC( "screen-caching" ); CaC( "bd-caching" );
804 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
805 CaCi( "http-caching", 2 );
806 if (module_exists ("access_realrtsp" ))
807 CaCi( "realrtsp-caching", 10 );
808 CaCi( "mms-caching", 10 );
810 CaC( "dshow-caching" );
812 if (module_exists ( "access_jack" ))
813 CaC( "jack-input-caching" );
814 if (module_exists ( "v4l2" ))
815 CaC( "v4l2-caching" );
816 if (module_exists ( "pvr" ))
817 CaC( "pvr-caching" );
819 //CaCi( "dv-caching" ) too short...
827 case SPrefsInterface:
829 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
830 config_PutPsz( p_intf, "intf", "skins2,any" );
832 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
833 config_PutPsz( p_intf, "intf", "" );
834 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
835 getSettings()->setValue( "MainWindow/QtStyle",
836 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
844 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
845 if( b_checked && !qs_filter.contains( "volnorm" ) )
846 qs_filter.append( "volnorm" );
847 if( !b_checked && qs_filter.contains( "volnorm" ) )
848 qs_filter.removeAll( "volnorm" );
851 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
853 if( b_checked && !qs_filter.contains( "headphone" ) )
854 qs_filter.append( "headphone" );
855 if( !b_checked && qs_filter.contains( "headphone" ) )
856 qs_filter.removeAll( "headphone" );
858 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
864 void SPrefsPanel::clean()
867 void SPrefsPanel::lastfm_Changed( int i_state )
869 if( i_state == Qt::Checked )
870 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
871 else if( i_state == Qt::Unchecked )
872 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
875 void SPrefsPanel::changeStyle( QString s_style )
877 QApplication::setStyle( s_style );
879 /* force refresh on all widgets */
880 QWidgetList widgets = QApplication::allWidgets();
881 QWidgetList::iterator it = widgets.begin();
882 while( it != widgets.end() ) {
889 #include <QDialogButtonBox>
890 #include <QHeaderView>
891 #include "util/registry.hpp"
894 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
895 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
898 const char* psz_VLC = "VLC";
899 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
901 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
903 current->setCheckState( 0, Qt::Checked );
908 current->setCheckState( 0, Qt::Unchecked );
911 listAsso.append( current );
915 void SPrefsPanel::assoDialog()
917 LPAPPASSOCREGUI p_appassoc;
920 if( S_OK == CoCreateInstance( &clsid_IApplication2,
921 NULL, CLSCTX_INPROC_SERVER,
922 &IID_IApplicationAssociationRegistrationUI,
923 (void **)&p_appassoc) )
925 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
934 QDialog *d = new QDialog( this );
935 QGridLayout *assoLayout = new QGridLayout( d );
937 QTreeWidget *filetypeList = new QTreeWidget;
938 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
939 filetypeList->header()->hide();
941 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
943 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
944 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
945 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
947 filetypeList->addTopLevelItem( audioType );
948 filetypeList->addTopLevelItem( videoType );
949 filetypeList->addTopLevelItem( otherType );
951 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
952 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
953 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
955 QTreeWidgetItem *currentItem;
958 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
959 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
960 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
962 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
963 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
964 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
965 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
966 audioType->setCheckState( 0, ( i_temp > 0 ) ?
967 ( ( i_temp == audioType->childCount() ) ?
968 Qt::Checked : Qt::PartiallyChecked )
972 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
973 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
974 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
975 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
976 aTv( ".mts" ); aTv( ".mxf" );
977 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
978 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
979 videoType->setCheckState( 0, ( i_temp > 0 ) ?
980 ( ( i_temp == audioType->childCount() ) ?
981 Qt::Checked : Qt::PartiallyChecked )
985 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
986 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
987 otherType->setCheckState( 0, ( i_temp > 0 ) ?
988 ( ( i_temp == audioType->childCount() ) ?
989 Qt::Checked : Qt::PartiallyChecked )
996 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
997 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
998 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
999 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1000 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1002 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1004 CONNECT( closeButton, clicked(), this, saveAsso() );
1005 CONNECT( clearButton, clicked(), d, reject() );
1006 d->resize( 300, 400 );
1013 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1015 std::string s_path( "VLC" ); s_path += psz_ext;
1016 std::string s_path2 = s_path;
1018 /* Save a backup if already assigned */
1019 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1021 if( !EMPTY_STR(psz_value) )
1022 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1025 /* Put a "link" to VLC.EXT as default */
1026 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1028 /* Create the needed Key if they weren't done in the installer */
1029 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1031 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1032 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1033 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1035 /* Get the installer path */
1036 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1037 std::string str_temp; str_temp.assign(
1038 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1040 if( str_temp.size() )
1042 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1043 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1045 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1046 "", str_temp.append(",0").c_str() );
1052 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1054 char psz_VLC[] = "VLC";
1055 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1057 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1060 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1062 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1064 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1066 delete( psz_value );
1068 void SPrefsPanel::saveAsso()
1070 QVLCRegistry * qvReg;
1071 for( int i = 0; i < listAsso.size(); i ++ )
1073 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1074 if( listAsso[i]->checkState( 0 ) > 0 )
1076 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1080 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1084 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();