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