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>
36 #include <vlc_aout_intf.h>
40 #include <QToolButton>
41 #include <QButtonGroup>
42 #include <QVBoxLayout>
43 #include <QScrollArea>
45 #include <QStyleFactory>
47 #include <QtAlgorithms>
50 #define ICON_HEIGHT 64
53 # include <vlc_windows_interfaces.h>
55 #include <vlc_modules.h>
57 /*********************************************************************
58 * The List of categories
59 *********************************************************************/
60 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
61 QWidget( _parent ), p_intf( _p_intf )
63 QVBoxLayout *layout = new QVBoxLayout();
65 QButtonGroup *buttonGroup = new QButtonGroup( this );
66 buttonGroup->setExclusive ( true );
67 CONNECT( buttonGroup, buttonClicked ( int ),
68 this, switchPanel( int ) );
70 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
72 #define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
73 QToolButton * button = new QToolButton( this ); \
74 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
75 button->setText( label ); \
76 button->setToolTip( ltooltip ); \
77 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
78 button->setIconSize( QSize( icon_height, icon_height ) ); \
79 button->resize( icon_height + 6 , icon_height + 6 ); \
80 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
81 button->setAutoRaise( true ); \
82 button->setCheckable( true ); \
83 buttonGroup->addButton( button, numb ); \
84 layout->addWidget( button );
86 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
87 cone_interface_64, 0 );
88 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
90 ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
92 ADD_CATEGORY( SPrefsSubtitles, SUBPIC_TITLE, qtr("Subtitles & On Screen Display Settings"),
93 cone_subtitles_64, 3 );
94 ADD_CATEGORY( SPrefsInputAndCodecs, INPUT_TITLE, qtr("Input & Codecs Settings"),
96 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
101 SPrefsInterface->setChecked( true );
102 layout->setMargin( 0 );
103 layout->setSpacing( 1 );
105 setMinimumWidth( 140 );
106 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
111 void SPrefsCatList::switchPanel( int i )
113 emit currentItemChanged( i );
116 /*********************************************************************
118 *********************************************************************/
119 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
120 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
122 module_config_t *p_config;
123 ConfigControl *control;
126 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
127 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
130 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
131 p_config, label, ui.qcontrol, false ); \
132 controls.append( control ); \
135 ui.qcontrol->setEnabled( false ); \
136 if( label ) label->setEnabled( false ); \
139 #define CONFIG_BOOL( option, qcontrol ) \
140 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
143 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
144 p_config, NULL, ui.qcontrol ); \
145 controls.append( control ); \
147 else { ui.qcontrol->setEnabled( false ); }
150 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
151 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
154 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
155 p_config, label, qcontrol, false ); \
156 controls.append( control ); \
159 QWidget *widget = label; \
160 qcontrol->setVisible( false ); \
161 if( widget ) widget->setEnabled( false ); \
165 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
166 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
169 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
170 p_config, label, ui.qcontrol ); \
171 controls.append( control ); \
174 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
175 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
178 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
179 p_config, label, qcontrol, qbutton ); \
180 controls.append( control ); \
183 #define START_SPREFS_CAT( name , label ) \
184 case SPrefs ## name: \
186 Ui::SPrefs ## name ui; \
187 ui.setupUi( panel ); \
188 panel_label->setText( label );
190 #define END_SPREFS_CAT \
194 QVBoxLayout *panel_layout = new QVBoxLayout();
195 QWidget *panel = new QWidget();
196 panel_layout->setMargin( 3 );
199 QLabel *panel_label = new QLabel;
200 QFont labelFont = QApplication::font();
201 labelFont.setPointSize( labelFont.pointSize() + 6 );
202 panel_label->setFont( labelFont );
205 QFrame *title_line = new QFrame;
206 title_line->setFrameShape(QFrame::HLine);
207 title_line->setFrameShadow(QFrame::Sunken);
209 QFont italicFont = QApplication::font();
210 italicFont.setItalic( true );
214 /******************************
215 * VIDEO Panel Implementation *
216 ******************************/
217 START_SPREFS_CAT( Video , qtr("Video Settings") );
218 CONFIG_BOOL( "video", enableVideo );
220 CONFIG_BOOL( "fullscreen", fullscreen );
221 CONFIG_BOOL( "overlay", overlay );
222 CONFIG_BOOL( "video-on-top", alwaysOnTop );
223 CONFIG_BOOL( "video-deco", windowDecorations );
224 CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
227 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
229 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
230 CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
232 ui.directXBox->setVisible( false );
233 ui.hwYUVBox->setVisible( false );
237 CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
238 CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
241 ui.kvaBox->setVisible( false );
244 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
245 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
246 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
248 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
249 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
250 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
251 CONFIG_BOOL( "snapshot-sequential",
252 snapshotsSequentialNumbering );
253 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
257 /******************************
258 * AUDIO Panel Implementation *
259 ******************************/
260 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
262 CONFIG_BOOL( "audio", enableAudio );
263 ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
264 CONNECT( ui.enableAudio, toggled( bool ),
265 ui.SPrefsAudio_zone, setEnabled( bool ) );
267 #define audioCommon( name ) \
268 QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
269 QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
270 name ## Layout->setMargin( 0 ); \
271 name ## Layout->setSpacing( 0 ); \
272 QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
273 name ## Label->setMinimumSize(QSize(250, 0)); \
274 name ## Layout->addWidget( name ## Label ); \
276 #define audioControl( name) \
277 audioCommon( name ) \
278 QComboBox * name ## Device = new QComboBox( name ## Control ); \
279 name ## Layout->addWidget( name ## Device ); \
280 name ## Label->setBuddy( name ## Device ); \
281 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
282 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
284 #define audioControl2( name) \
285 audioCommon( name ) \
286 QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
287 name ## Layout->addWidget( name ## Device ); \
288 name ## Label->setBuddy( name ## Device ); \
289 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
290 name ## Layout->addWidget( name ## Browse ); \
291 outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
293 /* Build if necessary */
294 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
296 audioControl( DirectX );
297 optionWidgets.append( DirectXControl );
298 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
299 DirectXLabel, DirectXDevice );
300 #elif defined( __OS2__ )
302 optionWidgets.append( kaiControl );
303 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
306 if( module_exists( "alsa" ) )
308 audioControl( alsa );
309 optionWidgets.append( alsaControl );
310 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
314 optionWidgets.append( NULL );
315 if( module_exists( "oss" ) )
317 audioControl2( OSS );
318 optionWidgets.append( OSSControl );
319 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
323 optionWidgets.append( NULL );
331 ui.volumeValue->setMaximum( 200 );
332 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
334 CONNECT( ui.defaultVolume, valueChanged( int ),
335 this, updateAudioVolume( int ) );
337 CONFIG_BOOL( "volume-save", keepVolumeRadio );
338 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
339 CONNECT( ui.resetVolumeRadio, toggled( bool ),
340 ui.defaultVolume_zone, setEnabled( bool ) );
342 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
343 preferredAudioLanguage );
345 CONFIG_BOOL( "spdif", spdifBox );
346 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
349 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
351 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
353 CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
355 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
357 /* Audio Output Specifics */
358 CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );
360 CONNECT( ui.outputModule, currentIndexChanged( int ),
361 this, updateAudioOptions( int ) );
363 /* File output exists on all platforms */
364 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
365 ui.fileName, ui.fileBrowseButton );
367 optionWidgets.append( ui.fileControl );
368 optionWidgets.append( ui.outputModule );
369 optionWidgets.append( ui.volNormBox );
370 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
371 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
372 optionWidgets.append( ui.volumeValue );
373 optionWidgets.append( ui.headphoneEffect );
374 optionWidgets.append( ui.spdifBox );
375 updateAudioOptions( ui.outputModule->currentIndex() );
378 if( module_exists( "audioscrobbler" ) )
380 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
382 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
385 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
386 ui.lastfm->setChecked( true );
388 ui.lastfm->setChecked( false );
390 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
392 CONNECT( ui.lastfm, toggled( bool ),
393 ui.lastfm_zone, setVisible( bool ) );
394 CONNECT( ui.lastfm, stateChanged( int ),
395 this, lastfm_Changed( int ) );
400 ui.lastfm_zone->hide();
404 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
405 setEnabled( bool ) );
407 char* psz = config_GetPsz( p_intf, "audio-filter" );
408 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
411 bool b_enabled = ( qs_filter.contains( "normvol" ) );
412 ui.volNormBox->setChecked( b_enabled );
413 ui.volNormSpin->setEnabled( b_enabled );
415 b_enabled = ( qs_filter.contains( "headphone" ) );
416 ui.headphoneEffect->setChecked( b_enabled );
419 updateAudioVolume( ui.defaultVolume->value() ); // First time init
423 /* Input and Codecs Panel Implementation */
424 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
428 ui.DVDDeviceComboBox->setToolTip(
429 qtr( "If this property is blank, different values\n"
430 "for DVD, VCD, and CDDA are set.\n"
431 "You can define a unique one or configure them \n"
432 "individually in the advanced preferences." ) );
433 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
434 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
435 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
436 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
437 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
438 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
440 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
442 free( psz_cddadiscpath );
443 free( psz_dvddiscpath );
444 free( psz_vcddiscpath );
447 QStringList DVDDeviceComboBoxStringList = QStringList();
448 DVDDeviceComboBoxStringList
449 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
450 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
451 .entryList( DVDDeviceComboBoxStringList, QDir::System )
452 .replaceInStrings( QRegExp("^"), "/dev/" )
455 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
456 DVDDeviceComboBox->lineEdit() );
457 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
458 ui.recordPath, ui.recordBrowse );
460 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
461 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
463 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
465 /* live555 module prefs */
466 CONFIG_BOOL( "rtsp-tcp",
467 live555TransportRTSP_TCPRadio );
468 if ( !module_exists( "live555" ) )
470 ui.live555TransportRTSP_TCPRadio->hide();
471 ui.live555TransportHTTPRadio->hide();
472 ui.live555TransportLabel->hide();
474 CONFIG_BOOL( "avcodec-hw", hwAccelBox );
476 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
478 ui.hwAccelBox->setEnabled( false );
480 FreeLibrary( hdxva2_dll );
482 optionWidgets.append( ui.DVDDeviceComboBox );
483 optionWidgets.append( ui.cachingCombo );
484 CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
485 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
486 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
487 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
488 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
489 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
492 /* Add the things to the ComboBox */
493 #define addToCachingBox( str, cachingNumber ) \
494 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
495 addToCachingBox( N_("Custom"), CachingCustom );
496 addToCachingBox( N_("Lowest latency"), CachingLowest );
497 addToCachingBox( N_("Low latency"), CachingLow );
498 addToCachingBox( N_("Normal"), CachingNormal );
499 addToCachingBox( N_("High latency"), CachingHigh );
500 addToCachingBox( N_("Higher latency"), CachingHigher );
501 #undef addToCachingBox
503 #define TestCaC( name, factor ) \
504 b_cache_equal = b_cache_equal && \
505 ( i_cache * factor == config_GetInt( p_intf, name ) );
506 /* Select the accurate value of the ComboBox */
507 bool b_cache_equal = true;
508 int i_cache = config_GetInt( p_intf, "file-caching" );
510 TestCaC( "network-caching", 10/3 );
511 TestCaC( "disc-caching", 1);
512 TestCaC( "live-caching", 1 );
513 if( b_cache_equal == 1 )
514 ui.cachingCombo->setCurrentIndex(
515 ui.cachingCombo->findData( QVariant( i_cache ) ) );
522 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
523 // ui.defaultLabel->setFont( italicFont );
524 ui.skinsLabel->setText(
525 qtr( "This is VLC's skinnable interface. You can download other skins at" )
526 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
527 + qtr( "VLC skins website" )+ QString( "</a>." ) );
528 ui.skinsLabel->setFont( italicFont );
531 CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
532 BUTTONACT( ui.assoButton, assoDialog() );
534 ui.languageBox->hide();
535 ui.assoButton->hide();
536 ui.assocLabel->hide();
539 BUTTONACT( ui.sqlMLbtn, configML() );
545 char *psz_intf = config_GetPsz( p_intf, "intf" );
548 if( strstr( psz_intf, "skin" ) )
549 ui.skins->setChecked( true );
552 ui.qt->setChecked( true );
556 optionWidgets.append( ui.skins );
557 optionWidgets.append( ui.qt );
559 ui.stylesCombo->addItem( qtr("System's default") );
560 ui.stylesCombo->addItems( QStyleFactory::keys() );
561 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
562 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
563 ui.stylesCombo->insertSeparator( 1 );
564 if ( ui.stylesCombo->currentIndex() < 0 )
565 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
567 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
568 optionWidgets.append( ui.stylesCombo );
570 ui.stylesCombo->hide();
571 ui.stylesLabel->hide();
572 optionWidgets.append( NULL );
574 radioGroup = new QButtonGroup(this);
575 radioGroup->addButton( ui.qt, 0 );
576 radioGroup->addButton( ui.skins, 1 );
577 CONNECT( radioGroup, buttonClicked( int ),
578 ui.styleStackedWidget, setCurrentIndex( int ) );
579 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
581 CONNECT( ui.minimalviewBox, toggled( bool ),
582 ui.mainPreview, setNormalPreview( bool ) );
583 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
584 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
585 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
587 CONFIG_BOOL( "embedded-video", embedVideo );
588 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
589 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
590 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
592 CONFIG_BOOL( "qt-fs-controller", fsController );
593 CONFIG_BOOL( "qt-system-tray", systrayBox );
594 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
596 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
597 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
599 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
600 CONFIG_BOOL( "playlist-tree", treePlaylist );
601 CONFIG_BOOL( "play-and-pause", playPauseBox );
602 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
603 ui.fileSkin, ui.skinBrowse );
605 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
610 CONFIG_BOOL( "qt-updates-notif", updatesBox );
611 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
613 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
614 CONNECT( ui.updatesBox, toggled( bool ),
615 ui.updatesDays, setEnabled( bool ) );
617 ui.updatesBox->hide();
618 ui.updatesDays->hide();
620 /* ONE INSTANCE options */
621 #if !defined( WIN32 ) && !defined(__APPLE__)
622 if( !module_exists( "dbus" ) )
623 ui.OneInterfaceBox->hide();
627 CONFIG_BOOL( "one-instance", OneInterfaceMode );
628 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
629 ui.EnqueueOneInterfaceMode->setEnabled(
630 ui.OneInterfaceMode->isChecked() );
631 CONNECT( ui.OneInterfaceMode, toggled( bool ),
632 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
635 /* RECENTLY PLAYED options */
636 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
637 ui.recentlyPlayedFilters, setEnabled( bool ) );
638 ui.recentlyPlayedFilters->setEnabled( false );
639 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
640 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
641 recentlyPlayedFilters );
645 START_SPREFS_CAT( Subtitles,
646 qtr("Subtitles & On Screen Display Settings") );
647 CONFIG_BOOL( "osd", OSDBox);
648 CONFIG_BOOL( "video-title-show", OSDTitleBox);
649 CONFIG_GENERIC( "video-title-position", IntegerList,
650 ui.OSDTitlePosLabel, OSDTitlePos );
652 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
654 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
657 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
658 ui.fontSizeLabel, fontSize );
660 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
661 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
663 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
664 ui.fontEffectLabel, effect );
665 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
668 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
670 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
671 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
672 optionWidgets.append( ui.shadowCheck );
673 optionWidgets.append( ui.backgroundCheck );
679 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
681 QGridLayout *gLayout = new QGridLayout;
682 panel->setLayout( gLayout );
685 panel_label->setText( qtr( "Configure Hotkeys" ) );
686 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
687 control->insertIntoExistingGrid( gLayout, line );
688 controls.append( control );
692 QFrame *sepline = new QFrame;
693 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
694 gLayout->addWidget( sepline, line, 0, 1, -1 );
698 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
699 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
700 p_config, this, false );
701 control->insertIntoExistingGrid( gLayout, line );
702 controls.append( control );
707 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
708 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
709 control->insertIntoExistingGrid( gLayout, line );
710 controls.append( control );
717 panel_layout->addWidget( panel_label );
718 panel_layout->addWidget( title_line );
722 QScrollArea *scroller= new QScrollArea;
723 scroller->setWidget( panel );
724 scroller->setWidgetResizable( true );
725 scroller->setFrameStyle( QFrame::NoFrame );
726 panel_layout->addWidget( scroller );
730 panel_layout->addWidget( panel );
731 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
734 setLayout( panel_layout );
736 #undef END_SPREFS_CAT
737 #undef START_SPREFS_CAT
738 #undef CONFIG_GENERIC_FILE
739 #undef CONFIG_GENERIC_NO_BOOL
740 #undef CONFIG_GENERIC_NO_UI
741 #undef CONFIG_GENERIC
746 void SPrefsPanel::updateAudioOptions( int number)
748 QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
749 ->itemData( number ).toString();
751 optionWidgets[directxW]->setVisible( ( value == "directsound" ) );
752 #elif defined( __OS2__ )
753 optionWidgets[kaiW]->setVisible( ( value == "kai" ) );
755 /* optionWidgets[ossW] can be NULL */
756 if( optionWidgets[ossW] )
757 optionWidgets[ossW]->setVisible( ( value == "oss" ) );
758 /* optionWidgets[alsaW] can be NULL */
759 if( optionWidgets[alsaW] )
760 optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
762 optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
763 optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
764 value == "directsound" || value == "waveout" ) );
768 SPrefsPanel::~SPrefsPanel()
770 qDeleteAll( controls ); controls.clear();
773 void SPrefsPanel::updateAudioVolume( int volume )
775 qobject_cast<QSpinBox *>(optionWidgets[volLW])
776 ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
780 /* Function called from the main Preferences dialog on each SPrefs Panel */
781 void SPrefsPanel::apply()
783 /* Generic save for ever panel */
784 QList<ConfigControl *>::const_iterator i;
785 for( i = controls.begin() ; i != controls.end() ; ++i )
787 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
793 case SPrefsInputAndCodecs:
795 /* Device default selection */
796 QByteArray devicepath =
797 qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
798 if( devicepath.size() > 0 )
800 config_PutPsz( p_intf, "dvd", devicepath );
801 config_PutPsz( p_intf, "vcd", devicepath );
802 config_PutPsz( p_intf, "cd-audio", devicepath );
805 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
807 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
808 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
811 CaC( "file-caching", 1 );
812 CaC( "network-caching", 10/3 );
813 CaC( "disc-caching", 1 );
814 CaC( "live-caching", 1 );
821 case SPrefsInterface:
823 if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
824 config_PutPsz( p_intf, "intf", "skins2,any" );
826 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
827 config_PutPsz( p_intf, "intf", "" );
828 if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
829 getSettings()->setValue( "MainWindow/QtStyle",
830 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
838 qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
839 if( b_checked && !qs_filter.contains( "normvol" ) )
840 qs_filter.append( "normvol" );
841 if( !b_checked && qs_filter.contains( "normvol" ) )
842 qs_filter.removeAll( "normvol" );
845 qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
847 if( b_checked && !qs_filter.contains( "headphone" ) )
848 qs_filter.append( "headphone" );
849 if( !b_checked && qs_filter.contains( "headphone" ) )
850 qs_filter.removeAll( "headphone" );
852 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
855 case SPrefsSubtitles:
857 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
858 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
859 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
861 else if (!b_checked ) {
862 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
865 b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
866 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
867 config_PutInt( p_intf, "freetype-background-opacity", 128 );
869 else if (!b_checked ) {
870 config_PutInt( p_intf, "freetype-background-opacity", 0 );
877 void SPrefsPanel::clean()
880 void SPrefsPanel::lastfm_Changed( int i_state )
882 if( i_state == Qt::Checked )
883 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
884 else if( i_state == Qt::Unchecked )
885 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
888 void SPrefsPanel::changeStyle( QString s_style )
890 QApplication::setStyle( s_style );
892 /* force refresh on all widgets */
893 QWidgetList widgets = QApplication::allWidgets();
894 QWidgetList::iterator it = widgets.begin();
895 while( it != widgets.end() ) {
901 void SPrefsPanel::configML()
904 MLConfDialog *mld = new MLConfDialog( this, p_intf );
911 #include <QDialogButtonBox>
912 #include "util/registry.hpp"
914 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
915 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
918 const char* psz_VLC = "VLC";
919 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
921 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
923 current->setCheckState( 0, Qt::Checked );
928 current->setCheckState( 0, Qt::Unchecked );
931 listAsso.append( current );
935 void SPrefsPanel::assoDialog()
937 IApplicationAssociationRegistrationUI *p_appassoc;
940 if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
941 NULL, CLSCTX_INPROC_SERVER,
942 IID_IApplicationAssociationRegistrationUI,
943 (void **)&p_appassoc) )
945 if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
954 QDialog *d = new QDialog( this );
955 d->setWindowTitle( qtr( "File associations" ) );
956 QGridLayout *assoLayout = new QGridLayout( d );
958 QTreeWidget *filetypeList = new QTreeWidget;
959 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
960 filetypeList->header()->hide();
962 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
964 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
965 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
966 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
968 filetypeList->addTopLevelItem( audioType );
969 filetypeList->addTopLevelItem( videoType );
970 filetypeList->addTopLevelItem( otherType );
972 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
973 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
974 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
976 QTreeWidgetItem *currentItem = NULL;
979 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
980 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
981 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
983 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
984 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
985 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
986 aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
987 audioType->setCheckState( 0, ( i_temp > 0 ) ?
988 ( ( i_temp == audioType->childCount() ) ?
989 Qt::Checked : Qt::PartiallyChecked )
993 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
994 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
995 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
996 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
997 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
998 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
999 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1000 videoType->setCheckState( 0, ( i_temp > 0 ) ?
1001 ( ( i_temp == audioType->childCount() ) ?
1002 Qt::Checked : Qt::PartiallyChecked )
1006 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1007 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1008 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1009 ( ( i_temp == audioType->childCount() ) ?
1010 Qt::Checked : Qt::PartiallyChecked )
1017 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1018 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1019 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1020 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1021 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1023 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1025 CONNECT( closeButton, clicked(), this, saveAsso() );
1026 CONNECT( clearButton, clicked(), d, reject() );
1027 d->resize( 300, 400 );
1034 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1036 QString s_path( "VLC" ); s_path += psz_ext;
1037 QString s_path2 = s_path;
1039 /* Save a backup if already assigned */
1040 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1042 if( !EMPTY_STR(psz_value) )
1043 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1046 /* Put a "link" to VLC.EXT as default */
1047 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1049 /* Create the needed Key if they weren't done in the installer */
1050 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1052 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1053 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1054 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1056 /* Get the installer path */
1057 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1058 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1060 if( str_temp.size() )
1062 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1063 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1065 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1066 "", qtu( str_temp.append(",0") ) );
1072 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1074 char psz_VLC[] = "VLC";
1075 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1077 if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1080 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1082 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1084 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1086 delete( psz_value );
1088 void SPrefsPanel::saveAsso()
1090 QVLCRegistry * qvReg = NULL;
1091 for( int i = 0; i < listAsso.size(); i ++ )
1093 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1094 if( listAsso[i]->checkState( 0 ) > 0 )
1096 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1100 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1104 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();