~nik90/ubuntu/precise/vlc/keywords

« back to all changes in this revision

Viewing changes to modules/gui/qt4/components/simple_preferences.cpp

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2012-02-13 01:34:02 UTC
  • mfrom: (1.1.44)
  • Revision ID: package-import@ubuntu.com-20120213013402-7utx6r7s9dg3r0pf
Tags: 2.0.0~unix-0ubuntu1
* New upstream release (Closes: #499381, #573064, #624027, LP: #455825,
  #573775, #695882, #705151, #708448, #738381, #743581, #747757, #817924,
  #931083).
* Remove dropped mozilla-plugin-vlc, vlc-plugin-ggi, and vlc-plugin-svgalib.
  The Mozilla browser plug-in is now provided by a separate source tarball.
* Add new plugins to and remove dropped plugins from vlc-nox.
* Add new and remove dropped build dependencies:
  + libbluray-dev (for Blu-ray support)
  + libresid-builder-dev
  + libsamplerate0-dev
  + libsidplay2-dev
  + lbspeexdsp-dev
  + libxcb-composite0-dev
  - libgtk2.0-dev
  - xulrunner-dev
* vlc-plugin-fluidsynth depends on fluid-soundfont-gm or
  musescore-soundfont-gm for having a sound font for playing MIDI files.
* Drop all patches (they were either backported or accepted by upstream).
* Update symbols for libvlc5.
* Install plugins.dat instead of running vlc-cache-gen in postinst.
* Update minimum version of build dependencies.
* Change Build-Dependency from libupnp3-dev to unversioned libupnp-dev.
  (Closes: #656831)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 * simple_preferences.cpp : "Simple preferences"
3
3
 ****************************************************************************
4
 
 * Copyright (C) 2006-2008 the VideoLAN team
5
 
 * $Id: 1abba1987896262ce37bc8a88c877c7818936296 $
 
4
 * Copyright (C) 2006-2010 the VideoLAN team
 
5
 * $Id: 9780ff80ede829c3db42baf7006815a3ab1caabe $
6
6
 *
7
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
8
 *          Antoine Cellerier <dionoea@videolan.org>
29
29
 
30
30
#include "components/simple_preferences.hpp"
31
31
#include "components/preferences_widgets.hpp"
 
32
#include "dialogs/ml_configuration.hpp"
32
33
 
33
34
#include <vlc_config_cat.h>
34
35
#include <vlc_configuration.h>
 
36
#include <vlc_aout_intf.h>
35
37
 
36
38
#include <QString>
37
39
#include <QFont>
43
45
#include <QStyleFactory>
44
46
#include <QSettings>
45
47
#include <QtAlgorithms>
 
48
#include <QDir>
46
49
 
47
50
#define ICON_HEIGHT 64
48
51
 
49
52
#ifdef WIN32
50
53
# include <vlc_windows_interfaces.h>
51
54
#endif
 
55
#include <vlc_modules.h>
52
56
 
53
57
/*********************************************************************
54
58
 * The List of categories
67
71
 
68
72
#define ADD_CATEGORY( button, label, icon, numb )                           \
69
73
    QToolButton * button = new QToolButton( this );                         \
70
 
    button->setIcon( QIcon( ":/prefsmenu/" #icon ) );                   \
 
74
    button->setIcon( QIcon( ":/prefsmenu/" #icon ) );                       \
71
75
    button->setText( label );                                               \
 
76
    button->setToolTip( label + qtr("Preferences") );                       \
72
77
    button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );              \
73
78
    button->setIconSize( QSize( icon_height, icon_height ) );               \
74
79
    button->resize( icon_height + 6 , icon_height + 6 );                    \
135
140
            if( p_config )                                                \
136
141
            {                                                             \
137
142
                control =  new BoolConfigControl( VLC_OBJECT(p_intf),     \
138
 
                           p_config, NULL, ui.qcontrol, false );          \
 
143
                           p_config, NULL, ui.qcontrol );          \
139
144
                controls.append( control );                               \
140
145
            }                                                             \
141
146
            else { ui.qcontrol->setEnabled( false ); }
191
196
 
192
197
    // Title Label
193
198
    QLabel *panel_label = new QLabel;
194
 
    QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
 
199
    QFont labelFont = QApplication::font();
195
200
    labelFont.setPointSize( labelFont.pointSize() + 6 );
196
 
    labelFont.setFamily( "Verdana" );
197
201
    panel_label->setFont( labelFont );
198
202
 
199
203
    // Title <hr>
201
205
    title_line->setFrameShape(QFrame::HLine);
202
206
    title_line->setFrameShadow(QFrame::Sunken);
203
207
 
204
 
    QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
 
208
    QFont italicFont = QApplication::font();
205
209
    italicFont.setItalic( true );
206
210
 
207
211
    switch( number )
216
220
            CONFIG_BOOL( "overlay", overlay );
217
221
            CONFIG_BOOL( "video-on-top", alwaysOnTop );
218
222
            CONFIG_BOOL( "video-deco", windowDecorations );
219
 
            CONFIG_BOOL( "skip-frames", skipFrames );
220
223
            CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );
221
224
 
222
 
            CONFIG_BOOL( "video-wallpaper", wallpaperMode );
223
225
#ifdef WIN32
224
226
            CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
225
227
                            dXdisplayDevice );
226
228
            CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
 
229
            CONNECT( ui.overlay, toggled( bool ), ui.hwYUVBox, setEnabled( bool ) );
227
230
#else
228
231
            ui.directXBox->setVisible( false );
229
232
            ui.hwYUVBox->setVisible( false );
230
233
#endif
231
234
 
 
235
#ifdef __OS2__
 
236
            CONFIG_BOOL( "kva-fixt23", kvaFixT23 );
 
237
            CONFIG_GENERIC( "kva-video-mode", StringList, ui.kvaVideoModeLabel,
 
238
                            kvaVideoMode );
 
239
#else
 
240
            ui.kvaBox->setVisible( false );
 
241
#endif
 
242
 
232
243
            CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
233
244
            CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
234
245
            CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
266
277
            QComboBox * name ## Device = new QComboBox( name ## Control ); \
267
278
            name ## Layout->addWidget( name ## Device ); \
268
279
            name ## Label->setBuddy( name ## Device ); \
 
280
            name ## Device->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred  );\
269
281
            outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );
270
282
 
271
283
#define audioControl2( name) \
284
296
            optionWidgets.append( DirectXControl );
285
297
            CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
286
298
                    DirectXLabel, DirectXDevice );
 
299
#elif defined( __OS2__ )
 
300
            audioControl( kai );
 
301
            optionWidgets.append( kaiControl );
 
302
            CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
 
303
                    kaiDevice );
287
304
#else
288
305
            if( module_exists( "alsa" ) )
289
306
            {
290
307
                audioControl( alsa );
291
308
                optionWidgets.append( alsaControl );
292
 
 
293
309
                CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
294
310
                                alsaDevice );
295
311
            }
311
327
#undef audioCommon
312
328
 
313
329
            /* Audio Options */
 
330
            ui.volumeValue->setMaximum( (AOUT_VOLUME_DEFAULT * 2) / AOUT_VOLUME_DEFAULT * 100 );
314
331
            CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
315
332
                                     defaultVolume );
316
333
            CONNECT( ui.defaultVolume, valueChanged( int ),
390
407
            qs_filter = qfu( psz ).split( ':', QString::SkipEmptyParts );
391
408
            free( psz );
392
409
 
393
 
            bool b_enabled = ( qs_filter.contains( "volnorm" ) );
 
410
            bool b_enabled = ( qs_filter.contains( "normvol" ) );
394
411
            ui.volNormBox->setChecked( b_enabled );
395
412
            ui.volNormSpin->setEnabled( b_enabled );
396
413
 
407
424
 
408
425
            /* Disk Devices */
409
426
            {
410
 
                ui.DVDDevice->setToolTip(
 
427
                ui.DVDDeviceComboBox->setToolTip(
411
428
                    qtr( "If this property is blank, different values\n"
412
429
                         "for DVD, VCD, and CDDA are set.\n"
413
430
                         "You can define a unique one or configure them \n"
419
436
                if( !strcmp( psz_cddadiscpath, psz_dvddiscpath ) &&
420
437
                    !strcmp( psz_dvddiscpath, psz_vcddiscpath ) )
421
438
                {
422
 
                    ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
 
439
                    ui.DVDDeviceComboBox->setEditText( qfu( psz_dvddiscpath ) );
423
440
                }
424
441
                free( psz_cddadiscpath );
425
442
                free( psz_dvddiscpath );
426
443
                free( psz_vcddiscpath );
427
444
            }
428
 
            CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
429
 
                                 ui.DVDDevice, ui.DVDBrowse );
 
445
#ifndef WIN32
 
446
            QStringList DVDDeviceComboBoxStringList = QStringList();
 
447
            DVDDeviceComboBoxStringList
 
448
                    << "dvd*" << "scd*" << "sr*" << "sg*" << "cd*";
 
449
            ui.DVDDeviceComboBox->addItems( QDir( "/dev/" )
 
450
                    .entryList( DVDDeviceComboBoxStringList, QDir::System )
 
451
                    .replaceInStrings( QRegExp("^"), "/dev/" )
 
452
            );
 
453
#endif
 
454
            CONFIG_GENERIC( "dvd", String, ui.DVDLabel,
 
455
                            DVDDeviceComboBox->lineEdit() );
430
456
            CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
431
457
                                 ui.recordPath, ui.recordBrowse );
432
458
 
433
 
            CONFIG_GENERIC_NO_BOOL( "server-port", Integer, ui.portLabel,
434
 
                                    UDPPort );
435
459
            CONFIG_GENERIC( "http-proxy", String , ui.httpProxyLabel, proxy );
436
460
            CONFIG_GENERIC_NO_BOOL( "postproc-q", Integer, ui.ppLabel,
437
461
                                    PostProcLevel );
457
481
#else
458
482
            ui.systemCodecBox->hide();
459
483
#endif
460
 
            optionWidgets.append( ui.DVDDevice );
 
484
            optionWidgets.append( ui.DVDDeviceComboBox );
461
485
            optionWidgets.append( ui.cachingCombo );
462
486
            CONFIG_GENERIC( "ffmpeg-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
 
487
            CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
 
488
            CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
 
489
            CONFIG_GENERIC( "sout-x264-profile", StringList, ui.x264profileLabel, profileBox );
 
490
            CONFIG_GENERIC( "sout-x264-level", String, ui.x264profileLabel, levelBox );
 
491
            CONFIG_BOOL( "mkv-preload-local-dir", mkvPreloadBox );
463
492
 
464
493
            /* Caching */
465
494
            /* Add the things to the ComboBox */
473
502
            addToCachingBox( N_("Higher latency"), CachingHigher );
474
503
            #undef addToCachingBox
475
504
 
476
 
#define TestCaC( name ) \
 
505
#define TestCaC( name, factor ) \
477
506
    b_cache_equal =  b_cache_equal && \
478
 
     ( i_cache == config_GetInt( p_intf, name ) )
479
 
 
480
 
#define TestCaCi( name, int ) \
481
 
    b_cache_equal = b_cache_equal &&  \
482
 
    ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
 
507
     ( i_cache * factor == config_GetInt( p_intf, name ) );
483
508
            /* Select the accurate value of the ComboBox */
484
509
            bool b_cache_equal = true;
485
 
            int i_cache = config_GetInt( p_intf, "file-caching");
 
510
            int i_cache = config_GetInt( p_intf, "file-caching" );
486
511
 
487
 
            TestCaC( "udp-caching" );
488
 
            if (module_exists ("dvdread"))
489
 
                TestCaC( "dvdread-caching" );
490
 
            if (module_exists ("dvdnav"))
491
 
                TestCaC( "dvdnav-caching" );
492
 
            TestCaC( "tcp-caching" );
493
 
            TestCaC( "fake-caching" ); TestCaC( "cdda-caching" );
494
 
            TestCaC( "screen-caching" ); TestCaC( "vcd-caching" );
495
 
            #ifdef WIN32
496
 
            TestCaC( "dshow-caching" );
497
 
            #else
498
 
            if (module_exists ("v4l"))
499
 
                TestCaC( "v4l-caching" );
500
 
            if (module_exists ("access_jack"))
501
 
                TestCaC( "jack-input-caching" );
502
 
            if (module_exists ("v4l2"))
503
 
                TestCaC( "v4l2-caching" );
504
 
            if (module_exists ("pvr"))
505
 
                TestCaC( "pvr-caching" );
506
 
            #endif
507
 
            if (module_exists ("livedotcom"))
508
 
                TestCaCi( "rtsp-caching", 4 );
509
 
            TestCaCi( "ftp-caching", 2 );
510
 
            TestCaCi( "http-caching", 2 );
511
 
            if (module_exists ("access_realrtsp"))
512
 
                TestCaCi( "realrtsp-caching", 10 );
513
 
            TestCaCi( "mms-caching", 10 );
 
512
            TestCaC( "network-caching", 10/3 );
 
513
            TestCaC( "disc-caching", 1);
 
514
            TestCaC( "live-caching", 1 );
514
515
            if( b_cache_equal == 1 )
515
516
                ui.cachingCombo->setCurrentIndex(
516
517
                ui.cachingCombo->findData( QVariant( i_cache ) ) );
517
 
#undef TestCaCi
518
518
#undef TestCaC
519
519
 
520
520
        END_SPREFS_CAT;
534
534
            BUTTONACT( ui.assoButton, assoDialog() );
535
535
#else
536
536
            ui.languageBox->hide();
537
 
            ui.assoBox->hide();
538
 
#endif
 
537
            ui.assoButton->hide();
 
538
            ui.assocLabel->hide();
 
539
#endif
 
540
#ifdef MEDIA_LIBRARY
 
541
            BUTTONACT( ui.sqlMLbtn, configML() );
 
542
#else
 
543
            ui.sqlMLbtn->hide();
 
544
#endif
 
545
 
539
546
            /* interface */
540
547
            char *psz_intf = config_GetPsz( p_intf, "intf" );
541
548
            if( psz_intf )
550
557
 
551
558
            optionWidgets.append( ui.skins );
552
559
            optionWidgets.append( ui.qt4 );
553
 
#if !defined(NDEBUG) || !defined( WIN32)
 
560
#if !defined( WIN32)
554
561
            ui.stylesCombo->addItem( qtr("System's default") );
555
562
            ui.stylesCombo->addItems( QStyleFactory::keys() );
556
563
            ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
557
564
                        getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
558
565
            ui.stylesCombo->insertSeparator( 1 );
 
566
            if ( ui.stylesCombo->currentIndex() < 0 )
 
567
                ui.stylesCombo->setCurrentIndex( 0 ); /* default */
559
568
 
560
569
            CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
561
570
            optionWidgets.append( ui.stylesCombo );
562
571
#else
563
572
            ui.stylesCombo->hide();
 
573
            ui.stylesLabel->hide();
564
574
            optionWidgets.append( NULL );
565
575
#endif
566
 
 
567
 
            ui.skins_zone->setEnabled( ui.skins->isChecked() );
568
 
            CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
569
 
 
570
 
            ui.native_zone->setEnabled( ui.qt4->isChecked() );
571
 
            CONNECT( ui.qt4, toggled( bool ), ui.native_zone, setEnabled( bool ) );
 
576
            radioGroup = new QButtonGroup(this);
 
577
            radioGroup->addButton( ui.qt4, 0 );
 
578
            radioGroup->addButton( ui.skins, 1 );
 
579
            CONNECT( radioGroup, buttonClicked( int ),
 
580
                     ui.styleStackedWidget, setCurrentIndex( int ) );
 
581
            ui.styleStackedWidget->setCurrentIndex( radioGroup->checkedId() );
572
582
 
573
583
            CONNECT( ui.minimalviewBox, toggled( bool ),
574
584
                     ui.mainPreview, setNormalPreview( bool ) );
577
587
            ui.skinsPreview->setPreview( InterfacePreviewWidget::SKINS );
578
588
 
579
589
            CONFIG_BOOL( "embedded-video", embedVideo );
 
590
            CONFIG_BOOL( "qt-video-autoresize", resizingBox );
 
591
            CONNECT( ui.embedVideo, toggled( bool ), ui.resizingBox, setEnabled( bool ) );
 
592
            ui.resizingBox->setEnabled( ui.embedVideo->isChecked() );
 
593
 
580
594
            CONFIG_BOOL( "qt-fs-controller", fsController );
581
595
            CONFIG_BOOL( "qt-system-tray", systrayBox );
582
596
            CONFIG_BOOL( "qt-notification", sysPop );
 
597
            CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) );
 
598
            ui.sysPop->setEnabled( ui.systrayBox->isChecked() );
 
599
 
 
600
            CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
 
601
            CONFIG_BOOL( "playlist-tree", treePlaylist );
 
602
            CONFIG_BOOL( "play-and-pause", playPauseBox );
583
603
            CONFIG_GENERIC_FILE( "skins2-last", File, ui.skinFileLabel,
584
604
                                 ui.fileSkin, ui.skinBrowse );
585
 
            CONFIG_BOOL( "qt-video-autoresize", resizingBox );
586
605
 
587
606
            CONFIG_GENERIC( "album-art", IntegerList, ui.artFetchLabel,
588
607
                                                      artFetcher );
596
615
            CONNECT( ui.updatesBox, toggled( bool ),
597
616
                     ui.updatesDays, setEnabled( bool ) );
598
617
#else
599
 
            ui.updatesBox->hide();
600
 
            ui.updatesDays->hide();
 
618
            ui.updateNotifierZone->hide();
601
619
#endif
602
620
            /* ONE INSTANCE options */
603
621
#if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
624
642
                            qtr("Subtitles & On Screen Display Settings") );
625
643
            CONFIG_BOOL( "osd", OSDBox);
626
644
            CONFIG_BOOL( "video-title-show", OSDTitleBox);
627
 
 
 
645
            CONFIG_GENERIC( "video-title-position", IntegerList,
 
646
                            ui.OSDTitlePosLabel, OSDTitlePos );
628
647
 
629
648
            CONFIG_GENERIC( "subsdec-encoding", StringList, ui.encodLabel,
630
649
                            encoding );
631
650
            CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
632
651
                            preferredLanguage );
 
