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 qcontrol->setVisible( false ); \
154 if( label ) label->setEnabled( false ); \
158 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
159 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
162 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
163 p_config, label, ui.qcontrol ); \
164 controls.append( control ); \
167 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
168 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
171 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
172 p_config, label, qcontrol, qbutton ); \
173 controls.append( control ); \
176 #define START_SPREFS_CAT( name , label ) \
177 case SPrefs ## name: \
179 Ui::SPrefs ## name ui; \
180 ui.setupUi( panel ); \
181 panel_label->setText( label );
183 #define END_SPREFS_CAT \
187 QVBoxLayout *panel_layout = new QVBoxLayout();
188 QWidget *panel = new QWidget();
189 panel_layout->setMargin( 3 );
192 QLabel *panel_label = new QLabel;
193 QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
194 labelFont.setPointSize( labelFont.pointSize() + 6 );
195 labelFont.setFamily( "Verdana" );
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( static_cast<QWidget*>(0) );
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_BOOL( "skip-frames", skipFrames );
219 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
221 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
223 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
225 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
227 ui.directXBox->setVisible( false );
228 ui.hwYUVBox->setVisible( false );
231 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
232 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
233 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
235 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
236 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
237 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
238 CONFIG_BOOL( "snapshot-sequential",
239 snapshotsSequentialNumbering );
240 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
244 /******************************
245 * AUDIO Panel Implementation *
246 ******************************/
247 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
249 CONFIG_BOOL( "audio", enableAudio );
250 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
251 CONNECT( ui.enableAudio, toggled( bool ),
252 ui.SPrefsAudio_zone, setEnabled( bool ) );
254 #define audioCommon( name ) \
255 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
256 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
257 name ## Layout->setMargin( 0 ); \
258 name ## Layout->setSpacing( 0 ); \
259 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
260 name ## Label->setMinimumSize(QSize(250, 0)); \
261 name ## Layout->addWidget( name ## Label ); \
263 #define audioControl( name) \
264 audioCommon( name ) \
265 QComboBox * name ## Device = new QComboBox( name ## Control ); \
266 name ## Layout->addWidget( name ## Device ); \
267 name ## Label->setBuddy( name ## Device ); \
268 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
270 #define audioControl2( name) \
271 audioCommon( name ) \
272 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
273 name ## Layout->addWidget( name ## Device ); \
274 name ## Label->setBuddy( name ## Device ); \
275 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
276 name ## Layout->addWidget( name ## Browse ); \
277 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
279 /* Build if necessary */
280 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
282 audioControl( DirectX );
283 optionWidgets.append( DirectXControl );
284 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
285 NULL, DirectXDevice );
287 if( module_exists( "alsa" ) )
289 audioControl( alsa );
290 optionWidgets.append( alsaControl );
292 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, NULL,
296 optionWidgets.append( NULL );
297 if( module_exists( "oss" ) )
299 audioControl2( OSS );
300 optionWidgets.append( OSSControl );
301 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
305 optionWidgets.append( NULL );
313 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
315 CONNECT( ui.defaultVolume, valueChanged( int ),
316 this, updateAudioVolume( int ) );
318 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
319 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
320 CONNECT( ui.resetVolumeRadio, toggled( bool ),
321 ui.defaultVolume_zone, setEnabled( bool ) );
323 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
324 preferredAudioLanguage );
326 CONFIG_BOOL( "spdif", spdifBox );
327 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
330 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
332 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
334 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
336 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
338 /* Audio Output Specifics */
339 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
341 CONNECT( ui.outputModule, currentIndexChanged( int ),
342 this, updateAudioOptions( int ) );
344 /* File output exists on all platforms */
345 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
346 ui.fileName, ui.fileBrowseButton );
348 optionWidgets.append( ui.fileControl );
349 optionWidgets.append( ui.outputModule );
350 optionWidgets.append( ui.volNormBox );
351 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
352 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
353 optionWidgets.append( ui.volumeValue );
354 optionWidgets.append( ui.headphoneEffect );
355 optionWidgets.append( ui.spdifBox );
356 updateAudioOptions( ui.outputModule->currentIndex() );
359 if( module_exists( "audioscrobbler" ) )
361 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
363 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
366 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
367 ui.lastfm->setChecked( true );
369 ui.lastfm->setChecked( false );
371 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
373 CONNECT( ui.lastfm, toggled( bool ),
374 ui.lastfm_zone, setVisible( bool ) );
375 CONNECT( ui.lastfm, stateChanged( int ),
376 this, lastfm_Changed( int ) );
381 ui.lastfm_zone->hide();
385 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
386 setEnabled( bool ) );
388 char* psz = config_GetPsz( p_intf, "audio-filter" );
389 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
392 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
393 ui.volNormBox->setChecked( b_enabled );
394 ui.volNormSpin->setEnabled( b_enabled );
396 b_enabled = ( qs_filter.contains( "headphone" ) );
397 ui.headphoneEffect->setChecked( b_enabled );
400 updateAudioVolume( ui.defaultVolume->value() ); // First time init
404 /* Input and Codecs Panel Implementation */
405 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
409 ui.DVDDevice->setToolTip(
410 qtr( "If this property is blank, different values\n"
411 "for DVD, VCD, and CDDA are set.\n"
412 "You can define a unique one or configure them \n"
413 "individually in the advanced preferences." ) );
414 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
415 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
416 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
417 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
418 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
419 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
421 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
423 free( psz_cddadiscpath );
424 free( psz_dvddiscpath );
425 free( psz_vcddiscpath );
427 CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
428 ui.DVDDevice, ui.DVDBrowse );
429 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
430 ui.recordPath, ui.recordBrowse );
432 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
434 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
435 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
437 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
439 /* live555 module prefs */
440 CONFIG_BOOL( "rtsp-tcp",
441 live555TransportRTSP_TCPRadio );
442 if ( !module_exists( "live555" ) )
444 ui.live555TransportRTSP_TCPRadio->hide();
445 ui.live555TransportHTTPRadio->hide();
446 ui.live555TransportLabel->hide();
449 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
451 ui.systemCodecBox->hide();
453 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
454 optionWidgets.append( ui.DVDDevice );
455 optionWidgets.append( ui.cachingCombo );
456 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
459 /* Add the things to the ComboBox */
460 #define addToCachingBox( str, cachingNumber ) \
461 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
462 addToCachingBox( N_("Custom"), CachingCustom );
463 addToCachingBox( N_("Lowest latency"), CachingLowest );
464 addToCachingBox( N_("Low latency"), CachingLow );
465 addToCachingBox( N_("Normal"), CachingNormal );
466 addToCachingBox( N_("High latency"), CachingHigh );
467 addToCachingBox( N_("Higher latency"), CachingHigher );
468 #undef addToCachingBox
470 #define TestCaC( name ) \
471 b_cache_equal = b_cache_equal && \
472 ( i_cache == config_GetInt( p_intf, name ) )
474 #define TestCaCi( name, int ) \
475 b_cache_equal = b_cache_equal && \
476 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
477 /* Select the accurate value of the ComboBox */
478 bool b_cache_equal = true;
479 int i_cache = config_GetInt( p_intf, "file-caching");
481 TestCaC( "udp-caching" );
482 if (module_exists ("dvdread"))
483 TestCaC( "dvdread-caching" );
484 if (module_exists ("dvdnav"))
485 TestCaC( "dvdnav-caching" );
486 TestCaC( "tcp-caching" );
487 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
488 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
490 TestCaC( "dshow-caching" );
492 if (module_exists ("v4l"))
493 TestCaC( "v4l-caching" );
494 if (module_exists ("access_jack"))
495 TestCaC( "jack-input-caching" );
496 if (module_exists ("v4l2"))
497 TestCaC( "v4l2-caching" );
498 if (module_exists ("pvr"))
499 TestCaC( "pvr-caching" );
501 if (module_exists ("livedotcom"))
502 TestCaCi( "rtsp-caching", 4 );
503 TestCaCi( "ftp-caching", 2 );
504 TestCaCi( "http-caching", 2 );
505 if (module_exists ("access_realrtsp"))
506 TestCaCi( "realrtsp-caching", 10 );
507 TestCaCi( "mms-caching", 10 );
508 if( b_cache_equal == 1 )
509 ui.cachingCombo->setCurrentIndex(
510 ui.cachingCombo->findData( QVariant( i_cache ) ) );
518 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
519 // ui.defaultLabel->setFont( italicFont );
520 ui.skinsLabel->setText(
521 qtr( "This is VLC's skinnable interface. You can download other skins at" )
522 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
523 ui.skinsLabel->setFont( italicFont );
526 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
527 BUTTONACT( ui.assoButton, assoDialog() );
529 ui.languageBox->hide();
533 char *psz_intf = config_GetPsz( p_intf, "intf" );
536 if( strstr( psz_intf, "skin" ) )
537 ui.skins->setChecked( true );
540 ui.qt4->setChecked( true );
544 optionWidgets.append( ui.skins );
545 optionWidgets.append( ui.qt4 );
546 #if !defined(NDEBUG) || !defined( WIN32)
547 ui.stylesCombo->addItem( qtr("System's default") );
548 ui.stylesCombo->addItems( QStyleFactory::keys() );
549 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
550 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
551 ui.stylesCombo->insertSeparator( 1 );
553 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
554 optionWidgets.append( ui.stylesCombo );
556 ui.stylesCombo->hide();
557 optionWidgets.append( NULL );
560 ui.skins_zone->setEnabled( ui.skins->isChecked() );
561 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
563 ui.native_zone->setEnabled( ui.qt4->isChecked() );
564 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
566 CONNECT( ui.displayModeBox, currentIndexChanged( int ),
567 ui.mainPreview, setPreview( int ) );
568 ui.skinsPreview->setPreview( 3 ); /* skins_preview resource index */
570 CONFIG_GENERIC( "qt-display-mode", IntegerList, ui.displayLabel,
572 CONFIG_BOOL( "embedded-video", embedVideo );
573 CONFIG_BOOL( "qt-fs-controller", fsController );
574 CONFIG_BOOL( "qt-system-tray", systrayBox );
575 CONFIG_BOOL( "qt-notification", sysPop );
576 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
577 ui.fileSkin, ui.skinBrowse );
578 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
580 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
585 CONFIG_BOOL( "qt-updates-notif", updatesBox );
586 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
588 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
589 CONNECT( ui.updatesBox, toggled( bool ),
590 ui.updatesDays, setEnabled( bool ) );
592 ui.updatesBox->hide();
593 ui.updatesDays->hide();
595 /* ONE INSTANCE options */
596 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
597 CONFIG_BOOL( "one-instance", OneInterfaceMode );
598 CONFIG_BOOL( "playlist-enqueue",
599 EnqueueOneInterfaceMode );
600 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
601 CONNECT( ui.OneInterfaceMode, toggled( bool ),
602 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
604 ui.OneInterfaceBox->hide();
606 /* RECENTLY PLAYED options */
607 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
608 ui.recentlyPlayedFilters, setEnabled( bool ) );
609 ui.recentlyPlayedFilters->setEnabled( false );
610 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
611 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
612 recentlyPlayedFilters );
616 START_SPREFS_CAT( Subtitles,
617 qtr("Subtitles & On Screen Display Settings") );
618 CONFIG_BOOL( "osd", OSDBox);
619 CONFIG_BOOL( "video-title-show", OSDTitleBox);
622 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
624 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
626 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
627 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
629 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
630 ui.fontSizeLabel, fontSize );
631 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
633 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
639 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
641 QGridLayout *gLayout = new QGridLayout;
642 panel->setLayout( gLayout );
645 panel_label->setText( qtr( "Configure Hotkeys" ) );
646 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
647 this, gLayout, line );
648 controls.append( control );
652 QFrame *sepline = new QFrame;
653 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
654 gLayout->addWidget( sepline, line, 0, 1, -1 );
658 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
659 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
660 p_config, false, this, gLayout, line );
661 controls.append( control );
667 panel_layout->addWidget( panel_label );
668 panel_layout->addWidget( title_line );
672 QScrollArea *scroller= new QScrollArea;
673 scroller->setWidget( panel );
674 scroller->setWidgetResizable( true );
675 scroller->setFrameStyle( QFrame::NoFrame );
676 panel_layout->addWidget( scroller );
680 panel_layout->addWidget( panel );
681 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
684 setLayout( panel_layout );
686 #undef END_SPREFS_CAT
687 #undef START_SPREFS_CAT
688 #undef CONFIG_GENERIC_FILE
689 #undef CONFIG_GENERIC_NO_BOOL
690 #undef CONFIG_GENERIC_NO_UI
691 #undef CONFIG_GENERIC
696 void SPrefsPanel::updateAudioOptions( int number)
698 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
699 ->itemData( number ).toString();
701 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
703 /* optionWidgets[ossW] can be NULL */
704 if( optionWidgets[ossW] )
705 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
706 /* optionWidgets[alsaW] can be NULL */
707 if( optionWidgets[alsaW] )
708 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
710 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
711 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
712 value == "aout_directx" || value == "waveout" ) );
716 SPrefsPanel::~SPrefsPanel()
718 qDeleteAll( controls ); controls.clear();
721 void SPrefsPanel::updateAudioVolume( int volume )
723 qobject_cast<QSpinBox *>(optionWidgets[volLW])
724 ->setValue( volume * 100 / 256 );
728 /* Function called from the main Preferences dialog on each SPrefs Panel */
729 void SPrefsPanel::apply()
731 /* Generic save for ever panel */
732 QList<ConfigControl *>::Iterator i;
733 for( i = controls.begin() ; i != controls.end() ; i++ )
735 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
736 c->doApply( p_intf );
741 case SPrefsInputAndCodecs:
743 /* Device default selection */
744 char *psz_devicepath =
745 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
746 if( !EMPTY_STR( psz_devicepath ) )
748 config_PutPsz( p_intf, "dvd", psz_devicepath );
749 config_PutPsz( p_intf, "vcd", psz_devicepath );
750 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
751 free( psz_devicepath );
754 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
755 #define CaC( name ) CaCi( name, 1 )
757 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
758 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
761 CaC( "udp-caching" );
762 if (module_exists ("dvdread" ))
763 CaC( "dvdread-caching" );
764 if (module_exists ("dvdnav" ))
765 CaC( "dvdnav-caching" );
766 CaC( "tcp-caching" ); CaC( "vcd-caching" );
767 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
768 CaC( "screen-caching" ); CaC( "bd-caching" );
769 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
770 CaCi( "http-caching", 2 );
771 if (module_exists ("access_realrtsp" ))
772 CaCi( "realrtsp-caching", 10 );
773 CaCi( "mms-caching", 10 );
775 CaC( "dshow-caching" );
777 if (module_exists ( "v4l" ))
778 CaC( "v4l-caching" );
779 if (module_exists ( "access_jack" ))
780 CaC( "jack-input-caching" );
781 if (module_exists ( "v4l2" ))
782 CaC( "v4l2-caching" );
783 if (module_exists ( "pvr" ))
784 CaC( "pvr-caching" );
786 //CaCi( "dv-caching" ) too short...
794 case SPrefsInterface:
796 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
797 config_PutPsz( p_intf, "intf", "skins2" );
798 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
799 config_PutPsz( p_intf, "intf", "qt" );
800 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
801 getSettings()->setValue( "MainWindow/QtStyle",
802 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
810 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
811 if( b_checked && !qs_filter.contains( "volnorm" ) )
812 qs_filter.append( "volnorm" );
813 if( !b_checked && qs_filter.contains( "volnorm" ) )
814 qs_filter.removeAll( "volnorm" );
817 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
819 if( b_checked && !qs_filter.contains( "headphone" ) )
820 qs_filter.append( "headphone" );
821 if( !b_checked && qs_filter.contains( "headphone" ) )
822 qs_filter.removeAll( "headphone" );
824 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
830 void SPrefsPanel::clean()
833 void SPrefsPanel::lastfm_Changed( int i_state )
835 if( i_state == Qt::Checked )
836 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
837 else if( i_state == Qt::Unchecked )
838 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
841 void SPrefsPanel::changeStyle( QString s_style )
843 QApplication::setStyle( s_style );
845 /* force refresh on all widgets */
846 QWidgetList widgets = QApplication::allWidgets();
847 QWidgetList::iterator it = widgets.begin();
848 while( it != widgets.end() ) {
855 #include <QDialogButtonBox>
856 #include <QHeaderView>
857 #include "util/registry.hpp"
860 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
861 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
864 const char* psz_VLC = "VLC";
865 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
867 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
869 current->setCheckState( 0, Qt::Checked );
874 current->setCheckState( 0, Qt::Unchecked );
877 listAsso.append( current );
881 void SPrefsPanel::assoDialog()
883 LPAPPASSOCREGUI p_appassoc;
886 if( S_OK == CoCreateInstance( &clsid_IApplication2,
887 NULL, CLSCTX_INPROC_SERVER,
888 &IID_IApplicationAssociationRegistrationUI,
889 (void **)&p_appassoc) )
891 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
900 QDialog *d = new QDialog( this );
901 QGridLayout *assoLayout = new QGridLayout( d );
903 QTreeWidget *filetypeList = new QTreeWidget;
904 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
905 filetypeList->header()->hide();
907 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
909 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
910 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
911 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
913 filetypeList->addTopLevelItem( audioType );
914 filetypeList->addTopLevelItem( videoType );
915 filetypeList->addTopLevelItem( otherType );
917 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
918 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
919 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
921 QTreeWidgetItem *currentItem;
924 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
925 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
926 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
928 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
929 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
930 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
931 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
932 audioType->setCheckState( 0, ( i_temp > 0 ) ?
933 ( ( i_temp == audioType->childCount() ) ?
934 Qt::Checked : Qt::PartiallyChecked )
938 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
939 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
940 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
941 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
942 aTv( ".mts" ); aTv( ".mxf" );
943 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
944 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
945 videoType->setCheckState( 0, ( i_temp > 0 ) ?
946 ( ( i_temp == audioType->childCount() ) ?
947 Qt::Checked : Qt::PartiallyChecked )
951 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
952 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
953 otherType->setCheckState( 0, ( i_temp > 0 ) ?
954 ( ( i_temp == audioType->childCount() ) ?
955 Qt::Checked : Qt::PartiallyChecked )
962 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
963 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
964 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
965 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
966 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
968 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
970 CONNECT( closeButton, clicked(), this, saveAsso() );
971 CONNECT( clearButton, clicked(), d, reject() );
972 d->resize( 300, 400 );
979 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
981 std::string s_path( "VLC" ); s_path += psz_ext;
982 std::string s_path2 = s_path;
984 /* Save a backup if already assigned */
985 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
987 if( psz_value && strlen( psz_value ) > 0 )
988 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
991 /* Put a "link" to VLC.EXT as default */
992 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
994 /* Create the needed Key if they weren't done in the installer */
995 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
997 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
998 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
999 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1001 /* Get the installer path */
1002 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1003 std::string str_temp; str_temp.assign(
1004 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1006 if( str_temp.size() )
1008 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1009 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1011 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1012 "", str_temp.append(",0").c_str() );
1018 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1020 char psz_VLC[] = "VLC";
1021 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1023 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1026 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1028 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1030 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1032 delete( psz_value );
1034 void SPrefsPanel::saveAsso()
1036 QVLCRegistry * qvReg;
1037 for( int i = 0; i < listAsso.size(); i ++ )
1039 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1040 if( listAsso[i]->checkState( 0 ) > 0 )
1042 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1046 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1050 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();