]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/simple_preferences.cpp
Qt4 - Dialog implementation for registering the file association on Windows.
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
1 /*****************************************************************************
2  * simple_preferences.cpp : "Simple preferences"
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id: preferences.cpp 16348 2006-08-25 21:10:10Z zorglub $
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 #include "components/simple_preferences.hpp"
27 #include "components/preferences_widgets.hpp"
28
29 #include <vlc_config_cat.h>
30 #include <vlc_configuration.h>
31
32 #include <QString>
33 #include <QFont>
34 #include <QToolButton>
35 #include <QButtonGroup>
36 #include <QUrl>
37 #include <QVBoxLayout>
38
39 #define ICON_HEIGHT 64
40 #define BUTTON_HEIGHT 74
41
42 /*********************************************************************
43  * The List of categories
44  *********************************************************************/
45 SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
46                                   QWidget( _parent ), p_intf( _p_intf )
47 {
48     QVBoxLayout *layout = new QVBoxLayout();
49
50     QButtonGroup *buttonGroup = new QButtonGroup( this );
51     buttonGroup->setExclusive ( true );
52     CONNECT( buttonGroup, buttonClicked ( int ),
53             this, switchPanel( int ) );
54
55 #define ADD_CATEGORY( button, label, icon, numb )                           \
56     QToolButton * button = new QToolButton( this );                         \
57     button->setIcon( QIcon( ":/pixmaps/" #icon ) );                         \
58     button->setIconSize( QSize( ICON_HEIGHT , ICON_HEIGHT ) );              \
59     button->setText( label );                                               \
60     button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );              \
61     button->resize( BUTTON_HEIGHT , BUTTON_HEIGHT);                         \
62     button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding) ;  \
63     button->setAutoRaise( true );                                           \
64     button->setCheckable( true );                                           \
65     buttonGroup->addButton( button, numb );                                 \
66     layout->addWidget( button );
67
68     ADD_CATEGORY( SPrefsInterface, qtr("Interface"),
69                   spref_cone_Interface_64.png, 0 );
70     ADD_CATEGORY( SPrefsAudio, qtr("Audio"), spref_cone_Audio_64.png, 1 );
71     ADD_CATEGORY( SPrefsVideo, qtr("Video"), spref_cone_Video_64.png, 2 );
72     ADD_CATEGORY( SPrefsSubtitles, qtr("Subtitles"),
73                   spref_cone_Subtitles_64.png, 3 );
74     ADD_CATEGORY( SPrefsInputAndCodecs, qtr("Input and Codecs"),
75                   spref_cone_Input_64.png, 4 );
76     ADD_CATEGORY( SPrefsHotkeys, qtr("Hotkeys"), spref_cone_Hotkeys_64.png, 5 );
77
78     SPrefsInterface->setChecked( true );
79     layout->setMargin( 0 );
80     layout->setSpacing( 1 );
81
82     this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
83     setLayout( layout );
84
85 }
86
87 void SPrefsCatList::switchPanel( int i )
88 {
89     emit currentItemChanged( i );
90 }
91
92 /*********************************************************************
93  * The Panels
94  *********************************************************************/
95 SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
96                           int _number ) : QWidget( _parent ), p_intf( _p_intf )
97 {
98     module_config_t *p_config;
99     ConfigControl *control;
100     number = _number;
101
102 #define CONFIG_GENERIC( option, type, label, qcontrol )                   \
103             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
104             if( p_config )                                                \
105             {                                                             \
106                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
107                            p_config, label, ui.qcontrol, false );         \
108                 controls.append( control );                               \
109             }
110
111 #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol )           \
112             p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
113             if( p_config )                                                \
114             {                                                             \
115                 control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
116                            p_config, label, ui.qcontrol );                \
117                 controls.append( control );                               \
118             }
119
120 #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton )         \
121                 p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
122                 if( p_config )                                                \
123                 {                                                             \
124                     control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
125                                p_config, label, ui.qcontrol, ui.qbutton,      \
126                             false );                                          \
127                     controls.append( control );                               \
128                 }
129
130 #define START_SPREFS_CAT( name , label )    \
131         case SPrefs ## name:                \
132         {                                   \
133             Ui::SPrefs ## name ui;      \
134             ui.setupUi( panel );            \
135             panel_label->setText( label );
136
137 #define END_SPREFS_CAT      \
138             break;          \
139         }
140
141     QVBoxLayout *panel_layout = new QVBoxLayout();
142     QWidget *panel = new QWidget();
143     panel_layout->setMargin( 3 );
144
145     // Title Label
146     QLabel *panel_label = new QLabel;
147     QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
148     labelFont.setPointSize( labelFont.pointSize() + 6 );
149     labelFont.setFamily( "Verdana" );
150     panel_label->setFont( labelFont );
151
152     // Title <hr>
153     QFrame *title_line = new QFrame;
154     title_line->setFrameShape(QFrame::HLine);
155     title_line->setFrameShadow(QFrame::Sunken);
156
157     QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
158     italicFont.setItalic( true );
159
160     switch( number )
161     {
162         /******************************
163          * VIDEO Panel Implementation *
164          ******************************/
165         START_SPREFS_CAT( Video , qtr("General video settings") );
166             CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
167
168             CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
169             CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
170             CONFIG_GENERIC( "video-on-top", Bool, NULL, alwaysOnTop );
171             CONFIG_GENERIC( "video-deco", Bool, NULL, windowDecorations );
172             CONFIG_GENERIC( "skip-frames" , Bool, NULL, skipFrames );
173             CONFIG_GENERIC( "vout", Module, NULL, outputModule );
174
175 #ifdef WIN32
176             CONFIG_GENERIC( "directx-wallpaper" , Bool , NULL, wallpaperMode );
177             CONFIG_GENERIC( "directx-device", StringList, NULL,
178                             dXdisplayDevice );
179 #else
180             ui.directXBox->setVisible( false );
181 #endif
182
183             CONFIG_GENERIC_FILE( "snapshot-path", Directory, NULL,
184                                  snapshotsDirectory, snapshotsDirectoryBrowse );
185             CONFIG_GENERIC( "snapshot-prefix", String, NULL, snapshotsPrefix );
186             CONFIG_GENERIC( "snapshot-sequential", Bool, NULL,
187                             snapshotsSequentialNumbering );
188             CONFIG_GENERIC( "snapshot-format", StringList, NULL,
189                             snapshotsFormat );
190          END_SPREFS_CAT;
191
192         /******************************
193          * AUDIO Panel Implementation *
194          ******************************/
195         START_SPREFS_CAT( Audio, qtr("General audio settings") );
196
197             CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
198
199             /* hide if necessary */
200 #ifdef WIN32
201             ui.OSSControl->hide();
202             ui.alsaControl->hide();
203 #else
204             ui.DirectXControl->hide();
205 #endif
206             ui.lastfm_user_edit->hide();
207             ui.lastfm_user_label->hide();
208             ui.lastfm_pass_edit->hide();
209             ui.lastfm_pass_label->hide();
210
211             /* General Audio Options */
212             CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
213                                      defaultVolume );
214             CONFIG_GENERIC( "audio-language" , String , NULL,
215                             preferredAudioLanguage );
216
217             CONFIG_GENERIC( "spdif", Bool, NULL, spdifBox );
218             CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
219                             detectionDolby );
220
221             CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
222
223             CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
224                                     volNormSpin );
225             CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
226
227             /* Audio Output Specifics */
228             CONFIG_GENERIC( "aout", Module, NULL, outputModule );
229
230             CONNECT( ui.outputModule, currentIndexChanged( int ),
231                      this, updateAudioOptions( int ) );
232
233 #ifndef WIN32
234             if( module_Exists( p_intf, "alsa" ) )
235             {
236                 CONFIG_GENERIC( "alsadev" , StringList , ui.alsaLabel,
237                                 alsaDevice );
238             }
239             if( module_Exists( p_intf, "oss" ) )
240             {
241                 CONFIG_GENERIC_FILE( "dspdev" , File , ui.OSSLabel, OSSDevice,
242                                  OSSBrowse );
243             }
244 #else
245             CONFIG_GENERIC( "directx-audio-device", IntegerList,
246                     ui.DirectXLabel, DirectXDevice );
247 #endif
248         // File exists everywhere
249             CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
250                                  fileName, fileBrowseButton );
251
252             optionWidgets.append( ui.alsaControl );
253             optionWidgets.append( ui.OSSControl );
254             optionWidgets.append( ui.DirectXControl );
255             optionWidgets.append( ui.fileControl );
256             optionWidgets.append( ui.outputModule );
257             optionWidgets.append( ui.volNormBox );
258             updateAudioOptions( ui.outputModule->currentIndex() );
259
260             /* LastFM */
261             if( module_Exists( p_intf, "audioscrobbler" ) )
262             {
263                 CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
264                         lastfm_user_edit );
265                 CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
266                         lastfm_pass_edit );
267
268                 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
269                     ui.lastfm->setChecked( true );
270                 else
271                     ui.lastfm->setChecked( false );
272                 CONNECT( ui.lastfm, stateChanged( int ), this ,
273                         lastfm_Changed( int ) );
274             }
275             else
276                 ui.lastfm->hide();
277
278             /* Normalizer */
279
280             CONNECT( ui.volNormBox, toggled( bool ), ui.volNormSpin,
281                      setEnabled( bool ) );
282             qs_filter = qfu( config_GetPsz( p_intf, "audio-filter" ) );
283             bool b_normalizer = ( qs_filter.contains( "volnorm" ) );
284             {
285                 ui.volNormBox->setChecked( b_normalizer );
286                 ui.volNormSpin->setEnabled( b_normalizer );
287             }
288
289         END_SPREFS_CAT;
290
291         /* Input and Codecs Panel Implementation */
292         START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs settings") );
293
294             /* Disk Devices */
295             {
296                 ui.DVDDevice->setToolTip(
297                     //TODO: make this sentence understandable
298                     qtr( "If this property is blank, then you have\n"
299                          "values for DVD, VCD, and CDDA.\n"
300                          "You can define a unique one or set that in"
301                          "the advanced preferences" ) );
302                 char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
303                 char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
304                 char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
305                 if( psz_dvddiscpath && psz_vcddiscpath && psz_cddadiscpath )
306                 if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
307                     !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
308                 {
309                     ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
310                 }
311                 delete psz_cddadiscpath; delete psz_dvddiscpath;
312                 delete psz_vcddiscpath;
313             }
314
315             CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
316             CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
317             CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, NULL, PostProcLevel );
318             CONFIG_GENERIC( "avi-index", IntegerList, NULL, AviRepair );
319             CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
320 #ifdef WIN32
321             CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
322 #else
323             ui.systemCodecBox->hide();
324 #endif
325             /* Access Filters */
326             qs_filter = qfu( config_GetPsz( p_intf, "access-filter" ) );
327             ui.timeshiftBox->setChecked( qs_filter.contains( "timeshift" ) );
328             ui.dumpBox->setChecked( qs_filter.contains( "dump" ) );
329             ui.recordBox->setChecked( qs_filter.contains( "record" ) );
330             ui.bandwidthBox->setChecked( qs_filter.contains( "bandwidth" ) );
331
332             optionWidgets.append( ui.recordBox );
333             optionWidgets.append( ui.dumpBox );
334             optionWidgets.append( ui.bandwidthBox );
335             optionWidgets.append( ui.timeshiftBox );
336             optionWidgets.append( ui.DVDDevice );
337             optionWidgets.append( ui.cachingCombo );
338
339             /* Caching */
340             /* Add the things to the ComboBox */
341             #define addToCachingBox( str, cachingNumber ) \
342                 ui.cachingCombo->addItem( str, QVariant( cachingNumber ) );
343             addToCachingBox( "Custom", CachingCustom );
344             addToCachingBox( "Lowest latency", CachingLowest );
345             addToCachingBox( "Low latency", CachingLow );
346             addToCachingBox( "Normal", CachingNormal );
347             addToCachingBox( "High latency", CachingHigh );
348             addToCachingBox( "Higher latency", CachingHigher );
349
350 #define TestCaC( name ) \
351     b_cache_equal =  b_cache_equal && \
352      ( i_cache == config_GetInt( p_intf, name ) )
353
354 #define TestCaCi( name, int ) \
355     b_cache_equal = b_cache_equal &&  \
356     ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
357             /* Select the accurate value of the ComboBox */
358             bool b_cache_equal = true;
359             int i_cache = config_GetInt( p_intf, "file-caching");
360
361             TestCaC( "udp-caching" );
362             if (module_Exists (p_intf, "dvdread"))
363                 TestCaC( "dvdread-caching" );
364             if (module_Exists (p_intf, "dvdnav"))
365                 TestCaC( "dvdnav-caching" );
366             TestCaC( "tcp-caching" );
367             TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
368             TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
369             #ifdef WIN32
370             TestCaC( "dshow-caching" );
371             #else
372             if (module_Exists (p_intf, "v4l"))
373                 TestCaC( "v4l-caching" );
374             if (module_Exists (p_intf, "access_jack"))
375                 TestCaC( "jack-input-caching" );
376             if (module_Exists (p_intf, "v4l2"))
377                 TestCaC( "v4l2-caching" );
378             if (module_Exists (p_intf, "pvr"))
379                 TestCaC( "pvr-caching" );
380             #endif
381             TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
382             TestCaCi( "http-caching", 4 );
383             if (module_Exists (p_intf, "access_realrtsp"))
384                 TestCaCi( "realrtsp-caching", 10 );
385             TestCaCi( "mms-caching", 19 );
386             if( b_cache_equal ) ui.cachingCombo->setCurrentIndex(
387                 ui.cachingCombo->findData( QVariant( i_cache ) ) );
388
389         END_SPREFS_CAT;
390         /*******************
391          * Interface Panel *
392          *******************/
393         START_SPREFS_CAT( Interface, qtr("Interface settings") );
394             ui.defaultLabel->setFont( italicFont );
395             ui.skinsLabel->setFont( italicFont );
396
397 #if defined( WIN32 ) || defined (__APPLE__)
398             CONFIG_GENERIC( "language", StringList, NULL, language );
399             BUTTONACT( ui.assoButton, assoDialog );
400 #else
401             ui.language->hide();
402             ui.languageLabel->hide();
403             ui.assoName->hide();
404             ui.assoButton->hide();
405 #endif
406             BUTTONACT( ui.assoButton, assoDialog() );
407
408             /* interface */
409             char *psz_intf = config_GetPsz( p_intf, "intf" );
410             if( psz_intf )
411             {
412                 msg_Dbg( p_intf, "Interface in config file: %s", psz_intf );
413                 if( strstr( psz_intf, "skin" ) )
414                     ui.skins->setChecked( true );
415                 else if( strstr( psz_intf, "qt" ) )
416                     ui.qt4->setChecked( true );
417             }
418             delete psz_intf;
419
420             optionWidgets.append( ui.skins );
421             optionWidgets.append( ui.qt4 );
422
423             CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel, artFetcher );
424             CONFIG_GENERIC( "fetch-meta", Bool, NULL, metaFetcher );
425 #ifdef UPDATE_CHECK
426             CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, qtUpdates );
427 #endif
428             CONFIG_GENERIC( "qt-always-video", Bool, NULL, qtAlwaysVideo );
429             CONFIG_GENERIC( "embeded-video", Bool, NULL, embedVideo );
430             CONFIG_GENERIC_FILE( "skins2-last", File, NULL, fileSkin,
431                     skinBrowse );
432 #if defined( WIN32 ) || defined( HAVE_DBUS_3 )
433             CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
434             CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
435                     EnqueueOneInterfaceMode );
436 #else
437             ui.OneInterfaceBox->hide();
438 #endif
439         END_SPREFS_CAT;
440
441         START_SPREFS_CAT( Subtitles, qtr("Subtitles & OSD settings") );
442             CONFIG_GENERIC( "osd", Bool, NULL, OSDBox);
443
444             CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
445             CONFIG_GENERIC( "sub-language", String, NULL, preferredLanguage );
446             CONFIG_GENERIC_FILE( "freetype-font", File, NULL, font,
447                             fontBrowse );
448             CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
449             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
450                             fontSize );
451             CONFIG_GENERIC( "freetype-effect", IntegerList, NULL, effect );
452
453         END_SPREFS_CAT;
454
455         case SPrefsHotkeys:
456         {
457             p_config = config_FindConfig( VLC_OBJECT(p_intf), "key-fullscreen" );
458
459             QGridLayout *gLayout = new QGridLayout;
460             panel->setLayout( gLayout );
461             int line = 0;
462
463             control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
464                                                 this, gLayout, line );
465
466             panel_label->setText( qtr( "Configure Hotkeys" ) );
467             controls.append( control );
468
469             break;
470         }
471     }
472
473     panel_layout->addWidget( panel_label );
474     panel_layout->addWidget( title_line );
475     panel_layout->addWidget( panel );
476     if( number != SPrefsHotkeys ) panel_layout->addStretch( 2 );
477
478     setLayout( panel_layout );
479 }
480
481 void SPrefsPanel::updateAudioOptions( int number)
482 {
483     QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB])
484                                             ->itemData( number ).toString();
485
486 #ifndef WIN32
487     optionWidgets[ossW]->setVisible( ( value == "oss" ) );
488     optionWidgets[alsaW]->setVisible( ( value == "alsa" ) );
489 #else
490     optionWidgets[directxW]->setVisible( ( value == "directx" ) );
491 #endif
492     optionWidgets[fileW]->setVisible( ( value == "aout_file" ) );
493 }
494
495 /* Function called from the main Preferences dialog on each SPrefs Panel */
496 void SPrefsPanel::apply()
497 {
498     msg_Dbg( p_intf, "Trying to save the %i simple panel", number );
499
500     /* Generic save for ever panel */
501     QList<ConfigControl *>::Iterator i;
502     for( i = controls.begin() ; i != controls.end() ; i++ )
503     {
504         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
505         c->doApply( p_intf );
506     }
507
508     switch( number )
509     {
510     case SPrefsInputAndCodecs:
511     {
512         /* Device default selection */
513         char *psz_devicepath =
514               qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
515         if( !EMPTY_STR( psz_devicepath ) )
516         {
517             config_PutPsz( p_intf, "dvd", psz_devicepath );
518             config_PutPsz( p_intf, "vcd", psz_devicepath );
519             config_PutPsz( p_intf, "cd-audio", psz_devicepath );
520         }
521
522         /* Access filters */
523 #define saveBox( name, box ) {\
524         if( box->isChecked() ) { \
525             if( b_first ) { \
526                 qs_filter.append( name ); \
527                 b_first = false; \
528             } \
529             else qs_filter.append( ":" ).append( name ); \
530         } }
531
532         bool b_first = true;
533         qs_filter.clear();
534         saveBox( "record", qobject_cast<QCheckBox *>(optionWidgets[recordChB]) );
535         saveBox( "dump", qobject_cast<QCheckBox *>(optionWidgets[dumpChB]) );
536         saveBox( "timeshift", qobject_cast<QCheckBox *>(optionWidgets[timeshiftChB]) );
537         saveBox( "bandwidth", qobject_cast<QCheckBox *>(optionWidgets[bandwidthChB] ) );
538         config_PutPsz( p_intf, "access-filter", qtu( qs_filter ) );
539
540 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
541 #define CaC( name ) CaCi( name, 1 )
542         /* Caching */
543         QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
544         int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
545         if( i_comboValue )
546         {
547             msg_Dbg( p_intf, "Adjusting all cache values at: %i", i_comboValue );
548             CaC( "udp-caching" );
549             if (module_Exists (p_intf, "dvdread"))
550                 CaC( "dvdread-caching" );
551             if (module_Exists (p_intf, "dvdnav"))
552                 CaC( "dvdnav-caching" );
553             CaC( "tcp-caching" ); CaC( "vcd-caching" );
554             CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
555             CaC( "screen-caching" );
556             CaCi( "rtsp-caching", 4 ); CaCi( "ftp-caching", 2 );
557             CaCi( "http-caching", 4 );
558             if (module_Exists (p_intf, "access_realrtsp"))
559                 CaCi( "realrtsp-caching", 10 );
560             CaCi( "mms-caching", 19 );
561             #ifdef WIN32
562             CaC( "dshow-caching" );
563             #else
564             if (module_Exists (p_intf, "v4l"))
565                 CaC( "v4l-caching" );
566             if (module_Exists (p_intf, "access_jack"))
567             CaC( "jack-input-caching" );
568             if (module_Exists (p_intf, "v4l2"))
569                 CaC( "v4l2-caching" );
570             if (module_Exists (p_intf, "pvr"))
571                 CaC( "pvr-caching" );
572             #endif
573             //CaCi( "dv-caching" ) too short...
574         }
575         break;
576     }
577
578     /* Interfaces */
579     case SPrefsInterface:
580     {
581         if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() )
582             config_PutPsz( p_intf, "intf", "skins2" );
583         if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
584             config_PutPsz( p_intf, "intf", "qt4" );
585         break;
586     }
587
588     case SPrefsAudio:
589     {
590         bool b_normChecked =
591             qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
592         if( qs_filter.isEmpty() )
593         {
594             /* the psz_filter is already empty, so we just append it needed */
595             if( b_normChecked ) qs_filter = "volnorm";
596         }
597         else /* Not Empty */
598         {
599             if( qs_filter.contains( "volnorm" ) )
600             {
601                 /* The qs_filter not empty and contains "volnorm"
602                    that we have to remove */
603                 if( !b_normChecked )
604                 {
605                     /* Ugly :D */
606                     qs_filter.remove( "volnorm:" );
607                     qs_filter.remove( ":volnorm" );
608                     qs_filter.remove( "volnorm" );
609                 }
610             }
611             else /* qs_filter not empty, but doesn't have volnorm inside */
612                 if( b_normChecked ) qs_filter.append( ":volnorm" );
613         }
614         config_PutPsz( p_intf, "audio-filter", qtu( qs_filter ) );
615         break;
616     }
617     }
618 }
619
620 void SPrefsPanel::clean()
621 {}
622
623 void SPrefsPanel::lastfm_Changed( int i_state )
624 {
625     if( i_state == Qt::Checked )
626         config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
627     else if( i_state == Qt::Unchecked )
628         config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
629 }
630
631 #ifdef WIN32
632
633 #include <QListWidget>
634 #include <QDialogButtonBox>
635 #include "util/registry.hpp"
636
637 void SPrefsPanel::assoDialog()
638 {
639     QDialog *d = new QDialog( this );
640     QGridLayout *assoLayout = new QGridLayout( d );
641
642     QListWidget *filetypeList = new QListWidget;
643     assoLayout->addWidget( filetypeList, 0, 0, 1, 4 );
644
645     QListWidgetItem *currentItem;
646
647 #define addType( ext ) \
648     currentItem = new QListWidgetItem( ext, filetypeList ); \
649     currentItem->setCheckState( Qt::Checked ); \
650     listAsso.append( currentItem );
651
652     addType( ".avi" );
653
654     QDialogButtonBox *buttonBox = new QDialogButtonBox( d );
655     QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) );
656     QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) );
657     buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
658     buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
659
660     assoLayout->addWidget( buttonBox, 1, 2, 1, 2 );
661
662     CONNECT( closeButton, clicked(), this, saveAsso() );
663     CONNECT( clearButton, clicked(), d, reject() );
664     d->exec();
665     delete d;
666 }
667
668 void addAsso( char *psz_ext )
669 {
670
671 }
672
673 void delAsso( char *psz_ext )
674 {
675
676 }
677 void SPrefsPanel::saveAsso()
678 {
679     for( int i = 0; i < listAsso.size(); i ++ )
680     {
681         if( listAsso[i]->checkState() > 0 )
682         {
683             addAsso( qtu( listAsso[i]->text() ) );
684         }
685         else
686         {
687             delAsso( qtu( listAsso[i]->text() ) );
688         }
689     }
690     /* Gruik ? Naaah */
691     qobject_cast<QDialog *>(listAsso[0]->listWidget()->parent())->accept();
692 }
693
694 #endif /* WIN32 */
695