1 /*****************************************************************************
2 * simple_preferences.cpp : "Simple preferences"
3 ****************************************************************************
4 * Copyright (C) 2006-2010 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"
32 #include "dialogs/ml_configuration.hpp"
34 #include <vlc_config_cat.h>
35 #include <vlc_configuration.h>
39 #include <QToolButton>
40 #include <QButtonGroup>
41 #include <QVBoxLayout>
42 #include <QScrollArea>
44 #include <QStyleFactory>
46 #include <QtAlgorithms>
49 #define ICON_HEIGHT 64
52 # include <vlc_windows_interfaces.h>
54 #include <vlc_modules.h>
56 /*********************************************************************
57 * The List of categories
58 *********************************************************************/
59 SPrefsCatList::SPrefsCatList( intf_thread_t
*_p_intf
, QWidget
*_parent
, bool small
) :
60 QWidget( _parent
), p_intf( _p_intf
)
62 QVBoxLayout
*layout
= new QVBoxLayout();
64 QButtonGroup
*buttonGroup
= new QButtonGroup( this );
65 buttonGroup
->setExclusive ( true );
66 CONNECT( buttonGroup
, buttonClicked ( int ),
67 this, switchPanel( int ) );
69 short icon_height
= small
? ICON_HEIGHT
/2 : ICON_HEIGHT
;
71 #define ADD_CATEGORY( button, label, icon, numb ) \
72 QToolButton * button = new QToolButton( this ); \
73 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
74 button->setText( label ); \
75 button->setToolTip( label + qtr("Preferences") ); \
76 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
77 button->setIconSize( QSize( icon_height, icon_height ) ); \
78 button->resize( icon_height + 6 , icon_height + 6 ); \
79 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
80 button->setAutoRaise( true ); \
81 button->setCheckable( true ); \
82 buttonGroup->addButton( button, numb ); \
83 layout->addWidget( button );
85 ADD_CATEGORY( SPrefsInterface
, qtr("Interface"),
86 cone_interface_64
, 0 );
87 ADD_CATEGORY( SPrefsAudio
, qtr("Audio"),
89 ADD_CATEGORY( SPrefsVideo
, qtr("Video"),
91 ADD_CATEGORY( SPrefsSubtitles
, qtr("Subtitles && OSD"),
92 cone_subtitles_64
, 3 );
93 ADD_CATEGORY( SPrefsInputAndCodecs
, qtr("Input && Codecs"),
95 ADD_CATEGORY( SPrefsHotkeys
, qtr("Hotkeys"),
100 SPrefsInterface
->setChecked( true );
101 layout
->setMargin( 0 );
102 layout
->setSpacing( 1 );
104 setSizePolicy(QSizePolicy::Expanding
,QSizePolicy::Expanding
);
109 void SPrefsCatList::switchPanel( int i
)
111 emit
currentItemChanged( i
);
114 /*********************************************************************
116 *********************************************************************/
117 SPrefsPanel::SPrefsPanel( intf_thread_t
*_p_intf
, QWidget
*_parent
,
118 int _number
, bool small
) : QWidget( _parent
), p_intf( _p_intf
)
120 module_config_t
*p_config
;
121 ConfigControl
*control
;
124 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
125 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
128 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
129 p_config, label, ui.qcontrol, false ); \
130 controls.append( control ); \
133 ui.qcontrol->setEnabled( false ); \
134 if( label ) label->setEnabled( false ); \
137 #define CONFIG_BOOL( option, qcontrol ) \
138 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
141 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
142 p_config, NULL, ui.qcontrol, false ); \
143 controls.append( control ); \
145 else { ui.qcontrol->setEnabled( false ); }
148 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
149 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
152 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
153 p_config, label, qcontrol, false ); \
154 controls.append( control ); \
157 QWidget *widget = label; \
158 qcontrol->setVisible( false ); \
159 if( widget ) widget->setEnabled( false ); \
163 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
164 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
167 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
168 p_config, label, ui.qcontrol ); \
169 controls.append( control ); \
172 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
173 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
176 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
177 p_config, label, qcontrol, qbutton ); \
178 controls.append( control ); \
181 #define START_SPREFS_CAT( name , label ) \
182 case SPrefs ## name: \
184 Ui::SPrefs ## name ui; \
185 ui.setupUi( panel ); \
186 panel_label->setText( label );
188 #define END_SPREFS_CAT \
192 QVBoxLayout
*panel_layout
= new QVBoxLayout();
193 QWidget
*panel
= new QWidget();
194 panel_layout
->setMargin( 3 );
197 QLabel
*panel_label
= new QLabel
;
198 QFont labelFont
= QApplication::font();
199 labelFont
.setPointSize( labelFont
.pointSize() + 6 );
200 panel_label
->setFont( labelFont
);
203 QFrame
*title_line
= new QFrame
;
204 title_line
->setFrameShape(QFrame::HLine
);
205 title_line
->setFrameShadow(QFrame::Sunken
);
207 QFont italicFont
= QApplication::font();
208 italicFont
.setItalic( true );
212 /******************************
213 * VIDEO Panel Implementation *
214 ******************************/
215 START_SPREFS_CAT( Video
, qtr("Video Settings") );
216 CONFIG_BOOL( "video", enableVideo
);
218 CONFIG_BOOL( "fullscreen", fullscreen
);
219 CONFIG_BOOL( "overlay", overlay
);
220 CONFIG_BOOL( "video-on-top", alwaysOnTop
);
221 CONFIG_BOOL( "video-deco", windowDecorations
);
222 CONFIG_GENERIC( "vout", Module
, ui
.voutLabel
, outputModule
);
224 CONFIG_BOOL( "video-wallpaper", wallpaperMode
);
226 CONFIG_GENERIC( "directx-device", StringList
, ui
.dxDeviceLabel
,
228 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox
);
230 ui
.directXBox
->setVisible( false );
231 ui
.hwYUVBox
->setVisible( false );
234 CONFIG_GENERIC( "deinterlace", IntegerList
, ui
.deinterLabel
, deinterlaceBox
);
235 CONFIG_GENERIC( "deinterlace-mode", StringList
, ui
.deinterModeLabel
, deinterlaceModeBox
);
236 CONFIG_GENERIC( "aspect-ratio", String
, ui
.arLabel
, arLine
);
238 CONFIG_GENERIC_FILE( "snapshot-path", Directory
, ui
.dirLabel
,
239 ui
.snapshotsDirectory
, ui
.snapshotsDirectoryBrowse
);
240 CONFIG_GENERIC( "snapshot-prefix", String
, ui
.prefixLabel
, snapshotsPrefix
);
241 CONFIG_BOOL( "snapshot-sequential",
242 snapshotsSequentialNumbering
);
243 CONFIG_GENERIC( "snapshot-format", StringList
, ui
.arLabel
,
247 /******************************
248 * AUDIO Panel Implementation *
249 ******************************/
250 START_SPREFS_CAT( Audio
, qtr("Audio Settings") );
252 CONFIG_BOOL( "audio", enableAudio
);
253 ui
.SPrefsAudio_zone
->setEnabled( ui
.enableAudio
->isChecked() );
254 CONNECT( ui
.enableAudio
, toggled( bool ),
255 ui
.SPrefsAudio_zone
, setEnabled( bool ) );
257 #define audioCommon( name ) \
258 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
259 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
260 name ## Layout->setMargin( 0 ); \
261 name ## Layout->setSpacing( 0 ); \
262 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
263 name ## Label->setMinimumSize(QSize(250, 0)); \
264 name ## Layout->addWidget( name ## Label ); \
266 #define audioControl( name) \
267 audioCommon( name ) \
268 QComboBox * name ## Device = new QComboBox( name ## Control ); \
269 name ## Layout->addWidget( name ## Device ); \
270 name ## Label->setBuddy( name ## Device ); \
271 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
272 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
274 #define audioControl2( name) \
275 audioCommon( name ) \
276 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
277 name ## Layout->addWidget( name ## Device ); \
278 name ## Label->setBuddy( name ## Device ); \
279 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
280 name ## Layout->addWidget( name ## Browse ); \
281 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
283 /* Build if necessary */
284 QGridLayout
* outputAudioLayout
= qobject_cast
<QGridLayout
*>(ui
.outputAudioBox
->layout());
286 audioControl( DirectX
);
287 optionWidgets
.append( DirectXControl
);
288 CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList
,
289 DirectXLabel
, DirectXDevice
);
291 if( module_exists( "alsa" ) )
293 audioControl( alsa
);
294 optionWidgets
.append( alsaControl
);
295 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList
, alsaLabel
,
299 optionWidgets
.append( NULL
);
300 if( module_exists( "oss" ) )
302 audioControl2( OSS
);
303 optionWidgets
.append( OSSControl
);
304 CONFIG_GENERIC_FILE( "oss-audio-device" , File
, NULL
, OSSDevice
,
308 optionWidgets
.append( NULL
);
316 ui
.volumeValue
->setMaximum( QT_VOLUME_MAX
/ QT_VOLUME_DEFAULT
* 100 );
317 CONFIG_GENERIC_NO_BOOL( "qt-startvolume" , IntegerRangeSlider
, NULL
,
319 CONNECT( ui
.defaultVolume
, valueChanged( int ),
320 this, updateAudioVolume( int ) );
322 CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio
);
323 ui
.defaultVolume_zone
->setEnabled( ui
.resetVolumeRadio
->isChecked() );
324 CONNECT( ui
.resetVolumeRadio
, toggled( bool ),
325 ui
.defaultVolume_zone
, setEnabled( bool ) );
327 CONFIG_GENERIC( "audio-language" , String
, ui
.langLabel
,
328 preferredAudioLanguage
);
330 CONFIG_BOOL( "spdif", spdifBox
);
331 CONFIG_GENERIC( "force-dolby-surround", IntegerList
, ui
.dolbyLabel
,
334 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float
, NULL
,
336 CONFIG_GENERIC( "audio-replay-gain-mode", StringList
, ui
.replayLabel
,
338 CONFIG_GENERIC( "audio-visual" , Module
, ui
.visuLabel
,
340 CONFIG_BOOL( "audio-time-stretch", autoscaleBox
);
342 /* Audio Output Specifics */
343 CONFIG_GENERIC( "aout", Module
, ui
.outputLabel
, outputModule
);
345 CONNECT( ui
.outputModule
, currentIndexChanged( int ),
346 this, updateAudioOptions( int ) );
348 /* File output exists on all platforms */
349 CONFIG_GENERIC_FILE( "audiofile-file", File
, ui
.fileLabel
,
350 ui
.fileName
, ui
.fileBrowseButton
);
352 optionWidgets
.append( ui
.fileControl
);
353 optionWidgets
.append( ui
.outputModule
);
354 optionWidgets
.append( ui
.volNormBox
);
355 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
356 ui
.volumeValue
->setButtonSymbols(QAbstractSpinBox::NoButtons
);
357 optionWidgets
.append( ui
.volumeValue
);
358 optionWidgets
.append( ui
.headphoneEffect
);
359 optionWidgets
.append( ui
.spdifBox
);
360 updateAudioOptions( ui
.outputModule
->currentIndex() );
363 if( module_exists( "audioscrobbler" ) )
365 CONFIG_GENERIC( "lastfm-username", String
, ui
.lastfm_user_label
,
367 CONFIG_GENERIC( "lastfm-password", String
, ui
.lastfm_pass_label
,
370 if( config_ExistIntf( VLC_OBJECT( p_intf
), "audioscrobbler" ) )
371 ui
.lastfm
->setChecked( true );
373 ui
.lastfm
->setChecked( false );
375 ui
.lastfm_zone
->setVisible( ui
.lastfm
->isChecked() );
377 CONNECT( ui
.lastfm
, toggled( bool ),
378 ui
.lastfm_zone
, setVisible( bool ) );
379 CONNECT( ui
.lastfm
, stateChanged( int ),
380 this, lastfm_Changed( int ) );
385 ui
.lastfm_zone
->hide();
389 CONNECT( ui
.volNormBox
, toggled( bool ), ui
.volNormSpin
,
390 setEnabled( bool ) );
392 char* psz
= config_GetPsz( p_intf
, "audio-filter" );
393 qs_filter
= qfu( psz
).split( ':', QString::SkipEmptyParts
);
396 bool b_enabled
= ( qs_filter
.contains( "volnorm" ) );
397 ui
.volNormBox
->setChecked( b_enabled
);
398 ui
.volNormSpin
->setEnabled( b_enabled
);
400 b_enabled
= ( qs_filter
.contains( "headphone" ) );
401 ui
.headphoneEffect
->setChecked( b_enabled
);
404 updateAudioVolume( ui
.defaultVolume
->value() ); // First time init
408 /* Input and Codecs Panel Implementation */
409 START_SPREFS_CAT( InputAndCodecs
, qtr("Input & Codecs Settings") );
413 ui
.DVDDeviceComboBox
->setToolTip(
414 qtr( "If this property is blank, different values\n"
415 "for DVD, VCD, and CDDA are set.\n"
416 "You can define a unique one or configure them \n"
417 "individually in the advanced preferences." ) );
418 char *psz_dvddiscpath
= config_GetPsz( p_intf
, "dvd" );
419 char *psz_vcddiscpath
= config_GetPsz( p_intf
, "vcd" );
420 char *psz_cddadiscpath
= config_GetPsz( p_intf
, "cd-audio" );
421 if( psz_dvddiscpath
&& psz_vcddiscpath
&& psz_cddadiscpath
)
422 if( !strcmp( psz_cddadiscpath
, psz_dvddiscpath
) &&
423 !strcmp( psz_dvddiscpath
, psz_vcddiscpath
) )
425 ui
.DVDDeviceComboBox
->setEditText( qfu( psz_dvddiscpath
) );
427 free( psz_cddadiscpath
);
428 free( psz_dvddiscpath
);
429 free( psz_vcddiscpath
);
432 QStringList DVDDeviceComboBoxStringList
= QStringList();
433 DVDDeviceComboBoxStringList
434 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
435 ui
.DVDDeviceComboBox
->addItems( QDir( "/dev/" )
436 .entryList( DVDDeviceComboBoxStringList
, QDir::System
)
437 .replaceInStrings( QRegExp("^"), "/dev/" )
440 CONFIG_GENERIC( "dvd", String
, ui
.DVDLabel
,
441 DVDDeviceComboBox
->lineEdit() );
442 CONFIG_GENERIC_FILE( "input-record-path", Directory
, ui
.recordLabel
,
443 ui
.recordPath
, ui
.recordBrowse
);
445 CONFIG_GENERIC( "http-proxy", String
, ui
.httpProxyLabel
, proxy
);
446 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer
, ui
.ppLabel
,
448 CONFIG_GENERIC( "avi-index", IntegerList
, ui
.aviLabel
, AviRepair
);
450 /* live555 module prefs */
451 CONFIG_BOOL( "rtsp-tcp",
452 live555TransportRTSP_TCPRadio
);
453 if ( !module_exists( "live555" ) )
455 ui
.live555TransportRTSP_TCPRadio
->hide();
456 ui
.live555TransportHTTPRadio
->hide();
457 ui
.live555TransportLabel
->hide();
459 CONFIG_BOOL( "ffmpeg-hw", hwAccelBox
);
461 CONFIG_BOOL( "prefer-system-codecs", systemCodecBox
);
462 HINSTANCE hdxva2_dll
= LoadLibrary(TEXT("DXVA2.DLL") );
464 ui
.hwAccelBox
->setEnabled( false );
466 FreeLibrary( hdxva2_dll
);
468 ui
.systemCodecBox
->hide();
470 optionWidgets
.append( ui
.DVDDeviceComboBox
);
471 optionWidgets
.append( ui
.cachingCombo
);
472 CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList
, ui
.filterLabel
, loopFilterBox
);
473 CONFIG_GENERIC( "sout-x264-tune", StringList
, ui
.x264Label
, tuneBox
);
474 CONFIG_GENERIC( "sout-x264-preset", StringList
, ui
.x264Label
, presetBox
);
475 CONFIG_GENERIC( "sout-x264-profile", StringList
, ui
.x264profileLabel
, profileBox
);
476 CONFIG_GENERIC( "sout-x264-level", String
, ui
.x264profileLabel
, levelBox
);
479 /* Add the things to the ComboBox */
480 #define addToCachingBox( str, cachingNumber ) \
481 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
482 addToCachingBox( N_("Custom"), CachingCustom
);
483 addToCachingBox( N_("Lowest latency"), CachingLowest
);
484 addToCachingBox( N_("Low latency"), CachingLow
);
485 addToCachingBox( N_("Normal"), CachingNormal
);
486 addToCachingBox( N_("High latency"), CachingHigh
);
487 addToCachingBox( N_("Higher latency"), CachingHigher
);
488 #undef addToCachingBox
490 #define TestCaC( name ) \
491 b_cache_equal = b_cache_equal && \
492 ( i_cache == config_GetInt( p_intf, name ) )
494 #define TestCaCi( name, int ) \
495 b_cache_equal = b_cache_equal && \
496 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
497 /* Select the accurate value of the ComboBox */
498 bool b_cache_equal
= true;
499 int i_cache
= config_GetInt( p_intf
, "file-caching");
501 TestCaC( "udp-caching" );
502 if (module_exists ("dvdread"))
503 TestCaC( "dvdread-caching" );
504 if (module_exists ("dvdnav"))
505 TestCaC( "dvdnav-caching" );
506 TestCaC( "tcp-caching" );
507 TestCaC( "cdda-caching" );
508 TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
510 TestCaC( "dshow-caching" );
512 if (module_exists ("access_jack"))
513 TestCaC( "jack-input-caching" );
514 if (module_exists ("v4l2"))
515 TestCaC( "v4l2-caching" );
516 if (module_exists ("pvr"))
517 TestCaC( "pvr-caching" );
519 if (module_exists ("livedotcom"))
520 TestCaCi( "rtsp-caching", 4 );
521 TestCaCi( "ftp-caching", 2 );
522 TestCaCi( "http-caching", 2 );
523 if (module_exists ("access_realrtsp"))
524 TestCaCi( "realrtsp-caching", 10 );
525 TestCaCi( "mms-caching", 10 );
526 if( b_cache_equal
== 1 )
527 ui
.cachingCombo
->setCurrentIndex(
528 ui
.cachingCombo
->findData( QVariant( i_cache
) ) );
536 START_SPREFS_CAT( Interface
, qtr("Interface Settings") );
537 // ui.defaultLabel->setFont( italicFont );
538 ui
.skinsLabel
->setText(
539 qtr( "This is VLC's skinnable interface. You can download other skins at" )
540 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
541 + qtr( "VLC skins website" )+ QString( "</a>." ) );
542 ui
.skinsLabel
->setFont( italicFont
);
545 CONFIG_GENERIC( "language", StringList
, ui
.languageLabel
, language
);
546 BUTTONACT( ui
.assoButton
, assoDialog() );
548 ui
.languageBox
->hide();
549 ui
.assoButton
->hide();
550 ui
.assocLabel
->hide();
552 BUTTONACT( ui
.sqlMLbtn
, configML() );
555 char *psz_intf
= config_GetPsz( p_intf
, "intf" );
558 if( strstr( psz_intf
, "skin" ) )
559 ui
.skins
->setChecked( true );
562 ui
.qt4
->setChecked( true );
566 optionWidgets
.append( ui
.skins
);
567 optionWidgets
.append( ui
.qt4
);
568 #if !defined(NDEBUG) || !defined( WIN32)
569 ui
.stylesCombo
->addItem( qtr("System's default") );
570 ui
.stylesCombo
->addItems( QStyleFactory::keys() );
571 ui
.stylesCombo
->setCurrentIndex( ui
.stylesCombo
->findText(
572 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
573 ui
.stylesCombo
->insertSeparator( 1 );
575 CONNECT( ui
.stylesCombo
, currentIndexChanged( QString
), this, changeStyle( QString
) );
576 optionWidgets
.append( ui
.stylesCombo
);
578 ui
.stylesCombo
->hide();
579 optionWidgets
.append( NULL
);
581 radioGroup
= new QButtonGroup(this);
582 radioGroup
->addButton( ui
.qt4
, 0 );
583 radioGroup
->addButton( ui
.skins
, 1 );
584 CONNECT( radioGroup
, buttonClicked( int ),
585 ui
.styleStackedWidget
, setCurrentIndex( int ) );
586 ui
.styleStackedWidget
->setCurrentIndex( radioGroup
->checkedId() );
588 CONNECT( ui
.minimalviewBox
, toggled( bool ),
589 ui
.mainPreview
, setNormalPreview( bool ) );
590 CONFIG_BOOL( "qt-minimal-view", minimalviewBox
);
591 ui
.mainPreview
->setNormalPreview( ui
.minimalviewBox
->isChecked() );
592 ui
.skinsPreview
->setPreview( InterfacePreviewWidget::SKINS
);
594 CONFIG_BOOL( "embedded-video", embedVideo
);
595 CONFIG_BOOL( "qt-video-autoresize", resizingBox
);
596 CONNECT( ui
.embedVideo
, toggled( bool ), ui
.resizingBox
, setEnabled( bool ) );
597 ui
.resizingBox
->setEnabled( ui
.embedVideo
->isChecked() );
599 CONFIG_BOOL( "qt-fs-controller", fsController
);
600 CONFIG_BOOL( "qt-system-tray", systrayBox
);
601 CONFIG_BOOL( "qt-notification", sysPop
);
602 CONNECT( ui
.systrayBox
, toggled( bool ), ui
.sysPop
, setEnabled( bool ) );
603 ui
.sysPop
->setEnabled( ui
.systrayBox
->isChecked() );
605 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox
);
606 CONFIG_BOOL( "playlist-tree", treePlaylist
);
607 CONFIG_BOOL( "play-and-pause", playPauseBox
);
608 CONFIG_GENERIC_FILE( "skins2-last", File
, ui
.skinFileLabel
,
609 ui
.fileSkin
, ui
.skinBrowse
);
611 CONFIG_GENERIC( "album-art", IntegerList
, ui
.artFetchLabel
,
616 CONFIG_BOOL( "qt-updates-notif", updatesBox
);
617 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer
, NULL
,
619 ui
.updatesDays
->setEnabled( ui
.updatesBox
->isChecked() );
620 CONNECT( ui
.updatesBox
, toggled( bool ),
621 ui
.updatesDays
, setEnabled( bool ) );
623 ui
.updateNotifierZone
->hide();
625 /* ONE INSTANCE options */
626 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
627 CONFIG_BOOL( "one-instance", OneInterfaceMode
);
628 CONFIG_BOOL( "playlist-enqueue",
629 EnqueueOneInterfaceMode
);
630 ui
.EnqueueOneInterfaceMode
->setEnabled( ui
.OneInterfaceMode
->isChecked() );
631 CONNECT( ui
.OneInterfaceMode
, toggled( bool ),
632 ui
.EnqueueOneInterfaceMode
, setEnabled( bool ) );
634 ui
.OneInterfaceBox
->hide();
636 /* RECENTLY PLAYED options */
637 CONNECT( ui
.saveRecentlyPlayed
, toggled( bool ),
638 ui
.recentlyPlayedFilters
, setEnabled( bool ) );
639 ui
.recentlyPlayedFilters
->setEnabled( false );
640 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed
);
641 CONFIG_GENERIC( "qt-recentplay-filter", String
, ui
.filterLabel
,
642 recentlyPlayedFilters
);
646 START_SPREFS_CAT( Subtitles
,
647 qtr("Subtitles & On Screen Display Settings") );
648 CONFIG_BOOL( "osd", OSDBox
);
649 CONFIG_BOOL( "video-title-show", OSDTitleBox
);
650 CONFIG_GENERIC( "video-title-position", IntegerList
,
651 ui
.OSDTitlePosLabel
, OSDTitlePos
);
653 CONFIG_GENERIC( "subsdec-encoding", StringList
, ui
.encodLabel
,
655 CONFIG_GENERIC( "sub-language", String
, ui
.subLangLabel
,
657 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font
, ui
.fontLabel
, font
);
658 CONFIG_GENERIC( "freetype-color", IntegerList
, ui
.fontColorLabel
,
660 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList
,
661 ui
.fontSizeLabel
, fontSize
);
662 CONFIG_GENERIC( "freetype-effect", IntegerList
, ui
.fontEffectLabel
,
664 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer
, ui
.subsPosLabel
, subsPosition
);
670 p_config
= config_FindConfig( VLC_OBJECT(p_intf
), "key-play" );
672 QGridLayout
*gLayout
= new QGridLayout
;
673 panel
->setLayout( gLayout
);
676 panel_label
->setText( qtr( "Configure Hotkeys" ) );
677 control
= new KeySelectorControl( VLC_OBJECT(p_intf
), p_config
,
678 this, gLayout
, line
);
679 controls
.append( control
);
683 QFrame
*sepline
= new QFrame
;
684 sepline
->setFrameStyle(QFrame::HLine
| QFrame::Sunken
);
685 gLayout
->addWidget( sepline
, line
, 0, 1, -1 );
689 p_config
= config_FindConfig( VLC_OBJECT(p_intf
), "hotkeys-mousewheel-mode" );
690 control
= new IntegerListConfigControl( VLC_OBJECT(p_intf
),
691 p_config
, this, false, gLayout
, line
);
692 controls
.append( control
);
697 p_config
= config_FindConfig( VLC_OBJECT(p_intf
), "qt-disable-volume-keys" );
698 control
= new BoolConfigControl( VLC_OBJECT(p_intf
), p_config
, this, gLayout
, line
);
699 controls
.append( control
);
706 panel_layout
->addWidget( panel_label
);
707 panel_layout
->addWidget( title_line
);
711 QScrollArea
*scroller
= new QScrollArea
;
712 scroller
->setWidget( panel
);
713 scroller
->setWidgetResizable( true );
714 scroller
->setFrameStyle( QFrame::NoFrame
);
715 panel_layout
->addWidget( scroller
);
719 panel_layout
->addWidget( panel
);
720 if( number
!= SPrefsHotkeys
) panel_layout
->addStretch( 2 );
723 setLayout( panel_layout
);
725 #undef END_SPREFS_CAT
726 #undef START_SPREFS_CAT
727 #undef CONFIG_GENERIC_FILE
728 #undef CONFIG_GENERIC_NO_BOOL
729 #undef CONFIG_GENERIC_NO_UI
730 #undef CONFIG_GENERIC
735 void SPrefsPanel::updateAudioOptions( int number
)
737 QString value
= qobject_cast
<QComboBox
*>(optionWidgets
[audioOutCoB
])
738 ->itemData( number
).toString();
740 optionWidgets
[directxW
]->setVisible( ( value
== "aout_directx" ) );
742 /* optionWidgets[ossW] can be NULL */
743 if( optionWidgets
[ossW
] )
744 optionWidgets
[ossW
]->setVisible( ( value
== "oss" ) );
745 /* optionWidgets[alsaW] can be NULL */
746 if( optionWidgets
[alsaW
] )
747 optionWidgets
[alsaW
]->setVisible( ( value
== "alsa" ) );
749 optionWidgets
[fileW
]->setVisible( ( value
== "aout_file" ) );
750 optionWidgets
[spdifChB
]->setVisible( ( value
== "alsa" || value
== "oss" || value
== "auhal" ||
751 value
== "aout_directx" || value
== "waveout" ) );
755 SPrefsPanel::~SPrefsPanel()
757 qDeleteAll( controls
); controls
.clear();
760 void SPrefsPanel::updateAudioVolume( int volume
)
762 qobject_cast
<QSpinBox
*>(optionWidgets
[volLW
])
763 ->setValue( volume
* 100 / QT_VOLUME_DEFAULT
);
767 /* Function called from the main Preferences dialog on each SPrefs Panel */
768 void SPrefsPanel::apply()
770 /* Generic save for ever panel */
771 QList
<ConfigControl
*>::Iterator i
;
772 for( i
= controls
.begin() ; i
!= controls
.end() ; ++i
)
774 ConfigControl
*c
= qobject_cast
<ConfigControl
*>(*i
);
780 case SPrefsInputAndCodecs
:
782 /* Device default selection */
783 char *psz_devicepath
=
784 strdup( qtu( qobject_cast
<QComboBox
*>(optionWidgets
[inputLE
])->currentText() ) );
785 if( !EMPTY_STR( psz_devicepath
) )
787 config_PutPsz( p_intf
, "dvd", psz_devicepath
);
788 config_PutPsz( p_intf
, "vcd", psz_devicepath
);
789 config_PutPsz( p_intf
, "cd-audio", psz_devicepath
);
790 free( psz_devicepath
);
793 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
794 #define CaC( name ) CaCi( name, 1 )
796 QComboBox
*cachingCombo
= qobject_cast
<QComboBox
*>(optionWidgets
[cachingCoB
]);
797 int i_comboValue
= cachingCombo
->itemData( cachingCombo
->currentIndex() ).toInt();
800 CaC( "udp-caching" );
801 if (module_exists ("dvdread" ))
802 CaC( "dvdread-caching" );
803 if (module_exists ("dvdnav" ))
804 CaC( "dvdnav-caching" );
805 CaC( "tcp-caching" ); CaC( "vcd-caching" );
806 CaC( "cdda-caching" ); CaC( "file-caching" );
807 CaC( "screen-caching" ); CaC( "bd-caching" );
808 CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
809 CaCi( "http-caching", 2 );
810 if (module_exists ("access_realrtsp" ))
811 CaCi( "realrtsp-caching", 10 );
812 CaCi( "mms-caching", 10 );
814 CaC( "dshow-caching" );
816 if (module_exists ( "access_jack" ))
817 CaC( "jack-input-caching" );
818 if (module_exists ( "v4l2" ))
819 CaC( "v4l2-caching" );
820 if (module_exists ( "pvr" ))
821 CaC( "pvr-caching" );
823 //CaCi( "dv-caching" ) too short...
831 case SPrefsInterface
:
833 if( qobject_cast
<QRadioButton
*>(optionWidgets
[skinRB
])->isChecked() )
834 config_PutPsz( p_intf
, "intf", "skins2,any" );
836 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
837 config_PutPsz( p_intf
, "intf", "" );
838 if( qobject_cast
<QComboBox
*>(optionWidgets
[styleCB
]) )
839 getSettings()->setValue( "MainWindow/QtStyle",
840 qobject_cast
<QComboBox
*>(optionWidgets
[styleCB
])->currentText() );
848 qobject_cast
<QCheckBox
*>(optionWidgets
[normalizerChB
])->isChecked();
849 if( b_checked
&& !qs_filter
.contains( "volnorm" ) )
850 qs_filter
.append( "volnorm" );
851 if( !b_checked
&& qs_filter
.contains( "volnorm" ) )
852 qs_filter
.removeAll( "volnorm" );
855 qobject_cast
<QCheckBox
*>(optionWidgets
[headphoneB
])->isChecked();
857 if( b_checked
&& !qs_filter
.contains( "headphone" ) )
858 qs_filter
.append( "headphone" );
859 if( !b_checked
&& qs_filter
.contains( "headphone" ) )
860 qs_filter
.removeAll( "headphone" );
862 config_PutPsz( p_intf
, "audio-filter", qtu( qs_filter
.join( ":" ) ) );
868 void SPrefsPanel::clean()
871 void SPrefsPanel::lastfm_Changed( int i_state
)
873 if( i_state
== Qt::Checked
)
874 config_AddIntf( VLC_OBJECT( p_intf
), "audioscrobbler" );
875 else if( i_state
== Qt::Unchecked
)
876 config_RemoveIntf( VLC_OBJECT( p_intf
), "audioscrobbler" );
879 void SPrefsPanel::changeStyle( QString s_style
)
881 QApplication::setStyle( s_style
);
883 /* force refresh on all widgets */
884 QWidgetList widgets
= QApplication::allWidgets();
885 QWidgetList::iterator it
= widgets
.begin();
886 while( it
!= widgets
.end() ) {
892 void SPrefsPanel::configML()
894 MLConfDialog
*mld
= new MLConfDialog( this, p_intf
);
900 #include <QDialogButtonBox>
901 #include "util/registry.hpp"
904 bool SPrefsPanel::addType( const char * psz_ext
, QTreeWidgetItem
* current
,
905 QTreeWidgetItem
* parent
, QVLCRegistry
*qvReg
)
908 const char* psz_VLC
= "VLC";
909 current
= new QTreeWidgetItem( parent
, QStringList( psz_ext
) );
911 if( strstr( qvReg
->ReadRegistryString( psz_ext
, "", "" ), psz_VLC
) )
913 current
->setCheckState( 0, Qt::Checked
);
918 current
->setCheckState( 0, Qt::Unchecked
);
921 listAsso
.append( current
);
925 void SPrefsPanel::assoDialog()
927 LPAPPASSOCREGUI p_appassoc
;
930 if( S_OK
== CoCreateInstance( &clsid_IApplication2
,
931 NULL
, CLSCTX_INPROC_SERVER
,
932 &IID_IApplicationAssociationRegistrationUI
,
933 (void **)&p_appassoc
) )
935 if(S_OK
== p_appassoc
->vt
->LaunchAdvancedAssociationUI(p_appassoc
, L
"VLC" ) )
944 QDialog
*d
= new QDialog( this );
945 QGridLayout
*assoLayout
= new QGridLayout( d
);
947 QTreeWidget
*filetypeList
= new QTreeWidget
;
948 assoLayout
->addWidget( filetypeList
, 0, 0, 1, 4 );
949 filetypeList
->header()->hide();
951 QVLCRegistry
* qvReg
= new QVLCRegistry( HKEY_CLASSES_ROOT
);
953 QTreeWidgetItem
*audioType
= new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
954 QTreeWidgetItem
*videoType
= new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
955 QTreeWidgetItem
*otherType
= new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
957 filetypeList
->addTopLevelItem( audioType
);
958 filetypeList
->addTopLevelItem( videoType
);
959 filetypeList
->addTopLevelItem( otherType
);
961 audioType
->setExpanded( true ); audioType
->setCheckState( 0, Qt::Unchecked
);
962 videoType
->setExpanded( true ); videoType
->setCheckState( 0, Qt::Unchecked
);
963 otherType
->setExpanded( true ); otherType
->setCheckState( 0, Qt::Unchecked
);
965 QTreeWidgetItem
*currentItem
;
968 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
969 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
970 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
972 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
973 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
974 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
975 aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
976 audioType
->setCheckState( 0, ( i_temp
> 0 ) ?
977 ( ( i_temp
== audioType
->childCount() ) ?
978 Qt::Checked
: Qt::PartiallyChecked
)
982 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
983 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
984 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
985 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
986 aTv( ".mts" ); aTv( ".mxf" );
987 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
988 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
989 videoType
->setCheckState( 0, ( i_temp
> 0 ) ?
990 ( ( i_temp
== audioType
->childCount() ) ?
991 Qt::Checked
: Qt::PartiallyChecked
)
995 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
996 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
997 otherType
->setCheckState( 0, ( i_temp
> 0 ) ?
998 ( ( i_temp
== audioType
->childCount() ) ?
999 Qt::Checked
: Qt::PartiallyChecked
)
1006 QDialogButtonBox
*buttonBox
= new QDialogButtonBox( d
);
1007 QPushButton
*closeButton
= new QPushButton( qtr( "&Apply" ) );
1008 QPushButton
*clearButton
= new QPushButton( qtr( "&Cancel" ) );
1009 buttonBox
->addButton( closeButton
, QDialogButtonBox::AcceptRole
);
1010 buttonBox
->addButton( clearButton
, QDialogButtonBox::ActionRole
);
1012 assoLayout
->addWidget( buttonBox
, 1, 2, 1, 2 );
1014 CONNECT( closeButton
, clicked(), this, saveAsso() );
1015 CONNECT( clearButton
, clicked(), d
, reject() );
1016 d
->resize( 300, 400 );
1023 void addAsso( QVLCRegistry
*qvReg
, const char *psz_ext
)
1025 std::string
s_path( "VLC" ); s_path
+= psz_ext
;
1026 std::string s_path2
= s_path
;
1028 /* Save a backup if already assigned */
1029 char *psz_value
= qvReg
->ReadRegistryString( psz_ext
, "", "" );
1031 if( !EMPTY_STR(psz_value
) )
1032 qvReg
->WriteRegistryString( psz_ext
, "VLC.backup", psz_value
);
1035 /* Put a "link" to VLC.EXT as default */
1036 qvReg
->WriteRegistryString( psz_ext
, "", s_path
.c_str() );
1038 /* Create the needed Key if they weren't done in the installer */
1039 if( !qvReg
->RegistryKeyExists( s_path
.c_str() ) )
1041 qvReg
->WriteRegistryString( psz_ext
, "", s_path
.c_str() );
1042 qvReg
->WriteRegistryString( s_path
.c_str(), "", "Media file" );
1043 qvReg
->WriteRegistryString( s_path
.append( "\\shell" ).c_str() , "", "Play" );
1045 /* Get the installer path */
1046 QVLCRegistry
*qvReg2
= new QVLCRegistry( HKEY_LOCAL_MACHINE
);
1047 std::string str_temp
; str_temp
.assign(
1048 qvReg2
->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
1050 if( str_temp
.size() )
1052 qvReg
->WriteRegistryString( s_path
.append( "\\Play\\command" ).c_str(),
1053 "", str_temp
.append(" --started-from-file \"%1\"" ).c_str() );
1055 qvReg
->WriteRegistryString( s_path2
.append( "\\DefaultIcon" ).c_str(),
1056 "", str_temp
.append(",0").c_str() );
1062 void delAsso( QVLCRegistry
*qvReg
, const char *psz_ext
)
1064 char psz_VLC
[] = "VLC";
1065 char *psz_value
= qvReg
->ReadRegistryString( psz_ext
, "", "" );
1067 if( psz_value
&& !strcmp( strcat( psz_VLC
, psz_ext
), psz_value
) )
1070 psz_value
= qvReg
->ReadRegistryString( psz_ext
, "VLC.backup", "" );
1072 qvReg
->WriteRegistryString( psz_ext
, "", psz_value
);
1074 qvReg
->DeleteKey( psz_ext
, "VLC.backup" );
1076 delete( psz_value
);
1078 void SPrefsPanel::saveAsso()
1080 QVLCRegistry
* qvReg
;
1081 for( int i
= 0; i
< listAsso
.size(); i
++ )
1083 qvReg
= new QVLCRegistry( HKEY_CLASSES_ROOT
);
1084 if( listAsso
[i
]->checkState( 0 ) > 0 )
1086 addAsso( qvReg
, qtu( listAsso
[i
]->text( 0 ) ) );
1090 delAsso( qvReg
, qtu( listAsso
[i
]->text( 0 ) ) );
1094 qobject_cast
<QDialog
*>(listAsso
[0]->treeWidget()->parent())->accept();