extended_panels.cpp 46.2 KB
Newer Older
zorglub's avatar
zorglub committed
1
/*****************************************************************************
zorglub's avatar
zorglub committed
2
 * extended_panels.cpp : Extended controls panels
zorglub's avatar
zorglub committed
3
 ****************************************************************************
4
 * Copyright (C) 2006-2007 the VideoLAN team
5
 * $Id$
zorglub's avatar
zorglub committed
6
7
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Antoine Cellerier <dionoea .t videolan d@t org>
zorglub's avatar
zorglub committed
9
10
11
12
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
13
 * ( at your option ) any later version.
zorglub's avatar
zorglub committed
14
15
16
17
18
19
20
21
22
23
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
24
25
26
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
zorglub's avatar
zorglub committed
27
28
29
30
31
32

#include <QLabel>
#include <QVariant>
#include <QString>
#include <QFont>
#include <QGridLayout>
zorglub's avatar
zorglub committed
33
#include <QSignalMapper>
34
#include <QComboBox>
zorglub's avatar
zorglub committed
35

zorglub's avatar
zorglub committed
36
#include "components/extended_panels.hpp"
37
#include "dialogs/preferences.hpp"
zorglub's avatar
zorglub committed
38
#include "dialogs_provider.hpp"
zorglub's avatar
zorglub committed
39
#include "qt4.hpp"
40
#include "input_manager.hpp"
zorglub's avatar
zorglub committed
41

zorglub's avatar
zorglub committed
42
#include <vlc_aout.h>
zorglub's avatar
zorglub committed
43
#include <vlc_intf_strings.h>
zorglub's avatar
zorglub committed
44
#include <vlc_vout.h>
45
#include <vlc_osd.h>
zorglub's avatar
zorglub committed
46

47
48

#if 0
zorglub's avatar
zorglub committed
49
50
51
class ConfClickHandler : public QObject
{
public:
52
    ConfClickHandler( intf_thread_t *_p_intf, ExtVideo *_e ) : QObject ( _e ) {
zorglub's avatar
zorglub committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        e = _e; p_intf = _p_intf;
    }
    virtual ~ConfClickHandler() {}
    bool eventFilter( QObject *obj, QEvent *evt )
    {
        if( evt->type() == QEvent::MouseButtonPress )
        {
            e->gotoConf( obj );
            return true;
        }
        return false;
    }
private:
    ExtVideo* e;
    intf_thread_t *p_intf;
};
69
#endif
zorglub's avatar
zorglub committed
70

71
72
QString ModuleFromWidgetName( QObject *obj )
{
73
    return obj->objectName().replace( "Enable","" );
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
}

QString OptionFromWidgetName( QObject *obj )
{
    /* Gruik ? ... nah */
    QString option = obj->objectName().replace( "Slider", "" )
                                      .replace( "Combo" , "" )
                                      .replace( "Dial"  , "" )
                                      .replace( "Check" , "" )
                                      .replace( "Spin"  , "" )
                                      .replace( "Text"  , "" );
    for( char a = 'A'; a <= 'Z'; a++ )
    {
        option = option.replace( QString( a ),
                                 QString( '-' ) + QString( a + 'a' - 'A' ) );
    }
    return option;
}
zorglub's avatar
zorglub committed
92

93
94
ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
                           p_intf( _p_intf )