652
 
 
653
            CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
 
654
                            ui.fontSizeLabel, fontSize );
 
655
 
633
656
            CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
634
 
            CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
 
657
            CONFIG_GENERIC_NO_BOOL( "freetype-color", Color, ui.fontColorLabel,
635
658
                            fontColor );
636
 
            CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
637
 
                            ui.fontSizeLabel, fontSize );
638
 
            CONFIG_GENERIC( "freetype-effect", IntegerList, ui.fontEffectLabel,
639
 
                            effect );
 
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
 
640
664
            CONFIG_GENERIC_NO_BOOL( "sub-margin", Integer, ui.subsPosLabel, subsPosition );
641
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
 
642
671
        END_SPREFS_CAT;
643
672
 
644
673
        case SPrefsHotkeys:
714
743
                                            ->itemData( number ).toString();
715
744
#ifdef WIN32
716
745
    optionWidgets[directxW]->setVisible( ( value == "aout_directx" ) );
 
746
#elif defined( __OS2__ )
 
747
    optionWidgets[kaiW]->setVisible( ( value == "kai" ) );
717
748
#else
718
749
    /* optionWidgets[ossW] can be NULL */
719
750
    if( optionWidgets[ossW] )
736
767
void SPrefsPanel::updateAudioVolume( int volume )
737
768
{
738
769
    qobject_cast<QSpinBox *>(optionWidgets[volLW])
739
 
        ->setValue( volume * 100 / 256 );
 
770
        ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
740
771
}
741
772
 
