]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.cpp
Preferences: fix some memleaks and fix horrible video-filter bug. :D
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
1 /*****************************************************************************
2  * preferences_widgets.cpp : Widgets for preferences displays
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.org>
9  *          Jean-Baptiste Kempf <jb@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /**
27  * Todo:
28  *  - Finish implementation (see WX, there might be missing a
29  *    i_action handler for IntegerLists, but I don't see any module using it...
30  *  - Improvements over WX
31  *      - Validator for modulelist
32  */
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include "components/preferences_widgets.hpp"
38 #include "util/customwidgets.hpp"
39 #include <vlc_keys.h>
40
41 #include <QString>
42 #include <QVariant>
43 #include <QGridLayout>
44 #include <QSlider>
45 #include <QFileDialog>
46 #include <QGroupBox>
47 #include <QTreeWidgetItem>
48 #include <QSignalMapper>
49 #include <QDialogButtonBox>
50
51 #define MINWIDTH_BOX 90
52 #define LAST_COLUMN 10
53
54 QString formatTooltip(const QString & tooltip)
55 {
56     QString formatted =
57     "<html><head><meta name=\"qrichtext\" content=\"1\" />"
58     "<style type=\"text/css\"> p, li { white-space: pre-wrap; } </style></head>"
59     "<body style=\" font-family:'Sans Serif'; font-size:9pt; font-weight:400; "
60     "font-style:normal; text-decoration:none;\">"
61     "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
62     "margin-right:0px; -qt-block-indent:0; text-indent:0px;\">" +
63     tooltip +
64     "</p></body></html>";
65     return formatted;
66 }
67
68 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
69                                              module_config_t *p_item,
70                                              QWidget *parent )
71 {
72     int i = 0;
73     return createControl( p_this, p_item, parent, NULL, i );
74 }
75
76 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
77                                              module_config_t *p_item,
78                                              QWidget *parent,
79                                              QGridLayout *l, int &line )
80 {
81     ConfigControl *p_control = NULL;
82
83     switch( p_item->i_type )
84     {
85     case CONFIG_ITEM_MODULE:
86         p_control = new ModuleConfigControl( p_this, p_item, parent, false,
87                                              l, line );
88         break;
89     case CONFIG_ITEM_MODULE_CAT:
90         p_control = new ModuleConfigControl( p_this, p_item, parent, true,
91                                              l, line );
92         break;
93     case CONFIG_ITEM_MODULE_LIST:
94         p_control = new ModuleListConfigControl( p_this, p_item, parent, false,
95                                              l, line );
96         break;
97     case CONFIG_ITEM_MODULE_LIST_CAT:
98         p_control = new ModuleListConfigControl( p_this, p_item, parent, true,
99                                              l, line );
100         break;
101     case CONFIG_ITEM_STRING:
102         if( !p_item->i_list )
103             p_control = new StringConfigControl( p_this, p_item, parent,
104                                                  l, line, false );
105         else
106             p_control = new StringListConfigControl( p_this, p_item,
107                                             parent, false, l, line );
108         break;
109     case CONFIG_ITEM_PASSWORD:
110         if( !p_item->i_list )
111             p_control = new StringConfigControl( p_this, p_item, parent,
112                                                  l, line, true );
113         else
114             p_control = new StringListConfigControl( p_this, p_item,
115                                             parent, true, l, line );
116         break;
117     case CONFIG_ITEM_INTEGER:
118         if( p_item->i_list )
119             p_control = new IntegerListConfigControl( p_this, p_item,
120                                             parent, false, l, line );
121         else if( p_item->min.i || p_item->max.i )
122             p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
123                                                        l, line );
124         else
125             p_control = new IntegerConfigControl( p_this, p_item, parent,
126                                                   l, line );
127         break;
128     case CONFIG_ITEM_FILE:
129         p_control = new FileConfigControl( p_this, p_item, parent, l,
130                                                 line, false );
131         break;
132     case CONFIG_ITEM_DIRECTORY:
133         p_control = new DirectoryConfigControl( p_this, p_item, parent, l,
134                                                 line, false );
135         break;
136 #if 0
137     case CONFIG_ITEM_FONT:
138         p_control = new FontConfigControl( p_this, p_item, parent, l,
139                                            line, false );
140         break;
141 #endif
142     case CONFIG_ITEM_KEY:
143         p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
144         break;
145     case CONFIG_ITEM_BOOL:
146         p_control = new BoolConfigControl( p_this, p_item, parent, l, line );
147         break;
148     case CONFIG_ITEM_FLOAT:
149         if( p_item->min.f || p_item->max.f )
150             p_control = new FloatRangeConfigControl( p_this, p_item, parent,
151                                                      l, line );
152         else
153             p_control = new FloatConfigControl( p_this, p_item, parent,
154                                                   l, line );
155         break;
156     default:
157         break;
158     }
159     return p_control;
160 }
161
162 void ConfigControl::doApply( intf_thread_t *p_intf )
163 {
164     switch( getType() )
165     {
166         case CONFIG_ITEM_INTEGER:
167         case CONFIG_ITEM_BOOL:
168         {
169             VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
170             assert( vicc );
171             config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
172             break;
173         }
174         case CONFIG_ITEM_FLOAT:
175         {
176             VFloatConfigControl *vfcc =
177                                     qobject_cast<VFloatConfigControl *>(this);
178             assert( vfcc );
179             config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
180             break;
181         }
182         case CONFIG_ITEM_STRING:
183         {
184             VStringConfigControl *vscc =
185                             qobject_cast<VStringConfigControl *>(this);
186             assert( vscc );
187             config_PutPsz( p_intf, vscc->getName(), qtu( vscc->getValue() ) );
188             break;
189         }
190         case CONFIG_ITEM_KEY:
191         {
192             KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
193             assert( ksc );
194             ksc->doApply();
195         }
196     }
197 }
198
199 /**************************************************************************
200  * String-based controls
201  *************************************************************************/
202
203 /*********** String **************/
204 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
205                                           module_config_t *_p_item,
206                                           QWidget *_parent, QGridLayout *l,
207                                           int &line, bool pwd ) :
208                            VStringConfigControl( _p_this, _p_item, _parent )
209 {
210     label = new QLabel( qtr(p_item->psz_text) );
211     text = new QLineEdit( qfu(p_item->value.psz) );
212     if( pwd ) text->setEchoMode( QLineEdit::Password );
213     finish();
214
215     if( !l )
216     {
217         QHBoxLayout *layout = new QHBoxLayout();
218         layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
219         layout->addWidget( text, LAST_COLUMN );
220         widget->setLayout( layout );
221     }
222     else
223     {
224         l->addWidget( label, line, 0 );
225         l->setColumnMinimumWidth( 1, 10 );
226         l->addWidget( text, line, LAST_COLUMN );
227     }
228 }
229
230 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
231                                    module_config_t *_p_item,
232                                    QLabel *_label, QLineEdit *_text, bool pwd ):
233                            VStringConfigControl( _p_this, _p_item )
234 {
235     text = _text;
236     label = _label;
237     finish( );
238 }
239
240 void StringConfigControl::finish()
241 {
242     text->setText( qfu(p_item->value.psz) );
243     text->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
244     if( label )
245         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
246 }
247
248 /*********** File **************/
249 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
250                                           module_config_t *_p_item,
251                                           QWidget *_parent, QGridLayout *l,
252                                           int &line, bool pwd ) :
253                            VStringConfigControl( _p_this, _p_item, _parent )
254 {
255     label = new QLabel( qtr(p_item->psz_text) );
256     text = new QLineEdit( qfu(p_item->value.psz) );
257     browse = new QPushButton( qtr( "Browse..." ) );
258     QHBoxLayout *textAndButton = new QHBoxLayout();
259     textAndButton->setMargin( 0 );
260     textAndButton->addWidget( text, 2 );
261     textAndButton->addWidget( browse, 0 );
262
263     BUTTONACT( browse, updateField() );
264
265     finish();
266
267     if( !l )
268     {
269         QHBoxLayout *layout = new QHBoxLayout();
270         layout->addWidget( label, 0 );
271         layout->insertSpacing( 1, 10 );
272         layout->addLayout( textAndButton, LAST_COLUMN );
273         widget->setLayout( layout );
274     }
275     else
276     {
277         l->addWidget( label, line, 0 );
278         l->setColumnMinimumWidth( 1, 10 );
279         l->addLayout( textAndButton, line, LAST_COLUMN );
280     }
281 }
282
283
284 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
285                                    module_config_t *_p_item,
286                                    QLabel *_label, QLineEdit *_text,
287                                    QPushButton *_button, bool pwd ):
288                            VStringConfigControl( _p_this, _p_item )
289 {
290     browse = _button;
291     text = _text;
292     label = _label;
293
294     BUTTONACT( browse, updateField() );
295
296     finish( );
297 }
298
299 void FileConfigControl::updateField()
300 {
301     QString file = QFileDialog::getOpenFileName( NULL,
302                   qtr( "Select File" ), qfu( config_GetHomeDir() ) );
303     if( file.isNull() ) return;
304     text->setText( file );
305 }
306
307 void FileConfigControl::finish()
308 {
309     text->setText( qfu(p_item->value.psz) );
310     text->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
311     if( label )
312         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
313 }
314
315 /********* String / Directory **********/
316 DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
317                         module_config_t *_p_item, QWidget *_p_widget,
318                         QGridLayout *_p_layout, int& _int, bool _pwd ) :
319      FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd)
320 {}
321
322 DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
323                         module_config_t *_p_item, QLabel *_p_label,
324                         QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ):
325      FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
326 {}
327
328 void DirectoryConfigControl::updateField()
329 {
330     QString dir = QFileDialog::getExistingDirectory( NULL,
331                       qtr( "Select Directory" ),
332                       text->text().isEmpty() ?
333                         qfu( config_GetHomeDir() ) : text->text(),
334                       QFileDialog::ShowDirsOnly |
335                         QFileDialog::DontResolveSymlinks );
336     if( dir.isNull() ) return;
337     text->setText( dir );
338 }
339
340 #if 0
341 #include <QFontDialog>
342
343 /********* String / Font **********/
344 FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
345                         module_config_t *_p_item, QWidget *_p_widget,
346                         QGridLayout *_p_layout, int& _int, bool _pwd ) :
347      FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd)
348 {}
349
350 FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
351                         module_config_t *_p_item, QLabel *_p_label,
352                         QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ):
353      FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
354 {}
355
356 void FontConfigControl::updateField()
357 {
358     bool ok;
359     QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL );
360     if( !ok ) return;
361     text->setText( font.family() );
362 }
363 #endif
364
365 /********* String / choice list **********/
366 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
367                module_config_t *_p_item, QWidget *_parent, bool bycat,
368                QGridLayout *l, int &line) :
369                VStringConfigControl( _p_this, _p_item, _parent )
370 {
371     label = new QLabel( qtr(p_item->psz_text) );
372     combo = new QComboBox();
373     combo->setMinimumWidth( MINWIDTH_BOX );
374     combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
375
376     module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
377     if(p_module_config && p_module_config->pf_update_list)
378     {
379        vlc_value_t val;
380        val.psz_string = strdup(p_module_config->value.psz);
381
382        p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
383
384        // assume in any case that dirty was set to true
385        // because lazy programmes will use the same callback for
386        // this, like the one behind the refresh push button?
387        p_module_config->b_dirty = false;
388
389        free( val.psz_string );
390     }
391
392     finish( p_module_config, bycat );
393     if( !l )
394     {
395         l = new QGridLayout();
396         l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN );
397         widget->setLayout( l );
398     }
399     else
400     {
401         l->addWidget( label, line, 0 );
402         l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
403     }
404
405     if( p_item->i_action )
406     {
407         QSignalMapper *signalMapper = new QSignalMapper(this);
408
409         /* Some stringLists like Capture listings have action associated */
410         for( int i = 0; i < p_item->i_action; i++ )
411         {
412             QPushButton *button =
413                 new QPushButton( qfu( p_item->ppsz_action_text[i] ));
414             CONNECT( button, clicked(), signalMapper, map() );
415             signalMapper->setMapping( button, i );
416             l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
417                     Qt::AlignRight );
418         }
419         CONNECT( signalMapper, mapped( int ),
420                 this, actionRequested( int ) );
421     }
422 }
423
424 void StringListConfigControl::actionRequested( int i_action )
425 {
426     /* Supplementary check for boundaries */
427     if( i_action < 0 || i_action >= p_item->i_action ) return;
428
429     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
430     if(!p_module_config) return;
431
432     vlc_value_t val;
433     val.psz_string =
434         qtu( (combo->itemData( combo->currentIndex() ).toString() ) );
435
436     p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
437
438     if( p_module_config->b_dirty )
439     {
440         combo->clear();
441         finish( p_module_config, true );
442         p_module_config->b_dirty = false;
443     }
444 }
445 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
446                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
447                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
448 {
449     combo = _combo;
450     label = _label;
451
452     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
453
454     finish( p_module_config, bycat );
455 }
456
457 void StringListConfigControl::finish(module_config_t *p_module_config, bool bycat )
458 {
459     combo->setEditable( false );
460
461     if(!p_module_config) return;
462
463     for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
464     {
465         combo->addItem( qfu((p_module_config->ppsz_list_text &&
466                             p_module_config->ppsz_list_text[i_index])?
467                             p_module_config->ppsz_list_text[i_index] :
468                             p_module_config->ppsz_list[i_index] ),
469                    QVariant( qfu(p_module_config->ppsz_list[i_index] )) );
470         if( p_item->value.psz && !strcmp( p_module_config->value.psz,
471                                           p_module_config->ppsz_list[i_index] ) )
472             combo->setCurrentIndex( combo->count() - 1 );
473     }
474     combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
475     if( label )
476         label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
477 }
478
479 QString StringListConfigControl::getValue()
480 {
481     return combo->itemData( combo->currentIndex() ).toString();
482 }
483
484 void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf,
485                         QComboBox *combo, QWidget *parent )
486 {
487     module_config_t *p_config =
488                       config_FindConfig( VLC_OBJECT(p_intf), configname );
489     if( p_config )
490     {
491        if(p_config->pf_update_list)
492         {
493             vlc_value_t val;
494             val.i_int = p_config->value.i;
495             p_config->pf_update_list(VLC_OBJECT(p_intf), configname, val, val, NULL);
496             // assume in any case that dirty was set to true
497             // because lazy programmes will use the same callback for
498             // this, like the one behind the refresh push button?
499             p_config->b_dirty = false;
500         }
501
502         for ( int i_index = 0; i_index < p_config->i_list; i_index++ )
503         {
504             combo->addItem( qfu( p_config->ppsz_list_text[i_index] ),
505                     QVariant( p_config->pi_list[i_index] ) );
506             if( p_config->value.i == p_config->pi_list[i_index] )
507             {
508                 combo->setCurrentIndex( i_index );
509             }
510         }
511         combo->setToolTip( qfu( p_config->psz_longtext ) );
512     }
513 }
514
515 /********* Module **********/
516 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
517                module_config_t *_p_item, QWidget *_parent, bool bycat,
518                QGridLayout *l, int &line) :
519                VStringConfigControl( _p_this, _p_item, _parent )
520 {
521     label = new QLabel( qtr(p_item->psz_text) );
522     combo = new QComboBox();
523     combo->setMinimumWidth( MINWIDTH_BOX );
524     finish( bycat );
525     if( !l )
526     {
527         QHBoxLayout *layout = new QHBoxLayout();
528         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
529         widget->setLayout( layout );
530     }
531     else
532     {
533         l->addWidget( label, line, 0 );
534         l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
535     }
536 }
537
538 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
539                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
540                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
541 {
542     combo = _combo;
543     label = _label;
544     finish( bycat );
545 }
546
547 void ModuleConfigControl::finish( bool bycat )
548 {
549     vlc_list_t *p_list;
550     module_t *p_parser;
551
552     combo->setEditable( false );
553
554     /* build a list of available modules */
555     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
556     combo->addItem( qtr("Default") );
557     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
558     {
559         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
560
561         if( bycat )
562         {
563             if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue;
564
565             unsigned confsize;
566             module_config_t *p_config;
567
568             p_config = module_GetConfig (p_parser, &confsize);
569              for (size_t i = 0; i < confsize; i++)
570             {
571                 /* Hack: required subcategory is stored in i_min */
572                 const module_config_t *p_cfg = p_config + i;
573                 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
574                     p_cfg->value.i == p_item->min.i )
575                     combo->addItem( qtr( module_GetLongName( p_parser )),
576                                     QVariant( module_GetObjName( p_parser ) ) );
577                 if( p_item->value.psz && !strcmp( p_item->value.psz,
578                                                   module_GetObjName( p_parser ) ) )
579                     combo->setCurrentIndex( combo->count() - 1 );
580             }
581             module_PutConfig (p_config);
582         }
583         else if( module_IsCapable( p_parser, p_item->psz_type ) )
584         {
585             combo->addItem( qtr(module_GetLongName( p_parser ) ),
586                             QVariant( module_GetObjName( p_parser ) ) );
587             if( p_item->value.psz && !strcmp( p_item->value.psz,
588                                               module_GetObjName( p_parser ) ) )
589                 combo->setCurrentIndex( combo->count() - 1 );
590         }
591     }
592     vlc_list_release( p_list );
593     combo->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
594     if( label )
595         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
596 }
597
598 QString ModuleConfigControl::getValue()
599 {
600     return combo->itemData( combo->currentIndex() ).toString();
601 }
602
603 /********* Module list **********/
604 ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
605         module_config_t *_p_item, QWidget *_parent, bool bycat,
606         QGridLayout *l, int &line) :
607     VStringConfigControl( _p_this, _p_item, _parent )
608 {
609     groupBox = NULL;
610     if( !p_item->psz_text ) return;
611
612     groupBox = new QGroupBox ( qtr(p_item->psz_text) );
613     text = new QLineEdit;
614     QGridLayout *layoutGroupBox = new QGridLayout( groupBox );
615
616     finish( bycat );
617
618     int boxline = 0;
619     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
620             it != modules.end(); it++ )
621     {
622         layoutGroupBox->addWidget( (*it)->checkBox, boxline++, 0 );
623     }
624     layoutGroupBox->addWidget( text, boxline, 0 );
625
626     if( !l )
627     {
628         QVBoxLayout *layout = new QVBoxLayout();
629         layout->addWidget( groupBox, line, 0 );
630         widget->setLayout( layout );
631     }
632     else
633     {
634         l->addWidget( groupBox, line, 0, 1, -1 );
635     }
636
637     text->setToolTip( formatTooltip( qtr( p_item->psz_longtext) ) );
638 }
639
640 ModuleListConfigControl::~ModuleListConfigControl()
641 {
642     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
643             it != modules.end(); it++ )
644     {
645         delete *it;
646     }
647     if( groupBox ) delete groupBox;
648 }
649
650 #define CHECKBOX_LISTS \
651 { \
652        QCheckBox *cb = new QCheckBox( qtr( module_GetLongName( p_parser ) ) );\
653        checkBoxListItem *cbl = new checkBoxListItem; \
654 \
655        CONNECT( cb, stateChanged( int ), this, onUpdate( int ) );\
656        cb->setToolTip( formatTooltip( qtr( module_GetHelp( p_parser ))));\
657        cbl->checkBox = cb; \
658 \
659        cbl->psz_module = strdup( module_GetObjName( p_parser ) ); \
660        modules.push_back( cbl ); \
661 \
662        if( p_item->value.psz && strstr( p_item->value.psz, cbl->psz_module ) ) \
663             cbl->checkBox->setChecked( true ); \
664 }
665
666
667 void ModuleListConfigControl::finish( bool bycat )
668 {
669     vlc_list_t *p_list;
670     module_t *p_parser;
671
672     /* build a list of available modules */
673     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
674     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
675     {
676         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
677
678         if( bycat )
679         {
680             if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue;
681
682             unsigned confsize;
683             module_config_t *p_config = module_GetConfig (p_parser, &confsize);
684
685             for (size_t i = 0; i < confsize; i++)
686             {
687                 module_config_t *p_cfg = p_config + i;
688                 /* Hack: required subcategory is stored in i_min */
689                 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
690                         p_cfg->value.i == p_item->min.i )
691                 {
692                     CHECKBOX_LISTS;
693                 }
694             }
695             module_PutConfig (p_config);
696         }
697         else if( module_IsCapable( p_parser, p_item->psz_type ) )
698         {
699             CHECKBOX_LISTS;
700         }
701     }
702     vlc_list_release( p_list );
703     text->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
704     if( groupBox )
705         groupBox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
706 }
707 #undef CHECKBOX_LISTS
708
709 QString ModuleListConfigControl::getValue()
710 {
711     return text->text();
712 }
713
714 void ModuleListConfigControl::hide()
715 {
716     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
717          it != modules.end(); it++ )
718     {
719         (*it)->checkBox->hide();
720     }
721     groupBox->hide();
722 }
723
724 void ModuleListConfigControl::show()
725 {
726     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
727          it != modules.end(); it++ )
728     {
729         (*it)->checkBox->show();
730     }
731     groupBox->show();
732 }
733
734
735 void ModuleListConfigControl::onUpdate( int value )
736 {
737     text->clear();
738     bool first = true;
739
740     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
741          it != modules.end(); it++ )
742     {
743         if( (*it)->checkBox->isChecked() )
744         {
745             if( first )
746             {
747                 text->setText( text->text() + (*it)->psz_module );
748                 first = false;
749             }
750             else
751             {
752                 text->setText( text->text() + ":" + (*it)->psz_module );
753             }
754         }
755     }
756 }
757
758 /**************************************************************************
759  * Integer-based controls
760  *************************************************************************/
761
762 /*********** Integer **************/
763 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
764                                             module_config_t *_p_item,
765                                             QWidget *_parent, QGridLayout *l,
766                                             int &line ) :
767                            VIntConfigControl( _p_this, _p_item, _parent )
768 {
769     label = new QLabel( qtr(p_item->psz_text) );
770     spin = new QSpinBox; spin->setMinimumWidth( MINWIDTH_BOX );
771     spin->setAlignment( Qt::AlignRight );
772     spin->setMaximumWidth( MINWIDTH_BOX );
773     finish();
774
775     if( !l )
776     {
777         QHBoxLayout *layout = new QHBoxLayout();
778         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
779         widget->setLayout( layout );
780     }
781     else
782     {
783         l->addWidget( label, line, 0 );
784         l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
785     }
786 }
787 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
788                                             module_config_t *_p_item,
789                                             QLabel *_label, QSpinBox *_spin ) :
790                                       VIntConfigControl( _p_this, _p_item )
791 {
792     spin = _spin;
793     label = _label;
794     finish();
795 }
796
797 void IntegerConfigControl::finish()
798 {
799     spin->setMaximum( 2000000000 );
800     spin->setMinimum( -2000000000 );
801     spin->setValue( p_item->value.i );
802     spin->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
803     if( label )
804         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
805 }
806
807 int IntegerConfigControl::getValue()
808 {
809     return spin->value();
810 }
811
812 /********* Integer range **********/
813 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
814                                             module_config_t *_p_item,
815                                             QWidget *_parent, QGridLayout *l,
816                                             int &line ) :
817             IntegerConfigControl( _p_this, _p_item, _parent, l, line )
818 {
819     finish();
820 }
821
822 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
823                                             module_config_t *_p_item,
824                                             QLabel *_label, QSpinBox *_spin ) :
825             IntegerConfigControl( _p_this, _p_item, _label, _spin )
826 {
827     finish();
828 }
829
830 void IntegerRangeConfigControl::finish()
831 {
832     spin->setMaximum( p_item->max.i );
833     spin->setMinimum( p_item->min.i );
834 }
835
836 IntegerRangeSliderConfigControl::IntegerRangeSliderConfigControl(
837                                             vlc_object_t *_p_this,
838                                             module_config_t *_p_item,
839                                             QLabel *_label, QSlider *_slider ):
840                     VIntConfigControl( _p_this, _p_item )
841 {
842     slider = _slider;
843     label = _label;
844     slider->setMaximum( p_item->max.i );
845     slider->setMinimum( p_item->min.i );
846     slider->setValue( p_item->value.i );
847     slider->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
848     if( label )
849         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
850 }
851
852 int IntegerRangeSliderConfigControl::getValue()
853 {
854         return slider->value();
855 }
856
857
858 /********* Integer / choice list **********/
859 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
860                module_config_t *_p_item, QWidget *_parent, bool bycat,
861                QGridLayout *l, int &line) :
862                VIntConfigControl( _p_this, _p_item, _parent )
863 {
864     label = new QLabel( qtr(p_item->psz_text) );
865     combo = new QComboBox();
866     combo->setMinimumWidth( MINWIDTH_BOX );
867
868     module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
869     if(p_module_config && p_module_config->pf_update_list)
870     {
871        vlc_value_t val;
872        val.i_int = p_module_config->value.i;
873
874        p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
875
876        // assume in any case that dirty was set to true
877        // because lazy programmes will use the same callback for
878        // this, like the one behind the refresh push button?
879        p_module_config->b_dirty = false;
880     }
881
882
883     finish( p_module_config, bycat );
884     if( !l )
885     {
886         QHBoxLayout *layout = new QHBoxLayout();
887         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
888         widget->setLayout( layout );
889     }
890     else
891     {
892         l->addWidget( label, line, 0 );
893         l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
894     }
895
896     if( p_item->i_action )
897     {
898         QSignalMapper *signalMapper = new QSignalMapper(this);
899
900         /* Some stringLists like Capture listings have action associated */
901         for( int i = 0; i < p_item->i_action; i++ )
902         {
903             QPushButton *button =
904                 new QPushButton( qfu( p_item->ppsz_action_text[i] ));
905             CONNECT( button, clicked(), signalMapper, map() );
906             signalMapper->setMapping( button, i );
907             l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
908                     Qt::AlignRight );
909         }
910         CONNECT( signalMapper, mapped( int ),
911                 this, actionRequested( int ) );
912     }
913
914 }
915 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
916                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
917                 bool bycat ) : VIntConfigControl( _p_this, _p_item )
918 {
919     combo = _combo;
920     label = _label;
921
922     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
923
924     finish( p_module_config, bycat );
925 }
926
927 void IntegerListConfigControl::finish(module_config_t *p_module_config, bool bycat )
928 {
929     combo->setEditable( false );
930
931     if(!p_module_config) return;
932
933     for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
934     {
935         combo->addItem( qtr(p_module_config->ppsz_list_text[i_index] ),
936                         QVariant( p_module_config->pi_list[i_index] ) );
937         if( p_module_config->value.i == p_module_config->pi_list[i_index] )
938             combo->setCurrentIndex( combo->count() - 1 );
939     }
940     combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
941     if( label )
942         label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
943 }
944
945 void IntegerListConfigControl::actionRequested( int i_action )
946 {
947     /* Supplementary check for boundaries */
948     if( i_action < 0 || i_action >= p_item->i_action ) return;
949
950     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
951     if(!p_module_config) return;
952
953
954     vlc_value_t val;
955     val.i_int = combo->itemData( combo->currentIndex() ).toInt();
956
957     p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
958
959     if( p_module_config->b_dirty )
960     {
961         combo->clear();
962         finish( p_module_config, true );
963         p_module_config->b_dirty = false;
964     }
965 }
966
967 int IntegerListConfigControl::getValue()
968 {
969     return combo->itemData( combo->currentIndex() ).toInt();
970 }
971
972 /*********** Boolean **************/
973 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
974                                       module_config_t *_p_item,
975                                       QWidget *_parent, QGridLayout *l,
976                                       int &line ) :
977                     VIntConfigControl( _p_this, _p_item, _parent )
978 {
979     checkbox = new QCheckBox( qtr(p_item->psz_text) );
980     finish();
981
982     if( !l )
983     {
984         QHBoxLayout *layout = new QHBoxLayout();
985         layout->addWidget( checkbox, 0 );
986         widget->setLayout( layout );
987     }
988     else
989     {
990         l->addWidget( checkbox, line, 0 );
991     }
992 }
993 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
994                                       module_config_t *_p_item,
995                                       QLabel *_label,
996                                       QCheckBox *_checkbox,
997                                       bool bycat ) :
998                    VIntConfigControl( _p_this, _p_item )
999 {
1000     checkbox = _checkbox;
1001     finish();
1002 }
1003
1004 void BoolConfigControl::finish()
1005 {
1006     checkbox->setCheckState( p_item->value.i == true ? Qt::Checked
1007                                                         : Qt::Unchecked );
1008     checkbox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1009 }
1010
1011 int BoolConfigControl::getValue()
1012 {
1013     return checkbox->checkState() == Qt::Checked ? true : false;
1014 }
1015
1016 /**************************************************************************
1017  * Float-based controls
1018  *************************************************************************/
1019
1020 /*********** Float **************/
1021 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1022                                         module_config_t *_p_item,
1023                                         QWidget *_parent, QGridLayout *l,
1024                                         int &line ) :
1025                     VFloatConfigControl( _p_this, _p_item, _parent )
1026 {
1027     label = new QLabel( qtr(p_item->psz_text) );
1028     spin = new QDoubleSpinBox;
1029     spin->setMinimumWidth( MINWIDTH_BOX );
1030     spin->setMaximumWidth( MINWIDTH_BOX );
1031     spin->setAlignment( Qt::AlignRight );
1032     finish();
1033
1034     if( !l )
1035     {
1036         QHBoxLayout *layout = new QHBoxLayout();
1037         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
1038         widget->setLayout( layout );
1039     }
1040     else
1041     {
1042         l->addWidget( label, line, 0 );
1043         l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
1044     }
1045 }
1046
1047 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1048                                         module_config_t *_p_item,
1049                                         QLabel *_label,
1050                                         QDoubleSpinBox *_spin ) :
1051                     VFloatConfigControl( _p_this, _p_item )
1052 {
1053     spin = _spin;
1054     label = _label;
1055     finish();
1056 }
1057
1058 void FloatConfigControl::finish()
1059 {
1060     spin->setMaximum( 2000000000. );
1061     spin->setMinimum( -2000000000. );
1062     spin->setSingleStep( 0.1 );
1063     spin->setValue( (double)p_item->value.f );
1064     spin->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1065     if( label )
1066         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1067 }
1068
1069 float FloatConfigControl::getValue()
1070 {
1071     return (float)spin->value();
1072 }
1073
1074 /*********** Float with range **************/
1075 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1076                                         module_config_t *_p_item,
1077                                         QWidget *_parent, QGridLayout *l,
1078                                         int &line ) :
1079                 FloatConfigControl( _p_this, _p_item, _parent, l, line )
1080 {
1081     finish();
1082 }
1083
1084 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1085                                         module_config_t *_p_item,
1086                                         QLabel *_label,
1087                                         QDoubleSpinBox *_spin ) :
1088                 FloatConfigControl( _p_this, _p_item, _label, _spin )
1089 {
1090     finish();
1091 }
1092
1093 void FloatRangeConfigControl::finish()
1094 {
1095     spin->setMaximum( (double)p_item->max.f );
1096     spin->setMinimum( (double)p_item->min.f );
1097 }
1098
1099
1100 /**********************************************************************
1101  * Key selector widget
1102  **********************************************************************/
1103 KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
1104                                       module_config_t *_p_item,
1105                                       QWidget *_parent, QGridLayout *l,
1106                                       int &line ) :
1107                                 ConfigControl( _p_this, _p_item, _parent )
1108
1109 {
1110     QWidget *keyContainer = new QWidget;
1111     QGridLayout *gLayout = new QGridLayout( keyContainer );
1112
1113     label = new QLabel(
1114             qtr( "Select an action to change the associated hotkey") );
1115
1116     /* Deactivated for now
1117     QLabel *searchLabel = new QLabel( qtr( "Search" ) );
1118     QLineEdit *actionSearch = new QLineEdit;*/
1119
1120     table = new QTreeWidget;
1121     table->setColumnCount(2);
1122     table->headerItem()->setText( 0, qtr( "Action" ) );
1123     table->headerItem()->setText( 1, qtr( "Shortcut" ) );
1124
1125     shortcutValue = new KeyShortcutEdit;
1126     shortcutValue->setReadOnly(true);
1127
1128     QPushButton *clearButton = new QPushButton( qtr( "Clear" ) );
1129     QPushButton *setButton = new QPushButton( qtr( "Set" ) );
1130     setButton->setDefault( true );
1131     finish();
1132
1133     gLayout->addWidget( label, 0, 0, 1, 4 );
1134   /* deactivated for now
1135     gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
1136     gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */
1137     gLayout->addWidget( table, 2, 0, 1, 4 );
1138     gLayout->addWidget( clearButton, 3, 0, 1, 1 );
1139     gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
1140     gLayout->addWidget( setButton, 3, 3, 1, 1 );
1141
1142     l->addWidget( keyContainer, line, 0, 1, 2 );
1143
1144     CONNECT( clearButton, clicked(), shortcutValue, clear() );
1145     CONNECT( clearButton, clicked(), this, setTheKey() );
1146     BUTTONACT( setButton, setTheKey() );
1147 }
1148
1149 void KeySelectorControl::finish()
1150 {
1151     if( label )
1152         label->setToolTip( formatTooltip( qtr( p_item->psz_longtext ) ) );
1153
1154     /* Fill the table */
1155     table->setColumnCount( 2 );
1156     table->setAlternatingRowColors( true );
1157
1158     /* Get the main Module */
1159     module_t *p_main = module_Find( p_this, "main" );
1160     assert( p_main );
1161
1162     /* Access to the module_config_t */
1163     unsigned confsize;
1164     module_config_t *p_config;
1165
1166     p_config = module_GetConfig (p_main, &confsize);
1167
1168     for (size_t i = 0; i < confsize; i++)
1169     {
1170         module_config_t *p_item = p_config + i;
1171
1172         /* If we are a key option not empty */
1173         if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
1174             && strstr( p_item->psz_name , "key-" )
1175             && !EMPTY_STR( p_item->psz_text ) )
1176         {
1177             /*
1178                Each tree item has:
1179                 - QString text in column 0
1180                 - QString name in data of column 0
1181                 - KeyValue in String in column 1
1182                 - KeyValue in int in column 1
1183              */
1184             QTreeWidgetItem *treeItem = new QTreeWidgetItem();
1185             treeItem->setText( 0, qtr( p_item->psz_text ) );
1186             treeItem->setData( 0, Qt::UserRole,
1187                                QVariant( qfu( p_item->psz_name ) ) );
1188             treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
1189             treeItem->setData( 1, Qt::UserRole, QVariant( p_item->value.i ) );
1190             table->addTopLevelItem( treeItem );
1191         }
1192     }
1193     module_PutConfig (p_config);
1194     module_Put (p_main);
1195
1196     table->resizeColumnToContents( 0 );
1197
1198     CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ),
1199              this, selectKey( QTreeWidgetItem * ) );
1200     CONNECT( table, itemSelectionChanged (),
1201              this, select1Key() );
1202
1203     CONNECT( shortcutValue, pressed(), this, selectKey() );
1204 }
1205
1206 /* Show the key selected from the table in the keySelector */
1207 void KeySelectorControl::select1Key()
1208 {
1209     QTreeWidgetItem *keyItem = table->currentItem();
1210     shortcutValue->setText( keyItem->text( 1 ) );
1211     shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toInt() );
1212 }
1213
1214 void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem )
1215 {
1216     /* This happens when triggered by ClickEater */
1217     if( keyItem == NULL ) keyItem = table->currentItem();
1218
1219     /* This can happen when nothing is selected on the treeView
1220        and the shortcutValue is clicked */
1221     if( !keyItem ) return;
1222
1223     /* Launch a small dialog to ask for a new key */
1224     KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget );
1225     d->exec();
1226
1227     if( d->result() == QDialog::Accepted )
1228     {
1229         int newValue = d->keyValue;
1230         shortcutValue->setText( VLCKeyToString( newValue ) );
1231         shortcutValue->setValue( newValue );
1232
1233         if( d->conflicts )
1234         {
1235             QTreeWidgetItem *it;
1236             for( int i = 0; i < table->topLevelItemCount() ; i++ )
1237             {
1238                 it = table->topLevelItem(i);
1239                 if( ( keyItem != it )
1240                         && ( it->data( 1, Qt::UserRole ).toInt() == newValue ) )
1241                 {
1242                     it->setData( 1, Qt::UserRole, QVariant( -1 ) );
1243                     it->setText( 1, qtr( "Unset" ) );
1244                 }
1245             }
1246             /* We already made an OK once. */
1247             setTheKey();
1248         }
1249     }
1250     delete d;
1251 }
1252
1253 void KeySelectorControl::setTheKey()
1254 {
1255     table->currentItem()->setText( 1, shortcutValue->text() );
1256     table->currentItem()->setData( 1, Qt::UserRole, shortcutValue->getValue() );
1257 }
1258
1259 void KeySelectorControl::doApply()
1260 {
1261     QTreeWidgetItem *it;
1262     for( int i = 0; i < table->topLevelItemCount() ; i++ )
1263     {
1264         it = table->topLevelItem(i);
1265         if( it->data( 1, Qt::UserRole ).toInt() >= 0 )
1266             config_PutInt( p_this,
1267                            qtu( it->data( 0, Qt::UserRole ).toString() ),
1268                            it->data( 1, Qt::UserRole ).toInt() );
1269     }
1270 }
1271
1272 KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
1273                                 QString keyToChange,
1274                                 QWidget *_parent ) :
1275                                 QDialog( _parent ), keyValue(0)
1276 {
1277     setModal( true );
1278     conflicts = false;
1279
1280     table = _table;
1281     setWindowTitle( qtr( "Hotkey for " ) + keyToChange );
1282
1283     vLayout = new QVBoxLayout( this );
1284     selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange );
1285     vLayout->addWidget( selected , Qt::AlignCenter );
1286
1287     buttonBox = new QDialogButtonBox;
1288     QPushButton *ok = new QPushButton( qtr("OK") );
1289     QPushButton *cancel = new QPushButton( qtr("Cancel") );
1290     buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
1291     buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
1292     ok->setDefault( true );
1293
1294     vLayout->addWidget( buttonBox );
1295     buttonBox->hide();
1296
1297     CONNECT( buttonBox, accepted(), this, accept() );
1298     CONNECT( buttonBox, rejected(), this, reject() );
1299 }
1300
1301 void KeyInputDialog::checkForConflicts( int i_vlckey )
1302 {
1303      QList<QTreeWidgetItem *> conflictList =
1304          table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly, 1 );
1305
1306     if( conflictList.size() )
1307     {
1308         QLabel *warning = new QLabel(
1309           qtr("Warning: the key is already assigned to \"") +
1310           conflictList[0]->text( 0 ) + "\"" );
1311         vLayout->insertWidget( 1, warning );
1312         buttonBox->show();
1313
1314         conflicts = true;
1315     }
1316     else accept();
1317 }
1318
1319 void KeyInputDialog::keyPressEvent( QKeyEvent *e )
1320 {
1321     if( e->key() == Qt::Key_Tab ||
1322         e->key() == Qt::Key_Shift ||
1323         e->key() == Qt::Key_Control ||
1324         e->key() == Qt::Key_Meta ||
1325         e->key() == Qt::Key_Alt ||
1326         e->key() == Qt::Key_AltGr )
1327         return;
1328     int i_vlck = qtEventToVLCKey( e );
1329     selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1330     checkForConflicts( i_vlck );
1331     keyValue = i_vlck;
1332 }
1333
1334 void KeyInputDialog::wheelEvent( QWheelEvent *e )
1335 {
1336     int i_vlck = qtWheelEventToVLCKey( e );
1337     selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1338     checkForConflicts( i_vlck );
1339     keyValue = i_vlck;
1340 }
1341
1342 void KeyShortcutEdit::mousePressEvent( QMouseEvent *)
1343 {
1344     emit pressed();
1345 }
1346