zorglub's avatar
zorglub committed
95
{
96
    ui.setupUi( _parent );
zorglub's avatar
zorglub committed
97

98
99
#define SETUP_VFILTER( widget ) \
    { \
100
        vlc_object_t *p_obj = ( vlc_object_t * ) \
101
102
103
            vlc_object_find_name( p_intf->p_libvlc, \
                                  #widget, \
                                  FIND_CHILD ); \
104
105
        QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
        QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
106
107
108
        if( p_obj ) \
        { \
            vlc_object_release( p_obj ); \
109
            if( checkbox ) checkbox->setChecked( true ); \
110
111
112
113
            else groupbox->setChecked( true ); \
        } \
        else \
        { \
114
            if( checkbox ) checkbox->setChecked( false ); \
115
116
117
118
119
            else groupbox->setChecked( false ); \
        } \
    } \
    CONNECT( ui.widget##Enable, clicked(), this, updateFilters() );
#define SETUP_VFILTER_OPTION( widget, signal ) \
120
    initComboBoxItems( ui.widget ); \
121
122
    setWidgetValue( ui.widget ); \
    CONNECT( ui.widget, signal, this, updateFilterOptions() );
dionoea's avatar
dionoea committed
123

124
    SETUP_VFILTER( adjust )
125
126
127
128
129
130
    SETUP_VFILTER_OPTION( hueSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( contrastSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( brightnessSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( saturationSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( gammaSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( brightnessThresholdCheck, stateChanged( int ) )
131
132

    SETUP_VFILTER( extract )
133
    SETUP_VFILTER_OPTION( extractComponentText, textChanged( QString ) )
134
135

    SETUP_VFILTER( colorthres )
136
137
138
    SETUP_VFILTER_OPTION( colorthresColorText, textChanged( QString ) )
    SETUP_VFILTER_OPTION( colorthresSaturationthresSlider, valueChanged( int ) )
    SETUP_VFILTER_OPTION( colorthresSimilaritythresSlider, valueChanged( int ) )
139
140
141
142

    SETUP_VFILTER( invert )

    SETUP_VFILTER( gradient )
143
144
145
    SETUP_VFILTER_OPTION( gradientModeCombo, currentIndexChanged( QString ) )
    SETUP_VFILTER_OPTION( gradientTypeCheck, stateChanged( int ) )
    SETUP_VFILTER_OPTION( gradientCartoonCheck, stateChanged( int ) )
146

147
    SETUP_VFILTER( motionblur )
148
    SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged( int ) )
149
150
151
152
153
154
155
156

    SETUP_VFILTER( motiondetect )

    SETUP_VFILTER( noise )

    SETUP_VFILTER( psychedelic )

    SETUP_VFILTER( sharpen )
157
    SETUP_VFILTER_OPTION( sharpenSigmaSlider, valueChanged( int ) )
158
159
160
161
162
163

    SETUP_VFILTER( ripple )

    SETUP_VFILTER( wave )

    SETUP_VFILTER( transform )
164
    SETUP_VFILTER_OPTION( transformTypeCombo, currentIndexChanged( QString ) )
165
166

    SETUP_VFILTER( rotate )
167
    SETUP_VFILTER_OPTION( rotateAngleDial, valueChanged( int ) )
168
169
    ui.rotateAngleDial->setWrapping( true );
    ui.rotateAngleDial->setNotchesVisible( true );
170
171

    SETUP_VFILTER( puzzle )
172
173
174
    SETUP_VFILTER_OPTION( puzzleRowsSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( puzzleColsSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( puzzleBlackSlotCheck, stateChanged( int ) )
175
176
177
178

    SETUP_VFILTER( magnify )

    SETUP_VFILTER( clone )
179
    SETUP_VFILTER_OPTION( cloneCountSpin, valueChanged( int ) )
180
181

    SETUP_VFILTER( wall )
182
183
    SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
184

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
185
    SETUP_VFILTER( panoramix )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
186
187
    SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
188
189


190
191
    SETUP_VFILTER( erase )
    SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
192
193
    SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) )
194
195

    SETUP_VFILTER( marq )
196
197
    SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( QString ) )
    SETUP_VFILTER_OPTION( marqPositionCombo, currentIndexChanged( QString ) )
198
199
200

    SETUP_VFILTER( logo )
    SETUP_VFILTER_OPTION( logoFileText, editingFinished() )
201
202
203
    SETUP_VFILTER_OPTION( logoYSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( logoXSpin, valueChanged( int ) )
    SETUP_VFILTER_OPTION( logoTransparencySlider, valueChanged( int ) )
204
205
206

#undef SETUP_VFILTER
#undef SETUP_VFILTER_OPTION
207
208
209
210
211
212
213
214
215

    CONNECT( ui.cropTopPx, valueChanged( int ), this, cropChange() );
    CONNECT( ui.cropBotPx, valueChanged( int ), this, cropChange() );
    CONNECT( ui.cropLeftPx, valueChanged( int ), this, cropChange() );
    CONNECT( ui.cropRightPx, valueChanged( int ), this, cropChange() );
    CONNECT( ui.topBotCropSync, toggled( bool ),
             ui.cropBotPx, setDisabled( bool ) );
    CONNECT( ui.leftRightCropSync, toggled( bool ),
             ui.cropRightPx, setDisabled( bool ) );
zorglub's avatar
zorglub committed
216
217
218
219
220
221
}

ExtVideo::~ExtVideo()
{
}

222
223
224
225
226
227
void ExtVideo::cropChange()
{
    p_vout = ( vout_thread_t * )vlc_object_find( p_intf,
                                VLC_OBJECT_VOUT, FIND_CHILD );
    if( p_vout )
    {
228
229
230
231
        var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
        var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() );
        var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() );
        var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() );
232
233
234
    }
}

235
void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add )
zorglub's avatar
zorglub committed
236
237
{
    char *psz_parser, *psz_string;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
238
    const char *psz_filter_type;
239
240
241

    /* Please leave p_libvlc_global. This is where cached modules are
     * stored. We're not trying to find a module instance. */
242
    module_t *p_obj = module_Find( p_intf, psz_name );
243
244
    if( !p_obj )
    {
245
        msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name );
246
247
248
        return;
    }

249
    if( module_IsCapable( p_obj, "video filter2" ) )
250
251
252
    {
        psz_filter_type = "video-filter";
    }
253
    else if( module_IsCapable( p_obj, "video filter" ) )
254
255
256
    {
        psz_filter_type = "vout-filter";
    }
257
    else if( module_IsCapable( p_obj, "sub filter" ) )
258
259
260
261
262
    {
        psz_filter_type = "sub-filter";
    }
    else
    {
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
263
        module_Put( p_obj );
264
265
266
        msg_Err( p_intf, "Unknown video filter type." );
        return;
    }
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
267
    module_Put( p_obj );
268
269

    psz_string = config_GetPsz( p_intf, psz_filter_type );
zorglub's avatar
zorglub committed
270

271
    if( !psz_string ) psz_string = strdup( "" );
zorglub's avatar
zorglub committed
272
273
274
275
276
277
278
279

    psz_parser = strstr( psz_string, psz_name );

    if( b_add )
    {
        if( !psz_parser )
        {
            psz_parser = psz_string;
ivoire's avatar
ivoire committed
280
281
282
            if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
                            psz_string, psz_name ) == -1 )
                return;
zorglub's avatar
zorglub committed
283
284
285
286
287
288
289
290
291
292
293
            free( psz_parser );
        }
        else
        {
            return;
        }
    }
    else
    {
        if( psz_parser )
        {
294
            if( *( psz_parser + strlen( psz_name ) ) == ':' )
295
            {
296
297
                memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
                         strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
298
299
300
301
302
            }
            else
            {
                *psz_parser = '\0';
            }
zorglub's avatar
zorglub committed
303
304

            /* Remove trailing : : */
305
306
            if( strlen( psz_string ) > 0 &&
                *( psz_string + strlen( psz_string ) -1 ) == ':' )
zorglub's avatar
zorglub committed
307
            {
308
                *( psz_string + strlen( psz_string ) -1 ) = '\0';
zorglub's avatar
zorglub committed
309
            }
310
311
312
313
314
315
        }
        else
        {
            free( psz_string );
            return;
        }
zorglub's avatar
zorglub committed
316
317
    }
    /* Vout is not kept, so put that in the config */
