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>
52 #include <vlc_modules.h>
54 /*********************************************************************
55 * The List of categories
56 *********************************************************************/
57 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
58 QWidget( _parent ), p_intf( _p_intf )
60 QVBoxLayout *layout = new QVBoxLayout();
62 QButtonGroup *buttonGroup = new QButtonGroup( this );
63 buttonGroup->setExclusive ( true );
64 CONNECT( buttonGroup, buttonClicked ( int ),
65 this, switchPanel( int ) );
67 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
69 #define ADD_CATEGORY( button, label, icon, numb ) \
70 QToolButton * button = new QToolButton( this ); \
71 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
72 button->setText( label ); \
73 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
74 button->setIconSize( QSize( icon_height, icon_height ) ); \
75 button->resize( icon_height + 6 , icon_height + 6 ); \
76 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
77 button->setAutoRaise( true ); \
78 button->setCheckable( true ); \
79 buttonGroup->addButton( button, numb ); \
80 layout->addWidget( button );
82 ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
83 cone_interface_64, 0 );
84 ADD_CATEGORY( SPrefsAudio, qtr("Audio"),
86 ADD_CATEGORY( SPrefsVideo, qtr("Video"),
88 ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles && OSD"),
89 cone_subtitles_64, 3 );
90 ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input && Codecs"),
92 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"),
97 SPrefsInterface->setChecked( true );
98 layout->setMargin( 0 );
99 layout->setSpacing( 1 );
101 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
106 void SPrefsCatList::switchPanel( int i )
108 emit currentItemChanged( i );
111 /*********************************************************************
113 *********************************************************************/
114 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
115 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
117 module_config_t *p_config;
118 ConfigControl *control;
121 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
122 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
125 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
126 p_config, label, ui.qcontrol, false ); \
127 controls.append( control ); \
130 ui.qcontrol->setEnabled( false ); \
131 if( label ) label->setEnabled( false ); \
134 #define CONFIG_BOOL( option, qcontrol ) \
135 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
138 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
139 p_config, NULL, ui.qcontrol, false ); \
140 controls.append( control ); \
142 else { ui.qcontrol->setEnabled( false ); }
145 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
146 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
149 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
150 p_config, label, qcontrol, false ); \
151 controls.append( control ); \
154 QWidget *widget = label; \
155 qcontrol->setVisible( false ); \
156 if( widget ) widget->setEnabled( false ); \
160 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
161 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
164 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
165 p_config, label, ui.qcontrol ); \
166 controls.append( control ); \
169 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
170 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
173 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
174 p_config, label, qcontrol, qbutton ); \
175 controls.append( control ); \
178 #define START_SPREFS_CAT( name , label ) \
179 case SPrefs ## name: \
181 Ui::SPrefs ## name ui; \
182 ui.setupUi( panel ); \
183 panel_label->setText( label );
185 #define END_SPREFS_CAT \
189 QVBoxLayout *panel_layout = new QVBoxLayout();
190 QWidget *panel = new QWidget();
191 panel_layout->setMargin( 3 );
194 QLabel *panel_label = new QLabel;
195 QFont labelFont = QApplication::font();
196 labelFont.setPointSize( labelFont.pointSize() + 6 );
197 panel_label->setFont( labelFont );
200 QFrame *title_line = new QFrame;
201 title_line->setFrameShape(QFrame::HLine);
202 title_line->setFrameShadow(QFrame::Sunken);
204 QFont italicFont = QApplication::font();
205 italicFont.setItalic( true );
209 /******************************
210 * VIDEO Panel Implementation *
211 ******************************/
212 START_SPREFS_CAT( Video , qtr("Video Settings") );
213 CONFIG_BOOL( "video", enableVideo );
215 CONFIG_BOOL( "fullscreen", fullscreen );
216 CONFIG_BOOL( "overlay", overlay );
217 CONFIG_BOOL( "video-on-top", alwaysOnTop );
218 CONFIG_BOOL( "video-deco", windowDecorations );
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 DirectXLabel, DirectXDevice );
287 if( module_exists( "alsa" ) )
289 audioControl( alsa );
290 optionWidgets.append( alsaControl );
292 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
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 );
457 CONFIG_BOOL( "skip-frames", skipFrames );
458 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
459 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
460 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
461 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
464 /* Add the things to the ComboBox */
465 #define addToCachingBox( str, cachingNumber ) \
466 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
467 addToCachingBox( N_("Custom"), CachingCustom );
468 addToCachingBox( N_("Lowest latency"), CachingLowest );
469 addToCachingBox( N_("Low latency"), CachingLow );
470 addToCachingBox( N_("Normal"), CachingNormal );
471 addToCachingBox( N_("High latency"), CachingHigh );
472 addToCachingBox( N_("Higher latency"), CachingHigher );
473 #undef addToCachingBox
475 #define TestCaC( name ) \
476 b_cache_equal = b_cache_equal && \
477 ( i_cache == config_GetInt( p_intf, name ) )
479 #define TestCaCi( name, int ) \
480 b_cache_equal = b_cache_equal && \
481 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
482 /* Select the accurate value of the ComboBox */
483 bool b_cache_equal = true;
484 int i_cache = config_GetInt( p_intf, "file-caching");
486 TestCaC( "udp-caching" );
487 if (module_exists ("dvdread"))
488 TestCaC( "dvdread-caching" );
489 if (module_exists ("dvdnav"))
490 TestCaC( "dvdnav-caching" );
491 TestCaC( "tcp-caching" );
492 TestCaC( "cdda-caching" );
493 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
495 TestCaC( "dshow-caching" );
497 if (module_exists ("v4l"))
498 TestCaC( "v4l-caching" );
499 if (module_exists ("access_jack"))
500 TestCaC( "jack-input-caching" );
501 if (module_exists ("v4l2"))
502 TestCaC( "v4l2-caching" );
503 if (module_exists ("pvr"))
504 TestCaC( "pvr-caching" );
506 if (module_exists ("livedotcom"))
507 TestCaCi( "rtsp-caching", 4 );
508 TestCaCi( "ftp-caching", 2 );
509 TestCaCi( "http-caching", 2 );
510 if (module_exists ("access_realrtsp"))
511 TestCaCi( "realrtsp-caching", 10 );
512 TestCaCi( "mms-caching", 10 );
513 if( b_cache_equal == 1 )
514 ui.cachingCombo->setCurrentIndex(
515 ui.cachingCombo->findData( QVariant( i_cache ) ) );
523 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
524 // ui.defaultLabel->setFont( italicFont );
525 ui.skinsLabel->setText(
526 qtr( "This is VLC's skinnable interface. You can download other skins at" )
527 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
528 + qtr( "VLC skins website" )+ QString( "</a>." ) );
529 ui.skinsLabel->setFont( italicFont );
532 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
533 BUTTONACT( ui.assoButton, assoDialog() );
535 ui.languageBox->hide();
536 ui.assoButton->hide();
537 ui.assocLabel->hide();
540 char *psz_intf = config_GetPsz( p_intf, "intf" );
543 if( strstr( psz_intf, "skin" ) )
544 ui.skins->setChecked( true );
547 ui.qt4->setChecked( true );
551 optionWidgets.append( ui.skins );
552 optionWidgets.append( ui.qt4 );
553 #if !defined(NDEBUG) || !defined( WIN32)
554 ui.stylesCombo->addItem( qtr("System's default") );
555 ui.stylesCombo->addItems( QStyleFactory::keys() );
556 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
557 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
558 ui.stylesCombo->insertSeparator( 1 );
560 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
561 optionWidgets.append( ui.stylesCombo );
563 ui.stylesCombo->hide();
564 optionWidgets.append( NULL );
567 ui.skins_zone->setEnabled( ui.skins->isChecked() );
568 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
570 ui.native_zone->setEnabled( ui.qt4->isChecked() );
571 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
573 CONNECT( ui.minimalviewBox, toggled( bool ),
574 ui.mainPreview, setNormalPreview( bool ) );
575 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
576 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
577 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
579 CONFIG_BOOL( "embedded-video", embedVideo );
580 CONFIG_BOOL( "qt-fs-controller", fsController );
581 CONFIG_BOOL( "qt-system-tray", systrayBox );
582 CONFIG_BOOL( "qt-notification", sysPop );
583 CONFIG_BOOL( "playlist-tree", treePlaylist );
584 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
585 ui.fileSkin, ui.skinBrowse );
586 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
588 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
593 CONFIG_BOOL( "qt-updates-notif", updatesBox );
594 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
596 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
597 CONNECT( ui.updatesBox, toggled( bool ),
598 ui.updatesDays, setEnabled( bool ) );
600 ui.updatesBox->hide();
601 ui.updatesDays->hide();
603 /* ONE INSTANCE options */
604 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
605 CONFIG_BOOL( "one-instance", OneInterfaceMode );
606 CONFIG_BOOL( "playlist-enqueue",
607 EnqueueOneInterfaceMode );
608 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
609 CONNECT( ui.OneInterfaceMode, toggled( bool ),
610 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
612 ui.OneInterfaceBox->hide();
614 /* RECENTLY PLAYED options */
615 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
616 ui.recentlyPlayedFilters, setEnabled( bool ) );
617 ui.recentlyPlayedFilters->setEnabled( false );
618 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
619 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
620 recentlyPlayedFilters );
624 START_SPREFS_CAT( Subtitles,
625 qtr("Subtitles & On Screen Display Settings") );
626 CONFIG_BOOL( "osd", OSDBox);
627 CONFIG_BOOL( "video-title-show", OSDTitleBox);
630 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
632 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
634 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
635 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
637 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
638 ui.fontSizeLabel, fontSize );
639 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
641 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
647 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
649 QGridLayout *gLayout = new QGridLayout;
650 panel->setLayout( gLayout );
653 panel_label->setText( qtr( "Configure Hotkeys" ) );
654 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
655 this, gLayout, line );
656 controls.append( control );
660 QFrame *sepline = new QFrame;
661 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
662 gLayout->addWidget( sepline, line, 0, 1, -1 );
666 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
667 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
668 p_config, false, this, gLayout, line );
669 controls.append( control );
675 panel_layout->addWidget( panel_label );
676 panel_layout->addWidget( title_line );
680 QScrollArea *scroller= new QScrollArea;
681 scroller->setWidget( panel );
682 scroller->setWidgetResizable( true );
683 scroller->setFrameStyle( QFrame::NoFrame );
684 panel_layout->addWidget( scroller );
688 panel_layout->addWidget( panel );
689 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
692 setLayout( panel_layout );
694 #undef END_SPREFS_CAT
695 #undef START_SPREFS_CAT
696 #undef CONFIG_GENERIC_FILE
697 #undef CONFIG_GENERIC_NO_BOOL
698 #undef CONFIG_GENERIC_NO_UI
699 #undef CONFIG_GENERIC
704 void SPrefsPanel::updateAudioOptions( int number)
706 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
707 ->itemData( number ).toString();
709 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
711 /* optionWidgets[ossW] can be NULL */
712 if( optionWidgets[ossW] )
713 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
714 /* optionWidgets[alsaW] can be NULL */
715 if( optionWidgets[alsaW] )
716 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
718 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
719 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
720 value == "aout_directx" || value == "waveout" ) );
724 SPrefsPanel::~SPrefsPanel()
726 qDeleteAll( controls ); controls.clear();
729 void SPrefsPanel::updateAudioVolume( int volume )
731 qobject_cast<QSpinBox *>(optionWidgets[volLW])
732 ->setValue( volume * 100 / 256 );
736 /* Function called from the main Preferences dialog on each SPrefs Panel */
737 void SPrefsPanel::apply()
739 /* Generic save for ever panel */
740 QList<ConfigControl *>::Iterator i;
741 for( i = controls.begin() ; i != controls.end() ; i++ )
743 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
744 c->doApply( p_intf );
749 case SPrefsInputAndCodecs:
751 /* Device default selection */
752 char *psz_devicepath =
753 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
754 if( !EMPTY_STR( psz_devicepath ) )
756 config_PutPsz( p_intf, "dvd", psz_devicepath );
757 config_PutPsz( p_intf, "vcd", psz_devicepath );
758 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
759 free( psz_devicepath );
762 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
763 #define CaC( name ) CaCi( name, 1 )
765 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
766 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
769 CaC( "udp-caching" );
770 if (module_exists ("dvdread" ))
771 CaC( "dvdread-caching" );
772 if (module_exists ("dvdnav" ))
773 CaC( "dvdnav-caching" );
774 CaC( "tcp-caching" ); CaC( "vcd-caching" );
775 CaC( "cdda-caching" ); CaC( "file-caching" );
776 CaC( "screen-caching" ); CaC( "bd-caching" );
777 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
778 CaCi( "http-caching", 2 );
779 if (module_exists ("access_realrtsp" ))
780 CaCi( "realrtsp-caching", 10 );
781 CaCi( "mms-caching", 10 );
783 CaC( "dshow-caching" );
785 if (module_exists ( "v4l" ))
786 CaC( "v4l-caching" );
787 if (module_exists ( "access_jack" ))
788 CaC( "jack-input-caching" );
789 if (module_exists ( "v4l2" ))
790 CaC( "v4l2-caching" );
791 if (module_exists ( "pvr" ))
792 CaC( "pvr-caching" );
794 //CaCi( "dv-caching" ) too short...
802 case SPrefsInterface:
804 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
805 config_PutPsz( p_intf, "intf", "skins2" );
806 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
807 config_PutPsz( p_intf, "intf", "qt" );
808 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
809 getSettings()->setValue( "MainWindow/QtStyle",
810 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
818 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
819 if( b_checked && !qs_filter.contains( "volnorm" ) )
820 qs_filter.append( "volnorm" );
821 if( !b_checked && qs_filter.contains( "volnorm" ) )
822 qs_filter.removeAll( "volnorm" );
825 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
827 if( b_checked && !qs_filter.contains( "headphone" ) )
828 qs_filter.append( "headphone" );
829 if( !b_checked && qs_filter.contains( "headphone" ) )
830 qs_filter.removeAll( "headphone" );
832 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
838 void SPrefsPanel::clean()
841 void SPrefsPanel::lastfm_Changed( int i_state )
843 if( i_state == Qt::Checked )
844 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
845 else if( i_state == Qt::Unchecked )
846 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
849 void SPrefsPanel::changeStyle( QString s_style )
851 QApplication::setStyle( s_style );
853 /* force refresh on all widgets */
854 QWidgetList widgets = QApplication::allWidgets();
855 QWidgetList::iterator it = widgets.begin();
856 while( it != widgets.end() ) {
863 #include <QDialogButtonBox>
864 #include <QHeaderView>
865 #include "util/registry.hpp"
868 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
869 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
872 const char* psz_VLC = "VLC";
873 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
875 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
877 current->setCheckState( 0, Qt::Checked );
882 current->setCheckState( 0, Qt::Unchecked );
885 listAsso.append( current );
889 void SPrefsPanel::assoDialog()
891 LPAPPASSOCREGUI p_appassoc;
894 if( S_OK == CoCreateInstance( &clsid_IApplication2,
895 NULL, CLSCTX_INPROC_SERVER,
896 &IID_IApplicationAssociationRegistrationUI,
897 (void **)&p_appassoc) )
899 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
908 QDialog *d = new QDialog( this );
909 QGridLayout *assoLayout = new QGridLayout( d );
911 QTreeWidget *filetypeList = new QTreeWidget;
912 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
913 filetypeList->header()->hide();
915 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
917 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
918 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
919 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
921 filetypeList->addTopLevelItem( audioType );
922 filetypeList->addTopLevelItem( videoType );
923 filetypeList->addTopLevelItem( otherType );
925 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
926 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
927 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
929 QTreeWidgetItem *currentItem;
932 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
933 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
934 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
936 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
937 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
938 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
939 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
940 audioType->setCheckState( 0, ( i_temp > 0 ) ?
941 ( ( i_temp == audioType->childCount() ) ?
942 Qt::Checked : Qt::PartiallyChecked )
946 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
947 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
948 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
949 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
950 aTv( ".mts" ); aTv( ".mxf" );
951 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
952 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
953 videoType->setCheckState( 0, ( i_temp > 0 ) ?
954 ( ( i_temp == audioType->childCount() ) ?
955 Qt::Checked : Qt::PartiallyChecked )
959 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
960 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
961 otherType->setCheckState( 0, ( i_temp > 0 ) ?
962 ( ( i_temp == audioType->childCount() ) ?
963 Qt::Checked : Qt::PartiallyChecked )
970 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
971 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
972 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
973 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
974 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
976 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
978 CONNECT( closeButton, clicked(), this, saveAsso() );
979 CONNECT( clearButton, clicked(), d, reject() );
980 d->resize( 300, 400 );
987 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
989 std::string s_path( "VLC" ); s_path += psz_ext;
990 std::string s_path2 = s_path;
992 /* Save a backup if already assigned */
993 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
995 if( psz_value && strlen( psz_value ) > 0 )
996 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
999 /* Put a "link" to VLC.EXT as default */
1000 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1002 /* Create the needed Key if they weren't done in the installer */
1003 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1005 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1006 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1007 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1009 /* Get the installer path */
1010 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1011 std::string str_temp; str_temp.assign(
1012 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1014 if( str_temp.size() )
1016 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1017 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1019 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1020 "", str_temp.append(",0").c_str() );
1026 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1028 char psz_VLC[] = "VLC";
1029 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1031 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1034 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1036 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1038 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1040 delete( psz_value );
1042 void SPrefsPanel::saveAsso()
1044 QVLCRegistry * qvReg;
1045 for( int i = 0; i < listAsso.size(); i ++ )
1047 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1048 if( listAsso[i]->checkState( 0 ) > 0 )
1050 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1054 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1058 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();