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 ui.volumeValue->setMaximum( QT_VOLUME_MAX / QT_VOLUME_DEFAULT * 100 );
314 CONFIG_GENERIC_NO_BOOL( "qt-startvolume" , 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_BOOL( "skip-frames", skipFrames );
459 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
460 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
461 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
462 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
465 /* Add the things to the ComboBox */
466 #define addToCachingBox( str, cachingNumber ) \
467 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
468 addToCachingBox( N_("Custom"), CachingCustom );
469 addToCachingBox( N_("Lowest latency"), CachingLowest );
470 addToCachingBox( N_("Low latency"), CachingLow );
471 addToCachingBox( N_("Normal"), CachingNormal );
472 addToCachingBox( N_("High latency"), CachingHigh );
473 addToCachingBox( N_("Higher latency"), CachingHigher );
474 #undef addToCachingBox
476 #define TestCaC( name ) \
477 b_cache_equal = b_cache_equal && \
478 ( i_cache == config_GetInt( p_intf, name ) )
480 #define TestCaCi( name, int ) \
481 b_cache_equal = b_cache_equal && \
482 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
483 /* Select the accurate value of the ComboBox */
484 bool b_cache_equal = true;
485 int i_cache = config_GetInt( p_intf, "file-caching");
487 TestCaC( "udp-caching" );
488 if (module_exists ("dvdread"))
489 TestCaC( "dvdread-caching" );
490 if (module_exists ("dvdnav"))
491 TestCaC( "dvdnav-caching" );
492 TestCaC( "tcp-caching" );
493 TestCaC( "cdda-caching" );
494 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
496 TestCaC( "dshow-caching" );
498 if (module_exists ("v4l"))
499 TestCaC( "v4l-caching" );
500 if (module_exists ("access_jack"))
501 TestCaC( "jack-input-caching" );
502 if (module_exists ("v4l2"))
503 TestCaC( "v4l2-caching" );
504 if (module_exists ("pvr"))
505 TestCaC( "pvr-caching" );
507 if (module_exists ("livedotcom"))
508 TestCaCi( "rtsp-caching", 4 );
509 TestCaCi( "ftp-caching", 2 );
510 TestCaCi( "http-caching", 2 );
511 if (module_exists ("access_realrtsp"))
512 TestCaCi( "realrtsp-caching", 10 );
513 TestCaCi( "mms-caching", 10 );
514 if( b_cache_equal == 1 )
515 ui.cachingCombo->setCurrentIndex(
516 ui.cachingCombo->findData( QVariant( i_cache ) ) );
524 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
525 // ui.defaultLabel->setFont( italicFont );
526 ui.skinsLabel->setText(
527 qtr( "This is VLC's skinnable interface. You can download other skins at" )
528 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
529 + qtr( "VLC skins website" )+ QString( "</a>." ) );
530 ui.skinsLabel->setFont( italicFont );
533 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
534 BUTTONACT( ui.assoButton, assoDialog() );
536 ui.languageBox->hide();
537 ui.assoButton->hide();
538 ui.assocLabel->hide();
541 char *psz_intf = config_GetPsz( p_intf, "intf" );
544 if( strstr( psz_intf, "skin" ) )
545 ui.skins->setChecked( true );
548 ui.qt4->setChecked( true );
552 optionWidgets.append( ui.skins );
553 optionWidgets.append( ui.qt4 );
554 #if !defined(NDEBUG) || !defined( WIN32)
555 ui.stylesCombo->addItem( qtr("System's default") );
556 ui.stylesCombo->addItems( QStyleFactory::keys() );
557 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
558 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
559 ui.stylesCombo->insertSeparator( 1 );
561 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
562 optionWidgets.append( ui.stylesCombo );
564 ui.stylesCombo->hide();
565 optionWidgets.append( NULL );
568 ui.skins_zone->setEnabled( ui.skins->isChecked() );
569 CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
571 ui.native_zone->setEnabled( ui.qt4->isChecked() );
572 CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
574 CONNECT( ui.minimalviewBox, toggled( bool ),
575 ui.mainPreview, setNormalPreview( bool ) );
576 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
577 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
578 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
580 CONFIG_BOOL( "embedded-video", embedVideo );
581 CONFIG_BOOL( "qt-fs-controller", fsController );
582 CONFIG_BOOL( "qt-system-tray", systrayBox );
583 CONFIG_BOOL( "qt-notification", sysPop );
584 CONFIG_BOOL( "playlist-tree", treePlaylist );
585 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
586 ui.fileSkin, ui.skinBrowse );
587 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
589 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
594 CONFIG_BOOL( "qt-updates-notif", updatesBox );
595 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
597 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
598 CONNECT( ui.updatesBox, toggled( bool ),
599 ui.updatesDays, setEnabled( bool ) );
601 ui.updatesBox->hide();
602 ui.updatesDays->hide();
604 /* ONE INSTANCE options */
605 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
606 CONFIG_BOOL( "one-instance", OneInterfaceMode );
607 CONFIG_BOOL( "playlist-enqueue",
608 EnqueueOneInterfaceMode );
609 ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
610 CONNECT( ui.OneInterfaceMode, toggled( bool ),
611 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
613 ui.OneInterfaceBox->hide();
615 /* RECENTLY PLAYED options */
616 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
617 ui.recentlyPlayedFilters, setEnabled( bool ) );
618 ui.recentlyPlayedFilters->setEnabled( false );
619 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
620 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
621 recentlyPlayedFilters );
625 START_SPREFS_CAT( Subtitles,
626 qtr("Subtitles & On Screen Display Settings") );
627 CONFIG_BOOL( "osd", OSDBox);
628 CONFIG_BOOL( "video-title-show", OSDTitleBox);
631 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
633 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
635 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
636 CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
638 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
639 ui.fontSizeLabel, fontSize );
640 CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
642 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
648 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
650 QGridLayout *gLayout = new QGridLayout;
651 panel->setLayout( gLayout );
654 panel_label->setText( qtr( "Configure Hotkeys" ) );
655 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
656 this, gLayout, line );
657 controls.append( control );
661 QFrame *sepline = new QFrame;
662 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
663 gLayout->addWidget( sepline, line, 0, 1, -1 );
667 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
668 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
669 p_config, false, this, gLayout, line );
670 controls.append( control );
676 panel_layout->addWidget( panel_label );
677 panel_layout->addWidget( title_line );
681 QScrollArea *scroller= new QScrollArea;
682 scroller->setWidget( panel );
683 scroller->setWidgetResizable( true );
684 scroller->setFrameStyle( QFrame::NoFrame );
685 panel_layout->addWidget( scroller );
689 panel_layout->addWidget( panel );
690 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
693 setLayout( panel_layout );
695 #undef END_SPREFS_CAT
696 #undef START_SPREFS_CAT
697 #undef CONFIG_GENERIC_FILE
698 #undef CONFIG_GENERIC_NO_BOOL
699 #undef CONFIG_GENERIC_NO_UI
700 #undef CONFIG_GENERIC
705 void SPrefsPanel::updateAudioOptions( int number)
707 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
708 ->itemData( number ).toString();
710 optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
712 /* optionWidgets[ossW] can be NULL */
713 if( optionWidgets[ossW] )
714 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
715 /* optionWidgets[alsaW] can be NULL */
716 if( optionWidgets[alsaW] )
717 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
719 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
720 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
721 value == "aout_directx" || value == "waveout" ) );
725 SPrefsPanel::~SPrefsPanel()
727 qDeleteAll( controls ); controls.clear();
730 void SPrefsPanel::updateAudioVolume( int volume )
732 qobject_cast<QSpinBox *>(optionWidgets[volLW])
733 ->setValue( volume * 100 / QT_VOLUME_DEFAULT );
737 /* Function called from the main Preferences dialog on each SPrefs Panel */
738 void SPrefsPanel::apply()
740 /* Generic save for ever panel */
741 QList<ConfigControl *>::Iterator i;
742 for( i = controls.begin() ; i != controls.end() ; i++ )
744 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
745 c->doApply( p_intf );
750 case SPrefsInputAndCodecs:
752 /* Device default selection */
753 char *psz_devicepath =
754 strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
755 if( !EMPTY_STR( psz_devicepath ) )
757 config_PutPsz( p_intf, "dvd", psz_devicepath );
758 config_PutPsz( p_intf, "vcd", psz_devicepath );
759 config_PutPsz( p_intf, "cd-audio", psz_devicepath );
760 free( psz_devicepath );
763 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
764 #define CaC( name ) CaCi( name, 1 )
766 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
767 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
770 CaC( "udp-caching" );
771 if (module_exists ("dvdread" ))
772 CaC( "dvdread-caching" );
773 if (module_exists ("dvdnav" ))
774 CaC( "dvdnav-caching" );
775 CaC( "tcp-caching" ); CaC( "vcd-caching" );
776 CaC( "cdda-caching" ); CaC( "file-caching" );
777 CaC( "screen-caching" ); CaC( "bd-caching" );
778 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
779 CaCi( "http-caching", 2 );
780 if (module_exists ("access_realrtsp" ))
781 CaCi( "realrtsp-caching", 10 );
782 CaCi( "mms-caching", 10 );
784 CaC( "dshow-caching" );
786 if (module_exists ( "v4l" ))
787 CaC( "v4l-caching" );
788 if (module_exists ( "access_jack" ))
789 CaC( "jack-input-caching" );
790 if (module_exists ( "v4l2" ))
791 CaC( "v4l2-caching" );
792 if (module_exists ( "pvr" ))
793 CaC( "pvr-caching" );
795 //CaCi( "dv-caching" ) too short...
803 case SPrefsInterface:
805 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
806 config_PutPsz( p_intf, "intf", "skins2" );
807 if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
808 config_PutPsz( p_intf, "intf", "qt" );
809 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
810 getSettings()->setValue( "MainWindow/QtStyle",
811 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
819 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
820 if( b_checked && !qs_filter.contains( "volnorm" ) )
821 qs_filter.append( "volnorm" );
822 if( !b_checked && qs_filter.contains( "volnorm" ) )
823 qs_filter.removeAll( "volnorm" );
826 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
828 if( b_checked && !qs_filter.contains( "headphone" ) )
829 qs_filter.append( "headphone" );
830 if( !b_checked && qs_filter.contains( "headphone" ) )
831 qs_filter.removeAll( "headphone" );
833 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
839 void SPrefsPanel::clean()
842 void SPrefsPanel::lastfm_Changed( int i_state )
844 if( i_state == Qt::Checked )
845 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
846 else if( i_state == Qt::Unchecked )
847 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
850 void SPrefsPanel::changeStyle( QString s_style )
852 QApplication::setStyle( s_style );
854 /* force refresh on all widgets */
855 QWidgetList widgets = QApplication::allWidgets();
856 QWidgetList::iterator it = widgets.begin();
857 while( it != widgets.end() ) {
864 #include <QDialogButtonBox>
865 #include <QHeaderView>
866 #include "util/registry.hpp"
869 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
870 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
873 const char* psz_VLC = "VLC";
874 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
876 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
878 current->setCheckState( 0, Qt::Checked );
883 current->setCheckState( 0, Qt::Unchecked );
886 listAsso.append( current );
890 void SPrefsPanel::assoDialog()
892 LPAPPASSOCREGUI p_appassoc;
895 if( S_OK == CoCreateInstance( &clsid_IApplication2,
896 NULL, CLSCTX_INPROC_SERVER,
897 &IID_IApplicationAssociationRegistrationUI,
898 (void **)&p_appassoc) )
900 if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
909 QDialog *d = new QDialog( this );
910 QGridLayout *assoLayout = new QGridLayout( d );
912 QTreeWidget *filetypeList = new QTreeWidget;
913 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
914 filetypeList->header()->hide();
916 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
918 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
919 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
920 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
922 filetypeList->addTopLevelItem( audioType );
923 filetypeList->addTopLevelItem( videoType );
924 filetypeList->addTopLevelItem( otherType );
926 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
927 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
928 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
930 QTreeWidgetItem *currentItem;
933 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
934 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
935 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
937 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
938 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
939 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
940 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
941 audioType->setCheckState( 0, ( i_temp > 0 ) ?
942 ( ( i_temp == audioType->childCount() ) ?
943 Qt::Checked : Qt::PartiallyChecked )
947 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
948 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
949 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
950 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
951 aTv( ".mts" ); aTv( ".mxf" );
952 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
953 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
954 videoType->setCheckState( 0, ( i_temp > 0 ) ?
955 ( ( i_temp == audioType->childCount() ) ?
956 Qt::Checked : Qt::PartiallyChecked )
960 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
961 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
962 otherType->setCheckState( 0, ( i_temp > 0 ) ?
963 ( ( i_temp == audioType->childCount() ) ?
964 Qt::Checked : Qt::PartiallyChecked )
971 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
972 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
973 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
974 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
975 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
977 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
979 CONNECT( closeButton, clicked(), this, saveAsso() );
980 CONNECT( clearButton, clicked(), d, reject() );
981 d->resize( 300, 400 );
988 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
990 std::string s_path( "VLC" ); s_path += psz_ext;
991 std::string s_path2 = s_path;
993 /* Save a backup if already assigned */
994 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
996 if( psz_value && strlen( psz_value ) > 0 )
997 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1000 /* Put a "link" to VLC.EXT as default */
1001 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1003 /* Create the needed Key if they weren't done in the installer */
1004 if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
1006 qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1007 qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1008 qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
1010 /* Get the installer path */
1011 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1012 std::string str_temp; str_temp.assign(
1013 qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1015 if( str_temp.size() )
1017 qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1018 "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
1020 qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1021 "", str_temp.append(",0").c_str() );
1027 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1029 char psz_VLC[] = "VLC";
1030 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1032 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1035 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1037 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1039 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1041 delete( psz_value );
1043 void SPrefsPanel::saveAsso()
1045 QVLCRegistry * qvReg;
1046 for( int i = 0; i < listAsso.size(); i ++ )
1048 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1049 if( listAsso[i]->checkState( 0 ) > 0 )
1051 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1055 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1059 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();