318
319
320
321
322
323
324
    config_PutPsz( p_intf, psz_filter_type, psz_string );
    if( !strcmp( psz_filter_type, "video-filter" ) )
        ui.videoFilterText->setText( psz_string );
    else if( !strcmp( psz_filter_type, "vout-filter" ) )
        ui.voutFilterText->setText( psz_string );
    else if( !strcmp( psz_filter_type, "sub-filter" ) )
        ui.subpictureFilterText->setText( psz_string );
zorglub's avatar
zorglub committed
325
326

    /* Try to set on the fly */
327
    p_vout = ( vout_thread_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT,
zorglub's avatar
zorglub committed
328
329
330
                                              FIND_ANYWHERE );
    if( p_vout )
    {
331
332
333
334
        if( !strcmp( psz_filter_type, "sub-filter" ) )
            var_SetString( p_vout->p_spu, psz_filter_type, psz_string );
        else
            var_SetString( p_vout, psz_filter_type, psz_string );
zorglub's avatar
zorglub committed
335
336
337
338
339
340
341
342
        vlc_object_release( p_vout );
    }

    free( psz_string );
}

void ExtVideo::updateFilters()
{
343
    QString module = ModuleFromWidgetName( sender() );
344
    //std::cout << "Module name: " << module.toStdString() << std::endl;
zorglub's avatar
zorglub committed
345

346
347
    QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
    QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
348

349
    ChangeVFiltersString( qtu( module ),
350
351
                          checkbox ? checkbox->isChecked()
                                   : groupbox->isChecked() );
zorglub's avatar
zorglub committed
352
353
}

354
355
void ExtVideo::initComboBoxItems( QObject *widget )
{
356
    QComboBox *combobox = qobject_cast<QComboBox*>( widget );
357
358
    if( !combobox ) return;
    QString option = OptionFromWidgetName( widget );
359
    module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
360
                                                 qtu( option ) );
361
362
363
364
365
366
367
    if( p_item )
    {
        int i_type = p_item->i_type & CONFIG_ITEM;
        for( int i_index = 0; i_index < p_item->i_list; i_index++ )
        {
            if( i_type == CONFIG_ITEM_INTEGER
             || i_type == CONFIG_ITEM_BOOL )
368
369
                combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ),
                                   p_item->pi_list[i_index] );
370
            else if( i_type == CONFIG_ITEM_STRING )
371
372
                combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ),
                                   p_item->ppsz_list[i_index] );
373
374
375
376
377
        }
    }
    else
    {
        msg_Err( p_intf, "Couldn't find option \"%s\".",
378
                 qtu( option ) );
379
380
381
    }
}

