]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.cpp
One more time removing of some useless tests.
[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(), qta( 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( p_this->p_libvlc->psz_homedir ) );
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( p_this->p_libvlc->psz_homedir ) : 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 aĂ—y case that dirty was set to VLC_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 = VLC_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 = VLC_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[i_index] ),
468                         QVariant( p_module_config->ppsz_list[i_index] ) );
469         if( p_item->value.psz && !strcmp( p_module_config->value.psz,
470                                           p_module_config->ppsz_list[i_index] ) )
471             combo->setCurrentIndex( combo->count() - 1 );
472     }
473     combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
474     if( label )
475         label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
476 }
477
478 QString StringListConfigControl::getValue()
479 {
480     return combo->itemData( combo->currentIndex() ).toString();
481 }
482
483 void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf,
484                         QComboBox *combo, QWidget *parent )
485 {
486     module_config_t *p_config =
487                       config_FindConfig( VLC_OBJECT(p_intf), configname );
488     if( p_config )
489     {
490        if(p_config->pf_update_list) 
491         {
492             vlc_value_t val;
493             val.i_int = p_config->value.i;
494             p_config->pf_update_list(VLC_OBJECT(p_intf), configname, val, val, NULL);
495             // assume in any case that dirty was set to VLC_TRUE
496             // because lazy programmes will use the same callback for
497             // this, like the one behind the refresh push button?
498             p_config->b_dirty = VLC_FALSE;
499         }
500
501         for ( int i_index = 0; i_index < p_config->i_list; i_index++ )
502         {
503             combo->addItem( qfu( p_config->ppsz_list_text[i_index] ),
504                     QVariant( p_config->pi_list[i_index] ) );
505             if( p_config->value.i == p_config->pi_list[i_index] )
506             {
507                 combo->setCurrentIndex( i_index );
508             }
509         }
510         combo->setToolTip( qfu( p_config->psz_longtext ) );
511     }
512 }
513
514 /********* Module **********/
515 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
516                module_config_t *_p_item, QWidget *_parent, bool bycat,
517                QGridLayout *l, int &line) :
518                VStringConfigControl( _p_this, _p_item, _parent )
519 {
520     label = new QLabel( qtr(p_item->psz_text) );
521     combo = new QComboBox();
522     combo->setMinimumWidth( MINWIDTH_BOX );
523     finish( bycat );
524     if( !l )
525     {
526         QHBoxLayout *layout = new QHBoxLayout();
527         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
528         widget->setLayout( layout );
529     }
530     else
531     {
532         l->addWidget( label, line, 0 );
533         l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
534     }
535 }
536
537 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
538                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
539                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
540 {
541     combo = _combo;
542     label = _label;
543     finish( bycat );
544 }
545
546 void ModuleConfigControl::finish( bool bycat )
547 {
548     vlc_list_t *p_list;
549     module_t *p_parser;
550
551     combo->setEditable( false );
552
553     /* build a list of available modules */
554     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
555     combo->addItem( qtr("Default") );
556     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
557     {
558         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
559
560         if( bycat )
561         {
562             if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue;
563
564             unsigned confsize;
565             module_config_t *p_config;
566
567             p_config = module_GetConfig (p_parser, &confsize);
568              for (size_t i = 0; i < confsize; i++)
569             {
570                 /* Hack: required subcategory is stored in i_min */
571                 const module_config_t *p_cfg = p_config + i;
572                 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
573                     p_cfg->value.i == p_item->min.i )
574                     combo->addItem( qtr( module_GetLongName( p_parser )),
575                                     QVariant( module_GetObjName( p_parser ) ) );
576                 if( p_item->value.psz && !strcmp( p_item->value.psz,
577                                                   module_GetObjName( p_parser ) ) )
578                     combo->setCurrentIndex( combo->count() - 1 );
579             }
580             module_PutConfig (p_config);
581         }
582         else if( module_IsCapable( p_parser, p_item->psz_type ) )
583         {
584             combo->addItem( qtr(module_GetLongName( p_parser ) ),
585                             QVariant( module_GetObjName( p_parser ) ) );
586             if( p_item->value.psz && !strcmp( p_item->value.psz,
587                                               module_GetObjName( p_parser ) ) )
588                 combo->setCurrentIndex( combo->count() - 1 );
589         }
590     }
591     vlc_list_release( p_list );
592     combo->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
593     if( label )
594         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
595 }
596
597 QString ModuleConfigControl::getValue()
598 {
599     return combo->itemData( combo->currentIndex() ).toString();
600 }
601
602 /********* Module list **********/
603 ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
604         module_config_t *_p_item, QWidget *_parent, bool bycat,
605         QGridLayout *l, int &line) :
606     VStringConfigControl( _p_this, _p_item, _parent )
607 {
608     groupBox = new QGroupBox ( qtr(p_item->psz_text) );
609     text = new QLineEdit();
610     QGridLayout *layoutGroupBox = new QGridLayout( groupBox );
611
612     finish( bycat );
613
614     int boxline = 0;
615     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
616             it != modules.end(); it++ )
617     {
618         layoutGroupBox->addWidget( (*it)->checkBox, boxline++, 0 );
619     }
620     layoutGroupBox->addWidget( text, boxline, 0 );
621
622     if( !l )
623     {
624         QVBoxLayout *layout = new QVBoxLayout();
625         layout->addWidget( groupBox, line, 0 );
626         widget->setLayout( layout );
627     }
628     else
629     {
630         l->addWidget( groupBox, line, 0, 1, -1 );
631     }
632
633     text->setToolTip( formatTooltip( qtr( p_item->psz_longtext) ) );
634 }
635
636 ModuleListConfigControl::~ModuleListConfigControl()
637 {
638     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
639             it != modules.end(); it++ )
640     {
641         delete *it;
642     }
643     delete groupBox;
644     delete text;
645 }
646
647 #define CHECKBOX_LISTS \
648 { \
649        QCheckBox *cb = new QCheckBox( qtr( module_GetLongName( p_parser ) ) );\
650        checkBoxListItem *cbl = new checkBoxListItem; \
651 \
652        CONNECT( cb, stateChanged( int ), this, onUpdate( int ) );\
653        cb->setToolTip( formatTooltip( qtr( module_GetHelp( p_parser ))));\
654        cbl->checkBox = cb; \
655 \
656        cbl->psz_module = strdup( module_GetObjName( p_parser ) ); \
657        modules.push_back( cbl ); \
658 \
659        if( p_item->value.psz && strstr( p_item->value.psz, cbl->psz_module ) ) \
660             cbl->checkBox->setChecked( true ); \
661 }
662
663
664 void ModuleListConfigControl::finish( bool bycat )
665 {
666     vlc_list_t *p_list;
667     module_t *p_parser;
668
669     /* build a list of available modules */
670     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
671     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
672     {
673         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
674
675         if( bycat )
676         {
677             if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue;
678
679             unsigned confsize;
680             module_config_t *p_config = module_GetConfig (p_parser, &confsize);
681
682             for (size_t i = 0; i < confsize; i++)
683             {
684                 module_config_t *p_cfg = p_config + i;
685                 /* Hack: required subcategory is stored in i_min */
686                 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
687                         p_cfg->value.i == p_item->min.i )
688                 {
689                     CHECKBOX_LISTS;
690                 }
691             }
692             module_PutConfig (p_config);
693         }
694         else if( module_IsCapable( p_parser, p_item->psz_type ) )
695         {
696             CHECKBOX_LISTS;
697         }
698     }
699     vlc_list_release( p_list );
700     text->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
701     if( groupBox )
702         groupBox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
703 }
704 #undef CHECKBOX_LISTS
705
706 QString ModuleListConfigControl::getValue()
707 {
708     return text->text();
709 }
710
711 void ModuleListConfigControl::hide()
712 {
713     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
714          it != modules.end(); it++ )
715     {
716         (*it)->checkBox->hide();
717     }
718     groupBox->hide();
719 }
720
721 void ModuleListConfigControl::show()
722 {
723     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
724          it != modules.end(); it++ )
725     {
726         (*it)->checkBox->show();
727     }
728     groupBox->show();
729 }
730
731
732 void ModuleListConfigControl::onUpdate( int value )
733 {
734     text->clear();
735     bool first = true;
736
737     for( QVector<checkBoxListItem*>::iterator it = modules.begin();
738          it != modules.end(); it++ )
739     {
740         if( (*it)->checkBox->isChecked() )
741         {
742             if( first )
743             {
744                 text->setText( text->text() + (*it)->psz_module );
745                 first = false;
746             }
747             else
748             {
749                 text->setText( text->text() + ":" + (*it)->psz_module );
750             }
751         }
752     }
753 }
754
755 /**************************************************************************
756  * Integer-based controls
757  *************************************************************************/
758
759 /*********** Integer **************/
760 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
761                                             module_config_t *_p_item,
762                                             QWidget *_parent, QGridLayout *l,
763                                             int &line ) :
764                            VIntConfigControl( _p_this, _p_item, _parent )
765 {
766     label = new QLabel( qtr(p_item->psz_text) );
767     spin = new QSpinBox; spin->setMinimumWidth( MINWIDTH_BOX );
768     spin->setAlignment( Qt::AlignRight );
769     spin->setMaximumWidth( MINWIDTH_BOX );
770     finish();
771
772     if( !l )
773     {
774         QHBoxLayout *layout = new QHBoxLayout();
775         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
776         widget->setLayout( layout );
777     }
778     else
779     {
780         l->addWidget( label, line, 0 );
781         l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
782     }
783 }
784 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
785                                             module_config_t *_p_item,
786                                             QLabel *_label, QSpinBox *_spin ) :
787                                       VIntConfigControl( _p_this, _p_item )
788 {
789     spin = _spin;
790     label = _label;
791     finish();
792 }
793
794 void IntegerConfigControl::finish()
795 {
796     spin->setMaximum( 2000000000 );
797     spin->setMinimum( -2000000000 );
798     spin->setValue( p_item->value.i );
799     spin->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
800     if( label )
801         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
802 }
803
804 int IntegerConfigControl::getValue()
805 {
806     return spin->value();
807 }
808
809 /********* Integer range **********/
810 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
811                                             module_config_t *_p_item,
812                                             QWidget *_parent, QGridLayout *l,
813                                             int &line ) :
814             IntegerConfigControl( _p_this, _p_item, _parent, l, line )
815 {
816     finish();
817 }
818
819 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
820                                             module_config_t *_p_item,
821                                             QLabel *_label, QSpinBox *_spin ) :
822             IntegerConfigControl( _p_this, _p_item, _label, _spin )
823 {
824     finish();
825 }
826
827 void IntegerRangeConfigControl::finish()
828 {
829     spin->setMaximum( p_item->max.i );
830     spin->setMinimum( p_item->min.i );
831 }
832
833 IntegerRangeSliderConfigControl::IntegerRangeSliderConfigControl(
834                                             vlc_object_t *_p_this,
835                                             module_config_t *_p_item,
836                                             QLabel *_label, QSlider *_slider ):
837                     VIntConfigControl( _p_this, _p_item )
838 {
839     slider = _slider;
840     label = _label;
841     slider->setMaximum( p_item->max.i );
842     slider->setMinimum( p_item->min.i );
843     slider->setValue( p_item->value.i );
844     slider->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
845     if( label )
846         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
847 }
848
849 int IntegerRangeSliderConfigControl::getValue()
850 {
851         return slider->value();
852 }
853
854
855 /********* Integer / choice list **********/
856 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
857                module_config_t *_p_item, QWidget *_parent, bool bycat,
858                QGridLayout *l, int &line) :
859                VIntConfigControl( _p_this, _p_item, _parent )
860 {
861     label = new QLabel( qtr(p_item->psz_text) );
862     combo = new QComboBox();
863     combo->setMinimumWidth( MINWIDTH_BOX );
864
865     module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
866     if(p_module_config && p_module_config->pf_update_list) 
867     {
868        vlc_value_t val;
869        val.i_int = p_module_config->value.i;
870        
871        p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
872
873        // assume in any case that dirty was set to VLC_TRUE
874        // because lazy programmes will use the same callback for
875        // this, like the one behind the refresh push button?
876        p_module_config->b_dirty = VLC_FALSE;
877     }
878
879
880     finish( p_module_config, bycat );
881     if( !l )
882     {
883         QHBoxLayout *layout = new QHBoxLayout();
884         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
885         widget->setLayout( layout );
886     }
887     else
888     {
889         l->addWidget( label, line, 0 );
890         l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
891     }
892
893     if( p_item->i_action )
894     {
895         QSignalMapper *signalMapper = new QSignalMapper(this);
896
897         /* Some stringLists like Capture listings have action associated */
898         for( int i = 0; i < p_item->i_action; i++ )
899         {
900             QPushButton *button =
901                 new QPushButton( qfu( p_item->ppsz_action_text[i] ));
902             CONNECT( button, clicked(), signalMapper, map() );
903             signalMapper->setMapping( button, i );
904             l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
905                     Qt::AlignRight );
906         }
907         CONNECT( signalMapper, mapped( int ),
908                 this, actionRequested( int ) );
909     }
910
911 }
912 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
913                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
914                 bool bycat ) : VIntConfigControl( _p_this, _p_item )
915 {
916     combo = _combo;
917     label = _label;
918
919     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
920
921     finish( p_module_config, bycat );
922 }
923
924 void IntegerListConfigControl::finish(module_config_t *p_module_config, bool bycat )
925 {
926     combo->setEditable( false );
927
928     if(!p_module_config) return;
929
930     for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
931     {
932         combo->addItem( qtr(p_module_config->ppsz_list_text[i_index] ),
933                         QVariant( p_module_config->pi_list[i_index] ) );
934         if( p_module_config->value.i == p_module_config->pi_list[i_index] )
935             combo->setCurrentIndex( combo->count() - 1 );
936     }
937     combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
938     if( label )
939         label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
940 }
941
942 void IntegerListConfigControl::actionRequested( int i_action )
943 {
944     /* Supplementary check for boundaries */
945     if( i_action < 0 || i_action >= p_item->i_action ) return;
946
947     module_config_t *p_module_config = config_FindConfig( p_this, getName() );
948     if(!p_module_config) return;
949
950
951     vlc_value_t val;
952     val.i_int = combo->itemData( combo->currentIndex() ).toInt();
953
954     p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
955
956     if( p_module_config->b_dirty )
957     {
958         combo->clear();
959         finish( p_module_config, true );
960         p_module_config->b_dirty = VLC_FALSE;
961     }
962 }
963
964 int IntegerListConfigControl::getValue()
965 {
966     return combo->itemData( combo->currentIndex() ).toInt();
967 }
968
969 /*********** Boolean **************/
970 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
971                                       module_config_t *_p_item,
972                                       QWidget *_parent, QGridLayout *l,
973                                       int &line ) :
974                     VIntConfigControl( _p_this, _p_item, _parent )
975 {
976     checkbox = new QCheckBox( qtr(p_item->psz_text) );
977     finish();
978
979     if( !l )
980     {
981         QHBoxLayout *layout = new QHBoxLayout();
982         layout->addWidget( checkbox, 0 );
983         widget->setLayout( layout );
984     }
985     else
986     {
987         l->addWidget( checkbox, line, 0 );
988     }
989 }
990 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
991                                       module_config_t *_p_item,
992                                       QLabel *_label,
993                                       QCheckBox *_checkbox,
994                                       bool bycat ) :
995                    VIntConfigControl( _p_this, _p_item )
996 {
997     checkbox = _checkbox;
998     finish();
999 }
1000
1001 void BoolConfigControl::finish()
1002 {
1003     checkbox->setCheckState( p_item->value.i == VLC_TRUE ? Qt::Checked
1004                                                         : Qt::Unchecked );
1005     checkbox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1006 }
1007
1008 int BoolConfigControl::getValue()
1009 {
1010     return checkbox->checkState() == Qt::Checked ? VLC_TRUE : VLC_FALSE;
1011 }
1012
1013 /**************************************************************************
1014  * Float-based controls
1015  *************************************************************************/
1016
1017 /*********** Float **************/
1018 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1019                                         module_config_t *_p_item,
1020                                         QWidget *_parent, QGridLayout *l,
1021                                         int &line ) :
1022                     VFloatConfigControl( _p_this, _p_item, _parent )
1023 {
1024     label = new QLabel( qtr(p_item->psz_text) );
1025     spin = new QDoubleSpinBox;
1026     spin->setMinimumWidth( MINWIDTH_BOX );
1027     spin->setMaximumWidth( MINWIDTH_BOX );
1028     spin->setAlignment( Qt::AlignRight );
1029     finish();
1030
1031     if( !l )
1032     {
1033         QHBoxLayout *layout = new QHBoxLayout();
1034         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
1035         widget->setLayout( layout );
1036     }
1037     else
1038     {
1039         l->addWidget( label, line, 0 );
1040         l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
1041     }
1042 }
1043
1044 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1045                                         module_config_t *_p_item,
1046                                         QLabel *_label,
1047                                         QDoubleSpinBox *_spin ) :
1048                     VFloatConfigControl( _p_this, _p_item )
1049 {
1050     spin = _spin;
1051     label = _label;
1052     finish();
1053 }
1054
1055 void FloatConfigControl::finish()
1056 {
1057     spin->setMaximum( 2000000000. );
1058     spin->setMinimum( -2000000000. );
1059     spin->setSingleStep( 0.1 );
1060     spin->setValue( (double)p_item->value.f );
1061     spin->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1062     if( label )
1063         label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1064 }
1065
1066 float FloatConfigControl::getValue()
1067 {
1068     return (float)spin->value();
1069 }
1070
1071 /*********** Float with range **************/
1072 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1073                                         module_config_t *_p_item,
1074                                         QWidget *_parent, QGridLayout *l,
1075                                         int &line ) :
1076                 FloatConfigControl( _p_this, _p_item, _parent, l, line )
1077 {
1078     finish();
1079 }
1080
1081 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1082                                         module_config_t *_p_item,
1083                                         QLabel *_label,
1084                                         QDoubleSpinBox *_spin ) :
1085                 FloatConfigControl( _p_this, _p_item, _label, _spin )
1086 {
1087     finish();
1088 }
1089
1090 void FloatRangeConfigControl::finish()
1091 {
1092     spin->setMaximum( (double)p_item->max.f );
1093     spin->setMinimum( (double)p_item->min.f );
1094 }
1095
1096
1097 /**********************************************************************
1098  * Key selector widget
1099  **********************************************************************/
1100 KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
1101                                       module_config_t *_p_item,
1102                                       QWidget *_parent, QGridLayout *l,
1103                                       int &line ) :
1104                                 ConfigControl( _p_this, _p_item, _parent )
1105
1106 {
1107     QWidget *keyContainer = new QWidget;
1108     QGridLayout *gLayout = new QGridLayout( keyContainer );
1109
1110     label = new QLabel(
1111             qtr( "Select an action to change the associated hotkey") );
1112
1113     /* Deactivated for now
1114     QLabel *searchLabel = new QLabel( qtr( "Search" ) );
1115     QLineEdit *actionSearch = new QLineEdit;*/
1116
1117     table = new QTreeWidget;
1118     table->setColumnCount(2);
1119     table->headerItem()->setText( 0, qtr( "Action" ) );
1120     table->headerItem()->setText( 1, qtr( "Shortcut" ) );
1121
1122     shortcutValue = new KeyShortcutEdit;
1123     shortcutValue->setReadOnly(true);
1124
1125     QPushButton *clearButton = new QPushButton( qtr( "Clear" ) );
1126     QPushButton *setButton = new QPushButton( qtr( "Set" ) );
1127     setButton->setDefault( true );
1128     finish();
1129
1130     gLayout->addWidget( label, 0, 0, 1, 4 );
1131   /* deactivated for now
1132     gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
1133     gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */
1134     gLayout->addWidget( table, 2, 0, 1, 4 );
1135     gLayout->addWidget( clearButton, 3, 0, 1, 1 );
1136     gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
1137     gLayout->addWidget( setButton, 3, 3, 1, 1 );
1138
1139     l->addWidget( keyContainer, line, 0, 1, 2 );
1140
1141     CONNECT( clearButton, clicked(), shortcutValue, clear() );
1142     BUTTONACT( setButton, setTheKey() );
1143 }
1144
1145 void KeySelectorControl::finish()
1146 {
1147     if( label )
1148         label->setToolTip( formatTooltip( qtr( p_item->psz_longtext ) ) );
1149
1150     /* Fill the table */
1151     table->setColumnCount( 2 );
1152     table->setAlternatingRowColors( true );
1153
1154     /* Get the main Module */
1155     module_t *p_main = module_Find( p_this, "main" );
1156     assert( p_main );
1157
1158     /* Access to the module_config_t */
1159     unsigned confsize;
1160     module_config_t *p_config;
1161
1162     p_config = module_GetConfig (p_main, &confsize);
1163
1164     for (size_t i = 0; i < confsize; i++)
1165     {
1166         module_config_t *p_item = p_config + i;
1167
1168         /* If we are a key option not empty */
1169         if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
1170             && strstr( p_item->psz_name , "key-" )
1171             && !EMPTY_STR( p_item->psz_text ) )
1172         {
1173             /*
1174                Each tree item has:
1175                 - QString text in column 0
1176                 - QString name in data of column 0
1177                 - KeyValue in String in column 1
1178                 - KeyValue in int in column 1
1179              */
1180             QTreeWidgetItem *treeItem = new QTreeWidgetItem();
1181             treeItem->setText( 0, qtr( p_item->psz_text ) );
1182             treeItem->setData( 0, Qt::UserRole,
1183                                QVariant( qfu( p_item->psz_name ) ) );
1184             treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
1185             treeItem->setData( 1, Qt::UserRole, QVariant( p_item->value.i ) );
1186             table->addTopLevelItem( treeItem );
1187         }
1188     }
1189     module_PutConfig (p_config);
1190     module_Put (p_main);
1191
1192     table->resizeColumnToContents( 0 );
1193
1194     CONNECT( table, itemClicked( QTreeWidgetItem *, int ),
1195              this, select1Key( QTreeWidgetItem * ) );
1196     CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ),
1197              this, selectKey( QTreeWidgetItem * ) );
1198     CONNECT( shortcutValue, pressed(), this, selectKey() );
1199 }
1200
1201 /* Show the key selected from the table in the keySelector */
1202 void KeySelectorControl::select1Key( QTreeWidgetItem *keyItem )
1203 {
1204     shortcutValue->setText( keyItem->text( 1 ) );
1205     shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toInt() );
1206 }
1207
1208 void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem )
1209 {
1210     /* This happens when triggered by ClickEater */
1211     if( keyItem == NULL ) keyItem = table->currentItem();
1212
1213     /* This can happen when nothing is selected on the treeView
1214        and the shortcutValue is clicked */
1215     if( !keyItem ) return;
1216
1217     /* Launch a small dialog to ask for a new key */
1218     KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget );
1219     d->exec();
1220
1221     if( d->result() == QDialog::Accepted )
1222     {
1223         int newValue = d->keyValue;
1224         shortcutValue->setText( VLCKeyToString( newValue ) );
1225         shortcutValue->setValue( newValue );
1226
1227         if( d->conflicts )
1228         {
1229             QTreeWidgetItem *it;
1230             for( int i = 0; i < table->topLevelItemCount() ; i++ )
1231             {
1232                 it = table->topLevelItem(i);
1233                 if( ( keyItem != it )
1234                         && ( it->data( 1, Qt::UserRole ).toInt() == newValue ) )
1235                 {
1236                     it->setData( 1, Qt::UserRole, QVariant( -1 ) );
1237                     it->setText( 1, qtr( "Unset" ) );
1238                 }
1239             }
1240             /* We already made an OK once. */
1241             setTheKey();
1242         }
1243     }
1244     delete d;
1245 }
1246
1247 void KeySelectorControl::setTheKey()
1248 {
1249     table->currentItem()->setText( 1, shortcutValue->text() );
1250     table->currentItem()->setData( 1, Qt::UserRole, shortcutValue->getValue() );
1251 }
1252
1253 void KeySelectorControl::doApply()
1254 {
1255     QTreeWidgetItem *it;
1256     for( int i = 0; i < table->topLevelItemCount() ; i++ )
1257     {
1258         it = table->topLevelItem(i);
1259         if( it->data( 1, Qt::UserRole ).toInt() >= 0 )
1260             config_PutInt( p_this,
1261                            qtu( it->data( 0, Qt::UserRole ).toString() ),
1262                            it->data( 1, Qt::UserRole ).toInt() );
1263     }
1264 }
1265
1266 KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
1267                                 QString keyToChange,
1268                                 QWidget *_parent ) :
1269                                 QDialog( _parent ), keyValue(0)
1270 {
1271     setModal( true );
1272     conflicts = false;
1273
1274     table = _table;
1275     setWindowTitle( qtr( "Hotkey for " ) + keyToChange );
1276
1277     vLayout = new QVBoxLayout( this );
1278     selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange );
1279     vLayout->addWidget( selected , Qt::AlignCenter );
1280
1281     buttonBox = new QDialogButtonBox;
1282     QPushButton *ok = new QPushButton( qtr("OK") );
1283     QPushButton *cancel = new QPushButton( qtr("Cancel") );
1284     buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
1285     buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
1286     ok->setDefault( true );
1287
1288     vLayout->addWidget( buttonBox );
1289     buttonBox->hide();
1290
1291     CONNECT( buttonBox, accepted(), this, accept() );
1292     CONNECT( buttonBox, rejected(), this, reject() );
1293 }
1294
1295 void KeyInputDialog::checkForConflicts( int i_vlckey )
1296 {
1297      QList<QTreeWidgetItem *> conflictList =
1298          table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly, 1 );
1299
1300     if( conflictList.size() )
1301     {
1302         QLabel *warning = new QLabel(
1303           qtr("Warning: the key is already assigned to \"") +
1304           conflictList[0]->text( 0 ) + "\"" );
1305         vLayout->insertWidget( 1, warning );
1306         buttonBox->show();
1307
1308         conflicts = true;
1309     }
1310     else accept();
1311 }
1312
1313 void KeyInputDialog::keyPressEvent( QKeyEvent *e )
1314 {
1315     if( e->key() == Qt::Key_Tab ||
1316         e->key() == Qt::Key_Shift ||
1317         e->key() == Qt::Key_Control ||
1318         e->key() == Qt::Key_Meta ||
1319         e->key() == Qt::Key_Alt ||
1320         e->key() == Qt::Key_AltGr )
1321         return;
1322     int i_vlck = qtEventToVLCKey( e );
1323     selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1324     checkForConflicts( i_vlck );
1325     keyValue = i_vlck;
1326 }
1327
1328 void KeyInputDialog::wheelEvent( QWheelEvent *e )
1329 {
1330     int i_vlck = qtWheelEventToVLCKey( e );
1331     selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1332     checkForConflicts( i_vlck );
1333     keyValue = i_vlck;
1334 }
1335
1336 void KeyShortcutEdit::mousePressEvent( QMouseEvent *)
1337 {
1338     emit pressed();
1339 }
1340