742
773
 
744
775
void SPrefsPanel::apply()
745
776
{
746
777
    /* Generic save for ever panel */
747
 
    QList<ConfigControl *>::Iterator i;
748
 
    for( i = controls.begin() ; i != controls.end() ; i++ )
 
778
    QList<ConfigControl *>::const_iterator i;
 
779
    for( i = controls.begin() ; i != controls.end() ; ++i )
749
780
    {
750
781
        ConfigControl *c = qobject_cast<ConfigControl *>(*i);
751
 
        c->doApply( p_intf );
 
782
        c->doApply();
752
783
    }
753
784
 
754
785
    switch( number )
756
787
    case SPrefsInputAndCodecs:
757
788
    {
758
789
        /* Device default selection */
759
 
        char *psz_devicepath =
760
 
            strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() ) );
761
 
        if( !EMPTY_STR( psz_devicepath ) )
 
790
        QByteArray devicepath =
 
791
            qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8();
 
792
        if( devicepath.size() > 0 )
762
793
        {
763
 
            config_PutPsz( p_intf, "dvd", psz_devicepath );
764
 
            config_PutPsz( p_intf, "vcd", psz_devicepath );
765
 
            config_PutPsz( p_intf, "cd-audio", psz_devicepath );
766
 
            free( psz_devicepath );
 
794
            config_PutPsz( p_intf, "dvd", devicepath );
 
795
            config_PutPsz( p_intf, "vcd", devicepath );
 
796
            config_PutPsz( p_intf, "cd-audio", devicepath );
767
797
        }
