]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
Qt: ConfigControl: rework layout insertion.
[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 #include <vlc_aout_intf.h>
37
38 #include <QString>
39 #include <QFont>
40 #include <QToolButton>
41 #include <QButtonGroup>
42 #include <QVBoxLayout>
43 #include <QScrollArea>
44
45 #include <QStyleFactory>
46 #include <QSettings>
47 #include <QtAlgorithms>
48 #include <QDir>
49
50 #define ICON_HEIGHT 64
51
52 #ifdef WIN32
53 # include <vlc_windows_interfaces.h>
54 #endif
55 #include <vlc_modules.h>
56
57 /*********************************************************************
58  * The List of categories
59  *********************************************************************/
60 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent, bool small ) :
61                                   QWidget( _parent ), p_intf( _p_intf )
62 {
63     QVBoxLayout *layout = new QVBoxLayout();
64
65     QButtonGroup *buttonGroup = new QButtonGroup( this );
66     buttonGroup->setExclusive ( true );
67     CONNECT( buttonGroup, buttonClicked ( int ),
68             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     buttonGroup->addButton( button, numb );                                 \
84     layout->addWidget( button );
85
86     ADD_CATEGORY( SPrefsInterface, qtr("Interface"), qtr("Interface Settings"),
87                   cone_interface_64, 0 );
88     ADD_CATEGORY( SPrefsAudio, qtr("Audio"), qtr("Audio Settings"),
89                   cone_audio_64, 1 );
90     ADD_CATEGORY( SPrefsVideo, qtr("Video"), qtr("Video Settings"),
91                   cone_video_64, 2 );
92     ADD_CATEGORY( SPrefsSubtitles, SUBPIC_TITLE, qtr("Subtitles & On Screen Display Settings"),
93                   cone_subtitles_64, 3 );
94     ADD_CATEGORY( SPrefsInputAndCodecs, INPUT_TITLE, qtr("Input & Codecs Settings"),
95                   cone_input_64, 4 );
96     ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), qtr("Configure Hotkeys"),
97                   cone_hotkeys_64, 5 );
98
99 #undef ADD_CATEGORY
100
101     SPrefsInterface->setChecked( true );
102     layout->setMargin( 0 );
103     layout->setSpacing( 1 );
104
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
219             CONFIG_BOOL( "fullscreen", fullscreen );
220             CONFIG_BOOL( "overlay", overlay );
221             CONFIG_BOOL( "video-on-top", alwaysOnTop );
222             CONFIG_BOOL( "video-deco", windowDecorations );
223             CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
224
225 #ifdef WIN32
226             CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
227                             dXdisplayDevice );
228             CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
229             CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
230 #else
231             ui.directXBox->setVisible( false );
232             ui.hwYUVBox->setVisible( false );
233 #endif
234
235 #ifdef __OS2__
236             CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
237             CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
238                             kvaVideoMode );
239 #else
240             ui.kvaBox->setVisible( false );
241 #endif
242
243             CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
244             CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
245             CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
246
247             CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
248                                  ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
249             CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
250             CONFIG_BOOL( "snapshot-sequential",
251                             snapshotsSequentialNumbering );
252             CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
253                             snapshotsFormat );
254          END_SPREFS_CAT;
255
256         /******************************
257          * AUDIO Panel Implementation *
258          ******************************/
259         START_SPREFS_CAT( Audio, qtr("Audio Settings") );
260
261             CONFIG_BOOL( "audio", enableAudio );
262             ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
263             CONNECT( ui.enableAudio, toggled( bool ),
264                      ui.SPrefsAudio_zone, setEnabled( bool ) );
265
266 #define audioCommon( name ) \
267             QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
268             QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
269             name ## Layout->setMargin( 0 ); \
270             name ## Layout->setSpacing( 0 ); \
271             QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
272             name ## Label->setMinimumSize(QSize(250, 0)); \
273             name ## Layout->addWidget( name ## Label ); \
274
275 #define audioControl( name) \
276             audioCommon( name ) \
277             QComboBox * name ## Device = new QComboBox( name ## Control ); \
278             name ## Layout->addWidget( name ## Device ); \
279             name ## Label->setBuddy( name ## Device ); \
280             name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred  );\
281             outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
282
283 #define audioControl2( name) \
284             audioCommon( name ) \
285             QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
286             name ## Layout->addWidget( name ## Device ); \
287             name ## Label->setBuddy( name ## Device ); \
288             QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
289             name ## Layout->addWidget( name ## Browse ); \
290             outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
291
292             /* Build if necessary */
293             QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
294 #ifdef WIN32
295             audioControl( DirectX );
296             optionWidgets.append( DirectXControl );
297             CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
298                     DirectXLabel, DirectXDevice );
299 #elif defined( __OS2__ )
300             audioControl( kai );
301             optionWidgets.append( kaiControl );
302             CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
303                     kaiDevice );
304 #else
305             if( module_exists( "alsa" ) )
306             {
307                 audioControl( alsa );
308                 optionWidgets.append( alsaControl );
309                 CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
310                                 alsaDevice );
311             }
312             else
313                 optionWidgets.append( NULL );
314             if( module_exists( "oss" ) )
315             {
316                 audioControl2( OSS );
317                 optionWidgets.append( OSSControl );
318                 CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
319                                  OSSBrowse );
320             }
321             else
322                 optionWidgets.append( NULL );
323 #endif
324
325 #undef audioControl2
326 #undef audioControl
327 #undef audioCommon
328
329             /* Audio Options */
330             ui.volumeValue->setMaximum( (AOUT_VOLUME_DEFAULT * 2) / AOUT_VOLUME_DEFAULT * 100 );
331             CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
332                                      defaultVolume );
333             CONNECT( ui.defaultVolume, valueChanged( int ),
334                      this, updateAudioVolume( int ) );
335
336             CONFIG_BOOL( "qt-autosave-volume", 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" , Module , ui.visuLabel,
353                             visualisation);
354             CONFIG_BOOL( "audio-time-stretch", autoscaleBox );
355
356             /* Audio Output Specifics */
357             CONFIG_GENERIC( "aout", Module, 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.append( ui.fileControl );
367             optionWidgets.append( ui.outputModule );
368             optionWidgets.append( ui.volNormBox );
369             /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
370             ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
371             optionWidgets.append( ui.volumeValue );
372             optionWidgets.append( ui.headphoneEffect );
373             optionWidgets.append( 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_BOOL( "ffmpeg-hw", hwAccelBox );
474 #ifdef WIN32
475             CONFIG_BOOL( "prefer-system-codecs", systemCodecBox );
476             HINSTANCE hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL") );
477             if( !hdxva2_dll )
478                 ui.hwAccelBox->setEnabled( false );
479             else
480                 FreeLibrary( hdxva2_dll );
481 #else
482             ui.systemCodecBox->hide();
483 #endif
484             optionWidgets.append( ui.DVDDeviceComboBox );
485             optionWidgets.append( ui.cachingCombo );
486             CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
487             CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
488             CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
489             CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
490             CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
491             CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
492
493             /* Caching */
494             /* Add the things to the ComboBox */
495             #define addToCachingBox( str, cachingNumber ) \
496                 ui.cachingCombo->addItem( qtr(str), QVariant( cachingNumber ) );
497             addToCachingBox( N_("Custom"), CachingCustom );
498             addToCachingBox( N_("Lowest latency"), CachingLowest );
499             addToCachingBox( N_("Low latency"), CachingLow );
500             addToCachingBox( N_("Normal"), CachingNormal );
501             addToCachingBox( N_("High latency"), CachingHigh );
502             addToCachingBox( N_("Higher latency"), CachingHigher );
503             #undef addToCachingBox
504
505 #define TestCaC( name, factor ) \
506     b_cache_equal =  b_cache_equal && \
507      ( i_cache * factor == config_GetInt( p_intf, name ) );
508             /* Select the accurate value of the ComboBox */
509             bool b_cache_equal = true;
510             int i_cache = config_GetInt( p_intf, "file-caching" );
511
512             TestCaC( "network-caching", 10/3 );
513             TestCaC( "disc-caching", 1);
514             TestCaC( "live-caching", 1 );
515             if( b_cache_equal == 1 )
516                 ui.cachingCombo->setCurrentIndex(
517                 ui.cachingCombo->findData( QVariant( i_cache ) ) );
518 #undef TestCaC
519
520         END_SPREFS_CAT;
521         /*******************
522          * Interface Panel *
523          *******************/
524         START_SPREFS_CAT( Interface, qtr("Interface Settings") );
525 //            ui.defaultLabel->setFont( italicFont );
526             ui.skinsLabel->setText(
527                     qtr( "This is VLC's skinnable interface. You can download other skins at" )
528                     + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">" )
529                     + qtr( "VLC skins website" )+ QString( "</a>." ) );
530             ui.skinsLabel->setFont( italicFont );
531
532 #if defined( WIN32 )
533             CONFIG_GENERIC( "language", StringList, ui.languageLabel, language );
534             BUTTONACT( ui.assoButton, assoDialog() );
535 #else
536             ui.languageBox->hide();
537             ui.assoButton->hide();
538             ui.assocLabel->hide();
539 #endif
540 #ifdef MEDIA_LIBRARY
541             BUTTONACT( ui.sqlMLbtn, configML() );
542 #else
543             ui.sqlMLbtn->hide();
544 #endif
545
546             /* interface */
547             char *psz_intf = config_GetPsz( p_intf, "intf" );
548             if( psz_intf )
549             {
550                 if( strstr( psz_intf, "skin" ) )
551                     ui.skins->setChecked( true );
552             } else {
553                 /* defaults to qt */
554                 ui.qt4->setChecked( true );
555             }
556             free( psz_intf );
557
558             optionWidgets.append( ui.skins );
559             optionWidgets.append( ui.qt4 );
560 #if !defined( WIN32)
561             ui.stylesCombo->addItem( qtr("System's default") );
562             ui.stylesCombo->addItems( QStyleFactory::keys() );
563             ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
564                         getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
565             ui.stylesCombo->insertSeparator( 1 );
566             if ( ui.stylesCombo->currentIndex() < 0 )
567                 ui.stylesCombo->setCurrentIndex( 0 ); /* default */
568
569             CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
570             optionWidgets.append( ui.stylesCombo );
571 #else
572             ui.stylesCombo->hide();
573             ui.stylesLabel->hide();
574             optionWidgets.append( NULL );
575 #endif
576             radioGroup = new QButtonGroup(this);
577             radioGroup->addButton( ui.qt4, 0 );
578             radioGroup->addButton( ui.skins, 1 );
579             CONNECT( radioGroup, buttonClicked( int ),
580                      ui.styleStackedWidget, setCurrentIndex( int ) );
581             ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
582
583             CONNECT( ui.minimalviewBox, toggled( bool ),
584                      ui.mainPreview, setNormalPreview( bool ) );
585             CONFIG_BOOL( "qt-minimal-view", minimalviewBox );
586             ui.mainPreview->setNormalPreview( ui.minimalviewBox->isChecked() );
587             ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
588
589             CONFIG_BOOL( "embedded-video", embedVideo );
590             CONFIG_BOOL( "qt-video-autoresize", resizingBox );
591             CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
592             ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
593
594             CONFIG_BOOL( "qt-fs-controller", fsController );
595             CONFIG_BOOL( "qt-system-tray", systrayBox );
596             CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
597                                                       notificationCombo );
598             CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
599             ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
600
601             CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
602             CONFIG_BOOL( "playlist-tree", treePlaylist );
603             CONFIG_BOOL( "play-and-pause", playPauseBox );
604             CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
605                                  ui.fileSkin, ui.skinBrowse );
606
607             CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
608                                                       artFetcher );
609
610             /* UPDATE options */
611 #ifdef UPDATE_CHECK
612             CONFIG_BOOL( "qt-updates-notif", updatesBox );
613             CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
614                     updatesDays );
615             ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
616             CONNECT( ui.updatesBox, toggled( bool ),
617                      ui.updatesDays, setEnabled( bool ) );
618 #else
619             ui.updateNotifierZone->hide();
620 #endif
621             /* ONE INSTANCE options */
622 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
623             CONFIG_BOOL( "one-instance", OneInterfaceMode );
624             CONFIG_BOOL( "playlist-enqueue",
625                     EnqueueOneInterfaceMode );
626             ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
627             CONNECT( ui.OneInterfaceMode, toggled( bool ),
628                      ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
629 #else
630             ui.OneInterfaceBox->hide();
631 #endif
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("Subtitles & 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_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
650                             encoding );
651             CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
652                             preferredLanguage );
653
654             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
655                             ui.fontSizeLabel, fontSize );
656
657             CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
658             CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
659                             fontColor );
660             CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
661                             ui.fontEffectLabel, effect );
662             CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
663                             outlineColor );
664
665             CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
666
667             ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
668             ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
669             optionWidgets.append( ui.shadowCheck );
670             optionWidgets.append( ui.backgroundCheck );
671
672         END_SPREFS_CAT;
673
674         case SPrefsHotkeys:
675         {
676             p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
677
678             QGridLayout *gLayout = new QGridLayout;
679             panel->setLayout( gLayout );
680             int line = 0;
681
682             panel_label->setText( qtr( "Configure Hotkeys" ) );
683             control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
684             control->insertIntoExistingGrid( gLayout, line );
685             controls.append( control );
686
687             line++;
688
689             QFrame *sepline = new QFrame;
690             sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
691             gLayout->addWidget( sepline, line, 0, 1, -1 );
692
693             line++;
694
695             p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
696             control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
697                     p_config, this, false );
698             control->insertIntoExistingGrid( gLayout, line );
699             controls.append( control );
700
701 #ifdef WIN32
702             line++;
703
704             p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
705             control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
706             control->insertIntoExistingGrid( gLayout, line );
707             controls.append( control );
708 #endif
709
710             break;
711         }
712     }
713
714     panel_layout->addWidget( panel_label );
715     panel_layout->addWidget( title_line );
716
717     if( small )
718     {
719         QScrollArea *scroller= new QScrollArea;
720         scroller->setWidget( panel );
721         scroller->setWidgetResizable( true );
722         scroller->setFrameStyle( QFrame::NoFrame );
723         panel_layout->addWidget( scroller );
724     }
725     else
726     {
727         panel_layout->addWidget( panel );
728         if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
729     }
730
731     setLayout( panel_layout );
732
733 #undef END_SPREFS_CAT
734 #undef START_SPREFS_CAT
735 #undef CONFIG_GENERIC_FILE
736 #undef CONFIG_GENERIC_NO_BOOL
737 #undef CONFIG_GENERIC_NO_UI
738 #undef CONFIG_GENERIC
739 #undef CONFIG_BOOL
740 }
741
742
743 void SPrefsPanel::updateAudioOptions( int number)
744 {
745     QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
746                                             ->itemData( number ).toString();
747 #ifdef WIN32
748     optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
749 #elif defined( __OS2__ )
750     optionWidgets[kaiW]->setVisible( ( value == "kai" ) );
751 #else
752     /* optionWidgets[ossW] can be NULL */
753     if( optionWidgets[ossW] )
754         optionWidgets[ossW]->setVisible( ( value == "oss" ) );
755     /* optionWidgets[alsaW] can be NULL */
756     if( optionWidgets[alsaW] )
757         optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
758 #endif
759     optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
760     optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
761                                            value == "aout_directx" || value == "waveout" ) );
762 }
763
764
765 SPrefsPanel::~SPrefsPanel()
766 {
767     qDeleteAll( controls ); controls.clear();
768 }
769
770 void SPrefsPanel::updateAudioVolume( int volume )
771 {
772     qobject_cast<QSpinBox *>(optionWidgets[volLW])
773         ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
774 }
775
776
777 /* Function called from the main Preferences dialog on each SPrefs Panel */
778 void SPrefsPanel::apply()
779 {
780     /* Generic save for ever panel */
781     QList<ConfigControl *>::const_iterator i;
782     for( i = controls.begin() ; i != controls.end() ; ++i )
783     {
784         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
785         c->doApply();
786     }
787
788     switch( number )
789     {
790     case SPrefsInputAndCodecs:
791     {
792         /* Device default selection */
793         QByteArray devicepath =
794             qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
795         if( devicepath.size() > 0 )
796         {
797             config_PutPsz( p_intf, "dvd", devicepath );
798             config_PutPsz( p_intf, "vcd", devicepath );
799             config_PutPsz( p_intf, "cd-audio", devicepath );
800         }
801
802 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
803         /* Caching */
804         QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
805         int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
806         if( i_comboValue )
807         {
808             CaC( "file-caching", 1 );
809             CaC( "network-caching", 10/3 );
810             CaC( "disc-caching", 1 );
811             CaC( "live-caching", 1 );
812         }
813         break;
814 #undef CaC
815     }
816
817     /* Interfaces */
818     case SPrefsInterface:
819     {
820         if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
821             config_PutPsz( p_intf, "intf", "skins2,any" );
822         else
823         //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
824             config_PutPsz( p_intf, "intf", "" );
825         if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
826             getSettings()->setValue( "MainWindow/QtStyle",
827                 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
828
829         break;
830     }
831
832     case SPrefsAudio:
833     {
834         bool b_checked =
835             qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
836         if( b_checked && !qs_filter.contains( "normvol" ) )
837             qs_filter.append( "normvol" );
838         if( !b_checked && qs_filter.contains( "normvol" ) )
839             qs_filter.removeAll( "normvol" );
840
841         b_checked =
842             qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
843
844         if( b_checked && !qs_filter.contains( "headphone" ) )
845             qs_filter.append( "headphone" );
846         if( !b_checked && qs_filter.contains( "headphone" ) )
847             qs_filter.removeAll( "headphone" );
848
849         config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
850         break;
851     }
852     case SPrefsSubtitles:
853     {
854         bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
855         if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
856             config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
857         }
858         else if (!b_checked ) {
859             config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
860         }
861
862         b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
863         if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
864             config_PutInt( p_intf, "freetype-background-opacity", 128 );
865         }
866         else if (!b_checked ) {
867             config_PutInt( p_intf, "freetype-background-opacity", 0 );
868         }
869
870     }
871     }
872 }
873
874 void SPrefsPanel::clean()
875 {}
876
877 void SPrefsPanel::lastfm_Changed( int i_state )
878 {
879     if( i_state == Qt::Checked )
880         config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
881     else if( i_state == Qt::Unchecked )
882         config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
883 }
884
885 void SPrefsPanel::changeStyle( QString s_style )
886 {
887     QApplication::setStyle( s_style );
888
889     /* force refresh on all widgets */
890     QWidgetList widgets = QApplication::allWidgets();
891     QWidgetList::iterator it = widgets.begin();
892     while( it != widgets.end() ) {
893         (*it)->update();
894         ++it;
895     };
896 }
897
898 void SPrefsPanel::configML()
899 {
900 #ifdef MEDIA_LIBRARY
901     MLConfDialog *mld = new MLConfDialog( this, p_intf );
902     mld->exec();
903     delete mld;
904 #endif
905 }
906
907 #ifdef WIN32
908 #include <QDialogButtonBox>
909 #include "util/registry.hpp"
910
911 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
912                            QTreeWidgetItem* parent, QVLCRegistry *qvReg )
913 {
914     bool b_temp;
915     const char* psz_VLC = "VLC";
916     current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
917
918     if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
919     {
920         current->setCheckState( 0, Qt::Checked );
921         b_temp = false;
922     }
923     else
924     {
925         current->setCheckState( 0, Qt::Unchecked );
926         b_temp = true;
927     }
928     listAsso.append( current );
929     return b_temp;
930 }
931
932 void SPrefsPanel::assoDialog()
933 {
934     IApplicationAssociationRegistrationUI *p_appassoc;
935     CoInitialize( 0 );
936
937     if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
938                 NULL, CLSCTX_INPROC_SERVER,
939                 IID_IApplicationAssociationRegistrationUI,
940                 (void **)&p_appassoc) )
941     {
942         if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
943         {
944             CoUninitialize();
945             return;
946         }
947     }
948
949     CoUninitialize();
950
951     QDialog *d = new QDialog( this );
952     d->setWindowTitle( qtr( "File associations" ) );
953     QGridLayout *assoLayout = new QGridLayout( d );
954
955     QTreeWidget *filetypeList = new QTreeWidget;
956     assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
957     filetypeList->header()->hide();
958
959     QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
960
961     QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
962     QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
963     QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
964
965     filetypeList->addTopLevelItem( audioType );
966     filetypeList->addTopLevelItem( videoType );
967     filetypeList->addTopLevelItem( otherType );
968
969     audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
970     videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
971     otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
972
973     QTreeWidgetItem *currentItem = NULL;
974
975     int i_temp = 0;
976 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
977 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
978 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
979
980     aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
981     aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
982     aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".spx" );
983     aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
984     audioType->setCheckState( 0, ( i_temp > 0 ) ?
985                               ( ( i_temp == audioType->childCount() ) ?
986                                Qt::Checked : Qt::PartiallyChecked )
987                             : Qt::Unchecked );
988
989     i_temp = 0;
990     aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
991     aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
992     aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
993     aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
994     aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
995     aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" );  aTv( ".ts" );
996     aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
997     videoType->setCheckState( 0, ( i_temp > 0 ) ?
998                               ( ( i_temp == audioType->childCount() ) ?
999                                Qt::Checked : Qt::PartiallyChecked )
1000                             : Qt::Unchecked );
1001
1002     i_temp = 0;
1003     aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1004     aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1005     otherType->setCheckState( 0, ( i_temp > 0 ) ?
1006                               ( ( i_temp == audioType->childCount() ) ?
1007                                Qt::Checked : Qt::PartiallyChecked )
1008                             : Qt::Unchecked );
1009
1010 #undef aTo
1011 #undef aTv
1012 #undef aTa
1013
1014     QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1015     QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1016     QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1017     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1018     buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1019
1020     assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1021
1022     CONNECT( closeButton, clicked(), this, saveAsso() );
1023     CONNECT( clearButton, clicked(), d, reject() );
1024     d->resize( 300, 400 );
1025     d->exec();
1026     delete d;
1027     delete qvReg;
1028     listAsso.clear();
1029 }
1030
1031 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1032 {
1033     QString s_path( "VLC" ); s_path += psz_ext;
1034     QString s_path2 = s_path;
1035
1036     /* Save a backup if already assigned */
1037     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
1038
1039     if( !EMPTY_STR(psz_value) )
1040         qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1041     delete psz_value;
1042
1043     /* Put a "link" to VLC.EXT as default */
1044     qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1045
1046     /* Create the needed Key if they weren't done in the installer */
1047     if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1048     {
1049         qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1050         qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1051         qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1052
1053         /* Get the installer path */
1054         QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1055         QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1056
1057         if( str_temp.size() )
1058         {
1059             qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1060                 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1061
1062             qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1063                         "", qtu( str_temp.append(",0") ) );
1064         }
1065         delete qvReg2;
1066     }
1067 }
1068
1069 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1070 {
1071     char psz_VLC[] = "VLC";
1072     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1073
1074     if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1075     {
1076         free( psz_value );
1077         psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1078         if( psz_value )
1079             qvReg->WriteRegistryString( psz_ext, "", psz_value );
1080
1081         qvReg->DeleteKey( psz_ext, "VLC.backup" );
1082     }
1083     delete( psz_value );
1084 }
1085 void SPrefsPanel::saveAsso()
1086 {
1087     QVLCRegistry * qvReg = NULL;
1088     for( int i = 0; i < listAsso.size(); i ++ )
1089     {
1090         qvReg  = new QVLCRegistry( HKEY_CLASSES_ROOT );
1091         if( listAsso[i]->checkState( 0 ) > 0 )
1092         {
1093             addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1094         }
1095         else
1096         {
1097             delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1098         }
1099     }
1100     /* Gruik ? Naaah */
1101     qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();
1102     delete qvReg;
1103 }
1104
1105 #endif /* WIN32 */
1106