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 #define CONFIG_GENERIC2( option, type, label, qcontrol ) \
130 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
133 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
134 p_config, label, qcontrol, false ); \
135 controls.append( control ); \
139 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
140 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
143 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
144 p_config, label, ui.qcontrol ); \
145 controls.append( control ); \
148 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
149 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
152 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
153 p_config, label, qcontrol, qbutton ); \
154 controls.append( control ); \
157 #define START_SPREFS_CAT( name , label ) \
158 case SPrefs ## name: \
160 Ui::SPrefs ## name ui; \
161 ui.setupUi( panel ); \
162 panel_label->setText( label );
164 #define END_SPREFS_CAT \
168 QVBoxLayout
*panel_layout
= new QVBoxLayout();
169 QWidget
*panel
= new QWidget();
170 panel_layout
->setMargin( 3 );
173 QLabel
*panel_label
= new QLabel
;
174 QFont labelFont
= QApplication::font( static_cast<QWidget
*>(0) );
175 labelFont
.setPointSize( labelFont
.pointSize() + 6 );
176 labelFont
.setFamily( "Verdana" );
177 panel_label
->setFont( labelFont
);
180 QFrame
*title_line
= new QFrame
;
181 title_line
->setFrameShape(QFrame::HLine
);
182 title_line
->setFrameShadow(QFrame::Sunken
);
184 QFont italicFont
= QApplication::font( static_cast<QWidget
*>(0) );
185 italicFont
.setItalic( true );
189 /******************************
190 * VIDEO Panel Implementation *
191 ******************************/
192 START_SPREFS_CAT( Video
, qtr("Video Settings") );
193 CONFIG_GENERIC( "video", Bool
, NULL
, enableVideo
);
195 CONFIG_GENERIC( "fullscreen", Bool
, NULL
, fullscreen
);
196 CONFIG_GENERIC( "overlay", Bool
, NULL
, overlay
);
197 CONFIG_GENERIC( "video-on-top", Bool
, NULL
, alwaysOnTop
);
198 CONFIG_GENERIC( "video-deco", Bool
, NULL
, windowDecorations
);
199 CONFIG_GENERIC( "skip-frames" , Bool
, NULL
, skipFrames
);
200 CONFIG_GENERIC( "vout", Module
, ui
.voutLabel
, outputModule
);
203 CONFIG_GENERIC( "directx-wallpaper" , Bool
, NULL
, wallpaperMode
);
204 CONFIG_GENERIC( "directx-device", StringList
, ui
.dxDeviceLabel
,
206 CONFIG_GENERIC( "directx-hw-yuv", Bool
, NULL
, hwYUVBox
);
208 ui
.directXBox
->setVisible( false );
209 ui
.hwYUVBox
->setVisible( false );
212 CONFIG_GENERIC( "deinterlace", StringList
, ui
.deinterLabel
, deinterlaceBox
);
213 CONFIG_GENERIC( "aspect-ratio", String
, ui
.arLabel
, arLine
);
215 CONFIG_GENERIC_FILE( "snapshot-path", Directory
, ui
.dirLabel
,
216 ui
.snapshotsDirectory
, ui
.snapshotsDirectoryBrowse
);
217 CONFIG_GENERIC( "snapshot-prefix", String
, ui
.prefixLabel
, snapshotsPrefix
);
218 CONFIG_GENERIC( "snapshot-sequential", Bool
, NULL
,
219 snapshotsSequentialNumbering
);
220 CONFIG_GENERIC( "snapshot-format", StringList
, ui
.arLabel
,
224 /******************************
225 * AUDIO Panel Implementation *
226 ******************************/
227 START_SPREFS_CAT( Audio
, qtr("Audio Settings") );
229 CONFIG_GENERIC( "audio", Bool
, NULL
, enableAudio
);
230 ui
.SPrefsAudio_zone
->setEnabled( ui
.enableAudio
->isChecked() );
231 CONNECT( ui
.enableAudio
, toggled( bool ),
232 ui
.SPrefsAudio_zone
, setEnabled( bool ) );
234 #define audioCommon( name ) \
235 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
236 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
237 name ## Layout->setMargin( 0 ); \
238 name ## Layout->setSpacing( 0 ); \
239 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
240 name ## Label->setMinimumSize(QSize(250, 0)); \
241 name ## Layout->addWidget( name ## Label ); \
243 #define audioControl( name) \
244 audioCommon( name ) \
245 QComboBox * name ## Device = new QComboBox( name ## Control ); \
246 name ## Layout->addWidget( name ## Device ); \
247 name ## Label->setBuddy( name ## Device ); \
248 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
250 #define audioControl2( name) \
251 audioCommon( name ) \
252 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
253 name ## Layout->addWidget( name ## Device ); \
254 name ## Label->setBuddy( name ## Device ); \
255 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
256 name ## Layout->addWidget( name ## Browse ); \
257 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
259 /* Build if necessary */
260 QGridLayout
* outputAudioLayout
= qobject_cast
<QGridLayout
*>(ui
.outputAudioBox
->layout());
262 audioControl( DirectX
);
263 optionWidgets
.append( DirectXControl
);
264 CONFIG_GENERIC2( "directx-audio-device", IntegerList
,
265 NULL
, DirectXDevice
);
267 if( module_exists( "alsa" ) )
269 audioControl( alsa
);
270 optionWidgets
.append( alsaControl
);
272 CONFIG_GENERIC2( "alsa-audio-device" , StringList
, NULL
,
276 optionWidgets
.append( NULL
);
277 if( module_exists( "oss" ) )
279 audioControl2( OSS
);
280 optionWidgets
.append( OSSControl
);
281 CONFIG_GENERIC_FILE( "oss-audio-device" , File
, NULL
, OSSDevice
,
285 optionWidgets
.append( NULL
);
293 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider
, NULL
,
295 CONNECT( ui
.defaultVolume
, valueChanged( int ),
296 this, updateAudioVolume( int ) );
298 CONFIG_GENERIC( "qt-autosave-volume", Bool
, NULL
, keepVolumeRadio
);
299 ui
.defaultVolume_zone
->setEnabled( ui
.resetVolumeRadio
->isChecked() );
300 CONNECT( ui
.resetVolumeRadio
, toggled( bool ),
301 ui
.defaultVolume_zone
, setEnabled( bool ) );
303 CONFIG_GENERIC( "audio-language" , String
, ui
.langLabel
,
304 preferredAudioLanguage
);
306 CONFIG_GENERIC( "spdif", Bool
, NULL
, spdifBox
);
307 CONFIG_GENERIC( "force-dolby-surround", IntegerList
, ui
.dolbyLabel
,
310 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float
, NULL
,
312 CONFIG_GENERIC( "audio-replay-gain-mode", StringList
, ui
.replayLabel
,
314 CONFIG_GENERIC( "audio-visual" , Module
, ui
.visuLabel
,
317 /* Audio Output Specifics */
318 CONFIG_GENERIC( "aout", Module
, ui
.outputLabel
, outputModule
);
320 CONNECT( ui
.outputModule
, currentIndexChanged( int ),
321 this, updateAudioOptions( int ) );
323 /* File output exists on all platforms */
324 CONFIG_GENERIC_FILE( "audiofile-file", File
, ui
.fileLabel
,
325 ui
.fileName
, ui
.fileBrowseButton
);
327 optionWidgets
.append( ui
.fileControl
);
328 optionWidgets
.append( ui
.outputModule
);
329 optionWidgets
.append( ui
.volNormBox
);
330 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
331 ui
.volumeValue
->setButtonSymbols(QAbstractSpinBox::NoButtons
);
332 optionWidgets
.append( ui
.volumeValue
);
333 optionWidgets
.append( ui
.headphoneEffect
);
334 optionWidgets
.append( ui
.spdifBox
);
335 updateAudioOptions( ui
.outputModule
->currentIndex() );
338 if( module_exists( "audioscrobbler" ) )
340 CONFIG_GENERIC( "lastfm-username", String
, ui
.lastfm_user_label
,
342 CONFIG_GENERIC( "lastfm-password", String
, ui
.lastfm_pass_label
,
345 if( config_ExistIntf( VLC_OBJECT( p_intf
), "audioscrobbler" ) )
346 ui
.lastfm
->setChecked( true );
348 ui
.lastfm
->setChecked( false );
350 ui
.lastfm_zone
->setVisible( ui
.lastfm
->isChecked() );
352 CONNECT( ui
.lastfm
, toggled( bool ),
353 ui
.lastfm_zone
, setVisible( bool ) );
354 CONNECT( ui
.lastfm
, stateChanged( int ),
355 this, lastfm_Changed( int ) );
360 ui
.lastfm_zone
->hide();
364 CONNECT( ui
.volNormBox
, toggled( bool ), ui
.volNormSpin
,
365 setEnabled( bool ) );
367 char* psz
= config_GetPsz( p_intf
, "audio-filter" );
368 qs_filter
= qfu( psz
).split( ':', QString::SkipEmptyParts
);
371 bool b_enabled
= ( qs_filter
.contains( "volnorm" ) );
372 ui
.volNormBox
->setChecked( b_enabled
);
373 ui
.volNormSpin
->setEnabled( b_enabled
);
375 b_enabled
= ( qs_filter
.contains( "headphone" ) );
376 ui
.headphoneEffect
->setChecked( b_enabled
);
379 updateAudioVolume( ui
.defaultVolume
->value() ); // First time init
383 /* Input and Codecs Panel Implementation */
384 START_SPREFS_CAT( InputAndCodecs
, qtr("Input & Codecs Settings") );
388 ui
.DVDDevice
->setToolTip(
389 qtr( "If this property is blank, different values\n"
390 "for DVD, VCD, and CDDA are set.\n"
391 "You can define a unique one or configure them \n"
392 "individually in the advanced preferences." ) );
393 char *psz_dvddiscpath
= config_GetPsz( p_intf
, "dvd" );
394 char *psz_vcddiscpath
= config_GetPsz( p_intf
, "vcd" );
395 char *psz_cddadiscpath
= config_GetPsz( p_intf
, "cd-audio" );
396 if( psz_dvddiscpath
&& psz_vcddiscpath
&& psz_cddadiscpath
)
397 if( !strcmp( psz_cddadiscpath
, psz_dvddiscpath
) &&
398 !strcmp( psz_dvddiscpath
, psz_vcddiscpath
) )
400 ui
.DVDDevice
->setText( qfu( psz_dvddiscpath
) );
402 free( psz_cddadiscpath
);
403 free( psz_dvddiscpath
);
404 free( psz_vcddiscpath
);
406 CONFIG_GENERIC_FILE( "dvd", File
, ui
.DVDLabel
,
407 ui
.DVDDevice
, ui
.DVDBrowse
);
408 CONFIG_GENERIC_FILE( "input-record-path", Directory
, ui
.recordLabel
,
409 ui
.recordPath
, ui
.recordBrowse
);
411 CONFIG_GENERIC_NO_BOOL( "server-port", Integer
, ui
.portLabel
,
413 CONFIG_GENERIC( "http-proxy", String
, ui
.httpProxyLabel
, proxy
);
414 CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer
, ui
.ppLabel
,
416 CONFIG_GENERIC( "avi-index", IntegerList
, ui
.aviLabel
, AviRepair
);
418 /* live555 module prefs */
419 CONFIG_GENERIC( "rtsp-tcp", Bool
, NULL
,
420 live555TransportRTSP_TCPRadio
);
421 if ( !module_exists( "live555" ) )
423 ui
.live555TransportRTSP_TCPRadio
->hide();
424 ui
.live555TransportHTTPRadio
->hide();
425 ui
.live555TransportLabel
->hide();
428 CONFIG_GENERIC( "prefer-system-codecs", Bool
, NULL
, systemCodecBox
);
430 ui
.systemCodecBox
->hide();
431 ui
.systemCodecLabel
->hide();
433 optionWidgets
.append( ui
.DVDDevice
);
434 optionWidgets
.append( ui
.cachingCombo
);
435 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList
, ui
.filterLabel
, loopFilterBox
);
438 /* Add the things to the ComboBox */
439 #define addToCachingBox( str, cachingNumber ) \
440 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
441 addToCachingBox( N_("Custom"), CachingCustom
);
442 addToCachingBox( N_("Lowest latency"), CachingLowest
);
443 addToCachingBox( N_("Low latency"), CachingLow
);
444 addToCachingBox( N_("Normal"), CachingNormal
);
445 addToCachingBox( N_("High latency"), CachingHigh
);
446 addToCachingBox( N_("Higher latency"), CachingHigher
);
447 #undef addToCachingBox
449 #define TestCaC( name ) \
450 b_cache_equal = b_cache_equal && \
451 ( i_cache == config_GetInt( p_intf, name ) )
453 #define TestCaCi( name, int ) \
454 b_cache_equal = b_cache_equal && \
455 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
456 /* Select the accurate value of the ComboBox */
457 bool b_cache_equal
= true;
458 int i_cache
= config_GetInt( p_intf
, "file-caching");
460 TestCaC( "udp-caching" );
461 if (module_exists ("dvdread"))
462 TestCaC( "dvdread-caching" );
463 if (module_exists ("dvdnav"))
464 TestCaC( "dvdnav-caching" );
465 TestCaC( "tcp-caching" );
466 TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
467 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
469 TestCaC( "dshow-caching" );
471 if (module_exists ("v4l"))
472 TestCaC( "v4l-caching" );
473 if (module_exists ("access_jack"))
474 TestCaC( "jack-input-caching" );
475 if (module_exists ("v4l2"))
476 TestCaC( "v4l2-caching" );
477 if (module_exists ("pvr"))
478 TestCaC( "pvr-caching" );
480 if (module_exists ("livedotcom"))
481 TestCaCi( "rtsp-caching", 4 );
482 TestCaCi( "ftp-caching", 2 );
483 TestCaCi( "http-caching", 4 );
484 if (module_exists ("access_realrtsp"))
485 TestCaCi( "realrtsp-caching", 10 );
486 TestCaCi( "mms-caching", 19 );
487 if( b_cache_equal
) ui
.cachingCombo
->setCurrentIndex(
488 ui
.cachingCombo
->findData( QVariant( i_cache
) ) );
496 START_SPREFS_CAT( Interface
, qtr("Interface Settings") );
497 // ui.defaultLabel->setFont( italicFont );
498 ui
.skinsLabel
->setText(
499 qtr( "This is VLC's skinnable interface. You can download other skins at" )
500 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
501 ui
.skinsLabel
->setFont( italicFont
);
504 CONFIG_GENERIC( "language", StringList
, ui
.languageLabel
, language
);
505 BUTTONACT( ui
.assoButton
, assoDialog() );
507 ui
.languageBox
->hide();
511 char *psz_intf
= config_GetPsz( p_intf
, "intf" );
514 if( strstr( psz_intf
, "skin" ) )
515 ui
.skins
->setChecked( true );
518 ui
.qt4
->setChecked( true );
522 optionWidgets
.append( ui
.skins
);
523 optionWidgets
.append( ui
.qt4
);
524 #if !defined(NDEBUG) || !defined( WIN32)
525 ui
.stylesCombo
->addItem( qtr("System's default") );
526 ui
.stylesCombo
->addItems( QStyleFactory::keys() );
527 ui
.stylesCombo
->setCurrentIndex( ui
.stylesCombo
->findText(
528 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
529 ui
.stylesCombo
->insertSeparator( 1 );
531 CONNECT( ui
.stylesCombo
, currentIndexChanged( QString
), this, changeStyle( QString
) );
532 optionWidgets
.append( ui
.stylesCombo
);
534 ui
.stylesCombo
->hide();
535 optionWidgets
.append( NULL
);
538 ui
.skins_zone
->setEnabled( ui
.skins
->isChecked() );
539 CONNECT( ui
.skins
, toggled( bool ), ui
.skins_zone
, setEnabled( bool ) );
541 ui
.native_zone
->setEnabled( ui
.qt4
->isChecked() );
542 CONNECT( ui
.qt4
, toggled( bool ), ui
.native_zone
, setEnabled( bool ) );
544 InterfacePreviewWidget
*preview
= new InterfacePreviewWidget( this );
545 ( (QGridLayout
*) ui
.LooknfeelBox
->layout() )->
546 addWidget( preview
, 1, 0, 1, 2 );
547 CONNECT( ui
.displayModeBox
, currentIndexChanged( int ),
548 preview
, setPreview( int ) );
549 InterfacePreviewWidget
*skinspreview
= new InterfacePreviewWidget( this );
550 skinspreview
->setPreview(3); /* skins_preview resource index */
551 ( (QGridLayout
*) ui
.LooknfeelBox
->layout() )->
552 addWidget( skinspreview
, 7, 0, 1, 2 );
554 CONFIG_GENERIC( "qt-display-mode", IntegerList
, ui
.displayLabel
,
556 CONFIG_GENERIC( "embedded-video", Bool
, NULL
, embedVideo
);
557 CONFIG_GENERIC( "qt-fs-controller", Bool
, NULL
, fsController
);
558 CONFIG_GENERIC( "qt-system-tray", Bool
, NULL
, systrayBox
);
559 CONFIG_GENERIC_FILE( "skins2-last", File
, ui
.skinFileLabel
,
560 ui
.fileSkin
, ui
.skinBrowse
);
561 CONFIG_GENERIC( "qt-video-autoresize", Bool
, NULL
, resizingBox
);
563 CONFIG_GENERIC( "album-art", IntegerList
, ui
.artFetchLabel
,
568 CONFIG_GENERIC( "qt-updates-notif", Bool
, NULL
, updatesBox
);
569 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer
, NULL
,
571 ui
.updatesDays
->setEnabled( ui
.updatesBox
->isChecked() );
572 CONNECT( ui
.updatesBox
, toggled( bool ),
573 ui
.updatesDays
, setEnabled( bool ) );
575 ui
.updatesBox
->hide();
576 ui
.updatesDays
->hide();
578 /* ONE INSTANCE options */
579 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
580 CONFIG_GENERIC( "one-instance", Bool
, NULL
, OneInterfaceMode
);
581 CONFIG_GENERIC( "playlist-enqueue", Bool
, NULL
,
582 EnqueueOneInterfaceMode
);
583 ui
.EnqueueOneInterfaceMode
->setEnabled( ui
.OneInterfaceMode
->isChecked() );
584 CONNECT( ui
.OneInterfaceMode
, toggled( bool ),
585 ui
.EnqueueOneInterfaceMode
, setEnabled( bool ) );
587 ui
.OneInterfaceBox
->hide();
589 /* RECENTLY PLAYED options */
590 CONNECT( ui
.saveRecentlyPlayed
, toggled( bool ),
591 ui
.recentlyPlayedFilters
, setEnabled( bool ) );
592 ui
.recentlyPlayedFilters
->setEnabled( false );
593 CONFIG_GENERIC( "qt-recentplay", Bool
, NULL
, saveRecentlyPlayed
);
594 CONFIG_GENERIC( "qt-recentplay-filter", String
, ui
.filterLabel
,
595 recentlyPlayedFilters
);
599 START_SPREFS_CAT( Subtitles
,
600 qtr("Subtitles & On Screen Display Settings") );
601 CONFIG_GENERIC( "osd", Bool
, NULL
, OSDBox
);
602 CONFIG_GENERIC( "video-title-show", Bool
, NULL
, OSDTitleBox
);
605 CONFIG_GENERIC( "subsdec-encoding", StringList
, ui
.encodLabel
,
607 CONFIG_GENERIC( "sub-language", String
, ui
.subLangLabel
,
609 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font
, ui
.fontLabel
, font
);
610 CONFIG_GENERIC( "freetype-color", IntegerList
, ui
.fontColorLabel
,
612 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList
,
613 ui
.fontSizeLabel
, fontSize
);
614 CONFIG_GENERIC( "freetype-effect", IntegerList
, ui
.fontEffectLabel
,
616 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer
, ui
.subsPosLabel
, subsPosition
);
622 p_config
= config_FindConfig( VLC_OBJECT(p_intf
), "key-fullscreen" );
624 QGridLayout
*gLayout
= new QGridLayout
;
625 panel
->setLayout( gLayout
);
628 panel_label
->setText( qtr( "Configure Hotkeys" ) );
629 control
= new KeySelectorControl( VLC_OBJECT(p_intf
), p_config
,
630 this, gLayout
, line
);
631 controls
.append( control
);
635 QFrame
*sepline
= new QFrame
;
636 sepline
->setFrameStyle(QFrame::HLine
| QFrame::Sunken
);
637 gLayout
->addWidget( sepline
, line
, 0, 1, -1 );
641 p_config
= config_FindConfig( VLC_OBJECT(p_intf
), "hotkeys-mousewheel-mode" );
642 control
= new IntegerListConfigControl( VLC_OBJECT(p_intf
),
643 p_config
, false, this, gLayout
, line
);
644 controls
.append( control
);
650 panel_layout
->addWidget( panel_label
);
651 panel_layout
->addWidget( title_line
);
655 QScrollArea
*scroller
= new QScrollArea
;
656 scroller
->setWidget( panel
);
657 scroller
->setWidgetResizable( true );
658 scroller
->setFrameStyle( QFrame::NoFrame
);
659 panel_layout
->addWidget( scroller
);
663 panel_layout
->addWidget( panel
);
664 if( number
!= SPrefsHotkeys
) panel_layout
->addStretch( 2 );
667 setLayout( panel_layout
);
669 #undef END_SPREFS_CAT
670 #undef START_SPREFS_CAT
671 #undef CONFIG_GENERIC_FILE
672 #undef CONFIG_GENERIC_NO_BOOL
673 #undef CONFIG_GENERIC2
674 #undef CONFIG_GENERIC
678 void SPrefsPanel::updateAudioOptions( int number
)
680 QString value
= qobject_cast
<QComboBox
*>(optionWidgets
[audioOutCoB
])
681 ->itemData( number
).toString();
683 optionWidgets
[directxW
]->setVisible( ( value
== "directx" ) );
685 /* optionWidgets[ossW] can be NULL */
686 if( optionWidgets
[ossW
] )
687 optionWidgets
[ossW
]->setVisible( ( value
== "oss" ) );
688 /* optionWidgets[alsaW] can be NULL */
689 if( optionWidgets
[alsaW
] )
690 optionWidgets
[alsaW
]->setVisible( ( value
== "alsa" ) );
692 optionWidgets
[fileW
]->setVisible( ( value
== "aout_file" ) );
693 optionWidgets
[spdifChB
]->setVisible( ( value
!= "aout_file"
694 && value
!= "dummy" ) );
698 SPrefsPanel::~SPrefsPanel()
700 qDeleteAll( controls
); controls
.clear();
703 void SPrefsPanel::updateAudioVolume( int volume
)
705 qobject_cast
<QSpinBox
*>(optionWidgets
[volLW
])
706 ->setValue( volume
* 100 / 256 );
710 /* Function called from the main Preferences dialog on each SPrefs Panel */
711 void SPrefsPanel::apply()
713 /* Generic save for ever panel */
714 QList
<ConfigControl
*>::Iterator i
;
715 for( i
= controls
.begin() ; i
!= controls
.end() ; i
++ )
717 ConfigControl
*c
= qobject_cast
<ConfigControl
*>(*i
);
718 c
->doApply( p_intf
);
723 case SPrefsInputAndCodecs
:
725 /* Device default selection */
726 char *psz_devicepath
=
727 strdup( qtu( qobject_cast
<QLineEdit
*>(optionWidgets
[inputLE
] )->text() ) );
728 if( !EMPTY_STR( psz_devicepath
) )
730 config_PutPsz( p_intf
, "dvd", psz_devicepath
);
731 config_PutPsz( p_intf
, "vcd", psz_devicepath
);
732 config_PutPsz( p_intf
, "cd-audio", psz_devicepath
);
733 free( psz_devicepath
);
736 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
737 #define CaC( name ) CaCi( name, 1 )
739 QComboBox
*cachingCombo
= qobject_cast
<QComboBox
*>(optionWidgets
[cachingCoB
]);
740 int i_comboValue
= cachingCombo
->itemData( cachingCombo
->currentIndex() ).toInt();
743 CaC( "udp-caching" );
744 if (module_exists ("dvdread" ))
745 CaC( "dvdread-caching" );
746 if (module_exists ("dvdnav" ))
747 CaC( "dvdnav-caching" );
748 CaC( "tcp-caching" ); CaC( "vcd-caching" );
749 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
750 CaC( "screen-caching" ); CaC( "bd-caching" );
751 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
752 CaCi( "http-caching", 2 );
753 if (module_exists ("access_realrtsp" ))
754 CaCi( "realrtsp-caching", 10 );
755 CaCi( "mms-caching", 10 );
757 CaC( "dshow-caching" );
759 if (module_exists ( "v4l" ))
760 CaC( "v4l-caching" );
761 if (module_exists ( "access_jack" ))
762 CaC( "jack-input-caching" );
763 if (module_exists ( "v4l2" ))
764 CaC( "v4l2-caching" );
765 if (module_exists ( "pvr" ))
766 CaC( "pvr-caching" );
768 //CaCi( "dv-caching" ) too short...
776 case SPrefsInterface
:
778 if( qobject_cast
<QRadioButton
*>(optionWidgets
[skinRB
])->isChecked() )
779 config_PutPsz( p_intf
, "intf", "skins2" );
780 if( qobject_cast
<QRadioButton
*>(optionWidgets
[qtRB
])->isChecked() )
781 config_PutPsz( p_intf
, "intf", "qt" );
782 if( qobject_cast
<QComboBox
*>(optionWidgets
[styleCB
]) )
783 getSettings()->setValue( "MainWindow/QtStyle",
784 qobject_cast
<QComboBox
*>(optionWidgets
[styleCB
])->currentText() );
792 qobject_cast
<QCheckBox
*>(optionWidgets
[normalizerChB
])->isChecked();
793 if( b_checked
&& !qs_filter
.contains( "volnorm" ) )
794 qs_filter
.append( "volnorm" );
795 if( !b_checked
&& qs_filter
.contains( "volnorm" ) )
796 qs_filter
.removeAll( "volnorm" );
799 qobject_cast
<QCheckBox
*>(optionWidgets
[headphoneB
])->isChecked();
801 if( b_checked
&& !qs_filter
.contains( "headphone" ) )
802 qs_filter
.append( "headphone" );
803 if( !b_checked
&& qs_filter
.contains( "headphone" ) )
804 qs_filter
.removeAll( "headphone" );
806 config_PutPsz( p_intf
, "audio-filter", qtu( qs_filter
.join( ":" ) ) );
812 void SPrefsPanel::clean()
815 void SPrefsPanel::lastfm_Changed( int i_state
)
817 if( i_state
== Qt::Checked
)
818 config_AddIntf( VLC_OBJECT( p_intf
), "audioscrobbler" );
819 else if( i_state
== Qt::Unchecked
)
820 config_RemoveIntf( VLC_OBJECT( p_intf
), "audioscrobbler" );
823 void SPrefsPanel::changeStyle( QString s_style
)
825 QApplication::setStyle( s_style
);
827 /* force refresh on all widgets */
828 QWidgetList widgets
= QApplication::allWidgets();
829 QWidgetList::iterator it
= widgets
.begin();
830 while( it
!= widgets
.end() ) {
837 #include <QDialogButtonBox>
838 #include <QHeaderView>
839 #include "util/registry.hpp"
842 bool SPrefsPanel::addType( const char * psz_ext
, QTreeWidgetItem
* current
,
843 QTreeWidgetItem
* parent
, QVLCRegistry
*qvReg
)
846 const char* psz_VLC
= "VLC";
847 current
= new QTreeWidgetItem( parent
, QStringList( psz_ext
) );
849 if( strstr( qvReg
->ReadRegistryString( psz_ext
, "", "" ), psz_VLC
) )
851 current
->setCheckState( 0, Qt::Checked
);
856 current
->setCheckState( 0, Qt::Unchecked
);
859 listAsso
.append( current
);
863 void SPrefsPanel::assoDialog()
865 OSVERSIONINFO winVer
;
866 winVer
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
867 //Vista specific file associations
868 if( GetVersionEx(&winVer
) && winVer
.dwMajorVersion
> 5 )
870 LPAPPASSOCREGUI p_appassoc
;
873 if( S_OK
== CoCreateInstance( &clsid_IApplication2
,
874 NULL
, CLSCTX_INPROC_SERVER
,
875 &IID_IApplicationAssociationRegistrationUI
,
876 (void **)&p_appassoc
) )
878 if(S_OK
== p_appassoc
->vt
->LaunchAdvancedAssociationUI(p_appassoc
, L
"VLC" ) )
887 QDialog
*d
= new QDialog( this );
888 QGridLayout
*assoLayout
= new QGridLayout( d
);
890 QTreeWidget
*filetypeList
= new QTreeWidget
;
891 assoLayout
->addWidget( filetypeList
, 0, 0, 1, 4 );
892 filetypeList
->header()->hide();
894 QVLCRegistry
* qvReg
= new QVLCRegistry( HKEY_CLASSES_ROOT
);
896 QTreeWidgetItem
*audioType
= new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
897 QTreeWidgetItem
*videoType
= new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
898 QTreeWidgetItem
*otherType
= new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
900 filetypeList
->addTopLevelItem( audioType
);
901 filetypeList
->addTopLevelItem( videoType
);
902 filetypeList
->addTopLevelItem( otherType
);
904 audioType
->setExpanded( true ); audioType
->setCheckState( 0, Qt::Unchecked
);
905 videoType
->setExpanded( true ); videoType
->setCheckState( 0, Qt::Unchecked
);
906 otherType
->setExpanded( true ); otherType
->setCheckState( 0, Qt::Unchecked
);
908 QTreeWidgetItem
*currentItem
;
911 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
912 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
913 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
915 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
916 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
917 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
918 aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
919 audioType
->setCheckState( 0, ( i_temp
> 0 ) ?
920 ( ( i_temp
== audioType
->childCount() ) ?
921 Qt::Checked
: Qt::PartiallyChecked
)
925 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
926 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
927 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
928 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
929 aTv( ".mts" ); aTv( ".mxf" );
930 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
931 aTv( ".vob" ); aTv( ".wmv" );
932 videoType
->setCheckState( 0, ( i_temp
> 0 ) ?
933 ( ( i_temp
== audioType
->childCount() ) ?
934 Qt::Checked
: Qt::PartiallyChecked
)
938 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".m3u" ); aTo( ".pls" ); aTo( ".vlc" );
940 otherType
->setCheckState( 0, ( i_temp
> 0 ) ?
941 ( ( i_temp
== audioType
->childCount() ) ?
942 Qt::Checked
: Qt::PartiallyChecked
)
949 QDialogButtonBox
*buttonBox
= new QDialogButtonBox( d
);
950 QPushButton
*closeButton
= new QPushButton( qtr( "&Apply" ) );
951 QPushButton
*clearButton
= new QPushButton( qtr( "&Cancel" ) );
952 buttonBox
->addButton( closeButton
, QDialogButtonBox::AcceptRole
);
953 buttonBox
->addButton( clearButton
, QDialogButtonBox::ActionRole
);
955 assoLayout
->addWidget( buttonBox
, 1, 2, 1, 2 );
957 CONNECT( closeButton
, clicked(), this, saveAsso() );
958 CONNECT( clearButton
, clicked(), d
, reject() );
959 d
->resize( 300, 400 );
966 void addAsso( QVLCRegistry
*qvReg
, const char *psz_ext
)
968 std::string
s_path( "VLC" ); s_path
+= psz_ext
;
969 std::string s_path2
= s_path
;
971 /* Save a backup if already assigned */
972 char *psz_value
= qvReg
->ReadRegistryString( psz_ext
, "", "" );
974 if( psz_value
&& strlen( psz_value
) > 0 )
975 qvReg
->WriteRegistryString( psz_ext
, "VLC.backup", psz_value
);
978 /* Put a "link" to VLC.EXT as default */
979 qvReg
->WriteRegistryString( psz_ext
, "", s_path
.c_str() );
981 /* Create the needed Key if they weren't done in the installer */
982 if( !qvReg
->RegistryKeyExists( s_path
.c_str() ) )
984 qvReg
->WriteRegistryString( psz_ext
, "", s_path
.c_str() );
985 qvReg
->WriteRegistryString( s_path
.c_str(), "", "Media file" );
986 qvReg
->WriteRegistryString( s_path
.append( "\\shell" ).c_str() , "", "Play" );
988 /* Get the installer path */
989 QVLCRegistry
*qvReg2
= new QVLCRegistry( HKEY_LOCAL_MACHINE
);
990 std::string str_temp
; str_temp
.assign(
991 qvReg2
->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
993 if( str_temp
.size() )
995 qvReg
->WriteRegistryString( s_path
.append( "\\Play\\command" ).c_str(),
996 "", str_temp
.append(" --started-from-file \"%1\"" ).c_str() );
998 qvReg
->WriteRegistryString( s_path2
.append( "\\DefaultIcon" ).c_str(),
999 "", str_temp
.append(",0").c_str() );
1005 void delAsso( QVLCRegistry
*qvReg
, const char *psz_ext
)
1007 char psz_VLC
[] = "VLC";
1008 char *psz_value
= qvReg
->ReadRegistryString( psz_ext
, "", "" );
1010 if( psz_value
&& !strcmp( strcat( psz_VLC
, psz_ext
), psz_value
) )
1013 psz_value
= qvReg
->ReadRegistryString( psz_ext
, "VLC.backup", "" );
1015 qvReg
->WriteRegistryString( psz_ext
, "", psz_value
);
1017 qvReg
->DeleteKey( psz_ext
, "VLC.backup" );
1019 delete( psz_value
);
1021 void SPrefsPanel::saveAsso()
1023 QVLCRegistry
* qvReg
;
1024 for( int i
= 0; i
< listAsso
.size(); i
++ )
1026 qvReg
= new QVLCRegistry( HKEY_CLASSES_ROOT
);
1027 if( listAsso
[i
]->checkState( 0 ) > 0 )
1029 addAsso( qvReg
, qtu( listAsso
[i
]->text( 0 ) ) );
1033 delAsso( qvReg
, qtu( listAsso
[i
]->text( 0 ) ) );
1037 qobject_cast
<QDialog
*>(listAsso
[0]->treeWidget()->parent())->accept();