768
798
 
769
 
#define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
770
 
#define CaC( name ) CaCi( name, 1 )
 
799
#define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
771
800
        /* Caching */
772
801
        QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]);
773
802
        int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
774
803
        if( i_comboValue )
775
804
        {
776
 
            CaC( "udp-caching" );
777
 
            if (module_exists ("dvdread" ))
778
 
                CaC( "dvdread-caching" );
779
 
            if (module_exists ("dvdnav" ))
780
 
                CaC( "dvdnav-caching" );
781
 
            CaC( "tcp-caching" ); CaC( "vcd-caching" );
782
 
            CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
783
 
            CaC( "screen-caching" ); CaC( "bd-caching" );
784
 
            CaCi( "rtsp-caching", 2 ); CaCi( "ftp-caching", 2 );
785
 
            CaCi( "http-caching", 2 );
786
 
            if (module_exists ("access_realrtsp" ))
787
 
                CaCi( "realrtsp-caching", 10 );
788
 
            CaCi( "mms-caching", 10 );
789
 
            #ifdef WIN32
790
 
            CaC( "dshow-caching" );
791
 
            #else
792
 
            if (module_exists ( "v4l" ))
793
 
                CaC( "v4l-caching" );
794
 
            if (module_exists ( "access_jack" ))
795
 
            CaC( "jack-input-caching" );
796
 
            if (module_exists ( "v4l2" ))
797
 
                CaC( "v4l2-caching" );
798
 
            if (module_exists ( "pvr" ))
799
 
                CaC( "pvr-caching" );
800
 
            #endif
801
 
            //CaCi( "dv-caching" ) too short...
 
805
            CaC( "file-caching", 1 );
 
806
            CaC( "network-caching", 10/3 );
 
807
            CaC( "disc-caching", 1 );
 
808
            CaC( "live-caching", 1 );
802
809
        }
