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"
33 #include <vlc_config_cat.h>
34 #include <vlc_configuration.h>
38 #include <QToolButton>
39 #include <QSignalMapper>
40 #include <QVBoxLayout>
41 #include <QScrollArea>
43 #include <QStyleFactory>
45 #include <QtAlgorithms>
50 #define ICON_HEIGHT 48
53 # include <vlc_windows_interfaces.h>
54 # include <vlc_charset.h>
56 #include <vlc_modules.h>
58 static const char *const ppsz_language[] =
123 static const char *const ppsz_language_text[] =
129 "Português Brasileiro",
187 static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout)
189 if (!strcmp(aout, "") || !strcmp(aout, "any"))
192 /* Note: For hysterical raisins, this is sorted by decreasing priority
193 * order (then alphabetical order). */
194 if (!strcmp(aout, "pulse"))
198 if (!strcmp(aout, "alsa") && module_exists("alsa"))
199 return cbrtf(config_GetFloat(obj, "alsa-gain")) * 100.f + .5f;
203 if (!strcmp(aout, "mmdevice"))
207 if (!strcmp(aout, "sndio"))
211 if (!strcmp(aout, "auhal") && module_exists("auhal"))
212 return (config_GetFloat(obj, "auhal-volume") * 100.f + .5f)
213 / AOUT_VOLUME_DEFAULT;
217 if (!strcmp(aout, "directsound") && module_exists("directsound"))
218 return config_GetFloat(obj, "directx-volume") * 100.f + .5f;
221 if (!strcmp(aout, "jack"))
222 return cbrtf(config_GetFloat(obj, "jack-gain")) * 100.f + 0.5f;
225 if (!strcmp(aout, "kai"))
226 return cbrtf(config_GetFloat(obj, "kai-gain")) * 100.f + .5f;
229 if (!strcmp(aout, "oss"))
233 if (!strcmp(aout, "waveout"))
234 return config_GetFloat(obj, "waveout-volume") * 100.f + .5f;
240 /*********************************************************************
241 * The List of categories
242 *********************************************************************/
243 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
244 QWidget( _parent ), p_intf( _p_intf )
246 QHBoxLayout *layout = new QHBoxLayout();
248 /* Use autoExclusive buttons and a mapper as QButtonGroup can't
249 set focus (keys) when it manages the buttons's exclusivity.
250 See QT bugs 131 & 816 and QAbstractButton's source code. */
251 QSignalMapper *mapper = new QSignalMapper( layout );
252 CONNECT( mapper, mapped(int), this, switchPanel(int) );
254 short icon_height = ICON_HEIGHT;
256 #define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
257 QToolButton * button = new QToolButton( this ); \
258 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
259 button->setText( label ); \
260 button->setToolTip( ltooltip ); \
261 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
262 button->setIconSize( QSize( icon_height + 40 , icon_height ) ); \
263 button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); \
264 button->setAutoRaise( true ); \
265 button->setCheckable( true ); \
266 button->setAutoExclusive( true ); \
267 CONNECT( button, clicked(), mapper, map() ); \
268 mapper->setMapping( button, numb ); \
269 layout->addWidget( button );
271 ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
272 cone_interface_64, 0 );
273 ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
275 ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
277 ADD_CATEGORY( SPrefsSubtitles, qtr(SUBPIC_TITLE), qtr("Subtitle & On Screen Display Settings"),
278 cone_subtitles_64, 3 );
279 ADD_CATEGORY( SPrefsInputAndCodecs, qtr(INPUT_TITLE), qtr("Input & Codecs Settings"),
281 ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
282 cone_hotkeys_64, 5 );
286 SPrefsInterface->setChecked( true );
287 layout->setMargin( 0 );
288 layout->setSpacing( 1 );
290 setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred);
291 setMinimumWidth( ICON_HEIGHT * 6 + 10 );
295 void SPrefsCatList::switchPanel( int i )
297 emit currentItemChanged( i );
300 /*********************************************************************
302 *********************************************************************/
303 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
304 int _number ) : QWidget( _parent ), p_intf( _p_intf )
306 module_config_t *p_config;
307 ConfigControl *control;
312 #define CONFIG_GENERIC( option, type, label, qcontrol ) \
313 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
316 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
317 p_config, label, ui.qcontrol, false ); \
318 controls.append( control ); \
321 ui.qcontrol->setEnabled( false ); \
322 if( label ) label->setEnabled( false ); \
325 #define CONFIG_BOOL( option, qcontrol ) \
326 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
329 control = new BoolConfigControl( VLC_OBJECT(p_intf), \
330 p_config, NULL, ui.qcontrol ); \
331 controls.append( control ); \
333 else { ui.qcontrol->setEnabled( false ); }
336 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \
337 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
340 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
341 p_config, label, qcontrol, false ); \
342 controls.append( control ); \
345 QWidget *widget = label; \
346 qcontrol->setVisible( false ); \
347 if( widget ) widget->setEnabled( false ); \
351 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \
352 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
355 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
356 p_config, label, ui.qcontrol ); \
357 controls.append( control ); \
360 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \
361 p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
364 control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
365 p_config, label, qcontrol, qbutton ); \
366 controls.append( control ); \
369 #define START_SPREFS_CAT( name , label ) \
370 case SPrefs ## name: \
372 Ui::SPrefs ## name ui; \
373 ui.setupUi( panel ); \
374 panel_label->setText( label );
376 #define END_SPREFS_CAT \
380 QVBoxLayout *panel_layout = new QVBoxLayout();
381 QWidget *panel = new QWidget();
382 panel_layout->setMargin( 3 );
385 QLabel *panel_label = new QLabel;
386 QFont labelFont = QApplication::font();
387 labelFont.setPointSize( labelFont.pointSize() + 6 );
388 panel_label->setFont( labelFont );
391 QFrame *title_line = new QFrame;
392 title_line->setFrameShape(QFrame::HLine);
393 title_line->setFrameShadow(QFrame::Sunken);
395 QFont italicFont = QApplication::font();
396 italicFont.setItalic( true );
400 /******************************
401 * VIDEO Panel Implementation *
402 ******************************/
403 START_SPREFS_CAT( Video , qtr("Video Settings") );
404 CONFIG_BOOL( "video", enableVideo );
405 ui.videoZone->setEnabled( ui.enableVideo->isChecked() );
406 CONNECT( ui.enableVideo, toggled( bool ),
407 ui.videoZone, setEnabled( bool ) );
409 CONFIG_BOOL( "fullscreen", fullscreen );
410 CONFIG_BOOL( "overlay", overlay );
411 CONFIG_BOOL( "video-on-top", alwaysOnTop );
412 CONFIG_BOOL( "video-deco", windowDecorations );
413 CONFIG_GENERIC( "vout", StringList, ui.voutLabel, outputModule );
416 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
418 CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
419 CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
421 ui.directXBox->setVisible( false );
422 ui.hwYUVBox->setVisible( false );
426 CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
427 CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
430 ui.kvaBox->setVisible( false );
433 CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
434 CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
435 CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
437 CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
438 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
439 CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
440 CONFIG_BOOL( "snapshot-sequential",
441 snapshotsSequentialNumbering );
442 CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
446 /******************************
447 * AUDIO Panel Implementation *
448 ******************************/
449 START_SPREFS_CAT( Audio, qtr("Audio Settings") );
451 CONFIG_BOOL( "audio", enableAudio );
452 ui.audioZone->setEnabled( ui.enableAudio->isChecked() );
453 CONNECT( ui.enableAudio, toggled( bool ),
454 ui.audioZone, setEnabled( bool ) );
456 #define audioCommon( name ) \
457 QLabel * name ## Label = new QLabel( qtr( "Device:" ) ); \
458 name ## Label->setMinimumSize(QSize(250, 0)); \
459 outputAudioLayout->addWidget( name ## Label, outputAudioLayout->rowCount(), 0, 1, 1 ); \
461 #define audioControl( name) \
462 audioCommon( name ) \
463 QComboBox * name ## Device = new QComboBox; \
464 name ## Label->setBuddy( name ## Device ); \
465 name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );\
466 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 1, 1, -1 );
468 #define audioControl2( name) \
469 audioCommon( name ) \
470 QHBoxLayout * name ## hboxLayout = new QHBoxLayout; \
471 QLineEdit * name ## Device = new QLineEdit; \
472 name ## Label->setBuddy( name ## Device ); \
473 name ## hboxLayout->addWidget( name ## Device ); \
474 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ) ); \
475 name ## hboxLayout->addWidget( name ## Browse ); \
476 outputAudioLayout->addLayout( name ## hboxLayout, outputAudioLayout->rowCount() - 1, 1, 1, 1, Qt::AlignLeft );
478 /* Build if necessary */
479 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
481 audioControl( DirectX );
482 optionWidgets["directxL" ] = DirectXLabel;
483 optionWidgets["directxW" ] = DirectXDevice;
484 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
485 DirectXLabel, DirectXDevice );
487 audioControl( Waveout );
488 optionWidgets["waveoutL" ] = WaveoutLabel;
489 optionWidgets["waveoutW" ] = WaveoutDevice;
490 CONFIG_GENERIC_NO_UI( "waveout-audio-device", StringList,
491 WaveoutLabel, WaveoutDevice );
493 #elif defined( __OS2__ )
495 optionWidgets["kaiL"] = kaiLabel;
496 optionWidgets["kaiW"] = kaiDevice;
497 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
500 if( module_exists( "alsa" ) )
502 audioControl( alsa );
503 optionWidgets["alsaL"] = alsaLabel;
504 optionWidgets["alsaW"] = alsaDevice;
505 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
508 if( module_exists( "oss" ) )
510 audioControl2( OSS );
511 optionWidgets["ossL"] = OSSLabel;
512 optionWidgets["ossW"] = OSSDevice;
513 optionWidgets["ossB"] = OSSBrowse;
514 CONFIG_GENERIC_FILE( "oss-audio-device" , File, OSSLabel, OSSDevice,
523 int i_max_volume = config_GetInt( p_intf, "qt-max-volume" );
526 ui.volumeValue->setMaximum( i_max_volume );
527 ui.defaultVolume->setMaximum( i_max_volume );
529 CONNECT( ui.defaultVolume, valueChanged( int ),
530 this, updateAudioVolume( int ) );
532 ui.defaultVolume_zone->setEnabled( ui.resetVolumeCheckbox->isChecked() );
533 CONNECT( ui.resetVolumeCheckbox, toggled( bool ),
534 ui.defaultVolume_zone, setEnabled( bool ) );
536 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
537 preferredAudioLanguage );
539 CONFIG_BOOL( "spdif", spdifBox );
540 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
543 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
545 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
547 CONFIG_GENERIC( "audio-visual" , StringList, ui.visuLabel,
549 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
551 /* Audio Output Specifics */
552 CONFIG_GENERIC( "aout", StringList, ui.outputLabel, outputModule );
554 CONNECT( ui.outputModule, currentIndexChanged( int ),
555 this, updateAudioOptions( int ) );
557 /* File output exists on all platforms */
558 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
559 ui.fileName, ui.fileBrowseButton );
561 optionWidgets["fileW"] = ui.fileControl;
562 optionWidgets["audioOutCoB"] = ui.outputModule;
563 optionWidgets["normalizerChB"] = ui.volNormBox;
564 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
565 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
566 optionWidgets["volLW"] = ui.volumeValue;
567 optionWidgets["headphoneB"] = ui.headphoneEffect;
568 optionWidgets["spdifChB"] = ui.spdifBox;
569 optionWidgets["defaultVolume"] = ui.defaultVolume;
570 optionWidgets["resetVolumeCheckbox"] = ui.resetVolumeCheckbox;
571 updateAudioOptions( ui.outputModule->currentIndex() );
574 if( module_exists( "audioscrobbler" ) )
576 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
578 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
581 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
582 ui.lastfm->setChecked( true );
584 ui.lastfm->setChecked( false );
586 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
588 CONNECT( ui.lastfm, toggled( bool ),
589 ui.lastfm_zone, setVisible( bool ) );
590 CONNECT( ui.lastfm, stateChanged( int ),
591 this, lastfm_Changed( int ) );
596 ui.lastfm_zone->hide();
600 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
601 setEnabled( bool ) );
603 char* psz = config_GetPsz( p_intf, "audio-filter" );
604 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
607 bool b_enabled = ( qs_filter.contains( "normvol" ) );
608 ui.volNormBox->setChecked( b_enabled );
609 ui.volNormSpin->setEnabled( b_enabled );
611 b_enabled = ( qs_filter.contains( "headphone" ) );
612 ui.headphoneEffect->setChecked( b_enabled );
615 updateAudioVolume( ui.defaultVolume->value() ); // First time init
619 /* Input and Codecs Panel Implementation */
620 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
624 ui.DVDDeviceComboBox->setToolTip(
625 qtr( "If this property is blank, different values\n"
626 "for DVD, VCD, and CDDA are set.\n"
627 "You can define a unique one or configure them \n"
628 "individually in the advanced preferences." ) );
629 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
630 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
631 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
632 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
633 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
634 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
636 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
638 free( psz_cddadiscpath );
639 free( psz_dvddiscpath );
640 free( psz_vcddiscpath );
643 QStringList DVDDeviceComboBoxStringList = QStringList();
644 DVDDeviceComboBoxStringList
645 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
646 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
647 .entryList( DVDDeviceComboBoxStringList, QDir::System )
648 .replaceInStrings( QRegExp("^"), "/dev/" )
651 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
652 DVDDeviceComboBox->lineEdit() );
653 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
654 ui.recordPath, ui.recordBrowse );
656 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
657 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
659 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
661 /* live555 module prefs */
662 CONFIG_BOOL( "rtsp-tcp",
663 live555TransportRTSP_TCPRadio );
664 if ( !module_exists( "live555" ) )
666 ui.live555TransportRTSP_TCPRadio->hide();
667 ui.live555TransportHTTPRadio->hide();
668 ui.live555TransportLabel->hide();
670 CONFIG_GENERIC( "avcodec-hw", StringList, ui.hwAccelLabel, hwAccelModule );
672 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
674 ui.hwAccelModule->setEnabled( false );
676 FreeLibrary( hdxva2_dll );
678 optionWidgets["inputLE"] = ui.DVDDeviceComboBox;
679 optionWidgets["cachingCoB"] = ui.cachingCombo;
680 CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
681 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
682 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
683 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
684 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
685 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
688 /* Add the things to the ComboBox */
689 #define addToCachingBox( str, cachingNumber ) \
690 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
691 addToCachingBox( N_("Custom"), CachingCustom );
692 addToCachingBox( N_("Lowest latency"), CachingLowest );
693 addToCachingBox( N_("Low latency"), CachingLow );
694 addToCachingBox( N_("Normal"), CachingNormal );
695 addToCachingBox( N_("High latency"), CachingHigh );
696 addToCachingBox( N_("Higher latency"), CachingHigher );
697 #undef addToCachingBox
699 #define TestCaC( name, factor ) \
700 b_cache_equal = b_cache_equal && \
701 ( i_cache * factor == config_GetInt( p_intf, name ) );
702 /* Select the accurate value of the ComboBox */
703 bool b_cache_equal = true;
704 int i_cache = config_GetInt( p_intf, "file-caching" );
706 TestCaC( "network-caching", 10/3 );
707 TestCaC( "disc-caching", 1);
708 TestCaC( "live-caching", 1 );
709 if( b_cache_equal == 1 )
710 ui.cachingCombo->setCurrentIndex(
711 ui.cachingCombo->findData( QVariant( i_cache ) ) );
718 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
723 for( int i = 0; ppsz_language[i] != NULL; i++)
724 ui.langCombo->addItem( qfu(ppsz_language_text[i]), ppsz_language[i]);
725 CONNECT( ui.langCombo, currentIndexChanged( int ), this, langChanged( int ) );
728 char *langReg = NULL;
729 if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\VideoLAN\\VLC\\"), 0, KEY_READ, &h_key )
734 if( RegQueryValueEx( h_key, TEXT("Lang"), NULL, NULL, (LPBYTE) &szData, &len ) == ERROR_SUCCESS ) {
735 langReg = FromWide( szData );
736 ui.langCombo->setCurrentIndex( ui.langCombo->findData(langReg) );
742 // ui.defaultLabel->setFont( italicFont );
743 ui.skinsLabel->setText(
744 qtr( "This is VLC's skinnable interface. You can download other skins at" )
745 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
746 + qtr( "VLC skins website" )+ QString( "</a>." ) );
747 ui.skinsLabel->setFont( italicFont );
750 BUTTONACT( ui.assoButton, assoDialog() );
752 ui.osGroupBox->hide();
756 char *psz_intf = config_GetPsz( p_intf, "intf" );
759 if( strstr( psz_intf, "skin" ) )
760 ui.skins->setChecked( true );
763 ui.qt->setChecked( true );
767 optionWidgets["skinRB"] = ui.skins;
768 optionWidgets["qtRB"] = ui.qt;
769 #if !defined( _WIN32)
770 ui.stylesCombo->addItem( qtr("System's default") );
771 ui.stylesCombo->addItems( QStyleFactory::keys() );
772 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
773 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
774 ui.stylesCombo->insertSeparator( 1 );
775 if ( ui.stylesCombo->currentIndex() < 0 )
776 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
778 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
779 optionWidgets["styleCB"] = ui.stylesCombo;
781 ui.stylesCombo->hide();
782 ui.stylesLabel->hide();
784 radioGroup = new QButtonGroup(this);
785 radioGroup->addButton( ui.qt, 0 );
786 radioGroup->addButton( ui.skins, 1 );
787 CONNECT( radioGroup, buttonClicked( int ),
788 ui.styleStackedWidget, setCurrentIndex( int ) );
789 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
791 CONNECT( ui.minimalviewBox, toggled( bool ),
792 ui.mainPreview, setNormalPreview( bool ) );
793 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
794 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
795 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
797 CONFIG_BOOL( "embedded-video", embedVideo );
798 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
799 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
800 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
802 CONFIG_BOOL( "qt-fs-controller", fsController );
803 CONFIG_BOOL( "qt-system-tray", systrayBox );
804 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
806 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
807 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationComboLabel, setEnabled( bool ) );
808 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
810 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
811 CONFIG_BOOL( "playlist-tree", treePlaylist );
812 CONFIG_BOOL( "play-and-pause", playPauseBox );
813 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
814 ui.fileSkin, ui.skinBrowse );
816 CONFIG_BOOL( "metadata-network-access", MetadataNetworkAccessMode );
820 CONFIG_BOOL( "qt-updates-notif", updatesBox );
821 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
823 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
824 CONNECT( ui.updatesBox, toggled( bool ),
825 ui.updatesDays, setEnabled( bool ) );
827 ui.updatesBox->hide();
828 ui.updatesDays->hide();
830 /* ONE INSTANCE options */
831 #if !defined( _WIN32 ) && !defined(__APPLE__) && !defined(__OS2__)
832 if( !module_exists( "dbus" ) )
833 ui.OneInterfaceBox->hide();
837 CONFIG_BOOL( "one-instance", OneInterfaceMode );
838 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
839 ui.EnqueueOneInterfaceMode->setEnabled(
840 ui.OneInterfaceMode->isChecked() );
841 CONNECT( ui.OneInterfaceMode, toggled( bool ),
842 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
843 CONFIG_BOOL( "one-instance-when-started-from-file", oneInstanceFromFile );
846 /* RECENTLY PLAYED options */
847 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
848 ui.recentlyPlayedFilters, setEnabled( bool ) );
849 ui.recentlyPlayedFilters->setEnabled( false );
850 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
851 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
852 recentlyPlayedFilters );
856 START_SPREFS_CAT( Subtitles,
857 qtr("Subtitle & On Screen Display Settings") );
858 CONFIG_BOOL( "osd", OSDBox);
859 CONFIG_BOOL( "video-title-show", OSDTitleBox);
860 CONFIG_GENERIC( "video-title-position", IntegerList,
861 ui.OSDTitlePosLabel, OSDTitlePos );
863 CONFIG_BOOL( "spu", spuActiveBox);
864 ui.spuZone->setEnabled( ui.spuActiveBox->isChecked() );
865 CONNECT( ui.spuActiveBox, toggled( bool ),
866 ui.spuZone, setEnabled( bool ) );
868 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
870 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
873 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
874 ui.fontSizeLabel, fontSize );
876 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
877 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
879 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
880 ui.fontEffectLabel, effect );
881 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
884 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
886 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
887 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
888 optionWidgets["shadowCB"] = ui.shadowCheck;
889 optionWidgets["backgroundCB"] = ui.backgroundCheck;
895 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
897 QGridLayout *gLayout = new QGridLayout;
898 panel->setLayout( gLayout );
901 panel_label->setText( qtr( "Configure Hotkeys" ) );
902 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
903 control->insertIntoExistingGrid( gLayout, line );
904 controls.append( control );
908 QFrame *sepline = new QFrame;
909 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
910 gLayout->addWidget( sepline, line, 0, 1, -1 );
914 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-y-wheel-mode" );
915 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
916 p_config, this, false );
917 control->insertIntoExistingGrid( gLayout, line );
918 controls.append( control );
922 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-x-wheel-mode" );
923 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
924 p_config, this, false );
925 control->insertIntoExistingGrid( gLayout, line );
926 controls.append( control );
931 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
932 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
933 control->insertIntoExistingGrid( gLayout, line );
934 controls.append( control );
941 panel_layout->addWidget( panel_label );
942 panel_layout->addWidget( title_line );
944 QScrollArea *scroller= new QScrollArea;
945 scroller->setWidget( panel );
946 scroller->setWidgetResizable( true );
947 scroller->setFrameStyle( QFrame::NoFrame );
948 panel_layout->addWidget( scroller );
950 setLayout( panel_layout );
952 #undef END_SPREFS_CAT
953 #undef START_SPREFS_CAT
954 #undef CONFIG_GENERIC_FILE
955 #undef CONFIG_GENERIC_NO_BOOL
956 #undef CONFIG_GENERIC_NO_UI
957 #undef CONFIG_GENERIC
962 void SPrefsPanel::updateAudioOptions( int number)
964 QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
965 ->itemData( number ).toString();
967 optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
968 optionWidgets["directxL"]->setVisible( ( value == "directsound" ) );
969 optionWidgets["waveoutW"]->setVisible( ( value == "waveout" ) );
970 optionWidgets["waveoutL"]->setVisible( ( value == "waveout" ) );
971 #elif defined( __OS2__ )
972 optionWidgets["kaiL"]->setVisible( ( value == "kai" ) );
973 optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
975 /* optionWidgets["ossW] can be NULL */
976 if( optionWidgets["ossW"] ) {
977 optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
978 optionWidgets["ossL"]->setVisible( ( value == "oss" ) );
979 optionWidgets["ossB"]->setVisible( ( value == "oss" ) );
981 /* optionWidgets["alsaW] can be NULL */
982 if( optionWidgets["alsaW"] ) {
983 optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
984 optionWidgets["alsaL"]->setVisible( ( value == "alsa" ) );
987 optionWidgets["fileW"]->setVisible( ( value == "afile" ) );
988 optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
989 value == "directsound" || value == "waveout" ) );
991 int volume = getDefaultAudioVolume(VLC_OBJECT(p_intf), qtu(value));
995 save = config_GetInt(VLC_OBJECT(p_intf), "volume-save");
997 QCheckBox *resetVolumeCheckBox =
998 qobject_cast<QCheckBox *>(optionWidgets["resetVolumeCheckbox"]);
999 resetVolumeCheckBox->setChecked(!save);
1000 resetVolumeCheckBox->setEnabled(volume >= 0);
1002 QSlider *defaultVolume =
1003 qobject_cast<QSlider *>(optionWidgets["defaultVolume"]);
1004 defaultVolume->setValue((volume >= 0) ? volume : 100);
1005 defaultVolume->setEnabled(volume >= 0);
1009 SPrefsPanel::~SPrefsPanel()
1011 qDeleteAll( controls ); controls.clear();
1014 void SPrefsPanel::updateAudioVolume( int volume )
1016 qobject_cast<QSpinBox *>(optionWidgets["volLW"])
1017 ->setValue( volume );
1021 /* Function called from the main Preferences dialog on each SPrefs Panel */
1022 void SPrefsPanel::apply()
1024 /* Generic save for ever panel */
1025 QList<ConfigControl *>::const_iterator i;
1026 for( i = controls.begin() ; i != controls.end() ; ++i )
1028 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
1034 case SPrefsInputAndCodecs:
1036 /* Device default selection */
1037 QByteArray devicepath =
1038 qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
1039 if( devicepath.size() > 0 )
1041 config_PutPsz( p_intf, "dvd", devicepath );
1042 config_PutPsz( p_intf, "vcd", devicepath );
1043 config_PutPsz( p_intf, "cd-audio", devicepath );
1046 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
1048 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
1049 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
1052 CaC( "file-caching", 1 );
1053 CaC( "network-caching", 10/3 );
1054 CaC( "disc-caching", 1 );
1055 CaC( "live-caching", 1 );
1062 case SPrefsInterface:
1064 if( qobject_cast<QRadioButton *>(optionWidgets["skinRB"])->isChecked() )
1065 config_PutPsz( p_intf, "intf", "skins2,any" );
1067 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
1068 config_PutPsz( p_intf, "intf", "" );
1069 if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
1070 getSettings()->setValue( "MainWindow/QtStyle",
1071 qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
1081 qobject_cast<QCheckBox *>(optionWidgets["normalizerChB"])->isChecked();
1082 if( b_checked && !qs_filter.contains( "normvol" ) )
1083 qs_filter.append( "normvol" );
1084 if( !b_checked && qs_filter.contains( "normvol" ) )
1085 qs_filter.removeAll( "normvol" );
1088 qobject_cast<QCheckBox *>(optionWidgets["headphoneB"])->isChecked();
1090 if( b_checked && !qs_filter.contains( "headphone" ) )
1091 qs_filter.append( "headphone" );
1092 if( !b_checked && qs_filter.contains( "headphone" ) )
1093 qs_filter.removeAll( "headphone" );
1095 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
1097 /* Default volume */
1099 qobject_cast<QSlider *>(optionWidgets["defaultVolume"])->value();
1100 bool b_reset_volume =
1101 qobject_cast<QCheckBox *>(optionWidgets["resetVolumeCheckbox"])->isChecked();
1102 char *psz_aout = config_GetPsz( p_intf, "aout" );
1104 float f_gain = powf( i_volume / 100.f, 3 );
1106 #define save_vol_aout( name ) \
1107 module_exists( name ) && ( !psz_aout || !strcmp( psz_aout, name ) || !strcmp( psz_aout, "any" ) )
1109 //FIXME this is moot
1110 #if defined( _WIN32 )
1111 VLC_UNUSED( f_gain );
1112 if( save_vol_aout( "directsound" ) )
1113 config_PutFloat( p_intf, "directx-volume", i_volume / 100.f );
1114 if( save_vol_aout( "waveout" ) )
1115 config_PutFloat( p_intf, "waveout-volume", i_volume / 100.f );
1116 #elif defined( Q_OS_MAC )
1117 VLC_UNUSED( f_gain );
1118 if( save_vol_aout( "auhal" ) )
1119 config_PutFloat( p_intf, "auhal-volume", i_volume / 100.f
1120 * AOUT_VOLUME_DEFAULT );
1121 #elif defined( __OS2__ )
1122 if( save_vol_aout( "kai" ) )
1123 config_PutFloat( p_intf, "kai-gain", f_gain );
1125 if( save_vol_aout( "alsa" ) )
1126 config_PutFloat( p_intf, "alsa-gain", f_gain );
1127 if( save_vol_aout( "jack" ) )
1128 config_PutFloat( p_intf, "jack-gain", f_gain );
1130 #undef save_vol_aout
1133 config_PutInt( p_intf, "volume-save", !b_reset_volume );
1137 case SPrefsSubtitles:
1139 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
1140 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
1141 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
1143 else if (!b_checked ) {
1144 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
1147 b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
1148 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
1149 config_PutInt( p_intf, "freetype-background-opacity", 128 );
1151 else if (!b_checked ) {
1152 config_PutInt( p_intf, "freetype-background-opacity", 0 );
1159 void SPrefsPanel::clean()
1162 void SPrefsPanel::lastfm_Changed( int i_state )
1164 if( i_state == Qt::Checked )
1165 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
1166 else if( i_state == Qt::Unchecked )
1167 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
1170 void SPrefsPanel::changeStyle( QString s_style )
1172 QApplication::setStyle( s_style );
1174 /* force refresh on all widgets */
1175 QWidgetList widgets = QApplication::allWidgets();
1176 QWidgetList::iterator it = widgets.begin();
1177 while( it != widgets.end() ) {
1183 void SPrefsPanel::langChanged( int i )
1185 lang = strdup( ppsz_language[i] );
1188 void SPrefsPanel::configML()
1190 #ifdef SQL_MEDIA_LIBRARY
1191 MLConfDialog *mld = new MLConfDialog( this, p_intf );
1198 #include <QDialogButtonBox>
1199 #include "util/registry.hpp"
1201 void SPrefsPanel::cleanLang() {
1202 QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
1203 qvReg->DeleteValue( "Software\\VideoLAN\\VLC\\", "Lang" );
1204 qvReg->DeleteKey( "Software\\VideoLAN\\", "VLC" );
1205 qvReg->DeleteKey( "Software\\", "VideoLAN" );
1209 void SPrefsPanel::saveLang() {
1212 if( !strncmp( lang, "auto", 4 ) ) {
1217 QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
1218 qvReg->WriteRegistryString( "Software\\VideoLAN\\VLC\\", "Lang", lang );
1222 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
1223 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
1226 const char* psz_VLC = "VLC";
1227 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
1229 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
1231 current->setCheckState( 0, Qt::Checked );
1236 current->setCheckState( 0, Qt::Unchecked );
1239 listAsso.append( current );
1243 #if !defined(__IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__)
1244 #define __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__
1245 const GUID IID_IApplicationAssociationRegistrationUI = {0x1f76a169,0xf994,0x40ac, {0x8f,0xc8,0x09,0x59,0xe8,0x87,0x47,0x10}};
1246 extern const GUID CLSID_ApplicationAssociationRegistrationUI;
1247 interface IApplicationAssociationRegistrationUI : public IUnknown
1249 virtual HRESULT STDMETHODCALLTYPE LaunchAdvancedAssociationUI(
1250 LPCWSTR pszAppRegName) = 0;
1252 #endif /* __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__ */
1254 void SPrefsPanel::assoDialog()
1258 hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
1263 hr = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
1264 NULL, CLSCTX_INPROC_SERVER,
1265 IID_IApplicationAssociationRegistrationUI, &p);
1268 IApplicationAssociationRegistrationUI *p_regui =
1269 (IApplicationAssociationRegistrationUI *)p;
1271 hr = p_regui->LaunchAdvancedAssociationUI(L"VLC" );
1280 QDialog *d = new QDialog( this );
1281 d->setWindowTitle( qtr( "File associations" ) );
1282 QGridLayout *assoLayout = new QGridLayout( d );
1284 QTreeWidget *filetypeList = new QTreeWidget;
1285 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
1286 filetypeList->header()->hide();
1288 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1290 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
1291 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
1292 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
1294 filetypeList->addTopLevelItem( audioType );
1295 filetypeList->addTopLevelItem( videoType );
1296 filetypeList->addTopLevelItem( otherType );
1298 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
1299 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
1300 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
1302 QTreeWidgetItem *currentItem = NULL;
1305 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
1306 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
1307 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
1309 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
1310 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
1311 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
1312 aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
1313 audioType->setCheckState( 0, ( i_temp > 0 ) ?
1314 ( ( i_temp == audioType->childCount() ) ?
1315 Qt::Checked : Qt::PartiallyChecked )
1319 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
1320 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
1321 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
1322 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
1323 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
1324 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
1325 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1326 videoType->setCheckState( 0, ( i_temp > 0 ) ?
1327 ( ( i_temp == audioType->childCount() ) ?
1328 Qt::Checked : Qt::PartiallyChecked )
1332 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1333 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1334 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1335 ( ( i_temp == audioType->childCount() ) ?
1336 Qt::Checked : Qt::PartiallyChecked )
1343 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1344 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1345 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1346 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1347 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1349 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1351 CONNECT( closeButton, clicked(), this, saveAsso() );
1352 CONNECT( clearButton, clicked(), d, reject() );
1353 d->resize( 300, 400 );
1359 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1361 QString s_path( "VLC" ); s_path += psz_ext;
1362 QString s_path2 = s_path;
1364 /* Save a backup if already assigned */
1365 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1367 if( !EMPTY_STR(psz_value) )
1368 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1371 /* Put a "link" to VLC.EXT as default */
1372 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1374 /* Create the needed Key if they weren't done in the installer */
1375 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1377 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1378 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1379 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1381 /* Get the installer path */
1382 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1383 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1385 if( str_temp.size() )
1387 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1388 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1390 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1391 "", qtu( str_temp.append(",0") ) );
1397 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1399 QString s_path( "VLC"); s_path += psz_ext;
1400 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1402 if( psz_value && !strcmp( qtu(s_path), psz_value ) )
1405 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1407 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1409 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1414 void SPrefsPanel::saveAsso()
1416 QVLCRegistry * qvReg = NULL;
1417 for( int i = 0; i < listAsso.size(); i ++ )
1419 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1420 if( listAsso[i]->checkState( 0 ) > 0 )
1422 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1426 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1430 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();