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>
49 #define ICON_HEIGHT 64
52 # include <vlc_windows_interfaces.h>
53 # include <vlc_charset.h>
55 #include <vlc_modules.h>
57 static const char *const ppsz_language[] =
122 static const char *const ppsz_language_text[] =
128 "Português Brasileiro",
186 static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout)
188 if (!strcmp(aout, "") || !strcmp(aout, "any"))
191 /* Note: For hysterical raisins, this is sorted by decreasing priority
192 * order (then alphabetical order). */
193 if (!strcmp(aout, "pulse"))
197 if (!strcmp(aout, "alsa") && module_exists("alsa"))
198 return cbrtf(config_GetFloat(obj, "alsa-gain")) * 100.f + .5f;
202 if (!strcmp(aout, "mmdevice"))
206 if (!strcmp(aout, "sndio"))
210 if (!strcmp("auhal") && module_exists("auhal"))
211 return (config_GetFloat(obj, "auhal-volume") * 100.f + .5f)
212 / AOUT_VOLUME_DEFAULT;
216 if (!strcmp(aout, "directsound") && module_exists("directsound"))
217 return config_GetFloat(obj, "directx-volume") * 100.f + .5f;
220 if (!strcmp(aout, "jack"))
221 return cbrtf(config_GetFloat(obj, "jack-gain")) * 100.f + 0.5f;
224 if (!strcmp(aout, "kai"))
225 return cbrtf(config_GetFloat(obj, "kai-gain")) * 100.f + .5f;
228 if (!strcmp(aout, "oss"))
232 if (!strcmp(aout, "waveout"))
233 return config_GetFloat(obj, "waveout-volume") * 100.f + .5f;
239 /*********************************************************************
240 * The List of categories
241 *********************************************************************/
242 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
243 QWidget( _parent ), p_intf( _p_intf )
245 QVBoxLayout *layout = new QVBoxLayout();
247 /* Use autoExclusive buttons and a mapper as QButtonGroup can't
248 set focus (keys) when it manages the buttons's exclusivity.
249 See QT bugs 131 & 816 and QAbstractButton's source code. */
250 QSignalMapper *mapper = new QSignalMapper( layout );
251 CONNECT( mapper, mapped(int), this, switchPanel(int) );
253 short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
255 #define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \
256 QToolButton * button = new QToolButton( this ); \
257 button->setIcon( QIcon( ":/prefsmenu/" #icon ) ); \
258 button->setText( label ); \
259 button->setToolTip( ltooltip ); \
260 button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \
261 button->setIconSize( QSize( icon_height, icon_height ) ); \
262 button->resize( icon_height + 6 , icon_height + 6 ); \
263 button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ; \
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 setMinimumWidth( 140 );
291 setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
296 void SPrefsCatList::switchPanel( int i )
298 emit currentItemChanged( i );
301 /*********************************************************************
303 *********************************************************************/
304 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
305 int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
307 module_config_t *p_config;
308 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 QLineEdit * name ## Device = new QLineEdit; \
471 name ## Label->setBuddy( name ## Device ); \
472 QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ) ); \
473 outputAudioLayout->addWidget( name ## Device, outputAudioLayout->rowCount() - 1, 0, 1, -1, Qt::AlignLeft );
475 /* Build if necessary */
476 QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
478 audioControl( DirectX );
479 optionWidgets["directxL" ] = DirectXLabel;
480 optionWidgets["directxW" ] = DirectXDevice;
481 CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
482 DirectXLabel, DirectXDevice );
484 audioControl( Waveout );
485 optionWidgets["waveoutL" ] = WaveoutLabel;
486 optionWidgets["waveoutW" ] = WaveoutDevice;
487 CONFIG_GENERIC_NO_UI( "waveout-audio-device", StringList,
488 WaveoutLabel, WaveoutDevice );
490 #elif defined( __OS2__ )
492 optionWidgets["kaiL"] = kaiLabel;
493 optionWidgets["kaiW"] = kaiDevice;
494 CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
497 if( module_exists( "alsa" ) )
499 audioControl( alsa );
500 optionWidgets["alsaL"] = alsaLabel;
501 optionWidgets["alsaW"] = alsaDevice;
502 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
505 if( module_exists( "oss" ) )
507 audioControl2( OSS );
508 optionWidgets["ossL"] = OSSLabel;
509 optionWidgets["ossW"] = OSSDevice;
510 optionWidgets["ossB"] = OSSBrowse;
511 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
520 int i_max_volume = config_GetInt( p_intf, "qt-max-volume" );
523 ui.volumeValue->setMaximum( i_max_volume );
524 ui.defaultVolume->setMaximum( i_max_volume );
526 CONNECT( ui.defaultVolume, valueChanged( int ),
527 this, updateAudioVolume( int ) );
529 ui.defaultVolume_zone->setEnabled( ui.resetVolumeCheckbox->isChecked() );
530 CONNECT( ui.resetVolumeCheckbox, toggled( bool ),
531 ui.defaultVolume_zone, setEnabled( bool ) );
533 CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
534 preferredAudioLanguage );
536 CONFIG_BOOL( "spdif", spdifBox );
537 CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
540 CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
542 CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
544 CONFIG_GENERIC( "audio-visual" , StringList, ui.visuLabel,
546 CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
548 /* Audio Output Specifics */
549 CONFIG_GENERIC( "aout", StringList, ui.outputLabel, outputModule );
551 CONNECT( ui.outputModule, currentIndexChanged( int ),
552 this, updateAudioOptions( int ) );
554 /* File output exists on all platforms */
555 CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
556 ui.fileName, ui.fileBrowseButton );
558 optionWidgets["fileW"] = ui.fileControl;
559 optionWidgets["audioOutCoB"] = ui.outputModule;
560 optionWidgets["normalizerChB"] = ui.volNormBox;
561 /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
562 ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
563 optionWidgets["volLW"] = ui.volumeValue;
564 optionWidgets["headphoneB"] = ui.headphoneEffect;
565 optionWidgets["spdifChB"] = ui.spdifBox;
566 optionWidgets["defaultVolume"] = ui.defaultVolume;
567 optionWidgets["resetVolumeCheckbox"] = ui.resetVolumeCheckbox;
568 updateAudioOptions( ui.outputModule->currentIndex() );
571 if( module_exists( "audioscrobbler" ) )
573 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
575 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
578 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
579 ui.lastfm->setChecked( true );
581 ui.lastfm->setChecked( false );
583 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
585 CONNECT( ui.lastfm, toggled( bool ),
586 ui.lastfm_zone, setVisible( bool ) );
587 CONNECT( ui.lastfm, stateChanged( int ),
588 this, lastfm_Changed( int ) );
593 ui.lastfm_zone->hide();
597 CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
598 setEnabled( bool ) );
600 char* psz = config_GetPsz( p_intf, "audio-filter" );
601 qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
604 bool b_enabled = ( qs_filter.contains( "normvol" ) );
605 ui.volNormBox->setChecked( b_enabled );
606 ui.volNormSpin->setEnabled( b_enabled );
608 b_enabled = ( qs_filter.contains( "headphone" ) );
609 ui.headphoneEffect->setChecked( b_enabled );
612 updateAudioVolume( ui.defaultVolume->value() ); // First time init
616 /* Input and Codecs Panel Implementation */
617 START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
621 ui.DVDDeviceComboBox->setToolTip(
622 qtr( "If this property is blank, different values\n"
623 "for DVD, VCD, and CDDA are set.\n"
624 "You can define a unique one or configure them \n"
625 "individually in the advanced preferences." ) );
626 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
627 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
628 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
629 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
630 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
631 !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
633 ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
635 free( psz_cddadiscpath );
636 free( psz_dvddiscpath );
637 free( psz_vcddiscpath );
640 QStringList DVDDeviceComboBoxStringList = QStringList();
641 DVDDeviceComboBoxStringList
642 << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
643 ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
644 .entryList( DVDDeviceComboBoxStringList, QDir::System )
645 .replaceInStrings( QRegExp("^"), "/dev/" )
648 CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
649 DVDDeviceComboBox->lineEdit() );
650 CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
651 ui.recordPath, ui.recordBrowse );
653 CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
654 CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
656 CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
658 /* live555 module prefs */
659 CONFIG_BOOL( "rtsp-tcp",
660 live555TransportRTSP_TCPRadio );
661 if ( !module_exists( "live555" ) )
663 ui.live555TransportRTSP_TCPRadio->hide();
664 ui.live555TransportHTTPRadio->hide();
665 ui.live555TransportLabel->hide();
667 CONFIG_GENERIC( "avcodec-hw", StringList, ui.hwAccelLabel, hwAccelModule );
669 HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
671 ui.hwAccelModule->setEnabled( false );
673 FreeLibrary( hdxva2_dll );
675 optionWidgets["inputLE"] = ui.DVDDeviceComboBox;
676 optionWidgets["cachingCoB"] = ui.cachingCombo;
677 CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
678 CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
679 CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
680 CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
681 CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
682 CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
685 /* Add the things to the ComboBox */
686 #define addToCachingBox( str, cachingNumber ) \
687 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
688 addToCachingBox( N_("Custom"), CachingCustom );
689 addToCachingBox( N_("Lowest latency"), CachingLowest );
690 addToCachingBox( N_("Low latency"), CachingLow );
691 addToCachingBox( N_("Normal"), CachingNormal );
692 addToCachingBox( N_("High latency"), CachingHigh );
693 addToCachingBox( N_("Higher latency"), CachingHigher );
694 #undef addToCachingBox
696 #define TestCaC( name, factor ) \
697 b_cache_equal = b_cache_equal && \
698 ( i_cache * factor == config_GetInt( p_intf, name ) );
699 /* Select the accurate value of the ComboBox */
700 bool b_cache_equal = true;
701 int i_cache = config_GetInt( p_intf, "file-caching" );
703 TestCaC( "network-caching", 10/3 );
704 TestCaC( "disc-caching", 1);
705 TestCaC( "live-caching", 1 );
706 if( b_cache_equal == 1 )
707 ui.cachingCombo->setCurrentIndex(
708 ui.cachingCombo->findData( QVariant( i_cache ) ) );
715 START_SPREFS_CAT( Interface, qtr("Interface Settings") );
720 for( int i = 0; ppsz_language[i] != NULL; i++)
721 ui.langCombo->addItem( qfu(ppsz_language_text[i]), ppsz_language[i]);
722 CONNECT( ui.langCombo, currentIndexChanged( int ), this, langChanged( int ) );
725 char *langReg = NULL;
726 if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\VideoLAN\\VLC\\"), 0, KEY_READ, &h_key )
731 if( RegQueryValueEx( h_key, TEXT("Lang"), NULL, NULL, (LPBYTE) &szData, &len ) == ERROR_SUCCESS ) {
732 langReg = FromWide( szData );
733 ui.langCombo->setCurrentIndex( ui.langCombo->findData(langReg) );
739 // ui.defaultLabel->setFont( italicFont );
740 ui.skinsLabel->setText(
741 qtr( "This is VLC's skinnable interface. You can download other skins at" )
742 + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
743 + qtr( "VLC skins website" )+ QString( "</a>." ) );
744 ui.skinsLabel->setFont( italicFont );
747 BUTTONACT( ui.assoButton, assoDialog() );
749 ui.osGroupBox->hide();
753 char *psz_intf = config_GetPsz( p_intf, "intf" );
756 if( strstr( psz_intf, "skin" ) )
757 ui.skins->setChecked( true );
760 ui.qt->setChecked( true );
764 optionWidgets["skinRB"] = ui.skins;
765 optionWidgets["qtRB"] = ui.qt;
766 #if !defined( _WIN32)
767 ui.stylesCombo->addItem( qtr("System's default") );
768 ui.stylesCombo->addItems( QStyleFactory::keys() );
769 ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
770 getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
771 ui.stylesCombo->insertSeparator( 1 );
772 if ( ui.stylesCombo->currentIndex() < 0 )
773 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
775 CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
776 optionWidgets["styleCB"] = ui.stylesCombo;
778 ui.stylesCombo->hide();
779 ui.stylesLabel->hide();
781 radioGroup = new QButtonGroup(this);
782 radioGroup->addButton( ui.qt, 0 );
783 radioGroup->addButton( ui.skins, 1 );
784 CONNECT( radioGroup, buttonClicked( int ),
785 ui.styleStackedWidget, setCurrentIndex( int ) );
786 ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
788 CONNECT( ui.minimalviewBox, toggled( bool ),
789 ui.mainPreview, setNormalPreview( bool ) );
790 CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
791 ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
792 ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
794 CONFIG_BOOL( "embedded-video", embedVideo );
795 CONFIG_BOOL( "qt-video-autoresize", resizingBox );
796 CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
797 ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
799 CONFIG_BOOL( "qt-fs-controller", fsController );
800 CONFIG_BOOL( "qt-system-tray", systrayBox );
801 CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
803 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
804 CONNECT( ui.systrayBox, toggled( bool ), ui.notificationComboLabel, setEnabled( bool ) );
805 ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
807 CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
808 CONFIG_BOOL( "playlist-tree", treePlaylist );
809 CONFIG_BOOL( "play-and-pause", playPauseBox );
810 CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
811 ui.fileSkin, ui.skinBrowse );
813 CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
818 CONFIG_BOOL( "qt-updates-notif", updatesBox );
819 CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
821 ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
822 CONNECT( ui.updatesBox, toggled( bool ),
823 ui.updatesDays, setEnabled( bool ) );
825 ui.updatesBox->hide();
826 ui.updatesDays->hide();
828 /* ONE INSTANCE options */
829 #if !defined( _WIN32 ) && !defined(__APPLE__) && !defined(__OS2__)
830 if( !module_exists( "dbus" ) )
831 ui.OneInterfaceBox->hide();
835 CONFIG_BOOL( "one-instance", OneInterfaceMode );
836 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
837 ui.EnqueueOneInterfaceMode->setEnabled(
838 ui.OneInterfaceMode->isChecked() );
839 CONNECT( ui.OneInterfaceMode, toggled( bool ),
840 ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
841 CONFIG_BOOL( "one-instance-when-started-from-file", oneInstanceFromFile );
844 /* RECENTLY PLAYED options */
845 CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
846 ui.recentlyPlayedFilters, setEnabled( bool ) );
847 ui.recentlyPlayedFilters->setEnabled( false );
848 CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
849 CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
850 recentlyPlayedFilters );
854 START_SPREFS_CAT( Subtitles,
855 qtr("Subtitle & On Screen Display Settings") );
856 CONFIG_BOOL( "osd", OSDBox);
857 CONFIG_BOOL( "video-title-show", OSDTitleBox);
858 CONFIG_GENERIC( "video-title-position", IntegerList,
859 ui.OSDTitlePosLabel, OSDTitlePos );
861 CONFIG_BOOL( "spu", spuActiveBox);
862 ui.spuZone->setEnabled( ui.spuActiveBox->isChecked() );
863 CONNECT( ui.spuActiveBox, toggled( bool ),
864 ui.spuZone, setEnabled( bool ) );
866 CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
868 CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
871 CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
872 ui.fontSizeLabel, fontSize );
874 CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
875 CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
877 CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
878 ui.fontEffectLabel, effect );
879 CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
882 CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
884 ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
885 ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
886 optionWidgets["shadowCB"] = ui.shadowCheck;
887 optionWidgets["backgroundCB"] = ui.backgroundCheck;
893 p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
895 QGridLayout *gLayout = new QGridLayout;
896 panel->setLayout( gLayout );
899 panel_label->setText( qtr( "Configure Hotkeys" ) );
900 control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
901 control->insertIntoExistingGrid( gLayout, line );
902 controls.append( control );
906 QFrame *sepline = new QFrame;
907 sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
908 gLayout->addWidget( sepline, line, 0, 1, -1 );
912 p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
913 control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
914 p_config, this, false );
915 control->insertIntoExistingGrid( gLayout, line );
916 controls.append( control );
921 p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
922 control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
923 control->insertIntoExistingGrid( gLayout, line );
924 controls.append( control );
931 panel_layout->addWidget( panel_label );
932 panel_layout->addWidget( title_line );
936 QScrollArea *scroller= new QScrollArea;
937 scroller->setWidget( panel );
938 scroller->setWidgetResizable( true );
939 scroller->setFrameStyle( QFrame::NoFrame );
940 panel_layout->addWidget( scroller );
944 panel_layout->addWidget( panel );
945 if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
948 setLayout( panel_layout );
950 #undef END_SPREFS_CAT
951 #undef START_SPREFS_CAT
952 #undef CONFIG_GENERIC_FILE
953 #undef CONFIG_GENERIC_NO_BOOL
954 #undef CONFIG_GENERIC_NO_UI
955 #undef CONFIG_GENERIC
960 void SPrefsPanel::updateAudioOptions( int number)
962 QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
963 ->itemData( number ).toString();
965 optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
966 optionWidgets["directxL"]->setVisible( ( value == "directsound" ) );
967 optionWidgets["waveoutW"]->setVisible( ( value == "waveout" ) );
968 optionWidgets["waveoutL"]->setVisible( ( value == "waveout" ) );
969 #elif defined( __OS2__ )
970 optionWidgets["kaiL"]->setVisible( ( value == "kai" ) );
971 optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
973 /* optionWidgets["ossW] can be NULL */
974 if( optionWidgets["ossW"] ) {
975 optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
976 optionWidgets["ossL"]->setVisible( ( value == "oss" ) );
977 optionWidgets["ossB"]->setVisible( ( value == "oss" ) );
979 /* optionWidgets["alsaW] can be NULL */
980 if( optionWidgets["alsaW"] ) {
981 optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
982 optionWidgets["alsaL"]->setVisible( ( value == "alsa" ) );
985 optionWidgets["fileW"]->setVisible( ( value == "afile" ) );
986 optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
987 value == "directsound" || value == "waveout" ) );
989 int volume = getDefaultAudioVolume(VLC_OBJECT(p_intf), qtu(value));
993 save = config_GetInt(VLC_OBJECT(p_intf), "volume-save");
995 QCheckBox *resetVolumeCheckBox =
996 qobject_cast<QCheckBox *>(optionWidgets["resetVolumeCheckbox"]);
997 resetVolumeCheckBox->setChecked(!save);
998 resetVolumeCheckBox->setEnabled(volume >= 0);
1000 QSlider *defaultVolume =
1001 qobject_cast<QSlider *>(optionWidgets["defaultVolume"]);
1002 defaultVolume->setValue((volume >= 0) ? volume : 100);
1003 defaultVolume->setEnabled(volume >= 0);
1007 SPrefsPanel::~SPrefsPanel()
1009 qDeleteAll( controls ); controls.clear();
1012 void SPrefsPanel::updateAudioVolume( int volume )
1014 qobject_cast<QSpinBox *>(optionWidgets["volLW"])
1015 ->setValue( volume );
1019 /* Function called from the main Preferences dialog on each SPrefs Panel */
1020 void SPrefsPanel::apply()
1022 /* Generic save for ever panel */
1023 QList<ConfigControl *>::const_iterator i;
1024 for( i = controls.begin() ; i != controls.end() ; ++i )
1026 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
1032 case SPrefsInputAndCodecs:
1034 /* Device default selection */
1035 QByteArray devicepath =
1036 qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
1037 if( devicepath.size() > 0 )
1039 config_PutPsz( p_intf, "dvd", devicepath );
1040 config_PutPsz( p_intf, "vcd", devicepath );
1041 config_PutPsz( p_intf, "cd-audio", devicepath );
1044 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
1046 QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
1047 int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
1050 CaC( "file-caching", 1 );
1051 CaC( "network-caching", 10/3 );
1052 CaC( "disc-caching", 1 );
1053 CaC( "live-caching", 1 );
1060 case SPrefsInterface:
1062 if( qobject_cast<QRadioButton *>(optionWidgets["skinRB"])->isChecked() )
1063 config_PutPsz( p_intf, "intf", "skins2,any" );
1065 //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
1066 config_PutPsz( p_intf, "intf", "" );
1067 if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
1068 getSettings()->setValue( "MainWindow/QtStyle",
1069 qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
1079 qobject_cast<QCheckBox *>(optionWidgets["normalizerChB"])->isChecked();
1080 if( b_checked && !qs_filter.contains( "normvol" ) )
1081 qs_filter.append( "normvol" );
1082 if( !b_checked && qs_filter.contains( "normvol" ) )
1083 qs_filter.removeAll( "normvol" );
1086 qobject_cast<QCheckBox *>(optionWidgets["headphoneB"])->isChecked();
1088 if( b_checked && !qs_filter.contains( "headphone" ) )
1089 qs_filter.append( "headphone" );
1090 if( !b_checked && qs_filter.contains( "headphone" ) )
1091 qs_filter.removeAll( "headphone" );
1093 config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
1095 /* Default volume */
1097 qobject_cast<QSlider *>(optionWidgets["defaultVolume"])->value();
1098 bool b_reset_volume =
1099 qobject_cast<QCheckBox *>(optionWidgets["resetVolumeCheckbox"])->isChecked();
1100 module_config_t *p_config = config_FindConfig( VLC_OBJECT(p_intf), "aout" );
1101 char *psz_aout = p_config->value.psz;
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
1132 config_PutInt( p_intf, "volume-save", !b_reset_volume );
1136 case SPrefsSubtitles:
1138 bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
1139 if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
1140 config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
1142 else if (!b_checked ) {
1143 config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
1146 b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
1147 if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
1148 config_PutInt( p_intf, "freetype-background-opacity", 128 );
1150 else if (!b_checked ) {
1151 config_PutInt( p_intf, "freetype-background-opacity", 0 );
1158 void SPrefsPanel::clean()
1161 void SPrefsPanel::lastfm_Changed( int i_state )
1163 if( i_state == Qt::Checked )
1164 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
1165 else if( i_state == Qt::Unchecked )
1166 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
1169 void SPrefsPanel::changeStyle( QString s_style )
1171 QApplication::setStyle( s_style );
1173 /* force refresh on all widgets */
1174 QWidgetList widgets = QApplication::allWidgets();
1175 QWidgetList::iterator it = widgets.begin();
1176 while( it != widgets.end() ) {
1182 void SPrefsPanel::langChanged( int i )
1184 lang = strdup( ppsz_language[i] );
1187 void SPrefsPanel::configML()
1189 #ifdef SQL_MEDIA_LIBRARY
1190 MLConfDialog *mld = new MLConfDialog( this, p_intf );
1197 #include <QDialogButtonBox>
1198 #include "util/registry.hpp"
1200 void SPrefsPanel::cleanLang() {
1201 QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
1202 qvReg->DeleteValue( "Software\\VideoLAN\\VLC\\", "Lang" );
1203 qvReg->DeleteKey( "Software\\VideoLAN\\", "VLC" );
1204 qvReg->DeleteKey( "Software\\", "VideoLAN" );
1208 void SPrefsPanel::saveLang() {
1211 if( !strncmp( lang, "auto", 4 ) ) {
1216 QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
1217 qvReg->WriteRegistryString( "Software\\VideoLAN\\VLC\\", "Lang", lang );
1221 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
1222 QTreeWidgetItem* parent, QVLCRegistry *qvReg )
1225 const char* psz_VLC = "VLC";
1226 current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
1228 if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
1230 current->setCheckState( 0, Qt::Checked );
1235 current->setCheckState( 0, Qt::Unchecked );
1238 listAsso.append( current );
1242 void SPrefsPanel::assoDialog()
1244 #if !defined(__IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__)
1245 #define __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__
1246 const GUID IID_IApplicationAssociationRegistrationUI = {0x1f76a169,0xf994,0x40ac, {0x8f,0xc8,0x09,0x59,0xe8,0x87,0x47,0x10}};
1247 const GUID CLSID_ApplicationAssociationRegistrationUI = { 0x1968106d,0xf3b5,0x44cf,{0x89,0x0e,0x11,0x6f,0xcb,0x9e,0xce,0xf1}};
1249 interface IApplicationAssociationRegistrationUI : public IUnknown
1251 virtual HRESULT STDMETHODCALLTYPE LaunchAdvancedAssociationUI(
1252 LPCWSTR pszAppRegName) = 0;
1254 #endif /* __cplusplus */
1255 #endif /* __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__ */
1257 IApplicationAssociationRegistrationUI *p_appassoc;
1258 CoInitializeEx( NULL, COINIT_MULTITHREADED );
1260 if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
1261 NULL, CLSCTX_INPROC_SERVER,
1262 IID_IApplicationAssociationRegistrationUI,
1263 (void **)&p_appassoc) )
1265 if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
1274 QDialog *d = new QDialog( this );
1275 d->setWindowTitle( qtr( "File associations" ) );
1276 QGridLayout *assoLayout = new QGridLayout( d );
1278 QTreeWidget *filetypeList = new QTreeWidget;
1279 assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
1280 filetypeList->header()->hide();
1282 QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1284 QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
1285 QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
1286 QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
1288 filetypeList->addTopLevelItem( audioType );
1289 filetypeList->addTopLevelItem( videoType );
1290 filetypeList->addTopLevelItem( otherType );
1292 audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
1293 videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
1294 otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
1296 QTreeWidgetItem *currentItem = NULL;
1299 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
1300 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
1301 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
1303 aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
1304 aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
1305 aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
1306 aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
1307 audioType->setCheckState( 0, ( i_temp > 0 ) ?
1308 ( ( i_temp == audioType->childCount() ) ?
1309 Qt::Checked : Qt::PartiallyChecked )
1313 aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
1314 aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
1315 aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
1316 aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
1317 aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
1318 aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" ); aTv( ".ts" );
1319 aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1320 videoType->setCheckState( 0, ( i_temp > 0 ) ?
1321 ( ( i_temp == audioType->childCount() ) ?
1322 Qt::Checked : Qt::PartiallyChecked )
1326 aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1327 aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1328 otherType->setCheckState( 0, ( i_temp > 0 ) ?
1329 ( ( i_temp == audioType->childCount() ) ?
1330 Qt::Checked : Qt::PartiallyChecked )
1337 QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1338 QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1339 QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1340 buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1341 buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1343 assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1345 CONNECT( closeButton, clicked(), this, saveAsso() );
1346 CONNECT( clearButton, clicked(), d, reject() );
1347 d->resize( 300, 400 );
1353 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1355 QString s_path( "VLC" ); s_path += psz_ext;
1356 QString s_path2 = s_path;
1358 /* Save a backup if already assigned */
1359 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1361 if( !EMPTY_STR(psz_value) )
1362 qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1365 /* Put a "link" to VLC.EXT as default */
1366 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1368 /* Create the needed Key if they weren't done in the installer */
1369 if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1371 qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1372 qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1373 qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1375 /* Get the installer path */
1376 QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1377 QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1379 if( str_temp.size() )
1381 qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1382 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1384 qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1385 "", qtu( str_temp.append(",0") ) );
1391 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1393 QString s_path( "VLC"); s_path += psz_ext;
1394 char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1396 if( psz_value && !strcmp( qtu(s_path), psz_value ) )
1399 psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1401 qvReg->WriteRegistryString( psz_ext, "", psz_value );
1403 qvReg->DeleteKey( psz_ext, "VLC.backup" );
1408 void SPrefsPanel::saveAsso()
1410 QVLCRegistry * qvReg = NULL;
1411 for( int i = 0; i < listAsso.size(); i ++ )
1413 qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
1414 if( listAsso[i]->checkState( 0 ) > 0 )
1416 addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1420 delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1424 qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();