803
810
        break;
804
811
#undef CaC
805
 
#undef CaCi
806
812
    }
807
813
 
808
814
    /* Interfaces */
824
830
    {
825
831
        bool b_checked =
826
832
            qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked();
827
 
        if( b_checked && !qs_filter.contains( "volnorm" ) )
828
 
            qs_filter.append( "volnorm" );
829
 
        if( !b_checked && qs_filter.contains( "volnorm" ) )
830
 
            qs_filter.removeAll( "volnorm" );
 
833
        if( b_checked && !qs_filter.contains( "normvol" ) )
 
834
            qs_filter.append( "normvol" );
 
835
        if( !b_checked && qs_filter.contains( "normvol" ) )
 
836
            qs_filter.removeAll( "normvol" );
831
837
 
832
838
        b_checked =
833
839
            qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked();
840
846
        config_PutPsz( p_intf, "audio-filter", qtu( qs_filter.join( ":" ) ) );
841
847
        break;
842
848
    }
 
849
    case SPrefsSubtitles:
 
850
    {
 
851
        bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked();
 
852
        if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
 
853
            config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
 
854
        }
 
855
        else if (!b_checked ) {
 
856
            config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
 
857
        }
 
858
 
 
859
        b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked();
 
860
        if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
 
861
            config_PutInt( p_intf, "freetype-background-opacity", 128 );
 
