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, ltooltip, icon, numb ) \
72 QToolButton * button = new QToolButton( this ); \
73 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
74 button->setText( label ); \
75 button->setToolTip( ltooltip ); \
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"), qtr("Interface Settings"),
86 cone_interface_64, 0 );
87 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
89 ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
91 ADD_CATEGORY( SPrefsSubtitles, SUBPIC_TITLE, qtr("Subtitle & On Screen Display Settings"),
92 cone_subtitles_64, 3 );
93 ADD_CATEGORY( SPrefsInputAndCodecs, INPUT_TITLE, qtr("Input & Codecs Settings"),
95 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
100 SPrefsInterface->setChecked( true );
101 layout->setMargin( 0 );
102 layout->setSpacing( 1 );
104 setMinimumWidth( 140 );
105 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
110 void SPrefsCatList::switchPanel( int i )
112 emit currentItemChanged( i );
115 /*********************************************************************
117 *********************************************************************/
118 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
119 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
121 module_config_t *p_config;
122 ConfigControl *control;
125 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
126 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
129 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
130 p_config, label, ui.qcontrol, false ); \
131 controls.append( control ); \
134 ui.qcontrol->setEnabled( false ); \
135 if( label ) label->setEnabled( false ); \
138 #define CONFIG_BOOL( option, qcontrol ) \
139 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
142 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
143 p_config, NULL, ui.qcontrol ); \
144 controls.append( control ); \
146 else { ui.qcontrol->setEnabled( false ); }
149 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
150 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
153 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
154 p_config, label, qcontrol, false ); \
155 controls.append( control ); \
158 QWidget *widget = label; \
159 qcontrol->setVisible( false ); \
160 if( widget ) widget->setEnabled( false ); \
164 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
165 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
168 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
169 p_config, label, ui.qcontrol ); \
170 controls.append( control ); \
173 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
174 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
177 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
178 p_config, label, qcontrol, qbutton ); \
179 controls.append( control ); \
182 #define START_SPREFS_CAT( name , label ) \
183 case SPrefs ## name: \
185 Ui::SPrefs ## name ui; \
186 ui.setupUi( panel ); \
187 panel_label->setText( label );
189 #define END_SPREFS_CAT \
193 QVBoxLayout *panel_layout = new QVBoxLayout();
194 QWidget *panel = new QWidget();
195 panel_layout->setMargin( 3 );
198 QLabel *panel_label = new QLabel;
199 QFont labelFont = QApplication::font();
200 labelFont.setPointSize( labelFont.pointSize() + 6 );
201 panel_label->setFont( labelFont );
204 QFrame *title_line = new QFrame;
205 title_line->setFrameShape(QFrame::HLine);
206 title_line->setFrameShadow(QFrame::Sunken);
208 QFont italicFont = QApplication::font();
209 italicFont.setItalic( true );
213 /******************************
214 * VIDEO Panel Implementation *
215 ******************************/
216 START_SPREFS_CAT( Video , qtr("Video Settings") );
217 CONFIG_BOOL( "video", enableVideo );
218 ui.videoZone->setEnabled( ui.enableVideo->isChecked() );
219 CONNECT( ui.enableVideo, toggled( bool ),
220 ui.videoZone, setEnabled( bool ) );
222 CONFIG_BOOL( "fullscreen", fullscreen );
223 CONFIG_BOOL( "overlay", overlay );
224 CONFIG_BOOL( "video-on-top", alwaysOnTop );
225 CONFIG_BOOL( "video-deco", windowDecorations );
226 CONFIG_GENERIC( "vout", StringList, ui.voutLabel, outputModule );
229 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
231 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
232 CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
234 ui.directXBox->setVisible( false );
235 ui.hwYUVBox->setVisible( false );
239 CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
240 CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
243 ui.kvaBox->setVisible( false );
246 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
247 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
248 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
250 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
251 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
252 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
253 CONFIG_BOOL( "snapshot-sequential",
254 snapshotsSequentialNumbering );
255 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
259 /******************************
260 * AUDIO Panel Implementation *
261 ******************************/
262 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
264 CONFIG_BOOL( "audio", enableAudio );
265 ui.audioZone->setEnabled( ui.enableAudio->isChecked() );
266 CONNECT( ui.enableAudio, toggled( bool ),
267 ui.audioZone, setEnabled( bool ) );
269 #define audioCommon( name ) \
270 QLabel * name ## Label = new QLabel( qtr( "Device:" ) ); \
271 name ## Label->setMinimumSize(QSize(250, 0)); \
272 outputAudioLayout->addWidget( name ## Label, outputAudioLayout->rowCount(), 0, 1, 1 ); \
274 #define audioControl( name) \
275 audioCommon( name ) \
276 QComboBox * name ## Device = new QComboBox; \
277 name ## Label->setBuddy( name ## Device ); \
278 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
279 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 1, 1, -1 );
281 #define audioControl2( name) \
282 audioCommon( name ) \
283 QLineEdit * name ## Device = new QLineEdit; \
284 name ## Label->setBuddy( name ## Device ); \
285 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ) ); \
286 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 0, 1, -1, Qt::AlignLeft );
288 /* Build if necessary */
289 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
291 audioControl( DirectX );
292 optionWidgets["directxL" ] = DirectXLabel;
293 optionWidgets["directxW" ] = DirectXDevice;
294 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
295 DirectXLabel, DirectXDevice );
296 #elif defined( __OS2__ )
298 optionWidgets["kaiL"] = kaiLabel;
299 optionWidgets["kaiW"] = kaiDevice;
300 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
303 if( module_exists( "alsa" ) )
305 audioControl( alsa );
306 optionWidgets["alsaL"] = alsaLabel;
307 optionWidgets["alsaW"] = alsaDevice;
308 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
311 if( module_exists( "oss" ) )
313 audioControl2( OSS );
314 optionWidgets["ossL"] = OSSLabel;
315 optionWidgets["ossW"] = OSSDevice;
316 optionWidgets["ossB"] = OSSBrowse;
317 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
327 ui.volumeValue->setMaximum( 200 );
328 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
330 CONNECT( ui.defaultVolume, valueChanged( int ),
331 this, updateAudioVolume( int ) );
333 CONFIG_BOOL( "volume-save", keepVolumeRadio );
334 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
335 CONNECT( ui.resetVolumeRadio, toggled( bool ),
336 ui.defaultVolume_zone, setEnabled( bool ) );
338 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
339 preferredAudioLanguage );
341 CONFIG_BOOL( "spdif", spdifBox );
342 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
345 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
347 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
349 CONFIG_GENERIC( "audio-visual" , StringList, ui.visuLabel,
351 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
353 /* Audio Output Specifics */
354 CONFIG_GENERIC( "aout", StringList, ui.outputLabel, outputModule );
356 CONNECT( ui.outputModule, currentIndexChanged( int ),
357 this, updateAudioOptions( int ) );
359 /* File output exists on all platforms */
360 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
361 ui.fileName, ui.fileBrowseButton );
363 optionWidgets["fileW"] = ui.fileControl;
364 optionWidgets["audioOutCoB"] = ui.outputModule;
365 optionWidgets["normalizerChB"] = ui.volNormBox;
366 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
367 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
368 optionWidgets["volLW"] = ui.volumeValue;
369 optionWidgets["headphoneB"] = ui.headphoneEffect;
370 optionWidgets["spdifChB"] = ui.spdifBox;
371 updateAudioOptions( ui.outputModule->currentIndex() );
374 if( module_exists( "audioscrobbler" ) )
376 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
378 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
381 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
382 ui.lastfm->setChecked( true );
384 ui.lastfm->setChecked( false );
386 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
388 CONNECT( ui.lastfm, toggled( bool ),
389 ui.lastfm_zone, setVisible( bool ) );
390 CONNECT( ui.lastfm, stateChanged( int ),
391 this, lastfm_Changed( int ) );
396 ui.lastfm_zone->hide();
400 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
401 setEnabled( bool ) );
403 char* psz = config_GetPsz( p_intf, "audio-filter" );
404 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
407 bool b_enabled = ( qs_filter.contains( "normvol" ) );
408 ui.volNormBox->setChecked( b_enabled );
409 ui.volNormSpin->setEnabled( b_enabled );
411 b_enabled = ( qs_filter.contains( "headphone" ) );
412 ui.headphoneEffect->setChecked( b_enabled );
415 updateAudioVolume( ui.defaultVolume->value() ); // First time init
419 /* Input and Codecs Panel Implementation */
420 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
424 ui.DVDDeviceComboBox->setToolTip(
425 qtr( "If this property is blank, different values\n"
426 "for DVD, VCD, and CDDA are set.\n"
427 "You can define a unique one or configure them \n"
428 "individually in the advanced preferences." ) );
429 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
430 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
431 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
432 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
433 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
434 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
436 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
438 free( psz_cddadiscpath );
439 free( psz_dvddiscpath );
440 free( psz_vcddiscpath );
443 QStringList DVDDeviceComboBoxStringList = QStringList();
444 DVDDeviceComboBoxStringList
445 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
446 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
447 .entryList( DVDDeviceComboBoxStringList, QDir::System )
448 .replaceInStrings( QRegExp("^"), "/dev/" )
451 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
452 DVDDeviceComboBox->lineEdit() );
453 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
454 ui.recordPath, ui.recordBrowse );
456 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
457 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
459 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
461 /* live555 module prefs */
462 CONFIG_BOOL( "rtsp-tcp",
463 live555TransportRTSP_TCPRadio );
464 if ( !module_exists( "live555" ) )
466 ui.live555TransportRTSP_TCPRadio->hide();
467 ui.live555TransportHTTPRadio->hide();
468 ui.live555TransportLabel->hide();
470 CONFIG_GENERIC( "avcodec-hw", StringList, ui.hwAccelLabel, hwAccelModule );
472 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
474 ui.hwAccelModule->setEnabled( false );
476 FreeLibrary( hdxva2_dll );
478 optionWidgets["inputLE"] = ui.DVDDeviceComboBox;
479 optionWidgets["cachingCoB"] = ui.cachingCombo;
480 CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
481 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
482 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
483 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
484 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
485 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
488 /* Add the things to the ComboBox */
489 #define addToCachingBox( str, cachingNumber ) \
490 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
491 addToCachingBox( N_("Custom"), CachingCustom );
492 addToCachingBox( N_("Lowest latency"), CachingLowest );
493 addToCachingBox( N_("Low latency"), CachingLow );
494 addToCachingBox( N_("Normal"), CachingNormal );
495 addToCachingBox( N_("High latency"), CachingHigh );
496 addToCachingBox( N_("Higher latency"), CachingHigher );
497 #undef addToCachingBox
499 #define TestCaC( name, factor ) \
500 b_cache_equal = b_cache_equal && \
501 ( i_cache * factor == config_GetInt( p_intf, name ) );
502 /* Select the accurate value of the ComboBox */
503 bool b_cache_equal = true;
504 int i_cache = config_GetInt( p_intf, "file-caching" );
506 TestCaC( "network-caching", 10/3 );
507 TestCaC( "disc-caching", 1);
508 TestCaC( "live-caching", 1 );
509 if( b_cache_equal == 1 )
510 ui.cachingCombo->setCurrentIndex(
511 ui.cachingCombo->findData( QVariant( i_cache ) ) );
518 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
519 // ui.defaultLabel->setFont( italicFont );
520 ui.skinsLabel->setText(
521 qtr( "This is VLC's skinnable interface. You can download other skins at" )
522 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
523 + qtr( "VLC skins website" )+ QString( "</a>." ) );
524 ui.skinsLabel->setFont( italicFont );
527 BUTTONACT( ui.assoButton, assoDialog() );
529 ui.assoButton->hide();
530 ui.assocLabel->hide();
533 BUTTONACT( ui.sqlMLbtn, configML() );
539 char *psz_intf = config_GetPsz( p_intf, "intf" );
542 if( strstr( psz_intf, "skin" ) )
543 ui.skins->setChecked( true );
546 ui.qt->setChecked( true );
550 optionWidgets["skinRB"] = ui.skins;
551 optionWidgets["qtRB"] = ui.qt;
553 ui.stylesCombo->addItem( qtr("System's default") );
554 ui.stylesCombo->addItems( QStyleFactory::keys() );
555 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
556 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
557 ui.stylesCombo->insertSeparator( 1 );
558 if ( ui.stylesCombo->currentIndex() < 0 )
559 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
561 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
562 optionWidgets["styleCB"] = ui.stylesCombo;
564 ui.stylesCombo->hide();
565 ui.stylesLabel->hide();
567 radioGroup = new QButtonGroup(this);
568 radioGroup->addButton( ui.qt, 0 );
569 radioGroup->addButton( ui.skins, 1 );
570 CONNECT( radioGroup, buttonClicked( int ),
571 ui.styleStackedWidget, setCurrentIndex( int ) );
572 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
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-video-autoresize", resizingBox );
582 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
583 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
585 CONFIG_BOOL( "qt-fs-controller", fsController );
586 CONFIG_BOOL( "qt-system-tray", systrayBox );
587 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
589 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
590 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
592 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
593 CONFIG_BOOL( "playlist-tree", treePlaylist );
594 CONFIG_BOOL( "play-and-pause", playPauseBox );
595 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
596 ui.fileSkin, ui.skinBrowse );
598 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
603 CONFIG_BOOL( "qt-updates-notif", updatesBox );
604 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
606 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
607 CONNECT( ui.updatesBox, toggled( bool ),
608 ui.updatesDays, setEnabled( bool ) );
610 ui.updatesBox->hide();
611 ui.updatesDays->hide();
613 /* ONE INSTANCE options */
614 #if !defined( WIN32 ) && !defined(__APPLE__) && !defined(__OS2__)
615 if( !module_exists( "dbus" ) )
616 ui.OneInterfaceBox->hide();
620 CONFIG_BOOL( "one-instance", OneInterfaceMode );
621 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
622 ui.EnqueueOneInterfaceMode->setEnabled(
623 ui.OneInterfaceMode->isChecked() );
624 CONNECT( ui.OneInterfaceMode, toggled( bool ),
625 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
628 /* RECENTLY PLAYED options */
629 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
630 ui.recentlyPlayedFilters, setEnabled( bool ) );
631 ui.recentlyPlayedFilters->setEnabled( false );
632 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
633 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
634 recentlyPlayedFilters );
638 START_SPREFS_CAT( Subtitles,
639 qtr("Subtitle & On Screen Display Settings") );
640 CONFIG_BOOL( "osd", OSDBox);
641 CONFIG_BOOL( "video-title-show", OSDTitleBox);
642 CONFIG_GENERIC( "video-title-position", IntegerList,
643 ui.OSDTitlePosLabel, OSDTitlePos );
645 CONFIG_BOOL( "spu", spuActiveBox);
646 ui.spuZone->setEnabled( ui.spuActiveBox->isChecked() );
647 CONNECT( ui.spuActiveBox, toggled( bool ),
648 ui.spuZone, setEnabled( bool ) );
650 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
652 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
655 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
656 ui.fontSizeLabel, fontSize );
658 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
659 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
661 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
662 ui.fontEffectLabel, effect );
663 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
666 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
668 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
669 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
670 optionWidgets["shadowCB"] = ui.shadowCheck;
671 optionWidgets["backgroundCB"] = ui.backgroundCheck;
677 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
679 QGridLayout *gLayout = new QGridLayout;
680 panel->setLayout( gLayout );
683 panel_label->setText( qtr( "Configure Hotkeys" ) );
684 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
685 control->insertIntoExistingGrid( gLayout, line );
686 controls.append( control );
690 QFrame *sepline = new QFrame;
691 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
692 gLayout->addWidget( sepline, line, 0, 1, -1 );
696 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
697 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
698 p_config, this, false );
699 control->insertIntoExistingGrid( gLayout, line );
700 controls.append( control );
705 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
706 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
707 control->insertIntoExistingGrid( gLayout, line );
708 controls.append( control );
715 panel_layout->addWidget( panel_label );
716 panel_layout->addWidget( title_line );
720 QScrollArea *scroller= new QScrollArea;
721 scroller->setWidget( panel );
722 scroller->setWidgetResizable( true );
723 scroller->setFrameStyle( QFrame::NoFrame );
724 panel_layout->addWidget( scroller );
728 panel_layout->addWidget( panel );
729 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
732 setLayout( panel_layout );
734 #undef END_SPREFS_CAT
735 #undef START_SPREFS_CAT
736 #undef CONFIG_GENERIC_FILE
737 #undef CONFIG_GENERIC_NO_BOOL
738 #undef CONFIG_GENERIC_NO_UI
739 #undef CONFIG_GENERIC
744 void SPrefsPanel::updateAudioOptions( int number)
746 QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
747 ->itemData( number ).toString();
749 optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
750 optionWidgets["directxL"]->setVisible( ( value == "directsound" ) );
751 #elif defined( __OS2__ )
752 optionWidgets["kaiL"]->setVisible( ( value == "kai" ) );
753 optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
755 /* optionWidgets["ossW] can be NULL */
756 if( optionWidgets["ossW"] ) {
757 optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
758 optionWidgets["ossL"]->setVisible( ( value == "oss" ) );
759 optionWidgets["ossB"]->setVisible( ( value == "oss" ) );
761 /* optionWidgets["alsaW] can be NULL */
762 if( optionWidgets["alsaW"] ) {
763 optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
764 optionWidgets["alsaL"]->setVisible( ( value == "alsa" ) );
767 optionWidgets["fileW"]->setVisible( ( value == "aout_file" ) );
768 optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
769 value == "directsound" || value == "waveout" ) );
773 SPrefsPanel::~SPrefsPanel()
775 qDeleteAll( controls ); controls.clear();
778 void SPrefsPanel::updateAudioVolume( int volume )
780 qobject_cast<QSpinBox *>(optionWidgets["volLW"])
781 ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
785 /* Function called from the main Preferences dialog on each SPrefs Panel */
786 void SPrefsPanel::apply()
788 /* Generic save for ever panel */
789 QList<ConfigControl *>::const_iterator i;
790 for( i = controls.begin() ; i != controls.end() ; ++i )
792 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
798 case SPrefsInputAndCodecs:
800 /* Device default selection */
801 QByteArray devicepath =
802 qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
803 if( devicepath.size() > 0 )
805 config_PutPsz( p_intf, "dvd", devicepath );
806 config_PutPsz( p_intf, "vcd", devicepath );
807 config_PutPsz( p_intf, "cd-audio", devicepath );
810 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
812 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
813 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
816 CaC( "file-caching", 1 );
817 CaC( "network-caching", 10/3 );
818 CaC( "disc-caching", 1 );
819 CaC( "live-caching", 1 );
826 case SPrefsInterface:
828 if( qobject_cast<QRadioButton *>(optionWidgets["skinRB"])->isChecked() )
829 config_PutPsz( p_intf, "intf", "skins2,any" );
831 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
832 config_PutPsz( p_intf, "intf", "" );
833 if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
834 getSettings()->setValue( "MainWindow/QtStyle",
835 qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
843 qobject_cast<QCheckBox *>(optionWidgets["normalizerChB"])->isChecked();
844 if( b_checked && !qs_filter.contains( "normvol" ) )
845 qs_filter.append( "normvol" );
846 if( !b_checked && qs_filter.contains( "normvol" ) )
847 qs_filter.removeAll( "normvol" );
850 qobject_cast<QCheckBox *>(optionWidgets["headphoneB"])->isChecked();
852 if( b_checked && !qs_filter.contains( "headphone" ) )
853 qs_filter.append( "headphone" );
854 if( !b_checked && qs_filter.contains( "headphone" ) )
855 qs_filter.removeAll( "headphone" );
857 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
860 case SPrefsSubtitles:
862 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
863 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
864 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
866 else if (!b_checked ) {
867 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
870 b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
871 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
872 config_PutInt( p_intf, "freetype-background-opacity", 128 );
874 else if (!b_checked ) {
875 config_PutInt( p_intf, "freetype-background-opacity", 0 );
882 void SPrefsPanel::clean()
885 void SPrefsPanel::lastfm_Changed( int i_state )
887 if( i_state == Qt::Checked )
888 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
889 else if( i_state == Qt::Unchecked )
890 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
893 void SPrefsPanel::changeStyle( QString s_style )
895 QApplication::setStyle( s_style );
897 /* force refresh on all widgets */
898 QWidgetList widgets = QApplication::allWidgets();
899 QWidgetList::iterator it = widgets.begin();
900 while( it != widgets.end() ) {
906 void SPrefsPanel::configML()
909 MLConfDialog *mld = new MLConfDialog( this, p_intf );
916 #include <QDialogButtonBox>
917 #include "util/registry.hpp"
919 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
920 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
923 const char* psz_VLC = "VLC";
924 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
926 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
928 current->setCheckState( 0, Qt::Checked );
933 current->setCheckState( 0, Qt::Unchecked );
936 listAsso.append( current );
940 void SPrefsPanel::assoDialog()
942 IApplicationAssociationRegistrationUI *p_appassoc;
943 CoInitializeEx( NULL, COINIT_MULTITHREADED );
945 if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
946 NULL, CLSCTX_INPROC_SERVER,
947 IID_IApplicationAssociationRegistrationUI,
948 (void **)&p_appassoc) )
950 if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
959 QDialog *d = new QDialog( this );
960 d->setWindowTitle( qtr( "File associations" ) );
961 QGridLayout *assoLayout = new QGridLayout( d );
963 QTreeWidget *filetypeList = new QTreeWidget;
964 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
965 filetypeList->header()->hide();
967 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
969 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
970 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
971 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
973 filetypeList->addTopLevelItem( audioType );
974 filetypeList->addTopLevelItem( videoType );
975 filetypeList->addTopLevelItem( otherType );
977 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
978 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
979 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
981 QTreeWidgetItem *currentItem = NULL;
984 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
985 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
986 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
988 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
989 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
990 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
991 aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
992 audioType->setCheckState( 0, ( i_temp > 0 ) ?
993 ( ( i_temp == audioType->childCount() ) ?
994 Qt::Checked : Qt::PartiallyChecked )
998 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
999 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
1000 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
1001 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
1002 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
1003 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
1004 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1005 videoType->setCheckState( 0, ( i_temp > 0 ) ?
1006 ( ( i_temp == audioType->childCount() ) ?
1007 Qt::Checked : Qt::PartiallyChecked )
1011 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1012 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1013 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1014 ( ( i_temp == audioType->childCount() ) ?
1015 Qt::Checked : Qt::PartiallyChecked )
1022 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1023 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1024 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1025 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1026 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1028 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1030 CONNECT( closeButton, clicked(), this, saveAsso() );
1031 CONNECT( clearButton, clicked(), d, reject() );
1032 d->resize( 300, 400 );
1038 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1040 QString s_path( "VLC" ); s_path += psz_ext;
1041 QString s_path2 = s_path;
1043 /* Save a backup if already assigned */
1044 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1046 if( !EMPTY_STR(psz_value) )
1047 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1050 /* Put a "link" to VLC.EXT as default */
1051 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1053 /* Create the needed Key if they weren't done in the installer */
1054 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1056 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1057 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1058 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1060 /* Get the installer path */
1061 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1062 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1064 if( str_temp.size() )
1066 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1067 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1069 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1070 "", qtu( str_temp.append(",0") ) );
1076 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1078 QString s_path( "VLC"); s_path += psz_ext;
1079 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1081 if( psz_value && !strcmp( qtu(s_path), psz_value ) )
1084 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1086 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1088 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1093 void SPrefsPanel::saveAsso()
1095 QVLCRegistry * qvReg = NULL;
1096 for( int i = 0; i < listAsso.size(); i ++ )
1098 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1099 if( listAsso[i]->checkState( 0 ) > 0 )
1101 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1105 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1109 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();