382
383
384
385
386
387
388
void ExtVideo::setWidgetValue( QObject *widget )
{
    QString module = ModuleFromWidgetName( widget->parent() );
    //std::cout << "Module name: " << module.toStdString() << std::endl;
    QString option = OptionFromWidgetName( widget );
    //std::cout << "Option name: " << option.toStdString() << std::endl;

389
    vlc_object_t *p_obj = ( vlc_object_t * )
390
        vlc_object_find_name( p_intf->p_libvlc,
391
                              qtu( module ),
392
393
394
395
396
397
                              FIND_CHILD );
    int i_type;
    vlc_value_t val;

    if( !p_obj )
    {
398
#if 0
399
400
        msg_Dbg( p_intf,
                 "Module instance %s not found, looking in config values.",
401
                 qtu( module ) );
402
#endif
403
        i_type = config_GetType( p_intf, qtu( option ) ) & 0xf0;
404
405
406
407
        switch( i_type )
        {
            case VLC_VAR_INTEGER:
            case VLC_VAR_BOOL:
408
                val.i_int = config_GetInt( p_intf, qtu( option ) );
409
410
                break;
            case VLC_VAR_FLOAT:
411
                val.f_float = config_GetFloat( p_intf, qtu( option ) );
412
413
                break;
            case VLC_VAR_STRING:
414
                val.psz_string = config_GetPsz( p_intf, qtu( option ) );
415
416
417
418
419
                break;
        }
    }
    else
    {
420
421
        i_type = var_Type( p_obj, qtu( option ) ) & 0xf0;
        var_Get( p_obj, qtu( option ), &val );
422
423
424
425
426
        vlc_object_release( p_obj );
    }

    /* Try to cast to all the widgets we're likely to encounter. Only
     * one of the casts is expected to work. */
427
428
429
430
431
432
433
    QSlider        *slider        = qobject_cast<QSlider*>       ( widget );
    QCheckBox      *checkbox      = qobject_cast<QCheckBox*>     ( widget );
    QSpinBox       *spinbox       = qobject_cast<QSpinBox*>      ( widget );
    QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( widget );
    QDial          *dial          = qobject_cast<QDial*>         ( widget );
    QLineEdit      *lineedit      = qobject_cast<QLineEdit*>     ( widget );
    QComboBox      *combobox      = qobject_cast<QComboBox*>     ( widget );
434
435
436
437
438
439
440
441

    if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
    {
        int i_int = 0;
        if( slider )        slider->setValue( val.i_int );
        else if( checkbox ) checkbox->setCheckState( val.i_int? Qt::Checked
                                                              : Qt::Unchecked );
        else if( spinbox )  spinbox->setValue( val.i_int );
442
        else if( dial )     dial->setValue( ( 540-val.i_int )%360 );
443
444
445
446
447
448
        else if( lineedit )
        {
            char str[30];
            sprintf( str, "%06X", val.i_int );
            lineedit->setText( str );
        }
449
        else if( combobox ) combobox->setCurrentIndex(
450
                            combobox->findData( val.i_int ) );
451
452
453
454
455
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
    }
    else if( i_type == VLC_VAR_FLOAT )
    {
        double f_float = 0;
456
457
        if( slider ) slider->setValue( ( int )( val.f_float*( double )slider->tickInterval() ) ); /* hack alert! */
        else if( doublespinbox ) doublespinbox->setValue( val.f_float );
458
459
460
461
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
    }
    else if( i_type == VLC_VAR_STRING )
    {
462
        if( lineedit ) lineedit->setText( qfu( val.psz_string ) );
463
        else if( combobox ) combobox->setCurrentIndex(
464
                            combobox->findData( qfu( val.psz_string ) ) );
465
466
467
468
469
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
        free( val.psz_string );
    }
    else
        msg_Err( p_intf,
470
                 "Module %s's %s variable is of an unsupported type ( %d )",
471
472
                 qtu( module ),
                 qtu( option ),
473
474
475
476
477
478
                 i_type );
}

void ExtVideo::updateFilterOptions()
{
    QString module = ModuleFromWidgetName( sender()->parent() );
479
    //std::cout << "Module name: " << module.toStdString() << std::endl;
480
    QString option = OptionFromWidgetName( sender() );
481
    //std::cout << "Option name: " << option.toStdString() << std::endl;
482

483
    vlc_object_t *p_obj = ( vlc_object_t * )
484
        vlc_object_find_name( p_intf->p_libvlc,
485
                              qtu( module ),
486
487
488
                              FIND_CHILD );
    if( !p_obj )
    {
489
        msg_Err( p_intf, "Module %s not found.", qtu( module ) );
490
491
492
        return;
    }

493
    int i_type = var_Type( p_obj, qtu( option ) );
494
495
    bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
    if( !b_is_command )
496
    {
497
        msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.",
498
499
                 qtu( module ),
                 qtu( option ) );
500
        /* FIXME: restart automatically somewhere near the end of this function */
501
502
503
504
    }

    /* Try to cast to all the widgets we're likely to encounter. Only
     * one of the casts is expected to work. */
505
506
507
508
509
510
511
    QSlider        *slider        = qobject_cast<QSlider*>       ( sender() );
    QCheckBox      *checkbox      = qobject_cast<QCheckBox*>     ( sender() );
    QSpinBox       *spinbox       = qobject_cast<QSpinBox*>      ( sender() );
    QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
    QDial          *dial          = qobject_cast<QDial*>         ( sender() );
    QLineEdit      *lineedit      = qobject_cast<QLineEdit*>     ( sender() );
    QComboBox      *combobox      = qobject_cast<QComboBox*>     ( sender() );
512
513
514
515
516
517
518
519

    i_type &= 0xf0;
    if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
    {
        int i_int = 0;
        if( slider )        i_int = slider->value();
        else if( checkbox ) i_int = checkbox->checkState() == Qt::Checked;
        else if( spinbox )  i_int = spinbox->value();
520
521
522
        else if( dial )     i_int = ( 540-dial->value() )%360;
        else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
        else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
523
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
524
        config_PutInt( p_intf, qtu( option ), i_int );
525
526
527
        if( b_is_command )
        {
            if( i_type == VLC_VAR_INTEGER )
528
                var_SetInteger( p_obj, qtu( option ), i_int );
529
            else
530
                var_SetBool( p_obj, qtu( option ), i_int );
531
        }
532
533
534
535
    }
    else if( i_type == VLC_VAR_FLOAT )
    {
        double f_float = 0;
536
537
        if( slider )             f_float = ( double )slider->value()
                                         / ( double )slider->tickInterval(); /* hack alert! */
538
539
540
        else if( doublespinbox ) f_float = doublespinbox->value();
        else if( lineedit ) f_float = lineedit->text().toDouble();
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
541
        config_PutFloat( p_intf, qtu( option ), f_float );
542
        if( b_is_command )
543
            var_SetFloat( p_obj, qtu( option ), f_float );
544
545
546
    }
    else if( i_type == VLC_VAR_STRING )
    {
547
        char *psz_string = NULL;
548
        if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
549
        else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
550
                                       combobox->currentIndex() ).toString() ) );
551
        else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