862
        }
 
863
        else if (!b_checked ) {
 
864
            config_PutInt( p_intf, "freetype-background-opacity", 0 );
 
865
        }
 
866
 
 
867
    }
843
868
    }
844
869
}
845
870
 
863
888
    QWidgetList::iterator it = widgets.begin();
864
889
    while( it != widgets.end() ) {
865
890
        (*it)->update();
866
 
        it++;
 
891
        ++it;
867
892
    };
868
893
}
869
894
 
 
895
void SPrefsPanel::configML()
 
896
{
 
897
#ifdef MEDIA_LIBRARY
 
898
    MLConfDialog *mld = new MLConfDialog( this, p_intf );
 
899
    mld->exec();
 
900
    delete mld;
 
901
#endif
 
902
}
 
903
 
870
904
#ifdef WIN32
871
905
#include <QDialogButtonBox>
872
 
#include <QHeaderView>
873
906
#include "util/registry.hpp"
874
 
#include <string>
875
907
 
876
908
bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
877
909
                           QTreeWidgetItem* parent, QVLCRegistry *qvReg )
880
912
    const char* psz_VLC = "VLC";
881
913
    current = new QTreeWidgetItem( parent, QStringList( psz_ext ) );
882
914
 
883
 
    if( strstr( qvReg->ReadRegistryString( psz_ext, "", ""  ), psz_VLC ) )
 
