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