]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
5c2dc605ca8b3ed53815198e125a51a0707c68ee
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
1 /*****************************************************************************
2  * simple_preferences.cpp : "Simple preferences"
3  ****************************************************************************
4  * Copyright (C) 2006-2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.org>
9  *          Jean-Baptiste Kempf <jb@videolan.org>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include "components/simple_preferences.hpp"
31 #include "components/preferences_widgets.hpp"
32 #include "dialogs/ml_configuration.hpp"
33
34 #include <vlc_config_cat.h>
35 #include <vlc_configuration.h>
36
37 #include <QString>
38 #include <QFont>
39 #include <QToolButton>
40 #include <QSignalMapper>
41 #include <QVBoxLayout>
42 #include <QScrollArea>
43
44 #include <QStyleFactory>
45 #include <QSettings>
46 #include <QtAlgorithms>
47 #include <QDir>
48
49 #define ICON_HEIGHT 64
50
51 #ifdef _WIN32
52 # include <vlc_windows_interfaces.h>
53 #endif
54 #include <vlc_modules.h>
55
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 )
61 {
62     QVBoxLayout *layout = new QVBoxLayout();
63
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) );
69
70     short icon_height = small ? ICON_HEIGHT /2 : ICON_HEIGHT;
71
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 );
87
88     ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
89                   cone_interface_64, 0 );
90     ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
91                   cone_audio_64, 1 );
92     ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
93                   cone_video_64, 2 );
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"),
97                   cone_input_64, 4 );
98     ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
99                   cone_hotkeys_64, 5 );
100
101 #undef ADD_CATEGORY
102
103     SPrefsInterface->setChecked( true );
104     layout->setMargin( 0 );
105     layout->setSpacing( 1 );
106
107     setMinimumWidth( 140 );
108     setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
109     setLayout( layout );
110
111 }
112
113 void SPrefsCatList::switchPanel( int i )
114 {
115     emit currentItemChanged( i );
116 }
117
118 /*********************************************************************
119  * The Panels
120  *********************************************************************/
121 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
122                           int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
123 {
124     module_config_t *p_config;
125     ConfigControl *control;
126     number = _number;
127
128 #define CONFIG_GENERIC( option, type, label, qcontrol )                   \
129             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
130             if( p_config )                                                \
131             {                                                             \
132                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
133                            p_config, label, ui.qcontrol, false );         \
134                 controls.append( control );                               \
135             }                                                             \
136             else {                                                        \
137                 ui.qcontrol->setEnabled( false );                         \
138                 if( label ) label->setEnabled( false );                   \
139             }
140
141 #define CONFIG_BOOL( option, qcontrol )                           \
142             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
143             if( p_config )                                                \
144             {                                                             \
145                 control =  new BoolConfigControl( VLC_OBJECT(p_intf),     \
146                            p_config, NULL, ui.qcontrol );          \
147                 controls.append( control );                               \
148             }                                                             \
149             else { ui.qcontrol->setEnabled( false ); }
150
151
152 #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol )             \
153             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
154             if( p_config )                                                \
155             {                                                             \
156                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
157                            p_config, label, qcontrol, false );            \
158                 controls.append( control );                               \
159             }                                                             \
160             else {                                                        \
161                 QWidget *widget = label;                                  \
162                 qcontrol->setVisible( false );                            \
163                 if( widget ) widget->setEnabled( false );                 \
164             }
165
166
167 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol )           \
168             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
169             if( p_config )                                                \
170             {                                                             \
171                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
172                            p_config, label, ui.qcontrol );                \
173                 controls.append( control );                               \
174             }
175
176 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton )     \
177             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
178             if( p_config )                                                \
179             {                                                             \
180                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
181                            p_config, label, qcontrol, qbutton );          \
182                 controls.append( control );                               \
183             }
184
185 #define START_SPREFS_CAT( name , label )    \
186         case SPrefs ## name:                \
187         {                                   \
188             Ui::SPrefs ## name ui;      \
189             ui.setupUi( panel );            \
190             panel_label->setText( label );
191
192 #define END_SPREFS_CAT      \
193             break;          \
194         }
195
196     QVBoxLayout *panel_layout = new QVBoxLayout();
197     QWidget *panel = new QWidget();
198     panel_layout->setMargin( 3 );
199
200     // Title Label
201     QLabel *panel_label = new QLabel;
202     QFont labelFont = QApplication::font();
203     labelFont.setPointSize( labelFont.pointSize() + 6 );
204     panel_label->setFont( labelFont );
205
206     // Title <hr>
207     QFrame *title_line = new QFrame;
208     title_line->setFrameShape(QFrame::HLine);
209     title_line->setFrameShadow(QFrame::Sunken);
210
211     QFont italicFont = QApplication::font();
212     italicFont.setItalic( true );
213
214     switch( number )
215     {
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 ) );
224
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 );
230
231 #ifdef _WIN32
232             CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
233                             dXdisplayDevice );
234             CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
235             CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
236 #else
237             ui.directXBox->setVisible( false );
238             ui.hwYUVBox->setVisible( false );
239 #endif
240
241 #ifdef __OS2__
242             CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
243             CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
244                             kvaVideoMode );
245 #else
246             ui.kvaBox->setVisible( false );
247 #endif
248
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 );
252
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,
259                             snapshotsFormat );
260          END_SPREFS_CAT;
261
262         /******************************
263          * AUDIO Panel Implementation *
264          ******************************/
265         START_SPREFS_CAT( Audio, qtr("Audio Settings") );
266
267             CONFIG_BOOL( "audio", enableAudio );
268             ui.audioZone->setEnabled( ui.enableAudio->isChecked() );
269             CONNECT( ui.enableAudio, toggled( bool ),
270                      ui.audioZone, setEnabled( bool ) );
271
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 ); \
276
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 );
283
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 );
290
291             /* Build if necessary */
292             QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
293 #ifdef _WIN32
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__ )
300             audioControl( kai );
301             optionWidgets["kaiL"] = kaiLabel;
302             optionWidgets["kaiW"] = kaiDevice;
303             CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
304                     kaiDevice );
305 #else
306             if( module_exists( "alsa" ) )
307             {
308                 audioControl( alsa );
309                 optionWidgets["alsaL"] = alsaLabel;
310                 optionWidgets["alsaW"] = alsaDevice;
311                 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
312                                 alsaDevice );
313             }
314             if( module_exists( "oss" ) )
315             {
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,
321                                  OSSBrowse );
322             }
323 #endif
324
325 #undef audioControl2
326 #undef audioControl
327 #undef audioCommon
328
329             /* Audio Options */
330             ui.volumeValue->setMaximum( 200 );
331             CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
332                                      defaultVolume );
333             CONNECT( ui.defaultVolume, valueChanged( int ),
334                      this, updateAudioVolume( int ) );
335
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 ) );
340
341             CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
342                             preferredAudioLanguage );
343
344             CONFIG_BOOL( "spdif", spdifBox );
345             CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
346                             detectionDolby );
347
348             CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
349                                     volNormSpin );
350             CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
351                             replayCombo );
352             CONFIG_GENERIC( "audio-visual" , StringList, ui.visuLabel,
353                             visualisation);
354             CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
355
356             /* Audio Output Specifics */
357             CONFIG_GENERIC( "aout", StringList, ui.outputLabel, outputModule );
358
359             CONNECT( ui.outputModule, currentIndexChanged( int ),
360                      this, updateAudioOptions( int ) );
361
362             /* File output exists on all platforms */
363             CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
364                                  ui.fileName, ui.fileBrowseButton );
365
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() );
375
376             /* LastFM */
377             if( module_exists( "audioscrobbler" ) )
378             {
379                 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
380                         lastfm_user_edit );
381                 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
382                         lastfm_pass_edit );
383
384                 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
385                     ui.lastfm->setChecked( true );
386                 else
387                     ui.lastfm->setChecked( false );
388
389                 ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
390
391                 CONNECT( ui.lastfm, toggled( bool ),
392                          ui.lastfm_zone, setVisible( bool ) );
393                 CONNECT( ui.lastfm, stateChanged( int ),
394                          this, lastfm_Changed( int ) );
395             }
396             else
397             {
398                 ui.lastfm->hide();
399                 ui.lastfm_zone->hide();
400             }
401
402             /* Normalizer */
403             CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
404                      setEnabled( bool ) );
405
406             char* psz = config_GetPsz( p_intf, "audio-filter" );
407             qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
408             free( psz );
409
410             bool b_enabled = ( qs_filter.contains( "normvol" ) );
411             ui.volNormBox->setChecked( b_enabled );
412             ui.volNormSpin->setEnabled( b_enabled );
413
414             b_enabled = ( qs_filter.contains( "headphone" ) );
415             ui.headphoneEffect->setChecked( b_enabled );
416
417             /* Volume Label */
418             updateAudioVolume( ui.defaultVolume->value() ); // First time init
419
420         END_SPREFS_CAT;
421
422         /* Input and Codecs Panel Implementation */
423         START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs Settings") );
424
425             /* Disk Devices */
426             {
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 ) )
438                 {
439                     ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
440                 }
441                 free( psz_cddadiscpath );
442                 free( psz_dvddiscpath );
443                 free( psz_vcddiscpath );
444             }
445 #ifndef _WIN32
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/" )
452             );
453 #endif
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 );
458
459             CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
460             CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
461                                     PostProcLevel );
462             CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
463
464             /* live555 module prefs */
465             CONFIG_BOOL( "rtsp-tcp",
466                                 live555TransportRTSP_TCPRadio );
467             if ( !module_exists( "live555" ) )
468             {
469                 ui.live555TransportRTSP_TCPRadio->hide();
470                 ui.live555TransportHTTPRadio->hide();
471                 ui.live555TransportLabel->hide();
472             }
473             CONFIG_GENERIC( "avcodec-hw", StringList, ui.hwAccelLabel, hwAccelModule );
474 #ifdef _WIN32
475             HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
476             if( !hdxva2_dll )
477                 ui.hwAccelModule->setEnabled( false );
478             else
479                 FreeLibrary( hdxva2_dll );
480 #endif
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 );
489
490             /* Caching */
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
501
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" );
508
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 ) ) );
515 #undef TestCaC
516
517         END_SPREFS_CAT;
518         /*******************
519          * Interface Panel *
520          *******************/
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 );
528
529 #ifdef _WIN32
530             BUTTONACT( ui.assoButton, assoDialog() );
531 #else
532             ui.osGroupBox->hide();
533 #endif
534 #ifdef MEDIA_LIBRARY
535             BUTTONACT( ui.sqlMLbtn, configML() );
536 #else
537             ui.sqlMLbtn->hide();
538 #endif
539
540             /* interface */
541             char *psz_intf = config_GetPsz( p_intf, "intf" );
542             if( psz_intf )
543             {
544                 if( strstr( psz_intf, "skin" ) )
545                     ui.skins->setChecked( true );
546             } else {
547                 /* defaults to qt */
548                 ui.qt->setChecked( true );
549             }
550             free( psz_intf );
551
552             optionWidgets["skinRB"] = ui.skins;
553             optionWidgets["qtRB"] = ui.qt;
554 #if !defined( _WIN32)
555             ui.stylesCombo->addItem( qtr("System's default") );
556             ui.stylesCombo->addItems( QStyleFactory::keys() );
557             ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
558                         getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
559             ui.stylesCombo->insertSeparator( 1 );
560             if ( ui.stylesCombo->currentIndex() < 0 )
561                 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
562
563             CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
564             optionWidgets["styleCB"] = ui.stylesCombo;
565 #else
566             ui.stylesCombo->hide();
567             ui.stylesLabel->hide();
568 #endif
569             radioGroup = new QButtonGroup(this);
570             radioGroup->addButton( ui.qt, 0 );
571             radioGroup->addButton( ui.skins, 1 );
572             CONNECT( radioGroup, buttonClicked( int ),
573                      ui.styleStackedWidget, setCurrentIndex( int ) );
574             ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
575
576             CONNECT( ui.minimalviewBox, toggled( bool ),
577                      ui.mainPreview, setNormalPreview( bool ) );
578             CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
579             ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
580             ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
581
582             CONFIG_BOOL( "embedded-video", embedVideo );
583             CONFIG_BOOL( "qt-video-autoresize", resizingBox );
584             CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
585             ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
586
587             CONFIG_BOOL( "qt-fs-controller", fsController );
588             CONFIG_BOOL( "qt-system-tray", systrayBox );
589             CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
590                                                       notificationCombo );
591             CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
592             CONNECT( ui.systrayBox, toggled( bool ), ui.notificationComboLabel, setEnabled( bool ) );
593             ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
594
595             CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
596             CONFIG_BOOL( "playlist-tree", treePlaylist );
597             CONFIG_BOOL( "play-and-pause", playPauseBox );
598             CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
599                                  ui.fileSkin, ui.skinBrowse );
600
601             CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
602                                                       artFetcher );
603
604             /* UPDATE options */
605 #ifdef UPDATE_CHECK
606             CONFIG_BOOL( "qt-updates-notif", updatesBox );
607             CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
608                     updatesDays );
609             ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
610             CONNECT( ui.updatesBox, toggled( bool ),
611                      ui.updatesDays, setEnabled( bool ) );
612 #else
613             ui.updatesBox->hide();
614             ui.updatesDays->hide();
615 #endif
616             /* ONE INSTANCE options */
617 #if !defined( _WIN32 ) && !defined(__APPLE__) && !defined(__OS2__)
618             if( !module_exists( "dbus" ) )
619                 ui.OneInterfaceBox->hide();
620             else
621 #endif
622             {
623                 CONFIG_BOOL( "one-instance", OneInterfaceMode );
624                 CONFIG_BOOL( "playlist-enqueue", EnqueueOneInterfaceMode );
625                 ui.EnqueueOneInterfaceMode->setEnabled(
626                                                        ui.OneInterfaceMode->isChecked() );
627                 CONNECT( ui.OneInterfaceMode, toggled( bool ),
628                          ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
629                 CONFIG_BOOL( "one-instance-when-started-from-file", oneInstanceFromFile );
630             }
631
632             /* RECENTLY PLAYED options */
633             CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
634                      ui.recentlyPlayedFilters, setEnabled( bool ) );
635             ui.recentlyPlayedFilters->setEnabled( false );
636             CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
637             CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
638                     recentlyPlayedFilters );
639
640         END_SPREFS_CAT;
641
642         START_SPREFS_CAT( Subtitles,
643                             qtr("Subtitle & On Screen Display Settings") );
644             CONFIG_BOOL( "osd", OSDBox);
645             CONFIG_BOOL( "video-title-show", OSDTitleBox);
646             CONFIG_GENERIC( "video-title-position", IntegerList,
647                             ui.OSDTitlePosLabel, OSDTitlePos );
648
649             CONFIG_BOOL( "spu", spuActiveBox);
650             ui.spuZone->setEnabled( ui.spuActiveBox->isChecked() );
651             CONNECT( ui.spuActiveBox, toggled( bool ),
652                      ui.spuZone, setEnabled( bool ) );
653
654             CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
655                             encoding );
656             CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
657                             preferredLanguage );
658
659             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
660                             ui.fontSizeLabel, fontSize );
661
662             CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
663             CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
664                             fontColor );
665             CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
666                             ui.fontEffectLabel, effect );
667             CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
668                             outlineColor );
669
670             CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
671
672             ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
673             ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
674             optionWidgets["shadowCB"] = ui.shadowCheck;
675             optionWidgets["backgroundCB"] = ui.backgroundCheck;
676
677         END_SPREFS_CAT;
678
679         case SPrefsHotkeys:
680         {
681             p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
682
683             QGridLayout *gLayout = new QGridLayout;
684             panel->setLayout( gLayout );
685             int line = 0;
686
687             panel_label->setText( qtr( "Configure Hotkeys" ) );
688             control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
689             control->insertIntoExistingGrid( gLayout, line );
690             controls.append( control );
691
692             line++;
693
694             QFrame *sepline = new QFrame;
695             sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
696             gLayout->addWidget( sepline, line, 0, 1, -1 );
697
698             line++;
699
700             p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
701             control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
702                     p_config, this, false );
703             control->insertIntoExistingGrid( gLayout, line );
704             controls.append( control );
705
706 #ifdef _WIN32
707             line++;
708
709             p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
710             control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
711             control->insertIntoExistingGrid( gLayout, line );
712             controls.append( control );
713 #endif
714
715             break;
716         }
717     }
718
719     panel_layout->addWidget( panel_label );
720     panel_layout->addWidget( title_line );
721
722     if( small )
723     {
724         QScrollArea *scroller= new QScrollArea;
725         scroller->setWidget( panel );
726         scroller->setWidgetResizable( true );
727         scroller->setFrameStyle( QFrame::NoFrame );
728         panel_layout->addWidget( scroller );
729     }
730     else
731     {
732         panel_layout->addWidget( panel );
733         if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
734     }
735
736     setLayout( panel_layout );
737
738 #undef END_SPREFS_CAT
739 #undef START_SPREFS_CAT
740 #undef CONFIG_GENERIC_FILE
741 #undef CONFIG_GENERIC_NO_BOOL
742 #undef CONFIG_GENERIC_NO_UI
743 #undef CONFIG_GENERIC
744 #undef CONFIG_BOOL
745 }
746
747
748 void SPrefsPanel::updateAudioOptions( int number)
749 {
750     QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
751                                             ->itemData( number ).toString();
752 #ifdef _WIN32
753     optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
754     optionWidgets["directxL"]->setVisible( ( value == "directsound" ) );
755 #elif defined( __OS2__ )
756     optionWidgets["kaiL"]->setVisible( ( value == "kai" ) );
757     optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
758 #else
759     /* optionWidgets["ossW] can be NULL */
760     if( optionWidgets["ossW"] ) {
761         optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
762         optionWidgets["ossL"]->setVisible( ( value == "oss" ) );
763         optionWidgets["ossB"]->setVisible( ( value == "oss" ) );
764     }
765     /* optionWidgets["alsaW] can be NULL */
766     if( optionWidgets["alsaW"] ) {
767         optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
768         optionWidgets["alsaL"]->setVisible( ( value == "alsa" ) );
769     }
770 #endif
771     optionWidgets["fileW"]->setVisible( ( value == "aout_file" ) );
772     optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
773                                            value == "directsound" || value == "waveout" ) );
774 }
775
776
777 SPrefsPanel::~SPrefsPanel()
778 {
779     qDeleteAll( controls ); controls.clear();
780 }
781
782 void SPrefsPanel::updateAudioVolume( int volume )
783 {
784     qobject_cast<QSpinBox *>(optionWidgets["volLW"])
785         ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
786 }
787
788
789 /* Function called from the main Preferences dialog on each SPrefs Panel */
790 void SPrefsPanel::apply()
791 {
792     /* Generic save for ever panel */
793     QList<ConfigControl *>::const_iterator i;
794     for( i = controls.begin() ; i != controls.end() ; ++i )
795     {
796         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
797         c->doApply();
798     }
799
800     switch( number )
801     {
802     case SPrefsInputAndCodecs:
803     {
804         /* Device default selection */
805         QByteArray devicepath =
806             qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
807         if( devicepath.size() > 0 )
808         {
809             config_PutPsz( p_intf, "dvd", devicepath );
810             config_PutPsz( p_intf, "vcd", devicepath );
811             config_PutPsz( p_intf, "cd-audio", devicepath );
812         }
813
814 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
815         /* Caching */
816         QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
817         int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
818         if( i_comboValue )
819         {
820             CaC( "file-caching", 1 );
821             CaC( "network-caching", 10/3 );
822             CaC( "disc-caching", 1 );
823             CaC( "live-caching", 1 );
824         }
825         break;
826 #undef CaC
827     }
828
829     /* Interfaces */
830     case SPrefsInterface:
831     {
832         if( qobject_cast<QRadioButton *>(optionWidgets["skinRB"])->isChecked() )
833             config_PutPsz( p_intf, "intf", "skins2,any" );
834         else
835         //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
836             config_PutPsz( p_intf, "intf", "" );
837         if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
838             getSettings()->setValue( "MainWindow/QtStyle",
839                 qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
840
841         break;
842     }
843
844     case SPrefsAudio:
845     {
846         bool b_checked =
847             qobject_cast<QCheckBox *>(optionWidgets["normalizerChB"])->isChecked();
848         if( b_checked && !qs_filter.contains( "normvol" ) )
849             qs_filter.append( "normvol" );
850         if( !b_checked && qs_filter.contains( "normvol" ) )
851             qs_filter.removeAll( "normvol" );
852
853         b_checked =
854             qobject_cast<QCheckBox *>(optionWidgets["headphoneB"])->isChecked();
855
856         if( b_checked && !qs_filter.contains( "headphone" ) )
857             qs_filter.append( "headphone" );
858         if( !b_checked && qs_filter.contains( "headphone" ) )
859             qs_filter.removeAll( "headphone" );
860
861         config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
862         break;
863     }
864     case SPrefsSubtitles:
865     {
866         bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
867         if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
868             config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
869         }
870         else if (!b_checked ) {
871             config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
872         }
873
874         b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
875         if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
876             config_PutInt( p_intf, "freetype-background-opacity", 128 );
877         }
878         else if (!b_checked ) {
879             config_PutInt( p_intf, "freetype-background-opacity", 0 );
880         }
881
882     }
883     }
884 }
885
886 void SPrefsPanel::clean()
887 {}
888
889 void SPrefsPanel::lastfm_Changed( int i_state )
890 {
891     if( i_state == Qt::Checked )
892         config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
893     else if( i_state == Qt::Unchecked )
894         config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
895 }
896
897 void SPrefsPanel::changeStyle( QString s_style )
898 {
899     QApplication::setStyle( s_style );
900
901     /* force refresh on all widgets */
902     QWidgetList widgets = QApplication::allWidgets();
903     QWidgetList::iterator it = widgets.begin();
904     while( it != widgets.end() ) {
905         (*it)->update();
906         ++it;
907     };
908 }
909
910 void SPrefsPanel::configML()
911 {
912 #ifdef MEDIA_LIBRARY
913     MLConfDialog *mld = new MLConfDialog( this, p_intf );
914     mld->exec();
915     delete mld;
916 #endif
917 }
918
919 #ifdef _WIN32
920 #include <QDialogButtonBox>
921 #include "util/registry.hpp"
922
923 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
924                            QTreeWidgetItem* parent, QVLCRegistry *qvReg )
925 {
926     bool b_temp;
927     const char* psz_VLC = "VLC";
928     current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
929
930     if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
931     {
932         current->setCheckState( 0, Qt::Checked );
933         b_temp = false;
934     }
935     else
936     {
937         current->setCheckState( 0, Qt::Unchecked );
938         b_temp = true;
939     }
940     listAsso.append( current );
941     return b_temp;
942 }
943
944 void SPrefsPanel::assoDialog()
945 {
946     IApplicationAssociationRegistrationUI *p_appassoc;
947     CoInitializeEx( NULL, COINIT_MULTITHREADED );
948
949     if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
950                 NULL, CLSCTX_INPROC_SERVER,
951                 IID_IApplicationAssociationRegistrationUI,
952                 (void **)&p_appassoc) )
953     {
954         if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
955         {
956             CoUninitialize();
957             return;
958         }
959     }
960
961     CoUninitialize();
962
963     QDialog *d = new QDialog( this );
964     d->setWindowTitle( qtr( "File associations" ) );
965     QGridLayout *assoLayout = new QGridLayout( d );
966
967     QTreeWidget *filetypeList = new QTreeWidget;
968     assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
969     filetypeList->header()->hide();
970
971     QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
972
973     QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
974     QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
975     QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
976
977     filetypeList->addTopLevelItem( audioType );
978     filetypeList->addTopLevelItem( videoType );
979     filetypeList->addTopLevelItem( otherType );
980
981     audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
982     videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
983     otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
984
985     QTreeWidgetItem *currentItem = NULL;
986
987     int i_temp = 0;
988 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
989 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
990 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
991
992     aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
993     aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
994     aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
995     aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
996     audioType->setCheckState( 0, ( i_temp > 0 ) ?
997                               ( ( i_temp == audioType->childCount() ) ?
998                                Qt::Checked : Qt::PartiallyChecked )
999                             : Qt::Unchecked );
1000
1001     i_temp = 0;
1002     aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
1003     aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
1004     aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
1005     aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
1006     aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
1007     aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" );  aTv( ".ts" );
1008     aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
1009     videoType->setCheckState( 0, ( i_temp > 0 ) ?
1010                               ( ( i_temp == audioType->childCount() ) ?
1011                                Qt::Checked : Qt::PartiallyChecked )
1012                             : Qt::Unchecked );
1013
1014     i_temp = 0;
1015     aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1016     aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1017     otherType->setCheckState( 0, ( i_temp > 0 ) ?
1018                               ( ( i_temp == audioType->childCount() ) ?
1019                                Qt::Checked : Qt::PartiallyChecked )
1020                             : Qt::Unchecked );
1021
1022 #undef aTo
1023 #undef aTv
1024 #undef aTa
1025
1026     QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1027     QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1028     QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1029     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1030     buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1031
1032     assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1033
1034     CONNECT( closeButton, clicked(), this, saveAsso() );
1035     CONNECT( clearButton, clicked(), d, reject() );
1036     d->resize( 300, 400 );
1037     d->exec();
1038     delete qvReg;
1039     listAsso.clear();
1040 }
1041
1042 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1043 {
1044     QString s_path( "VLC" ); s_path += psz_ext;
1045     QString s_path2 = s_path;
1046
1047     /* Save a backup if already assigned */
1048     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
1049
1050     if( !EMPTY_STR(psz_value) )
1051         qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1052     free( psz_value );
1053
1054     /* Put a "link" to VLC.EXT as default */
1055     qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1056
1057     /* Create the needed Key if they weren't done in the installer */
1058     if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1059     {
1060         qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1061         qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1062         qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1063
1064         /* Get the installer path */
1065         QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1066         QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1067
1068         if( str_temp.size() )
1069         {
1070             qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1071                 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1072
1073             qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1074                         "", qtu( str_temp.append(",0") ) );
1075         }
1076         delete qvReg2;
1077     }
1078 }
1079
1080 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1081 {
1082     QString s_path( "VLC"); s_path += psz_ext;
1083     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1084
1085     if( psz_value && !strcmp( qtu(s_path), psz_value ) )
1086     {
1087         free( psz_value );
1088         psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1089         if( psz_value )
1090             qvReg->WriteRegistryString( psz_ext, "", psz_value );
1091
1092         qvReg->DeleteKey( psz_ext, "VLC.backup" );
1093     }
1094     free( psz_value );
1095 }
1096
1097 void SPrefsPanel::saveAsso()
1098 {
1099     QVLCRegistry * qvReg = NULL;
1100     for( int i = 0; i < listAsso.size(); i ++ )
1101     {
1102         qvReg  = new QVLCRegistry( HKEY_CLASSES_ROOT );
1103         if( listAsso[i]->checkState( 0 ) > 0 )
1104         {
1105             addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1106         }
1107         else
1108         {
1109             delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1110         }
1111     }
1112     /* Gruik ? Naaah */
1113     qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();
1114     delete qvReg;
1115 }
1116
1117 #endif /* _WIN32 */
1118