915
    if( strstr( qvReg->ReadRegistryString( psz_ext, "", "" ), psz_VLC ) )
884
916
    {
885
917
        current->setCheckState( 0, Qt::Checked );
886
918
        b_temp = false;
901
933
 
902
934
    if( S_OK == CoCreateInstance( &clsid_IApplication2,
903
935
                NULL, CLSCTX_INPROC_SERVER,
904
 
                &IID_IApplicationAssociationRegistrationUI,
 
936
                IID_IApplicationAssociationRegistrationUI,
905
937
                (void **)&p_appassoc) )
906
938
    {
907
939
        if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
914
946
    CoUninitialize();
915
947
 
916
948
    QDialog *d = new QDialog( this );
 
949
    d->setWindowTitle( qtr( "File associations" ) );
917
950
    QGridLayout *assoLayout = new QGridLayout( d );
918
951
 
919
952
    QTreeWidget *filetypeList = new QTreeWidget;
934
967
    videoType->setExpanded( true ); videoType->setCheckState( 0, Qt::Unchecked );
935
968
    otherType->setExpanded( true ); otherType->setCheckState( 0, Qt::Unchecked );
936
969
 
937
 
    QTreeWidgetItem *currentItem;
 
970
    QTreeWidgetItem *currentItem = NULL;
938
971
 
939
972
    int i_temp = 0;
940
973
#define aTa( name ) i_temp += addType( name, currentItem, audioType, qvReg )
955
988
    aTv( ".gxf" ); aTv( ".m1v" ); aTv( ".m2v" ); aTv( ".m2ts" ); aTv( ".m4v" );
956
989
    aTv( ".mkv" ); aTv( ".mov" ); aTv( ".mp2" ); aTv( ".mp4" ); aTv( ".mpeg" );
957
990
    aTv( ".mpeg1" ); aTv( ".mpeg2" ); aTv( ".mpeg4" ); aTv( ".mpg" );
958
 
    aTv( ".mts" ); aTv( ".mxf" );
 
991
    aTv( ".mts" ); aTv( ".mtv" ); aTv( ".mxf" );
959
992
    aTv( ".ogg" ); aTv( ".ogm" ); aTv( ".ogx" ); aTv( ".ogv" );  aTv( ".ts" );
960
993
    aTv( ".vob" ); aTv( ".vro" ); aTv( ".wmv" );
961
994
    videoType->setCheckState( 0, ( i_temp > 0 ) ?
994
1027
 
995
1028
void addAsso( QVLCRegistry *qvReg, const char *psz_ext )
996
1029
{
997
 
    std::string s_path( "VLC" ); s_path += psz_ext;
998
 
    std::string s_path2 = s_path;
 
1030
    QString s_path( "VLC" ); s_path += psz_ext;
 
1031
    QString s_path2 = s_path;
999
1032
 
1000
1033
    /* Save a backup if already assigned */
1001
1034
    char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
1002
1035
 
1003
 
    if( psz_value && strlen( psz_value ) > 0 )
 
1036
    if( !EMPTY_STR(psz_value) )
1004
1037
        qvReg->WriteRegistryString( psz_ext, "VLC.backup", psz_value );
1005
1038
    delete psz_value;
1006
1039
 
1007
1040
    /* Put a "link" to VLC.EXT as default */
1008
 
    qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
 
1041
    qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
1009
1042
 
1010
1043
    /* Create the needed Key if they weren't done in the installer */
1011
 
    if( !qvReg->RegistryKeyExists( s_path.c_str() ) )
 
1044
    if( !qvReg->RegistryKeyExists( qtu( s_path ) ) )
1012
1045
    {
1013
 
        qvReg->WriteRegistryString( psz_ext, "", s_path.c_str() );
1014
 
        qvReg->WriteRegistryString( s_path.c_str(), "", "Media file" );
1015
 
        qvReg->WriteRegistryString( s_path.append( "\\shell" ).c_str() , "", "Play" );
 
1046
        qvReg->WriteRegistryString( psz_ext, "", qtu( s_path ) );
 
1047
        qvReg->WriteRegistryString( qtu( s_path ), "", "Media file" );
 
1048
        qvReg->WriteRegistryString( qtu( s_path.append( "\\shell" ) ), "", "Play" );
1016
1049
 
1017
1050
        /* Get the installer path */
1018
1051
        QVLCRegistry *qvReg2 = new QVLCRegistry( HKEY_LOCAL_MACHINE );
1019
 
        std::string str_temp; str_temp.assign(
1020
 
            qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" ) );
 
1052
        QString str_temp = qvReg2->ReadRegistryString( "Software\\VideoLAN\\VLC", "", "" );
1021
1053
 
1022
1054
        if( str_temp.size() )
1023
1055
        {
1024
 
            qvReg->WriteRegistryString( s_path.append( "\\Play\\command" ).c_str(),
1025
 
                "", str_temp.append(" --started-from-file \"%1\"" ).c_str() );
 
1056
            qvReg->WriteRegistryString( qtu( s_path.append( "\\Play\\command" ) ),
 
1057
                "", qtu( str_temp.append(" --started-from-file \"%1\"" ) ) );
1026
1058
 
1027
 
            qvReg->WriteRegistryString( s_path2.append( "\\DefaultIcon" ).c_str(),
1028
 
                        "", str_temp.append(",0").c_str() );
 
1059
            qvReg->WriteRegistryString( qtu( s_path2.append( "\\DefaultIcon" ) ),
 
1060
                        "", qtu( str_temp.append(",0") ) );
1029
1061
        }
1030
1062
        delete qvReg2;
1031
1063
    }
1034
1066
void delAsso( QVLCRegistry *qvReg, const char *psz_ext )
1035
1067
{
1036
1068
    char psz_VLC[] = "VLC";
1037
 
    char *psz_value = qvReg->ReadRegistryString( psz_ext, "", ""  );
 
1069
    char *psz_value = qvReg->ReadRegistryString( psz_ext, "", "" );
1038
1070
 
1039
1071
    if( psz_value && !strcmp( strcat( psz_VLC, psz_ext ), psz_value ) )
1040
1072
    {
1049
1081
}
1050
1082
void SPrefsPanel::saveAsso()
1051
1083
{
1052
 
    QVLCRegistry * qvReg;
 
1084
    QVLCRegistry * qvReg = NULL;
1053
1085
    for( int i = 0; i < listAsso.size(); i ++ )
1054
1086
    {
1055
1087
        qvReg  = new QVLCRegistry( HKEY_CLASSES_ROOT );