552
        config_PutPsz( p_intf, qtu( option ), psz_string );
553
        if( b_is_command )
554
            var_SetString( p_obj, qtu( option ), psz_string );
555
        free( psz_string );
556
557
558
    }
    else
        msg_Err( p_intf,
559
                 "Module %s's %s variable is of an unsupported type ( %d )",
560
561
                 qtu( module ),
                 qtu( option ),
562
563
564
565
566
567
                 i_type );

    vlc_object_release( p_obj );
}

#if 0
zorglub's avatar
zorglub committed
568
569
void ExtVideo::gotoConf( QObject* src )
{
570
571
#define SHOWCONF( module ) \
    if( src->objectName().contains( module ) ) \
zorglub's avatar
zorglub committed
572
573
574
575
576
577
578
579
580
581
582
583
584
585
    { \
        PrefsDialog::getInstance( p_intf )->showModulePrefs( module ); \
        return; \
    }
    SHOWCONF( "clone" );
    SHOWCONF( "magnify" );
    SHOWCONF( "wave" );
    SHOWCONF( "ripple" );
    SHOWCONF( "invert" );
    SHOWCONF( "puzzle" );
    SHOWCONF( "wall" );
    SHOWCONF( "gradient" );
    SHOWCONF( "colorthres" )
}
586
#endif
zorglub's avatar
zorglub committed
587

588
589
590
591
592
593
594
595
596
597
598
/**********************************************************************
 * v4l2 controls
 **********************************************************************/

ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
    : QWidget( _parent ), p_intf( _p_intf )
{
    ui.setupUi( this );

    BUTTONACT( ui.refresh, Refresh() );

599
    box = NULL;
600
601
602
603
}

ExtV4l2::~ExtV4l2()
{
604
605
    if( box )
        delete box;
606
607
}

608
609
610
611
612
613
void ExtV4l2::showEvent( QShowEvent *event )
{
    QWidget::showEvent( event );
    Refresh();
}

614
615
616
void ExtV4l2::Refresh( void )
{
    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
617
618
619
620
621
622
623
    ui.help->hide();
    if( box )
    {
        ui.vboxLayout->removeWidget( box );
        delete box;
        box = NULL;
    }
624
625
626
627
628
629
630
    if( p_obj )
    {
        vlc_value_t val, text, name;
        int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
                                &val, &text );
        if( i_ret < 0 )
        {
631
632
            msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
            ui.help->show();
633
634
635
            vlc_object_release( p_obj );
            return;
        }
636
637
638
639
640
641

        box = new QGroupBox( this );
        ui.vboxLayout->addWidget( box );
        QVBoxLayout *layout = new QVBoxLayout( box );
        box->setLayout( layout );

642
643
644
645
646
647
648
649
650
651
652
653
654
        for( int i = 0; i < val.p_list->i_count; i++ )
        {
            const char *psz_var = text.p_list->p_values[i].psz_string;
            var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &name, NULL );
            const char *psz_label = name.psz_string;
            msg_Dbg( p_intf, "v4l2 control \"%x\": %s (%s)",
                     val.p_list->p_values[i].i_int, psz_var, name.psz_string );

            int i_type = var_Type( p_obj, psz_var );
            switch( i_type & VLC_VAR_TYPE )
            {
                case VLC_VAR_INTEGER:
                {
655
                    QLabel *label = new QLabel( psz_label, box );
656
                    QHBoxLayout *hlayout = new QHBoxLayout();
657
658
659
660
                    hlayout->addWidget( label );
                    int i_val = var_GetInteger( p_obj, psz_var );
                    if( i_type & VLC_VAR_HASCHOICE )
                    {
661
                        QComboBox *combobox = new QComboBox( box );
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
                        combobox->setObjectName( psz_var );

                        vlc_value_t val2, text2;
                        var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
                                    &val2, &text2 );
                        for( int j = 0; j < val2.p_list->i_count; j++ )
                        {
                            combobox->addItem(
                                       text2.p_list->p_values[j].psz_string,
                                       val2.p_list->p_values[j].i_int );
                            if( i_val == val2.p_list->p_values[j].i_int )
                                combobox->setCurrentIndex( j );
                        }
                        var_Change( p_obj, psz_var, VLC_VAR_FREELIST,
                                    &val2, &text2 );

                        CONNECT( combobox, currentIndexChanged( int ), this,
                                 ValueChange( int ) );
                        hlayout->addWidget( combobox );
                    }
                    else
                    {
684
                        QSlider *slider = new QSlider( box );
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
                        slider->setObjectName( psz_var );
                        slider->setOrientation( Qt::Horizontal );
                        vlc_value_t val2;
                        var_Change( p_obj, psz_var, VLC_VAR_GETMIN,
                                    &val2, NULL );
                        slider->setMinimum( val2.i_int );
                        var_Change( p_obj, psz_var, VLC_VAR_GETMAX,
                                    &val2, NULL );
                        slider->setMaximum( val2.i_int );
                        var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
                                    &val2, NULL );
                        slider->setSingleStep( val2.i_int );
                        slider->setValue( i_val );

                        CONNECT( slider, valueChanged( int ), this,
                                 ValueChange( int ) );
                        hlayout->addWidget( slider );
                    }
                    layout->addLayout( hlayout );
                    break;
                }
                case VLC_VAR_BOOL:
                {
708
                    QCheckBox *button = new QCheckBox( psz_label, box );
709
710
711
712
713
714
715
716
717
718
                    button->setObjectName( psz_var );
                    button->setChecked( var_GetBool( p_obj, psz_var ) );

                    CONNECT( button, clicked( bool ), this,
                             ValueChange( bool ) );
                    layout->addWidget( button );
                    break;
                }
                case VLC_VAR_VOID:
                {
719
720
721
722
                    if( i_type & VLC_VAR_ISCOMMAND )
                    {
                        QPushButton *button = new QPushButton( psz_label, box );
                        button->setObjectName( psz_var );
723

724
725
726
727
728
729
730
731
732
                        CONNECT( button, clicked( bool ), this,
                                 ValueChange( bool ) );
                        layout->addWidget( button );
                    }
                    else
                    {
                        QLabel *label = new QLabel( psz_label, box );
                        layout->addWidget( label );
                    }
733
734
735
736
737
738
739
740
741
742
743
744
745
746
                    break;
                }
                default:
                    msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
                    break;
            }
            free( name.psz_string );
        }
        var_Change( p_obj, "controls", VLC_VAR_FREELIST, &val, &text );
        vlc_object_release( p_obj );
    }
    else
    {
        msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
747
        ui.help->show();
748
749
750
751
752
753
754
755
756
757
758
759
760
761
    }
}

