]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
Opus decoder.
[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( HAVE_DBUS ) || defined(__APPLE__)
622             CONFIG_BOOL( "one-instance", OneInterfaceMode );
623             CONFIG_BOOL( "playlist-enqueue",
624                     EnqueueOneInterfaceMode );
625             ui.EnqueueOneInterfaceMode->setEnabled( ui.OneInterfaceMode->isChecked() );
626             CONNECT( ui.OneInterfaceMode, toggled( bool ),
627                      ui.EnqueueOneInterfaceMode, setEnabled( bool ) );
628 #else
629             ui.OneInterfaceBox->hide();
630 #endif
631             /* RECENTLY PLAYED options */
632             CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
633                      ui.recentlyPlayedFilters, setEnabled( bool ) );
634             ui.recentlyPlayedFilters->setEnabled( false );
635             CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
636             CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
637                     recentlyPlayedFilters );
638
639         END_SPREFS_CAT;
640
641         START_SPREFS_CAT( Subtitles,
642                             qtr("Subtitles & On Screen Display Settings") );
643             CONFIG_BOOL( "osd", OSDBox);
644             CONFIG_BOOL( "video-title-show", OSDTitleBox);
645             CONFIG_GENERIC( "video-title-position", IntegerList,
646                             ui.OSDTitlePosLabel, OSDTitlePos );
647
648             CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
649                             encoding );
650             CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
651                             preferredLanguage );
652
653             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
654                             ui.fontSizeLabel, fontSize );
655
656             CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
657             CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
658                             fontColor );
659             CONFIG_GENERIC( "freetype-outline-thickness", IntegerList,
660                             ui.fontEffectLabel, effect );
661             CONFIG_GENERIC_NO_BOOL( "freetype-outline-color", Color, ui.outlineColorLabel,
662                             outlineColor );
663
664             CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
665
666             ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
667             ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
668             optionWidgets.append( ui.shadowCheck );
669             optionWidgets.append( ui.backgroundCheck );
670
671         END_SPREFS_CAT;
672
673         case SPrefsHotkeys:
674         {
675             p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-play" );
676
677             QGridLayout *gLayout = new QGridLayout;
678             panel->setLayout( gLayout );
679             int line = 0;
680
681             panel_label->setText( qtr( "Configure Hotkeys" ) );
682             control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
683             control->insertIntoExistingGrid( gLayout, line );
684             controls.append( control );
685
686             line++;
687
688             QFrame *sepline = new QFrame;
689             sepline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
690             gLayout->addWidget( sepline, line, 0, 1, -1 );
691
692             line++;
693
694             p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
695             control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
696                     p_config, this, false );
697             control->insertIntoExistingGrid( gLayout, line );
698             controls.append( control );
699
700 #ifdef WIN32
701             line++;
702
703             p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
704             control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
705             control->insertIntoExistingGrid( gLayout, line );
706             controls.append( control );
707 #endif
708
709             break;
710         }
711     }
712
713     panel_layout->addWidget( panel_label );
714     panel_layout->addWidget( title_line );
715
716     if( small )
717     {
718         QScrollArea *scroller= new QScrollArea;
719         scroller->setWidget( panel );
720         scroller->setWidgetResizable( true );
721         scroller->setFrameStyle( QFrame::NoFrame );
722         panel_layout->addWidget( scroller );
723     }
724     else
725     {
726         panel_layout->addWidget( panel );
727         if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
728     }
729
730     setLayout( panel_layout );
731
732 #undef END_SPREFS_CAT
733 #undef START_SPREFS_CAT
734 #undef CONFIG_GENERIC_FILE
735 #undef CONFIG_GENERIC_NO_BOOL
736 #undef CONFIG_GENERIC_NO_UI
737 #undef CONFIG_GENERIC
738 #undef CONFIG_BOOL
739 }
740
741
742 void SPrefsPanel::updateAudioOptions( int number)
743 {
744     QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
745                                             ->itemData( number ).toString();
746 #ifdef WIN32
747     optionWidgets[directxW]->setVisible( ( value == "directsound" ) );
748 #elif defined( __OS2__ )
749     optionWidgets[kaiW]->setVisible( ( value == "kai" ) );
750 #else
751     /* optionWidgets[ossW] can be NULL */
752     if( optionWidgets[ossW] )
753         optionWidgets[ossW]->setVisible( ( value == "oss" ) );
754     /* optionWidgets[alsaW] can be NULL */
755     if( optionWidgets[alsaW] )
756         optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
757 #endif
758     optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
759     optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
760                                            value == "directsound" || value == "waveout" ) );
761 }
762
763
764 SPrefsPanel::~SPrefsPanel()
765 {
766     qDeleteAll( controls ); controls.clear();
767 }
768
769 void SPrefsPanel::updateAudioVolume( int volume )
770 {
771     qobject_cast<QSpinBox *>(optionWidgets[volLW])
772         ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
773 }
774
775
776 /* Function called from the main Preferences dialog on each SPrefs Panel */
777 void SPrefsPanel::apply()
778 {
779     /* Generic save for ever panel */
780     QList<ConfigControl *>::const_iterator i;
781     for( i = controls.begin() ; i != controls.end() ; ++i )
782     {
783         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
784         c->doApply();
785     }
786
787     switch( number )
788     {
789     case SPrefsInputAndCodecs:
790     {
791         /* Device default selection */
792         QByteArray devicepath =
793             qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
794         if( devicepath.size() > 0 )
795         {
796             config_PutPsz( p_intf, "dvd", devicepath );
797             config_PutPsz( p_intf, "vcd", devicepath );
798             config_PutPsz( p_intf, "cd-audio", devicepath );
799         }
800
801 #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
802         /* Caching */
803         QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
804         int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
805         if( i_comboValue )
806         {
807             CaC( "file-caching", 1 );
808             CaC( "network-caching", 10/3 );
809             CaC( "disc-caching", 1 );
810             CaC( "live-caching", 1 );
811         }
812         break;
813 #undef CaC
814     }
815
816     /* Interfaces */
817     case SPrefsInterface:
818     {
819         if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
820             config_PutPsz( p_intf, "intf", "skins2,any" );
821         else
822         //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
823             config_PutPsz( p_intf, "intf", "" );
824         if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
825             getSettings()->setValue( "MainWindow/QtStyle",
826                 qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
827
828         break;
829     }
830
831     case SPrefsAudio:
832     {
833         bool b_checked =
834             qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
835         if( b_checked && !qs_filter.contains( "normvol" ) )
836             qs_filter.append( "normvol" );
837         if( !b_checked && qs_filter.contains( "normvol" ) )
838             qs_filter.removeAll( "normvol" );
839
840         b_checked =
841             qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
842
843         if( b_checked && !qs_filter.contains( "headphone" ) )
844             qs_filter.append( "headphone" );
845         if( !b_checked && qs_filter.contains( "headphone" ) )
846             qs_filter.removeAll( "headphone" );
847
848         config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
849         break;
850     }
851     case SPrefsSubtitles:
852     {
853         bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
854         if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
855             config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
856         }
857         else if (!b_checked ) {
858             config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
859         }
860
861         b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
862         if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
863             config_PutInt( p_intf, "freetype-background-opacity", 128 );
864         }
865         else if (!b_checked ) {
866             config_PutInt( p_intf, "freetype-background-opacity", 0 );
867         }
868
869     }
870     }
871 }
872
873 void SPrefsPanel::clean()
874 {}
875
876 void SPrefsPanel::lastfm_Changed( int i_state )
877 {
878     if( i_state == Qt::Checked )
879         config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
880     else if( i_state == Qt::Unchecked )
881         config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
882 }
883
884 void SPrefsPanel::changeStyle( QString s_style )
885 {
886     QApplication::setStyle( s_style );
887
888     /* force refresh on all widgets */
889     QWidgetList widgets = QApplication::allWidgets();
890     QWidgetList::iterator it = widgets.begin();
891     while( it != widgets.end() ) {
892         (*it)->update();
893         ++it;
894     };
895 }
896
897 void SPrefsPanel::configML()
898 {
899 #ifdef MEDIA_LIBRARY
900     MLConfDialog *mld = new MLConfDialog( this, p_intf );
901     mld->exec();
902     delete mld;
903 #endif
904 }
905
906 #ifdef WIN32
907 #include <QDialogButtonBox>
908 #include "util/registry.hpp"
909
910 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
911                            QTreeWidgetItem* parent, QVLCRegistry *qvReg )
912 {
913     bool b_temp;
914     const char* psz_VLC = "VLC";
915     current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
916
917     if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
918     {
919         current->setCheckState( 0, Qt::Checked );
920         b_temp = false;
921     }
922     else
923     {
924         current->setCheckState( 0, Qt::Unchecked );
925         b_temp = true;
926     }
927     listAsso.append( current );
928     return b_temp;
929 }
930
931 void SPrefsPanel::assoDialog()
932 {
933     IApplicationAssociationRegistrationUI *p_appassoc;
934     CoInitialize( 0 );
935
936     if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
937                 NULL, CLSCTX_INPROC_SERVER,
938                 IID_IApplicationAssociationRegistrationUI,
939                 (void **)&p_appassoc) )
940     {
941         if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
942         {
943             CoUninitialize();
944             return;
945         }
946     }
947
948     CoUninitialize();
949
950     QDialog *d = new QDialog( this );
951     d->setWindowTitle( qtr( "File associations" ) );
952     QGridLayout *assoLayout = new QGridLayout( d );
953
954     QTreeWidget *filetypeList = new QTreeWidget;
955     assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
956     filetypeList->header()->hide();
957
958     QVLCRegistry * qvReg = new QVLCRegistry( HKEY_CLASSES_ROOT );
959
960     QTreeWidgetItem *audioType = new QTreeWidgetItem( QStringList( qtr( "Audio Files" ) ) );
961     QTreeWidgetItem *videoType = new QTreeWidgetItem( QStringList( qtr( "Video Files" ) ) );
962     QTreeWidgetItem *otherType = new QTreeWidgetItem( QStringList( qtr( "Playlist Files" ) ) );
963
964     filetypeList->addTopLevelItem( audioType );
965     filetypeList->addTopLevelItem( videoType );
966     filetypeList->addTopLevelItem( otherType );
967
968     audioType->setExpanded( true ); audioType->setCheckState( 0, Qt::Unchecked );
969     videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
970     otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
971
972     QTreeWidgetItem *currentItem = NULL;
973
974     int i_temp = 0;
975 #define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
976 #define aTv( name ) i_temp += addType( name, currentItem, videoType, qvReg )
977 #define aTo( name ) i_temp += addType( name, currentItem, otherType, qvReg )
978
979     aTa( ".a52" ); aTa( ".aac" ); aTa( ".ac3" ); aTa( ".dts" ); aTa( ".flac" );
980     aTa( ".m4a" ); aTa( ".m4p" ); aTa( ".mka" ); aTa( ".mod" ); aTa( ".mp1" );
981     aTa( ".mp2" ); aTa( ".mp3" ); aTa( ".oma" ); aTa( ".oga" ); aTa( ".opus" );
982     aTa( ".spx" ); aTa( ".tta" ); aTa( ".wav" ); aTa( ".wma" ); aTa( ".xm" );
983     audioType->setCheckState( 0, ( i_temp > 0 ) ?
984                               ( ( i_temp == audioType->childCount() ) ?
985                                Qt::Checked : Qt::PartiallyChecked )
986                             : Qt::Unchecked );
987
988     i_temp = 0;
989     aTv( ".asf" ); aTv( ".avi" ); aTv( ".divx" ); aTv( ".dv" ); aTv( ".flv" );
990     aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
991     aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
992     aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
993     aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
994     aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" );  aTv( ".ts" );
995     aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
996     videoType->setCheckState( 0, ( i_temp > 0 ) ?
997                               ( ( i_temp == audioType->childCount() ) ?
998                                Qt::Checked : Qt::PartiallyChecked )
999                             : Qt::Unchecked );
1000
1001     i_temp = 0;
1002     aTo( ".asx" ); aTo( ".b4s" ); aTo( ".ifo" ); aTo( ".m3u" ); aTo( ".pls" );
1003     aTo( ".sdp" ); aTo( ".vlc" ); aTo( ".xspf" );
1004     otherType->setCheckState( 0, ( i_temp > 0 ) ?
1005                               ( ( i_temp == audioType->childCount() ) ?
1006                                Qt::Checked : Qt::PartiallyChecked )
1007                             : Qt::Unchecked );
1008
1009 #undef aTo
1010 #undef aTv
1011 #undef aTa
1012
1013     QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
1014     QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
1015     QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
1016     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1017     buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
1018
1019     assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
1020
1021     CONNECT( closeButton, clicked(), this, saveAsso() );
1022     CONNECT( clearButton, clicked(), d, reject() );
1023     d->resize( 300, 400 );
1024     d->exec();
1025     delete d;
1026     delete qvReg;
1027     listAsso.clear();
1028 }
1029
1030 void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
1031 {
1032     QString s_path( "VLC" ); s_path += psz_ext;
1033     QString s_path2 = s_path;
1034
1035     /* Save a backup if already assigned */
1036     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
1037
1038     if( !EMPTY_STR(psz_value) )
1039         qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1040     delete psz_value;
1041
1042     /* Put a "link" to VLC.EXT as default */
1043     qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1044
1045     /* Create the needed Key if they weren't done in the installer */
1046     if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1047     {
1048         qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1049         qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
1050         qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1051
1052         /* Get the installer path */
1053         QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1054         QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1055
1056         if( str_temp.size() )
1057         {
1058             qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
1059                 "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1060
1061             qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
1062                         "", qtu( str_temp.append(",0") ) );
1063         }
1064         delete qvReg2;
1065     }
1066 }
1067
1068 void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1069 {
1070     char psz_VLC[] = "VLC";
1071     char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1072
1073     if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1074     {
1075         free( psz_value );
1076         psz_value = qvReg->ReadRegistryString( psz_ext, "VLC.backup", "" );
1077         if( psz_value )
1078             qvReg->WriteRegistryString( psz_ext, "", psz_value );
1079
1080         qvReg->DeleteKey( psz_ext, "VLC.backup" );
1081     }
1082     delete( psz_value );
1083 }
1084 void SPrefsPanel::saveAsso()
1085 {
1086     QVLCRegistry * qvReg = NULL;
1087     for( int i = 0; i < listAsso.size(); i ++ )
1088     {
1089         qvReg  = new QVLCRegistry( HKEY_CLASSES_ROOT );
1090         if( listAsso[i]->checkState( 0 ) > 0 )
1091         {
1092             addAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1093         }
1094         else
1095         {
1096             delAsso( qvReg, qtu( listAsso[i]->text( 0 ) ) );
1097         }
1098     }
1099     /* Gruik ? Naaah */
1100     qobject_cast<QDialog *>(listAsso[0]->treeWidget()->parent())->accept();
1101     delete qvReg;
1102 }
1103
1104 #endif /* WIN32 */
1105