1 /*****************************************************************************
2 * simple_preferences.cpp : "Simple preferences"
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
9 * Jean-Baptiste Kempf <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include "components/simple_preferences.hpp"
31 #include "components/preferences_widgets.hpp"
33 #include <vlc_config_cat.h>
34 #include <vlc_configuration.h>
38 #include <QToolButton>
39 #include <QButtonGroup>
40 #include <QVBoxLayout>
41 #include <QScrollArea>
43 #include <QStyleFactory>
45 #include <QtAlgorithms>
47 #define ICON_HEIGHT 64
50 # include <vlc_windows_interfaces.h>
53 /*********************************************************************
54 * The List of categories
55 *********************************************************************/
56 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
57 QWidget( _parent ), p_intf( _p_intf )
59 QVBoxLayout *layout = new QVBoxLayout();
61 QButtonGroup *buttonGroup = new QButtonGroup( this );
62 buttonGroup->setExclusive ( true );
63 CONNECT( buttonGroup, buttonClicked ( int ),
64 this, switchPanel( int ) );
66 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
68 #define ADD_CATEGORY( button, label, icon, numb ) \
69 QToolButton * button = new QToolButton( this ); \
70 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
71 button->setText( label ); \
72 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
73 button->setIconSize( QSize( icon_height, icon_height ) ); \
74 button->resize( icon_height + 6 , icon_height + 6 ); \
75 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
76 button->setAutoRaise( true ); \
77 button->setCheckable( true ); \
78 buttonGroup->addButton( button, numb ); \
79 layout->addWidget( button );
81 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
82 cone_interface_64, 0 );
83 ADD_CATEGORY( SPrefsAudio, qtr("Audio"),
85 ADD_CATEGORY( SPrefsVideo, qtr("Video"),
87 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
88 cone_subtitles_64, 3 );
89 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
91 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"),
96 SPrefsInterface->setChecked( true );
97 layout->setMargin( 0 );
98 layout->setSpacing( 1 );
100 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
105 void SPrefsCatList::switchPanel( int i )
107 emit currentItemChanged( i );
110 /*********************************************************************
112 *********************************************************************/
113 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
114 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
116 module_config_t *p_config;
117 ConfigControl *control;
120 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
121 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
124 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
125 p_config, label, ui.qcontrol, false ); \
126 controls.append( control ); \
129 ui.qcontrol->setEnabled( false ); \
130 if( label ) label->setEnabled( false ); \
133 #define CONFIG_BOOL( option, qcontrol ) \
134 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
137 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
138 p_config, NULL, ui.qcontrol, false ); \
139 controls.append( control ); \
141 else { ui.qcontrol->setEnabled( false ); }
144 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
145 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
148 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
149 p_config, label, qcontrol, false ); \
150 controls.append( control ); \
153 QWidget *widget = label; \
154 qcontrol->setVisible( false ); \
155 if( widget ) widget->setEnabled( false ); \
159 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
160 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
163 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
164 p_config, label, ui.qcontrol ); \
165 controls.append( control ); \
168 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
169 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
172 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
173 p_config, label, qcontrol, qbutton ); \
174 controls.append( control ); \
177 #define START_SPREFS_CAT( name , label ) \
178 case SPrefs ## name: \
180 Ui::SPrefs ## name ui; \
181 ui.setupUi( panel ); \
182 panel_label->setText( label );
184 #define END_SPREFS_CAT \
188 QVBoxLayout *panel_layout = new QVBoxLayout();
189 QWidget *panel = new QWidget();
190 panel_layout->setMargin( 3 );
193 QLabel *panel_label = new QLabel;
194 QFont labelFont = QApplication::font();
195 labelFont.setPointSize( labelFont.pointSize() + 6 );
196 panel_label->setFont( labelFont );
199 QFrame *title_line = new QFrame;
200 title_line->setFrameShape(QFrame::HLine);
201 title_line->setFrameShadow(QFrame::Sunken);
203 QFont italicFont = QApplication::font();
204 italicFont.setItalic( true );
208 /******************************
209 * VIDEO Panel Implementation *
210 ******************************/
211 START_SPREFS_CAT( Video , qtr("Video Settings") );
212 CONFIG_BOOL( "video", enableVideo );
214 CONFIG_BOOL( "fullscreen", fullscreen );
215 CONFIG_BOOL( "overlay", overlay );
216 CONFIG_BOOL( "video-on-top", alwaysOnTop );
217 CONFIG_BOOL( "video-deco", windowDecorations );
218 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
220 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
222 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
224 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
226 ui.directXBox->setVisible( false );
227 ui.hwYUVBox->setVisible( false );
230 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
231 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
232 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
234 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
235 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
236 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
237 CONFIG_BOOL( "snapshot-sequential",
238 snapshotsSequentialNumbering );
239 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
243 /******************************
244 * AUDIO Panel Implementation *
245 ******************************/
246 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
248 CONFIG_BOOL( "audio", enableAudio );
249 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
250 CONNECT( ui.enableAudio, toggled( bool ),
251 ui.SPrefsAudio_zone, setEnabled( bool ) );
253 #define audioCommon( name ) \
254 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
255 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
256 name ## Layout->setMargin( 0 ); \
257 name ## Layout->setSpacing( 0 ); \
258 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
259 name ## Label->setMinimumSize(QSize(250, 0)); \
260 name ## Layout->addWidget( name ## Label ); \
262 #define audioControl( name) \
263 audioCommon( name ) \
264 QComboBox * name ## Device = new QComboBox( name ## Control ); \
265 name ## Layout->addWidget( name ## Device ); \
266 name ## Label->setBuddy( name ## Device ); \
267 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
269 #define audioControl2( name) \
270 audioCommon( name ) \
271 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
272 name ## Layout->addWidget( name ## Device ); \
273 name ## Label->setBuddy( name ## Device ); \
274 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
275 name ## Layout->addWidget( name ## Browse ); \
276 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
278 /* Build if necessary */
279 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
281 audioControl( DirectX );
282 optionWidgets.append( DirectXControl );
283 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
284 DirectXLabel, DirectXDevice );
286 if( module_exists( "alsa" ) )
288 audioControl( alsa );
289 optionWidgets.append( alsaControl );
291 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
295 optionWidgets.append( NULL );
296 if( module_exists( "oss" ) )
298 audioControl2( OSS );
299 optionWidgets.append( OSSControl );
300 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
304 optionWidgets.append( NULL );
312 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
314 CONNECT( ui.defaultVolume, valueChanged( int ),
315 this, updateAudioVolume( int ) );
317 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
318 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
319 CONNECT( ui.resetVolumeRadio, toggled( bool ),
320 ui.defaultVolume_zone, setEnabled( bool ) );
322 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
323 preferredAudioLanguage );
325 CONFIG_BOOL( "spdif", spdifBox );
326 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
329 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
331 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
333 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
335 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
337 /* Audio Output Specifics */
338 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
340 CONNECT( ui.outputModule, currentIndexChanged( int ),
341 this, updateAudioOptions( int ) );
343 /* File output exists on all platforms */
344 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
345 ui.fileName, ui.fileBrowseButton );
347 optionWidgets.append( ui.fileControl );
348 optionWidgets.append( ui.outputModule );
349 optionWidgets.append( ui.volNormBox );
350 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
351 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
352 optionWidgets.append( ui.volumeValue );
353 optionWidgets.append( ui.headphoneEffect );
354 optionWidgets.append( ui.spdifBox );
355 updateAudioOptions( ui.outputModule->currentIndex() );
358 if( module_exists( "audioscrobbler" ) )
360 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
362 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
365 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
366 ui.lastfm->setChecked( true );
368 ui.lastfm->setChecked( false );
370 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
372 CONNECT( ui.lastfm, toggled( bool ),
373 ui.lastfm_zone, setVisible( bool ) );
374 CONNECT( ui.lastfm, stateChanged( int ),
375 this, lastfm_Changed( int ) );
380 ui.lastfm_zone->hide();
384 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
385 setEnabled( bool ) );
387 char* psz = config_GetPsz( p_intf, "audio-filter" );
388 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
391 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
392 ui.volNormBox->setChecked( b_enabled );
393 ui.volNormSpin->setEnabled( b_enabled );
395 b_enabled = ( qs_filter.contains( "headphone" ) );
396 ui.headphoneEffect->setChecked( b_enabled );
399 updateAudioVolume( ui.defaultVolume->value() ); // First time init
403 /* Input and Codecs Panel Implementation */
404 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
408 ui.DVDDevice->setToolTip(
409 qtr( "If this property is blank, different values\n"
410 "for DVD, VCD, and CDDA are set.\n"
411 "You can define a unique one or configure them \n"
412 "individually in the advanced preferences." ) );
413 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
414 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
415 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
416 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
417 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
418 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
420 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
422 free( psz_cddadiscpath );
423 free( psz_dvddiscpath );
424 free( psz_vcddiscpath );
426 CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
427 ui.DVDDevice, ui.DVDBrowse );
428 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
429 ui.recordPath, ui.recordBrowse );
431 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
433 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
434 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
436 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
438 /* live555 module prefs */
439 CONFIG_BOOL( "rtsp-tcp",
440 live555TransportRTSP_TCPRadio );
441 if ( !module_exists( "live555" ) )
443 ui.live555TransportRTSP_TCPRadio->hide();
444 ui.live555TransportHTTPRadio->hide();
445 ui.live555TransportLabel->hide();
448 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
450 ui.systemCodecBox->hide();
452 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
453 optionWidgets.append( ui.DVDDevice );
454 optionWidgets.append( ui.cachingCombo );
455 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
456 CONFIG_BOOL( "skip-frames", skipFrames );
457 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
458 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
459 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
460 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
463 /* Add the things to the ComboBox */
464 #define addToCachingBox( str, cachingNumber ) \
465 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
466 addToCachingBox( N_("Custom"), CachingCustom );
467 addToCachingBox( N_("Lowest latency"), CachingLowest );
468 addToCachingBox( N_("Low latency"), CachingLow );
469 addToCachingBox( N_("Normal"), CachingNormal );
470 addToCachingBox( N_("High latency"), CachingHigh );
471 addToCachingBox( N_("Higher latency"), CachingHigher );
472 #undef addToCachingBox
474 #define TestCaC( name ) \
475 b_cache_equal = b_cache_equal && \
476 ( i_cache == config_GetInt( p_intf, name ) )
478 #define TestCaCi( name, int ) \
479 b_cache_equal = b_cache_equal && \
480 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
481 /* Select the accurate value of the ComboBox */
482 bool b_cache_equal = true;
483 int i_cache = config_GetInt( p_intf, "file-caching");
485 TestCaC( "udp-caching" );
486 if (module_exists ("dvdread"))
487 TestCaC( "dvdread-caching" );
488 if (module_exists ("dvdnav"))
489 TestCaC( "dvdnav-caching" );
490 TestCaC( "tcp-caching" );
491 TestCaC( "cdda-caching" );
492 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
494 TestCaC( "dshow-caching" );
496 if (module_exists ("v4l"))
497 TestCaC( "v4l-caching" );
498 if (module_exists ("access_jack"))
499 TestCaC( "jack-input-caching" );
500 if (module_exists ("v4l2"))
501 TestCaC( "v4l2-caching" );
502 if (module_exists ("pvr"))
503 TestCaC( "pvr-caching" );
505 if (module_exists ("livedotcom"))
506 TestCaCi( "rtsp-caching", 4 );
507 TestCaCi( "ftp-caching", 2 );
508 TestCaCi( "http-caching", 2 );
509 if (module_exists ("access_realrtsp"))
510 TestCaCi( "realrtsp-caching", 10 );
511 TestCaCi( "mms-caching", 10 );
512 if( b_cache_equal == 1 )
513 ui.cachingCombo->setCurrentIndex(
514 ui.cachingCombo->findData( QVariant( i_cache ) ) );
522 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
523 // ui.defaultLabel->setFont( italicFont );
524 ui.skinsLabel->setText(
525 qtr( "This is VLC's skinnable interface. You can download other skins at" )
526 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
527 + qtr( "VLC skins website" )+ QString( "</a>." ) );
528 ui.skinsLabel->setFont( italicFont );
531 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
532 BUTTONACT( ui.assoButton, assoDialog() );
534 ui.languageBox->hide();
535 ui.assoButton->hide();
536 ui.assocLabel->hide();
539 char *psz_intf = config_GetPsz( p_intf, "intf" );
542 if( strstr( psz_intf, "skin" ) )
543 ui.skins->setChecked( true );
546 ui.qt4->setChecked( true );
550 optionWidgets.append( ui.skins );
551 optionWidgets.append( ui.qt4 );
552 #if !defined(NDEBUG) || !defined( WIN32)
553 ui.stylesCombo->addItem( qtr("System's default") );
554 ui.stylesCombo->addItems( QStyleFactory::keys() );
555 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
556 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
557 ui.stylesCombo->insertSeparator( 1 );
559 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
560 optionWidgets.append( ui.stylesCombo );
562 ui.stylesCombo->hide();
563 optionWidgets.append( NULL );
566 ui.skins_zone->setEnabled( ui.skins->isChecked() );
567 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
569 ui.native_zone->setEnabled( ui.qt4->isChecked() );
570 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
572 CONNECT( ui.minimalviewBox, toggled( bool ),
573 ui.mainPreview, setNormalPreview( bool ) );
574 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
575 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
576 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
578 CONFIG_BOOL( "embedded-video", embedVideo );
579 CONFIG_BOOL( "qt-fs-controller", fsController );
580 CONFIG_BOOL( "qt-system-tray", systrayBox );
581 CONFIG_BOOL( "qt-notification", sysPop );
582 CONFIG_BOOL( "playlist-tree", treePlaylist );
583 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
584 ui.fileSkin, ui.skinBrowse );
585 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
587 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
592 CONFIG_BOOL( "qt-updates-notif", updatesBox );
593 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
595 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
596 CONNECT( ui.updatesBox, toggled( bool ),
597 ui.updatesDays, setEnabled( bool ) );
599 ui.updatesBox->hide();
600 ui.updatesDays->hide();
602 /* ONE INSTANCE options */
603 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
604 CONFIG_BOOL( "one-instance", OneInterfaceMode );
605 CONFIG_BOOL( "playlist-enqueue",
606 EnqueueOneInterfaceMode );
607 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
608 CONNECT( ui.OneInterfaceMode, toggled( bool ),
609 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
611 ui.OneInterfaceBox->hide();
613 /* RECENTLY PLAYED options */
614 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
615 ui.recentlyPlayedFilters, setEnabled( bool ) );
616 ui.recentlyPlayedFilters->setEnabled( false );
617 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
618 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
619 recentlyPlayedFilters );
623 START_SPREFS_CAT( Subtitles,
624 qtr("Subtitles & On Screen Display Settings") );
625 CONFIG_BOOL( "osd", OSDBox);
626 CONFIG_BOOL( "video-title-show", OSDTitleBox);
629 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
631 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
633 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
634 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
636 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
637 ui.fontSizeLabel, fontSize );
638 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
640 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
646 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
648 QGridLayout *gLayout = new QGridLayout;
649 panel->setLayout( gLayout );
652 panel_label->setText( qtr( "Configure Hotkeys" ) );
653 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
654 this, gLayout, line );
655 controls.append( control );
659 QFrame *sepline = new QFrame;
660 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
661 gLayout->addWidget( sepline, line, 0, 1, -1 );
665 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
666 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
667 p_config, false, this, gLayout, line );
668 controls.append( control );
674 panel_layout->addWidget( panel_label );
675 panel_layout->addWidget( title_line );
679 QScrollArea *scroller= new QScrollArea;
680 scroller->setWidget( panel );
681 scroller->setWidgetResizable( true );
682 scroller->setFrameStyle( QFrame::NoFrame );
683 panel_layout->addWidget( scroller );
687 panel_layout->addWidget( panel );
688 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
691 setLayout( panel_layout );
693 #undef END_SPREFS_CAT
694 #undef START_SPREFS_CAT
695 #undef CONFIG_GENERIC_FILE
696 #undef CONFIG_GENERIC_NO_BOOL
697 #undef CONFIG_GENERIC_NO_UI
698 #undef CONFIG_GENERIC
703 void SPrefsPanel::updateAudioOptions( int number)
705 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
706 ->itemData( number ).toString();
708 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
710 /* optionWidgets[ossW] can be NULL */
711 if( optionWidgets[ossW] )
712 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
713 /* optionWidgets[alsaW] can be NULL */
714 if( optionWidgets[alsaW] )
715 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
717 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
718 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
719 value == "aout_directx" || value == "waveout" ) );
723 SPrefsPanel::~SPrefsPanel()
725 qDeleteAll( controls ); controls.clear();
728 void SPrefsPanel::updateAudioVolume( int volume )
730 qobject_cast<QSpinBox *>(optionWidgets[volLW])
731 ->setValue( volume * 100 / 256 );
735 /* Function called from the main Preferences dialog on each SPrefs Panel */
736 void SPrefsPanel::apply()
738 /* Generic save for ever panel */
739 QList<ConfigControl *>::Iterator i;
740 for( i = controls.begin() ; i != controls.end() ; i++ )
742 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
743 c->doApply( p_intf );
748 case SPrefsInputAndCodecs:
750 /* Device default selection */
751 char *psz_devicepath =
752 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
753 if( !EMPTY_STR( psz_devicepath ) )
755 config_PutPsz( p_intf, "dvd", psz_devicepath );
756 config_PutPsz( p_intf, "vcd", psz_devicepath );
757 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
758 free( psz_devicepath );
761 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
762 #define CaC( name ) CaCi( name, 1 )
764 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
765 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
768 CaC( "udp-caching" );
769 if (module_exists ("dvdread" ))
770 CaC( "dvdread-caching" );
771 if (module_exists ("dvdnav" ))
772 CaC( "dvdnav-caching" );
773 CaC( "tcp-caching" ); CaC( "vcd-caching" );
774 CaC( "cdda-caching" ); CaC( "file-caching" );
775 CaC( "screen-caching" ); CaC( "bd-caching" );
776 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
777 CaCi( "http-caching", 2 );
778 if (module_exists ("access_realrtsp" ))
779 CaCi( "realrtsp-caching", 10 );
780 CaCi( "mms-caching", 10 );
782 CaC( "dshow-caching" );
784 if (module_exists ( "v4l" ))
785 CaC( "v4l-caching" );
786 if (module_exists ( "access_jack" ))
787 CaC( "jack-input-caching" );
788 if (module_exists ( "v4l2" ))
789 CaC( "v4l2-caching" );
790 if (module_exists ( "pvr" ))
791 CaC( "pvr-caching" );
793 //CaCi( "dv-caching" ) too short...
801 case SPrefsInterface:
803 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
804 config_PutPsz( p_intf, "intf", "skins2" );
805 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
806 config_PutPsz( p_intf, "intf", "qt" );
807 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
808 getSettings()->setValue( "MainWindow/QtStyle",
809 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
817 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
818 if( b_checked && !qs_filter.contains( "volnorm" ) )
819 qs_filter.append( "volnorm" );
820 if( !b_checked && qs_filter.contains( "volnorm" ) )
821 qs_filter.removeAll( "volnorm" );
824 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
826 if( b_checked && !qs_filter.contains( "headphone" ) )
827 qs_filter.append( "headphone" );
828 if( !b_checked && qs_filter.contains( "headphone" ) )
829 qs_filter.removeAll( "headphone" );
831 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
837 void SPrefsPanel::clean()
840 void SPrefsPanel::lastfm_Changed( int i_state )
842 if( i_state == Qt::Checked )
843 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
844 else if( i_state == Qt::Unchecked )
845 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
848 void SPrefsPanel::changeStyle( QString s_style )
850 QApplication::setStyle( s_style );
852 /* force refresh on all widgets */
853 QWidgetList widgets = QApplication::allWidgets();
854 QWidgetList::iterator it = widgets.begin();
855 while( it != widgets.end() ) {
862 #include <QDialogButtonBox>
863 #include <QHeaderView>
864 #include "util/registry.hpp"
867 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
868 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
871 const char* psz_VLC = "VLC";
872 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
874 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
876 current->setCheckState( 0, Qt::Checked );
881 current->setCheckState( 0, Qt::Unchecked );
884 listAsso.append( current );
888 void SPrefsPanel::assoDialog()
890 LPAPPASSOCREGUI p_appassoc;
893 if( S_OK == CoCreateInstance( &clsid_IApplication2,
894 NULL, CLSCTX_INPROC_SERVER,
895 &IID_IApplicationAssociationRegistrationUI,
896 (void **)&p_appassoc) )
898 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
907 QDialog *d = new QDialog( this );
908 QGridLayout *assoLayout = new QGridLayout( d );
910 QTreeWidget *filetypeList = new QTreeWidget;
911 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
912 filetypeList->header()->hide();
914 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
916 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
917 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
918 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
920 filetypeList->addTopLevelItem( audioType );
921 filetypeList->addTopLevelItem( videoType );
922 filetypeList->addTopLevelItem( otherType );
924 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
925 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
926 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
928 QTreeWidgetItem *currentItem;
931 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
932 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
933 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
935 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
936 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
937 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
938 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
939 audioType->setCheckState( 0, ( i_temp > 0 ) ?
940 ( ( i_temp == audioType->childCount() ) ?
941 Qt::Checked : Qt::PartiallyChecked )
945 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
946 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
947 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
948 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
949 aTv( ".mts" ); aTv( ".mxf" );
950 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
951 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
952 videoType->setCheckState( 0, ( i_temp > 0 ) ?
953 ( ( i_temp == audioType->childCount() ) ?
954 Qt::Checked : Qt::PartiallyChecked )
958 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
959 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
960 otherType->setCheckState( 0, ( i_temp > 0 ) ?
961 ( ( i_temp == audioType->childCount() ) ?
962 Qt::Checked : Qt::PartiallyChecked )
969 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
970 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
971 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
972 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
973 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
975 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
977 CONNECT( closeButton, clicked(), this, saveAsso() );
978 CONNECT( clearButton, clicked(), d, reject() );
979 d->resize( 300, 400 );
986 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
988 std::string s_path( "VLC" ); s_path += psz_ext;
989 std::string s_path2 = s_path;
991 /* Save a backup if already assigned */
992 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
994 if( psz_value && strlen( psz_value ) > 0 )
995 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
998 /* Put a "link" to VLC.EXT as default */
999 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1001 /* Create the needed Key if they weren't done in the installer */
1002 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1004 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1005 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1006 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1008 /* Get the installer path */
1009 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1010 std::string str_temp; str_temp.assign(
1011 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1013 if( str_temp.size() )
1015 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1016 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1018 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1019 "", str_temp.append(",0").c_str() );
1025 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1027 char psz_VLC[] = "VLC";
1028 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1030 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1033 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1035 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1037 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1039 delete( psz_value );
1041 void SPrefsPanel::saveAsso()
1043 QVLCRegistry * qvReg;
1044 for( int i = 0; i < listAsso.size(); i ++ )
1046 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1047 if( listAsso[i]->checkState( 0 ) > 0 )
1049 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1053 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1057 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();