void ExtV4l2::ValueChange( bool value )
{
    ValueChange( (int)value );
}

void ExtV4l2::ValueChange( int value )
{
    QObject *s = sender();
    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
    if( p_obj )
    {
762
        char *psz_var = strdup( qtu( s->objectName() ) );
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
        int i_type = var_Type( p_obj, psz_var );
        switch( i_type & VLC_VAR_TYPE )
        {
            case VLC_VAR_INTEGER:
                if( i_type & VLC_VAR_HASCHOICE )
                {
                    QComboBox *combobox = qobject_cast<QComboBox*>( s );
                    value = combobox->itemData( value ).toInt();
                }
                var_SetInteger( p_obj, psz_var, value );
                break;
            case VLC_VAR_BOOL:
                var_SetBool( p_obj, psz_var, value );
                break;
            case VLC_VAR_VOID:
                var_SetVoid( p_obj, psz_var );
                break;
        }
        free( psz_var );
        vlc_object_release( p_obj );
    }
    else
    {
        msg_Warn( p_intf, "Oops, v4l2 object isn't available anymore" );
        Refresh();
    }
}

zorglub's avatar
zorglub committed
791
792
793
794
/**********************************************************************
 * Equalizer
 **********************************************************************/

zorglub's avatar
zorglub committed
795
796
static const QString band_frequencies[] =
{
797
798
    "  60 Hz  ", " 170 Hz ", " 310 Hz ", " 600 Hz ", "  1 kHz ",
    "  3 kHz  ", "  6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
zorglub's avatar
zorglub committed
799
800
801
802
803
};

Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
                            QWidget( _parent ) , p_intf( _p_intf )
{
804
    QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
zorglub's avatar
zorglub committed
805
806
    smallFont.setPointSize( smallFont.pointSize() - 3 );

zorglub's avatar
zorglub committed
807
    ui.setupUi( this );
808
    presetsComboBox = ui.presetsCombo;
zorglub's avatar
zorglub committed
809

zorglub's avatar
zorglub committed
810
811
    ui.preampLabel->setFont( smallFont );
    ui.preampSlider->setMaximum( 400 );
zorglub's avatar
zorglub committed
812
813
    for( int i = 0 ; i < NB_PRESETS ; i ++ )
    {
Christophe Mutricy's avatar
Christophe Mutricy committed
814
        ui.presetsCombo->addItem( qtr( preset_list_text[i] ),
zorglub's avatar
zorglub committed
815
816
817
818
                                  QVariant( i ) );
    }
    CONNECT( ui.presetsCombo, activated( int ), this, setPreset( int ) );

zorglub's avatar
zorglub committed
819
820
821
    BUTTONACT( ui.enableCheck, enable() );
    BUTTONACT( ui.eq2PassCheck, set2Pass() );

822
    CONNECT( ui.preampSlider, valueChanged( int ), this, setPreamp() );
zorglub's avatar
zorglub committed
823
824
825

    QGridLayout *grid = new QGridLayout( ui.frame );
    grid->setMargin( 0 );
zorglub's avatar
zorglub committed
826
827
    for( int i = 0 ; i < BANDS ; i++ )
    {
zorglub's avatar
zorglub committed
828
        bands[i] = new QSlider( Qt::Vertical );
zorglub's avatar
zorglub committed
829
        bands[i]->setMaximum( 400 );
zorglub's avatar
zorglub committed
830
        bands[i]->setValue( 200 );
831
        CONNECT( bands[i], valueChanged( int ), this, setBand() );
zorglub's avatar
zorglub committed
832
        band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" );
zorglub's avatar
zorglub committed
833
        band_texts[i]->setFont( smallFont );
zorglub's avatar
zorglub committed
834
835
836
        grid->addWidget( bands[i], 0, i );
        grid->addWidget( band_texts[i], 1, i );
    }
zorglub's avatar
zorglub committed
837
838

    /* Write down initial values */
839
840
    aout_instance_t *p_aout = ( aout_instance_t * )vlc_object_find( p_intf,
                                    VLC_OBJECT_AOUT, FIND_ANYWHERE );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
841
    char *psz_af;
zorglub's avatar
zorglub committed
842
843
844
845
    char *psz_bands;
    float f_preamp;
    if( p_aout )
    {
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
846
        psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
zorglub's avatar
zorglub committed
847
848
        if( var_GetBool( p_aout, "equalizer-2pass" ) )
            ui.eq2PassCheck->setChecked( true );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
849
        psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
zorglub's avatar
zorglub committed
850
851
852
853
854
855
856
857
858
859
860
861
862
        f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
        vlc_object_release( p_aout );
    }
    else
    {
        psz_af = config_GetPsz( p_intf, "audio-filter" );
        if( config_GetInt( p_intf, "equalizer-2pass" ) )
            ui.eq2PassCheck->setChecked( true );
        psz_bands = config_GetPsz( p_intf, "equalizer-bands" );
        f_preamp = config_GetFloat( p_intf, "equalizer-preamp" );
    }
    if( psz_af && strstr( psz_af, "equalizer" ) != NULL )
        ui.enableCheck->setChecked( true );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
863
    free( psz_af );
zorglub's avatar
zorglub committed
864
865
866
    enable( ui.enableCheck->isChecked() );

    setValues( psz_bands, f_preamp );
zorglub's avatar
zorglub committed
867
868
869
870
871
872
873
874
875
876
}

