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( static_cast<QWidget*>(0) );
195 labelFont.setPointSize( labelFont.pointSize() + 6 );
196 labelFont.setFamily( "Verdana" );
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( static_cast<QWidget*>(0) );
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_BOOL( "skip-frames", skipFrames );
220 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
222 CONFIG_BOOL( "video-wallpaper", wallpaperMode );
224 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
226 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
228 ui.directXBox->setVisible( false );
229 ui.hwYUVBox->setVisible( false );
232 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
233 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
234 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
236 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
237 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
238 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
239 CONFIG_BOOL( "snapshot-sequential",
240 snapshotsSequentialNumbering );
241 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
245 /******************************
246 * AUDIO Panel Implementation *
247 ******************************/
248 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
250 CONFIG_BOOL( "audio", enableAudio );
251 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
252 CONNECT( ui.enableAudio, toggled( bool ),
253 ui.SPrefsAudio_zone, setEnabled( bool ) );
255 #define audioCommon( name ) \
256 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
257 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
258 name ## Layout->setMargin( 0 ); \
259 name ## Layout->setSpacing( 0 ); \
260 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
261 name ## Label->setMinimumSize(QSize(250, 0)); \
262 name ## Layout->addWidget( name ## Label ); \
264 #define audioControl( name) \
265 audioCommon( name ) \
266 QComboBox * name ## Device = new QComboBox( name ## Control ); \
267 name ## Layout->addWidget( name ## Device ); \
268 name ## Label->setBuddy( name ## Device ); \
269 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
271 #define audioControl2( name) \
272 audioCommon( name ) \
273 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
274 name ## Layout->addWidget( name ## Device ); \
275 name ## Label->setBuddy( name ## Device ); \
276 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
277 name ## Layout->addWidget( name ## Browse ); \
278 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
280 /* Build if necessary */
281 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
283 audioControl( DirectX );
284 optionWidgets.append( DirectXControl );
285 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
286 DirectXLabel, DirectXDevice );
288 if( module_exists( "alsa" ) )
290 audioControl( alsa );
291 optionWidgets.append( alsaControl );
293 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
297 optionWidgets.append( NULL );
298 if( module_exists( "oss" ) )
300 audioControl2( OSS );
301 optionWidgets.append( OSSControl );
302 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
306 optionWidgets.append( NULL );
314 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
316 CONNECT( ui.defaultVolume, valueChanged( int ),
317 this, updateAudioVolume( int ) );
319 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
320 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
321 CONNECT( ui.resetVolumeRadio, toggled( bool ),
322 ui.defaultVolume_zone, setEnabled( bool ) );
324 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
325 preferredAudioLanguage );
327 CONFIG_BOOL( "spdif", spdifBox );
328 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
331 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
333 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
335 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
337 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
339 /* Audio Output Specifics */
340 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
342 CONNECT( ui.outputModule, currentIndexChanged( int ),
343 this, updateAudioOptions( int ) );
345 /* File output exists on all platforms */
346 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
347 ui.fileName, ui.fileBrowseButton );
349 optionWidgets.append( ui.fileControl );
350 optionWidgets.append( ui.outputModule );
351 optionWidgets.append( ui.volNormBox );
352 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
353 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
354 optionWidgets.append( ui.volumeValue );
355 optionWidgets.append( ui.headphoneEffect );
356 optionWidgets.append( ui.spdifBox );
357 updateAudioOptions( ui.outputModule->currentIndex() );
360 if( module_exists( "audioscrobbler" ) )
362 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
364 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
367 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
368 ui.lastfm->setChecked( true );
370 ui.lastfm->setChecked( false );
372 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
374 CONNECT( ui.lastfm, toggled( bool ),
375 ui.lastfm_zone, setVisible( bool ) );
376 CONNECT( ui.lastfm, stateChanged( int ),
377 this, lastfm_Changed( int ) );
382 ui.lastfm_zone->hide();
386 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
387 setEnabled( bool ) );
389 char* psz = config_GetPsz( p_intf, "audio-filter" );
390 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
393 bool b_enabled = ( qs_filter.contains( "volnorm" ) );
394 ui.volNormBox->setChecked( b_enabled );
395 ui.volNormSpin->setEnabled( b_enabled );
397 b_enabled = ( qs_filter.contains( "headphone" ) );
398 ui.headphoneEffect->setChecked( b_enabled );
401 updateAudioVolume( ui.defaultVolume->value() ); // First time init
405 /* Input and Codecs Panel Implementation */
406 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
410 ui.DVDDevice->setToolTip(
411 qtr( "If this property is blank, different values\n"
412 "for DVD, VCD, and CDDA are set.\n"
413 "You can define a unique one or configure them \n"
414 "individually in the advanced preferences." ) );
415 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
416 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
417 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
418 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
419 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
420 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
422 ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
424 free( psz_cddadiscpath );
425 free( psz_dvddiscpath );
426 free( psz_vcddiscpath );
428 CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
429 ui.DVDDevice, ui.DVDBrowse );
430 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
431 ui.recordPath, ui.recordBrowse );
433 CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
435 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
436 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
438 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
440 /* live555 module prefs */
441 CONFIG_BOOL( "rtsp-tcp",
442 live555TransportRTSP_TCPRadio );
443 if ( !module_exists( "live555" ) )
445 ui.live555TransportRTSP_TCPRadio->hide();
446 ui.live555TransportHTTPRadio->hide();
447 ui.live555TransportLabel->hide();
450 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
452 ui.systemCodecBox->hide();
454 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox );
455 optionWidgets.append( ui.DVDDevice );
456 optionWidgets.append( ui.cachingCombo );
457 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
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();
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_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
583 ui.fileSkin, ui.skinBrowse );
584 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
586 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
591 CONFIG_BOOL( "qt-updates-notif", updatesBox );
592 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
594 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
595 CONNECT( ui.updatesBox, toggled( bool ),
596 ui.updatesDays, setEnabled( bool ) );
598 ui.updatesBox->hide();
599 ui.updatesDays->hide();
601 /* ONE INSTANCE options */
602 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
603 CONFIG_BOOL( "one-instance", OneInterfaceMode );
604 CONFIG_BOOL( "playlist-enqueue",
605 EnqueueOneInterfaceMode );
606 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
607 CONNECT( ui.OneInterfaceMode, toggled( bool ),
608 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
610 ui.OneInterfaceBox->hide();
612 /* RECENTLY PLAYED options */
613 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
614 ui.recentlyPlayedFilters, setEnabled( bool ) );
615 ui.recentlyPlayedFilters->setEnabled( false );
616 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
617 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
618 recentlyPlayedFilters );
622 START_SPREFS_CAT( Subtitles,
623 qtr("Subtitles & On Screen Display Settings") );
624 CONFIG_BOOL( "osd", OSDBox);
625 CONFIG_BOOL( "video-title-show", OSDTitleBox);
628 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
630 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
632 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
633 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
635 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
636 ui.fontSizeLabel, fontSize );
637 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
639 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
645 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
647 QGridLayout *gLayout = new QGridLayout;
648 panel->setLayout( gLayout );
651 panel_label->setText( qtr( "Configure Hotkeys" ) );
652 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
653 this, gLayout, line );
654 controls.append( control );
658 QFrame *sepline = new QFrame;
659 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
660 gLayout->addWidget( sepline, line, 0, 1, -1 );
664 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
665 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
666 p_config, false, this, gLayout, line );
667 controls.append( control );
673 panel_layout->addWidget( panel_label );
674 panel_layout->addWidget( title_line );
678 QScrollArea *scroller= new QScrollArea;
679 scroller->setWidget( panel );
680 scroller->setWidgetResizable( true );
681 scroller->setFrameStyle( QFrame::NoFrame );
682 panel_layout->addWidget( scroller );
686 panel_layout->addWidget( panel );
687 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
690 setLayout( panel_layout );
692 #undef END_SPREFS_CAT
693 #undef START_SPREFS_CAT
694 #undef CONFIG_GENERIC_FILE
695 #undef CONFIG_GENERIC_NO_BOOL
696 #undef CONFIG_GENERIC_NO_UI
697 #undef CONFIG_GENERIC
702 void SPrefsPanel::updateAudioOptions( int number)
704 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
705 ->itemData( number ).toString();
707 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
709 /* optionWidgets[ossW] can be NULL */
710 if( optionWidgets[ossW] )
711 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
712 /* optionWidgets[alsaW] can be NULL */
713 if( optionWidgets[alsaW] )
714 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
716 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
717 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
718 value == "aout_directx" || value == "waveout" ) );
722 SPrefsPanel::~SPrefsPanel()
724 qDeleteAll( controls ); controls.clear();
727 void SPrefsPanel::updateAudioVolume( int volume )
729 qobject_cast<QSpinBox *>(optionWidgets[volLW])
730 ->setValue( volume * 100 / 256 );
734 /* Function called from the main Preferences dialog on each SPrefs Panel */
735 void SPrefsPanel::apply()
737 /* Generic save for ever panel */
738 QList<ConfigControl *>::Iterator i;
739 for( i = controls.begin() ; i != controls.end() ; i++ )
741 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
742 c->doApply( p_intf );
747 case SPrefsInputAndCodecs:
749 /* Device default selection */
750 char *psz_devicepath =
751 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
752 if( !EMPTY_STR( psz_devicepath ) )
754 config_PutPsz( p_intf, "dvd", psz_devicepath );
755 config_PutPsz( p_intf, "vcd", psz_devicepath );
756 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
757 free( psz_devicepath );
760 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
761 #define CaC( name ) CaCi( name, 1 )
763 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
764 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
767 CaC( "udp-caching" );
768 if (module_exists ("dvdread" ))
769 CaC( "dvdread-caching" );
770 if (module_exists ("dvdnav" ))
771 CaC( "dvdnav-caching" );
772 CaC( "tcp-caching" ); CaC( "vcd-caching" );
773 CaC( "cdda-caching" ); CaC( "file-caching" );
774 CaC( "screen-caching" ); CaC( "bd-caching" );
775 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
776 CaCi( "http-caching", 2 );
777 if (module_exists ("access_realrtsp" ))
778 CaCi( "realrtsp-caching", 10 );
779 CaCi( "mms-caching", 10 );
781 CaC( "dshow-caching" );
783 if (module_exists ( "v4l" ))
784 CaC( "v4l-caching" );
785 if (module_exists ( "access_jack" ))
786 CaC( "jack-input-caching" );
787 if (module_exists ( "v4l2" ))
788 CaC( "v4l2-caching" );
789 if (module_exists ( "pvr" ))
790 CaC( "pvr-caching" );
792 //CaCi( "dv-caching" ) too short...
800 case SPrefsInterface:
802 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
803 config_PutPsz( p_intf, "intf", "skins2" );
804 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
805 config_PutPsz( p_intf, "intf", "qt" );
806 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
807 getSettings()->setValue( "MainWindow/QtStyle",
808 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
816 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
817 if( b_checked && !qs_filter.contains( "volnorm" ) )
818 qs_filter.append( "volnorm" );
819 if( !b_checked && qs_filter.contains( "volnorm" ) )
820 qs_filter.removeAll( "volnorm" );
823 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
825 if( b_checked && !qs_filter.contains( "headphone" ) )
826 qs_filter.append( "headphone" );
827 if( !b_checked && qs_filter.contains( "headphone" ) )
828 qs_filter.removeAll( "headphone" );
830 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
836 void SPrefsPanel::clean()
839 void SPrefsPanel::lastfm_Changed( int i_state )
841 if( i_state == Qt::Checked )
842 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
843 else if( i_state == Qt::Unchecked )
844 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
847 void SPrefsPanel::changeStyle( QString s_style )
849 QApplication::setStyle( s_style );
851 /* force refresh on all widgets */
852 QWidgetList widgets = QApplication::allWidgets();
853 QWidgetList::iterator it = widgets.begin();
854 while( it != widgets.end() ) {
861 #include <QDialogButtonBox>
862 #include <QHeaderView>
863 #include "util/registry.hpp"
866 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
867 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
870 const char* psz_VLC = "VLC";
871 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
873 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
875 current->setCheckState( 0, Qt::Checked );
880 current->setCheckState( 0, Qt::Unchecked );
883 listAsso.append( current );
887 void SPrefsPanel::assoDialog()
889 LPAPPASSOCREGUI p_appassoc;
892 if( S_OK == CoCreateInstance( &clsid_IApplication2,
893 NULL, CLSCTX_INPROC_SERVER,
894 &IID_IApplicationAssociationRegistrationUI,
895 (void **)&p_appassoc) )
897 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
906 QDialog *d = new QDialog( this );
907 QGridLayout *assoLayout = new QGridLayout( d );
909 QTreeWidget *filetypeList = new QTreeWidget;
910 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
911 filetypeList->header()->hide();
913 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
915 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
916 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
917 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
919 filetypeList->addTopLevelItem( audioType );
920 filetypeList->addTopLevelItem( videoType );
921 filetypeList->addTopLevelItem( otherType );
923 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
924 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
925 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
927 QTreeWidgetItem *currentItem;
930 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
931 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
932 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
934 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
935 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
936 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
937 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
938 audioType->setCheckState( 0, ( i_temp > 0 ) ?
939 ( ( i_temp == audioType->childCount() ) ?
940 Qt::Checked : Qt::PartiallyChecked )
944 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
945 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
946 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
947 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
948 aTv( ".mts" ); aTv( ".mxf" );
949 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
950 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
951 videoType->setCheckState( 0, ( i_temp > 0 ) ?
952 ( ( i_temp == audioType->childCount() ) ?
953 Qt::Checked : Qt::PartiallyChecked )
957 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
958 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
959 otherType->setCheckState( 0, ( i_temp > 0 ) ?
960 ( ( i_temp == audioType->childCount() ) ?
961 Qt::Checked : Qt::PartiallyChecked )
968 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
969 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
970 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
971 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
972 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
974 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
976 CONNECT( closeButton, clicked(), this, saveAsso() );
977 CONNECT( clearButton, clicked(), d, reject() );
978 d->resize( 300, 400 );
985 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
987 std::string s_path( "VLC" ); s_path += psz_ext;
988 std::string s_path2 = s_path;
990 /* Save a backup if already assigned */
991 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
993 if( psz_value && strlen( psz_value ) > 0 )
994 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
997 /* Put a "link" to VLC.EXT as default */
998 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1000 /* Create the needed Key if they weren't done in the installer */
1001 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1003 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1004 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1005 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1007 /* Get the installer path */
1008 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1009 std::string str_temp; str_temp.assign(
1010 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1012 if( str_temp.size() )
1014 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1015 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1017 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1018 "", str_temp.append(",0").c_str() );
1024 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1026 char psz_VLC[] = "VLC";
1027 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1029 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1032 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1034 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1036 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1038 delete( psz_value );
1040 void SPrefsPanel::saveAsso()
1042 QVLCRegistry * qvReg;
1043 for( int i = 0; i < listAsso.size(); i ++ )
1045 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1046 if( listAsso[i]->checkState( 0 ) > 0 )
1048 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1052 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1056 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();