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 <QSignalMapper>
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 /* Use autoExclusive buttons and a mapper as QButtonGroup can't
65 set focus (keys) when it manages the buttons's exclusivity.
66 See QT bugs 131 & 816 and QAbstractButton's source code. */
67 QSignalMapper *mapper = new QSignalMapper( layout );
68 CONNECT( mapper, mapped(int), 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 button->setAutoExclusive( true ); \
84 CONNECT( button, clicked(), mapper, map() ); \
85 mapper->setMapping( button, numb ); \
86 layout->addWidget( button );
88 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
89 cone_interface_64, 0 );
90 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
92 ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
94 ADD_CATEGORY( SPrefsSubtitles, SUBPIC_TITLE, qtr("Subtitle & On Screen Display Settings"),
95 cone_subtitles_64, 3 );
96 ADD_CATEGORY( SPrefsInputAndCodecs, INPUT_TITLE, qtr("Input & Codecs Settings"),
98 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
103 SPrefsInterface->setChecked( true );
104 layout->setMargin( 0 );
105 layout->setSpacing( 1 );
107 setMinimumWidth( 140 );
108 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
113 void SPrefsCatList::switchPanel( int i )
115 emit currentItemChanged( i );
118 /*********************************************************************
120 *********************************************************************/
121 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
122 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
124 module_config_t *p_config;
125 ConfigControl *control;
128 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
129 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
132 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
133 p_config, label, ui.qcontrol, false ); \
134 controls.append( control ); \
137 ui.qcontrol->setEnabled( false ); \
138 if( label ) label->setEnabled( false ); \
141 #define CONFIG_BOOL( option, qcontrol ) \
142 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
145 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
146 p_config, NULL, ui.qcontrol ); \
147 controls.append( control ); \
149 else { ui.qcontrol->setEnabled( false ); }
152 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
153 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
156 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
157 p_config, label, qcontrol, false ); \
158 controls.append( control ); \
161 QWidget *widget = label; \
162 qcontrol->setVisible( false ); \
163 if( widget ) widget->setEnabled( false ); \
167 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
168 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
171 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
172 p_config, label, ui.qcontrol ); \
173 controls.append( control ); \
176 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
177 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
180 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
181 p_config, label, qcontrol, qbutton ); \
182 controls.append( control ); \
185 #define START_SPREFS_CAT( name , label ) \
186 case SPrefs ## name: \
188 Ui::SPrefs ## name ui; \
189 ui.setupUi( panel ); \
190 panel_label->setText( label );
192 #define END_SPREFS_CAT \
196 QVBoxLayout *panel_layout = new QVBoxLayout();
197 QWidget *panel = new QWidget();
198 panel_layout->setMargin( 3 );
201 QLabel *panel_label = new QLabel;
202 QFont labelFont = QApplication::font();
203 labelFont.setPointSize( labelFont.pointSize() + 6 );
204 panel_label->setFont( labelFont );
207 QFrame *title_line = new QFrame;
208 title_line->setFrameShape(QFrame::HLine);
209 title_line->setFrameShadow(QFrame::Sunken);
211 QFont italicFont = QApplication::font();
212 italicFont.setItalic( true );
216 /******************************
217 * VIDEO Panel Implementation *
218 ******************************/
219 START_SPREFS_CAT( Video , qtr("Video Settings") );
220 CONFIG_BOOL( "video", enableVideo );
221 ui.videoZone->setEnabled( ui.enableVideo->isChecked() );
222 CONNECT( ui.enableVideo, toggled( bool ),
223 ui.videoZone, setEnabled( bool ) );
225 CONFIG_BOOL( "fullscreen", fullscreen );
226 CONFIG_BOOL( "overlay", overlay );
227 CONFIG_BOOL( "video-on-top", alwaysOnTop );
228 CONFIG_BOOL( "video-deco", windowDecorations );
229 CONFIG_GENERIC( "vout", StringList, ui.voutLabel, outputModule );
232 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
234 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
235 CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
237 ui.directXBox->setVisible( false );
238 ui.hwYUVBox->setVisible( false );
242 CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
243 CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
246 ui.kvaBox->setVisible( false );
249 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
250 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
251 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
253 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
254 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
255 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
256 CONFIG_BOOL( "snapshot-sequential",
257 snapshotsSequentialNumbering );
258 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
262 /******************************
263 * AUDIO Panel Implementation *
264 ******************************/
265 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
267 CONFIG_BOOL( "audio", enableAudio );
268 ui.audioZone->setEnabled( ui.enableAudio->isChecked() );
269 CONNECT( ui.enableAudio, toggled( bool ),
270 ui.audioZone, setEnabled( bool ) );
272 #define audioCommon( name ) \
273 QLabel * name ## Label = new QLabel( qtr( "Device:" ) ); \
274 name ## Label->setMinimumSize(QSize(250, 0)); \
275 outputAudioLayout->addWidget( name ## Label, outputAudioLayout->rowCount(), 0, 1, 1 ); \
277 #define audioControl( name) \
278 audioCommon( name ) \
279 QComboBox * name ## Device = new QComboBox; \
280 name ## Label->setBuddy( name ## Device ); \
281 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
282 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 1, 1, -1 );
284 #define audioControl2( name) \
285 audioCommon( name ) \
286 QLineEdit * name ## Device = new QLineEdit; \
287 name ## Label->setBuddy( name ## Device ); \
288 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ) ); \
289 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 0, 1, -1, Qt::AlignLeft );
291 /* Build if necessary */
292 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
294 audioControl( DirectX );
295 optionWidgets["directxL" ] = DirectXLabel;
296 optionWidgets["directxW" ] = DirectXDevice;
297 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
298 DirectXLabel, DirectXDevice );
299 #elif defined( __OS2__ )
301 optionWidgets["kaiL"] = kaiLabel;
302 optionWidgets["kaiW"] = kaiDevice;
303 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
306 if( module_exists( "alsa" ) )
308 audioControl( alsa );
309 optionWidgets["alsaL"] = alsaLabel;
310 optionWidgets["alsaW"] = alsaDevice;
311 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
314 if( module_exists( "oss" ) )
316 audioControl2( OSS );
317 optionWidgets["ossL"] = OSSLabel;
318 optionWidgets["ossW"] = OSSDevice;
319 optionWidgets["ossB"] = OSSBrowse;
320 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
330 ui.volumeValue->setMaximum( 200 );
331 CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
333 CONNECT( ui.defaultVolume, valueChanged( int ),
334 this, updateAudioVolume( int ) );
336 CONFIG_BOOL( "volume-save", keepVolumeRadio );
337 ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
338 CONNECT( ui.resetVolumeRadio, toggled( bool ),
339 ui.defaultVolume_zone, setEnabled( bool ) );
341 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
342 preferredAudioLanguage );
344 CONFIG_BOOL( "spdif", spdifBox );
345 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
348 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
350 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
352 CONFIG_GENERIC( "audio-visual" , StringList, ui.visuLabel,
354 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
356 /* Audio Output Specifics */
357 CONFIG_GENERIC( "aout", StringList, ui.outputLabel, outputModule );
359 CONNECT( ui.outputModule, currentIndexChanged( int ),
360 this, updateAudioOptions( int ) );
362 /* File output exists on all platforms */
363 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
364 ui.fileName, ui.fileBrowseButton );
366 optionWidgets["fileW"] = ui.fileControl;
367 optionWidgets["audioOutCoB"] = ui.outputModule;
368 optionWidgets["normalizerChB"] = ui.volNormBox;
369 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
370 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
371 optionWidgets["volLW"] = ui.volumeValue;
372 optionWidgets["headphoneB"] = ui.headphoneEffect;
373 optionWidgets["spdifChB"] = ui.spdifBox;
374 updateAudioOptions( ui.outputModule->currentIndex() );
377 if( module_exists( "audioscrobbler" ) )
379 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
381 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
384 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
385 ui.lastfm->setChecked( true );
387 ui.lastfm->setChecked( false );
389 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
391 CONNECT( ui.lastfm, toggled( bool ),
392 ui.lastfm_zone, setVisible( bool ) );
393 CONNECT( ui.lastfm, stateChanged( int ),
394 this, lastfm_Changed( int ) );
399 ui.lastfm_zone->hide();
403 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
404 setEnabled( bool ) );
406 char* psz = config_GetPsz( p_intf, "audio-filter" );
407 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
410 bool b_enabled = ( qs_filter.contains( "normvol" ) );
411 ui.volNormBox->setChecked( b_enabled );
412 ui.volNormSpin->setEnabled( b_enabled );
414 b_enabled = ( qs_filter.contains( "headphone" ) );
415 ui.headphoneEffect->setChecked( b_enabled );
418 updateAudioVolume( ui.defaultVolume->value() ); // First time init
422 /* Input and Codecs Panel Implementation */
423 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
427 ui.DVDDeviceComboBox->setToolTip(
428 qtr( "If this property is blank, different values\n"
429 "for DVD, VCD, and CDDA are set.\n"
430 "You can define a unique one or configure them \n"
431 "individually in the advanced preferences." ) );
432 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
433 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
434 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
435 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
436 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
437 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
439 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
441 free( psz_cddadiscpath );
442 free( psz_dvddiscpath );
443 free( psz_vcddiscpath );
446 QStringList DVDDeviceComboBoxStringList = QStringList();
447 DVDDeviceComboBoxStringList
448 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
449 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
450 .entryList( DVDDeviceComboBoxStringList, QDir::System )
451 .replaceInStrings( QRegExp("^"), "/dev/" )
454 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
455 DVDDeviceComboBox->lineEdit() );
456 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
457 ui.recordPath, ui.recordBrowse );
459 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
460 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
462 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
464 /* live555 module prefs */
465 CONFIG_BOOL( "rtsp-tcp",
466 live555TransportRTSP_TCPRadio );
467 if ( !module_exists( "live555" ) )
469 ui.live555TransportRTSP_TCPRadio->hide();
470 ui.live555TransportHTTPRadio->hide();
471 ui.live555TransportLabel->hide();
473 CONFIG_GENERIC( "avcodec-hw", StringList, ui.hwAccelLabel, hwAccelModule );
475 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
477 ui.hwAccelModule->setEnabled( false );
479 FreeLibrary( hdxva2_dll );
481 optionWidgets["inputLE"] = ui.DVDDeviceComboBox;
482 optionWidgets["cachingCoB"] = ui.cachingCombo;
483 CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
484 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
485 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
486 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
487 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
488 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
491 /* Add the things to the ComboBox */
492 #define addToCachingBox( str, cachingNumber ) \
493 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
494 addToCachingBox( N_("Custom"), CachingCustom );
495 addToCachingBox( N_("Lowest latency"), CachingLowest );
496 addToCachingBox( N_("Low latency"), CachingLow );
497 addToCachingBox( N_("Normal"), CachingNormal );
498 addToCachingBox( N_("High latency"), CachingHigh );
499 addToCachingBox( N_("Higher latency"), CachingHigher );
500 #undef addToCachingBox
502 #define TestCaC( name, factor ) \
503 b_cache_equal = b_cache_equal && \
504 ( i_cache * factor == config_GetInt( p_intf, name ) );
505 /* Select the accurate value of the ComboBox */
506 bool b_cache_equal = true;
507 int i_cache = config_GetInt( p_intf, "file-caching" );
509 TestCaC( "network-caching", 10/3 );
510 TestCaC( "disc-caching", 1);
511 TestCaC( "live-caching", 1 );
512 if( b_cache_equal == 1 )
513 ui.cachingCombo->setCurrentIndex(
514 ui.cachingCombo->findData( QVariant( i_cache ) ) );
521 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
522 // ui.defaultLabel->setFont( italicFont );
523 ui.skinsLabel->setText(
524 qtr( "This is VLC's skinnable interface. You can download other skins at" )
525 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
526 + qtr( "VLC skins website" )+ QString( "</a>." ) );
527 ui.skinsLabel->setFont( italicFont );
530 BUTTONACT( ui.assoButton, assoDialog() );
532 ui.assoButton->hide();
533 ui.assocLabel->hide();
536 BUTTONACT( ui.sqlMLbtn, configML() );
542 char *psz_intf = config_GetPsz( p_intf, "intf" );
545 if( strstr( psz_intf, "skin" ) )
546 ui.skins->setChecked( true );
549 ui.qt->setChecked( true );
553 optionWidgets["skinRB"] = ui.skins;
554 optionWidgets["qtRB"] = ui.qt;
555 #if !defined( _WIN32)
556 ui.stylesCombo->addItem( qtr("System's default") );
557 ui.stylesCombo->addItems( QStyleFactory::keys() );
558 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
559 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
560 ui.stylesCombo->insertSeparator( 1 );
561 if ( ui.stylesCombo->currentIndex() < 0 )
562 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
564 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
565 optionWidgets["styleCB"] = ui.stylesCombo;
567 ui.stylesCombo->hide();
568 ui.stylesLabel->hide();
570 radioGroup = new QButtonGroup(this);
571 radioGroup->addButton( ui.qt, 0 );
572 radioGroup->addButton( ui.skins, 1 );
573 CONNECT( radioGroup, buttonClicked( int ),
574 ui.styleStackedWidget, setCurrentIndex( int ) );
575 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
577 CONNECT( ui.minimalviewBox, toggled( bool ),
578 ui.mainPreview, setNormalPreview( bool ) );
579 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
580 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
581 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
583 CONFIG_BOOL( "embedded-video", embedVideo );
584 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
585 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
586 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
588 CONFIG_BOOL( "qt-fs-controller", fsController );
589 CONFIG_BOOL( "qt-system-tray", systrayBox );
590 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
592 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
593 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationComboLabel, setEnabled( bool ) );
594 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
596 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
597 CONFIG_BOOL( "playlist-tree", treePlaylist );
598 CONFIG_BOOL( "play-and-pause", playPauseBox );
599 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
600 ui.fileSkin, ui.skinBrowse );
602 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
607 CONFIG_BOOL( "qt-updates-notif", updatesBox );
608 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
610 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
611 CONNECT( ui.updatesBox, toggled( bool ),
612 ui.updatesDays, setEnabled( bool ) );
614 ui.updatesBox->hide();
615 ui.updatesDays->hide();
617 /* ONE INSTANCE options */
618 #if !defined( _WIN32 ) && !defined(__APPLE__) && !defined(__OS2__)
619 if( !module_exists( "dbus" ) )
620 ui.OneInterfaceBox->hide();
624 CONFIG_BOOL( "one-instance", OneInterfaceMode );
625 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
626 ui.EnqueueOneInterfaceMode->setEnabled(
627 ui.OneInterfaceMode->isChecked() );
628 CONNECT( ui.OneInterfaceMode, toggled( bool ),
629 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
630 CONFIG_BOOL( "one-instance-when-started-from-file", oneInstanceFromFile );
633 /* RECENTLY PLAYED options */
634 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
635 ui.recentlyPlayedFilters, setEnabled( bool ) );
636 ui.recentlyPlayedFilters->setEnabled( false );
637 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
638 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
639 recentlyPlayedFilters );
643 START_SPREFS_CAT( Subtitles,
644 qtr("Subtitle & On Screen Display Settings") );
645 CONFIG_BOOL( "osd", OSDBox);
646 CONFIG_BOOL( "video-title-show", OSDTitleBox);
647 CONFIG_GENERIC( "video-title-position", IntegerList,
648 ui.OSDTitlePosLabel, OSDTitlePos );
650 CONFIG_BOOL( "spu", spuActiveBox);
651 ui.spuZone->setEnabled( ui.spuActiveBox->isChecked() );
652 CONNECT( ui.spuActiveBox, toggled( bool ),
653 ui.spuZone, setEnabled( bool ) );
655 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
657 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
660 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
661 ui.fontSizeLabel, fontSize );
663 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
664 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
666 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
667 ui.fontEffectLabel, effect );
668 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
671 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
673 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
674 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
675 optionWidgets["shadowCB"] = ui.shadowCheck;
676 optionWidgets["backgroundCB"] = ui.backgroundCheck;
682 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
684 QGridLayout *gLayout = new QGridLayout;
685 panel->setLayout( gLayout );
688 panel_label->setText( qtr( "Configure Hotkeys" ) );
689 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
690 control->insertIntoExistingGrid( gLayout, line );
691 controls.append( control );
695 QFrame *sepline = new QFrame;
696 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
697 gLayout->addWidget( sepline, line, 0, 1, -1 );
701 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
702 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
703 p_config, this, false );
704 control->insertIntoExistingGrid( gLayout, line );
705 controls.append( control );
710 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
711 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
712 control->insertIntoExistingGrid( gLayout, line );
713 controls.append( control );
720 panel_layout->addWidget( panel_label );
721 panel_layout->addWidget( title_line );
725 QScrollArea *scroller= new QScrollArea;
726 scroller->setWidget( panel );
727 scroller->setWidgetResizable( true );
728 scroller->setFrameStyle( QFrame::NoFrame );
729 panel_layout->addWidget( scroller );
733 panel_layout->addWidget( panel );
734 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
737 setLayout( panel_layout );
739 #undef END_SPREFS_CAT
740 #undef START_SPREFS_CAT
741 #undef CONFIG_GENERIC_FILE
742 #undef CONFIG_GENERIC_NO_BOOL
743 #undef CONFIG_GENERIC_NO_UI
744 #undef CONFIG_GENERIC
749 void SPrefsPanel::updateAudioOptions( int number)
751 QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
752 ->itemData( number ).toString();
754 optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
755 optionWidgets["directxL"]->setVisible( ( value == "directsound" ) );
756 #elif defined( __OS2__ )
757 optionWidgets["kaiL"]->setVisible( ( value == "kai" ) );
758 optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
760 /* optionWidgets["ossW] can be NULL */
761 if( optionWidgets["ossW"] ) {
762 optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
763 optionWidgets["ossL"]->setVisible( ( value == "oss" ) );
764 optionWidgets["ossB"]->setVisible( ( value == "oss" ) );
766 /* optionWidgets["alsaW] can be NULL */
767 if( optionWidgets["alsaW"] ) {
768 optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
769 optionWidgets["alsaL"]->setVisible( ( value == "alsa" ) );
772 optionWidgets["fileW"]->setVisible( ( value == "aout_file" ) );
773 optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
774 value == "directsound" || value == "waveout" ) );
778 SPrefsPanel::~SPrefsPanel()
780 qDeleteAll( controls ); controls.clear();
783 void SPrefsPanel::updateAudioVolume( int volume )
785 qobject_cast<QSpinBox *>(optionWidgets["volLW"])
786 ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
790 /* Function called from the main Preferences dialog on each SPrefs Panel */
791 void SPrefsPanel::apply()
793 /* Generic save for ever panel */
794 QList<ConfigControl *>::const_iterator i;
795 for( i = controls.begin() ; i != controls.end() ; ++i )
797 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
803 case SPrefsInputAndCodecs:
805 /* Device default selection */
806 QByteArray devicepath =
807 qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
808 if( devicepath.size() > 0 )
810 config_PutPsz( p_intf, "dvd", devicepath );
811 config_PutPsz( p_intf, "vcd", devicepath );
812 config_PutPsz( p_intf, "cd-audio", devicepath );
815 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
817 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
818 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
821 CaC( "file-caching", 1 );
822 CaC( "network-caching", 10/3 );
823 CaC( "disc-caching", 1 );
824 CaC( "live-caching", 1 );
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( "normvol" ) )
850 qs_filter.append( "normvol" );
851 if( !b_checked && qs_filter.contains( "normvol" ) )
852 qs_filter.removeAll( "normvol" );
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( ":" ) ) );
865 case SPrefsSubtitles:
867 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
868 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
869 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
871 else if (!b_checked ) {
872 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
875 b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
876 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
877 config_PutInt( p_intf, "freetype-background-opacity", 128 );
879 else if (!b_checked ) {
880 config_PutInt( p_intf, "freetype-background-opacity", 0 );
887 void SPrefsPanel::clean()
890 void SPrefsPanel::lastfm_Changed( int i_state )
892 if( i_state == Qt::Checked )
893 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
894 else if( i_state == Qt::Unchecked )
895 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
898 void SPrefsPanel::changeStyle( QString s_style )
900 QApplication::setStyle( s_style );
902 /* force refresh on all widgets */
903 QWidgetList widgets = QApplication::allWidgets();
904 QWidgetList::iterator it = widgets.begin();
905 while( it != widgets.end() ) {
911 void SPrefsPanel::configML()
914 MLConfDialog *mld = new MLConfDialog( this, p_intf );
921 #include <QDialogButtonBox>
922 #include "util/registry.hpp"
924 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
925 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
928 const char* psz_VLC = "VLC";
929 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
931 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
933 current->setCheckState( 0, Qt::Checked );
938 current->setCheckState( 0, Qt::Unchecked );
941 listAsso.append( current );
945 void SPrefsPanel::assoDialog()
947 IApplicationAssociationRegistrationUI *p_appassoc;
948 CoInitializeEx( NULL, COINIT_MULTITHREADED );
950 if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
951 NULL, CLSCTX_INPROC_SERVER,
952 IID_IApplicationAssociationRegistrationUI,
953 (void **)&p_appassoc) )
955 if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
964 QDialog *d = new QDialog( this );
965 d->setWindowTitle( qtr( "File associations" ) );
966 QGridLayout *assoLayout = new QGridLayout( d );
968 QTreeWidget *filetypeList = new QTreeWidget;
969 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
970 filetypeList->header()->hide();
972 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
974 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
975 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
976 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
978 filetypeList->addTopLevelItem( audioType );
979 filetypeList->addTopLevelItem( videoType );
980 filetypeList->addTopLevelItem( otherType );
982 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
983 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
984 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
986 QTreeWidgetItem *currentItem = NULL;
989 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
990 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
991 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
993 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
994 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
995 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
996 aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
997 audioType->setCheckState( 0, ( i_temp > 0 ) ?
998 ( ( i_temp == audioType->childCount() ) ?
999 Qt::Checked : Qt::PartiallyChecked )
1003 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
1004 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
1005 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
1006 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
1007 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
1008 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
1009 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1010 videoType->setCheckState( 0, ( i_temp > 0 ) ?
1011 ( ( i_temp == audioType->childCount() ) ?
1012 Qt::Checked : Qt::PartiallyChecked )
1016 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1017 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1018 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1019 ( ( i_temp == audioType->childCount() ) ?
1020 Qt::Checked : Qt::PartiallyChecked )
1027 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1028 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1029 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1030 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1031 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1033 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1035 CONNECT( closeButton, clicked(), this, saveAsso() );
1036 CONNECT( clearButton, clicked(), d, reject() );
1037 d->resize( 300, 400 );
1043 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1045 QString s_path( "VLC" ); s_path += psz_ext;
1046 QString s_path2 = s_path;
1048 /* Save a backup if already assigned */
1049 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1051 if( !EMPTY_STR(psz_value) )
1052 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1055 /* Put a "link" to VLC.EXT as default */
1056 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1058 /* Create the needed Key if they weren't done in the installer */
1059 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1061 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1062 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1063 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1065 /* Get the installer path */
1066 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1067 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1069 if( str_temp.size() )
1071 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1072 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1074 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1075 "", qtu( str_temp.append(",0") ) );
1081 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1083 QString s_path( "VLC"); s_path += psz_ext;
1084 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1086 if( psz_value && !strcmp( qtu(s_path), psz_value ) )
1089 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1091 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1093 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1098 void SPrefsPanel::saveAsso()
1100 QVLCRegistry * qvReg = NULL;
1101 for( int i = 0; i < listAsso.size(); i ++ )
1103 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1104 if( listAsso[i]->checkState( 0 ) > 0 )
1106 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1110 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1114 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();