Equalizer::~Equalizer()
{
}

void Equalizer::enable()
{
    bool en = ui.enableCheck->isChecked();
    aout_EnableFilter( VLC_OBJECT( p_intf ), "equalizer",
877
                       en ? true : false );
878
//    aout_EnableFilter( VLC_OBJECT( p_intf ), "upmixer",
879
//                       en ? true : false );
880
//     aout_EnableFilter( VLC_OBJECT( p_intf ), "vsurround",
881
//                       en ? true : false );
882
     enable( en );
zorglub's avatar
zorglub committed
883
}
zorglub's avatar
zorglub committed
884

zorglub's avatar
zorglub committed
885
886
void Equalizer::enable( bool en )
{
zorglub's avatar
zorglub committed
887
    ui.eq2PassCheck->setEnabled( en );
zorglub's avatar
zorglub committed
888
    ui.preampLabel->setEnabled( en );
zorglub's avatar
zorglub committed
889
890
891
892
893
894
895
896
897
    ui.preampSlider->setEnabled( en  );
    for( int i = 0 ; i< BANDS; i++ )
    {
        bands[i]->setEnabled( en ); band_texts[i]->setEnabled( en );
    }
}

void Equalizer::set2Pass()
{
898
899
    aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
                                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
900
    bool b_2p = ui.eq2PassCheck->isChecked();
zorglub's avatar
zorglub committed
901
902
903
904
905
906
907
908
909

    if( p_aout == NULL )
        config_PutInt( p_intf, "equalizer-2pass", b_2p );
    else
    {
        var_SetBool( p_aout, "equalizer-2pass", b_2p );
        config_PutInt( p_intf, "equalizer-2pass", b_2p );
        for( int i = 0; i < p_aout->i_nb_inputs; i++ )
        {
910
            p_aout->pp_inputs[i]->b_restart = true;
zorglub's avatar
zorglub committed
911
912
913
914
915
916
917
        }
        vlc_object_release( p_aout );
    }
}

void Equalizer::setPreamp()
{
918
    float f= ( float )(  ui.preampSlider->value() ) /10 - 20;
zorglub's avatar
zorglub committed
919
    char psz_val[5];
920
921
    aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
                                       VLC_OBJECT_AOUT, FIND_ANYWHERE );
zorglub's avatar
zorglub committed
922
923

    sprintf( psz_val, "%.1f", f );
924
    ui.preampLabel->setText( qtr( "Preamp\n" ) + psz_val + qtr( "dB" ) );
zorglub's avatar
zorglub committed
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
    if( p_aout )
    {
        delCallbacks( p_aout );
        var_SetFloat( p_aout, "equalizer-preamp", f );
        addCallbacks( p_aout );
        vlc_object_release( p_aout );
    }
    config_PutFloat( p_intf, "equalizer-preamp", f );
}

void Equalizer::setBand()
{
    char psz_values[102]; memset( psz_values, 0, 102 );

    /**\todo smoothing */

    for( int i = 0 ; i< BANDS ; i++ )
    {
943
        char psz_val[8];
944
        float f_val = ( float )(  bands[i]->value() ) / 10 - 20 ;
zorglub's avatar
zorglub committed
945
        sprintf( psz_values, "%s %f", psz_values, f_val );
zorglub's avatar
zorglub committed
946
        sprintf( psz_val, "% 5.1f", f_val );
zorglub's avatar
zorglub committed
947
948
        band_texts[i]->setText( band_frequencies[i] + "\n" + psz_val + "dB" );
    }
949
950
    aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
                                          VLC_OBJECT_AOUT, FIND_ANYWHERE );
zorglub's avatar
zorglub committed
951
952
953
954
955
956
957
958
959
960
961
    if( p_aout )
    {
        delCallbacks( p_aout );
        var_SetString( p_aout, "equalizer-bands", psz_values );
        addCallbacks( p_aout );
        vlc_object_release( p_aout );
    }
}
void Equalizer::setValues( char *psz_bands, float f_preamp )
{
    char *p = psz_bands;
zorglub's avatar
zorglub committed
962
    if ( p )
zorglub's avatar
zorglub committed
963
    {
964
        for( int i = 0; i < BANDS; i++ )
zorglub's avatar
zorglub committed
965
        {
966
            char psz_val[8];
zorglub's avatar
zorglub committed
967
            float f = strtof( p, &p );
968
            int  i_val= ( int )( ( f + 20 ) * 10 );
zorglub's avatar
zorglub committed
969
970
971
972
            bands[i]->setValue(  i_val );
            sprintf( psz_val, "% 5.1f", f );
            band_texts[i]->setText( band_frequencies[i] + "\n" + psz_val +
                                    "dB" );
973
            if( p == NULL || *p == '\0' ) break;
zorglub's avatar
zorglub committed
974
            p++;
975
            if( *p == '\0' )  break;
zorglub's avatar
zorglub committed
976
        }
zorglub's avatar
zorglub committed
977
978
    }
    char psz_val[5];
979
    int i_val = ( int )( ( f_preamp + 20 ) * 10 );
zorglub's avatar
zorglub committed
980
    sprintf( psz_val, "%.1f", f_preamp );
zorglub's avatar
zorglub committed
981
    ui.preampSlider->setValue( i_val );
982
    ui.preampLabel->setText( qtr( "Preamp\n" ) + psz_val + qtr( "dB" ) );
zorglub's avatar
zorglub committed
983
984
985
986
}

void Equalizer::setPreset( int preset )
{
987
988
    aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
                                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
zorglub's avatar
zorglub committed
989
990

    char psz_values[102]; memset( psz_values, 0, 102 );
991
992
993
994
995
996
997
998
    char psz_values2[102];memset( psz_values2, 0, 102 );
    for( int i = 0 ; i< BANDS ;i++ )
    {
        strcpy( psz_values2, psz_values );

        sprintf( psz_values, "%s %5.1f",
                 psz_values2, eqz_preset_10b[preset]->f_amp[i] );
    }
zorglub's avatar
zorglub committed
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015

    if( p_aout )
    {
        delCallbacks( p_aout );
        var_SetString( p_aout, "equalizer-bands", psz_values );
        var_SetFloat( p_aout, "equalizer-preamp",
                      eqz_preset_10b[preset]->f_preamp );
        addCallbacks( p_aout );
        vlc_object_release( p_aout );
    }
    config_PutPsz( p_intf, "equalizer-bands", psz_values );
    config_PutFloat( p_intf, "equalizer-preamp",
                    eqz_preset_10b[preset]->f_preamp );

    setValues( psz_values, eqz_preset_10b[preset]->f_preamp );
}

1016
1017
1018
1019
static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    char *psz_preset = newval.psz_string;
1020
1021
    Equalizer *eq = ( Equalizer * )p_data;
    eq->presetsComboBox->setCurrentIndex( eq->presetsComboBox->findText( qfu( psz_preset ) ) );
1022
1023
1024
    return VLC_SUCCESS;
}

zorglub's avatar
zorglub committed
1025
1026
void Equalizer::delCallbacks( aout_instance_t *p_aout )
{
1027
1028
1029
    //var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this );
    //var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this );
    var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this );
zorglub's avatar
zorglub committed
1030
1031
1032
1033
}

void Equalizer::addCallbacks( aout_instance_t *p_aout )
{
1034
1035
1036
    //var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this );
    //var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this );
    var_AddCallback( p_aout, "equalizer-preset", PresetCallback, this );
zorglub's avatar
zorglub committed
1037
}
zorglub's avatar
zorglub committed
1038

1039
1040
1041
1042
/**********************************************************************
 * Audio filters
 **********************************************************************/

1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
/**********************************************************************
 * Spatializer
 **********************************************************************/
static const char *psz_control_names[] =
{
    "Roomsize", "Width" , "Wet", "Dry", "Damp"
};

Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
    QWidget( _parent ) , p_intf( _p_intf )
{
1054
    QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
1055
1056
    smallFont.setPointSize( smallFont.pointSize() - 3 );

1057
1058
    QGridLayout *layout = new QGridLayout( this );
    layout->setMargin( 0 );
1059

1060
1061
    enableCheck = new QCheckBox( qfu( "Enable spatializer" ) );
    layout->addWidget( enableCheck, 0, 0, 1, NUM_SP_CTRL );
1062
1063
1064
1065

    for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
    {
        spatCtrl[i] = new QSlider( Qt::Vertical );
1066
        if( i < 2 )
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
        {
            spatCtrl[i]->setMaximum( 10 );
            spatCtrl[i]->setValue( 2 );
        }
        else
        {
            spatCtrl[i]->setMaximum( 10 );
            spatCtrl[i]->setValue( 0 );
            spatCtrl[i]->setMinimum( -10 );
        }
        oldControlVars[i] = spatCtrl[i]->value();
1078
1079
        CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
        ctrl_texts[i] = new QLabel( qfu( psz_control_names[i] ) + "\n" );
1080
1081
1082
        ctrl_texts[i]->setFont( smallFont );
        ctrl_readout[i] = new QLabel( "" );
        ctrl_readout[i]->setFont( smallFont );
1083
1084
1085
        layout->addWidget( spatCtrl[i], 1, i );
        layout->addWidget( ctrl_readout[i], 2, i );
        layout->addWidget( ctrl_texts[i], 3, i );
1086
1087
    }

1088
    BUTTONACT( enableCheck, enable() );