]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.cpp
Very beginning of hotkey widget + Fix 4.2 compilation issue
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
1 /*****************************************************************************
2  * preferences_widgets.cpp : Widgets for preferences displays
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /**
26  * Todo:
27  *  - Finish implementation (see WX)
28  *  - Improvements over WX
29  *      - Password field implementation (through "pwd" bool param
30  *      - Validator for modulelist
31  *  - Implement update stuff using a general Updated signal
32  */
33
34 #include "components/preferences_widgets.hpp"
35 #include "qt4.hpp"
36 #include <QLineEdit>
37 #include <QString>
38 #include <QSpinBox>
39 #include <QDoubleSpinBox>
40 #include <QVariant>
41 #include <QComboBox>
42 #include <QGridLayout>
43
44 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
45                                              module_config_t *p_item,
46                                              QWidget *parent )
47 {
48     int i=0;
49     return createControl( p_this, p_item, parent, NULL, i );
50 }
51
52 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
53                                              module_config_t *p_item,
54                                              QWidget *parent,
55                                              QGridLayout *l, int &line )
56 {
57     ConfigControl *p_control = NULL;
58     if( p_item->psz_current ) return NULL;
59
60     switch( p_item->i_type )
61     {
62     case CONFIG_ITEM_MODULE:
63         p_control = new ModuleConfigControl( p_this, p_item, parent, false,
64                                              l, line );
65         break;
66     case CONFIG_ITEM_MODULE_CAT:
67         p_control = new ModuleConfigControl( p_this, p_item, parent, true,
68                                              l, line );
69         break;
70     case CONFIG_ITEM_MODULE_LIST:
71         p_control = new ModuleListConfigControl( p_this, p_item, parent, false,
72                                              l, line );
73         break;
74     case CONFIG_ITEM_MODULE_LIST_CAT:
75         p_control = new ModuleListConfigControl( p_this, p_item, parent, true,
76                                              l, line );
77         break;
78     case CONFIG_ITEM_STRING:
79         if( !p_item->i_list )
80             p_control = new StringConfigControl( p_this, p_item, parent,
81                                                  l, line, false );
82         else
83             p_control = new StringListConfigControl( p_this, p_item,
84                                             parent, false, l, line );
85         break;
86     case CONFIG_ITEM_INTEGER:
87         if( p_item->i_list )
88             p_control = new IntegerListConfigControl( p_this, p_item,
89                                             parent, false, l, line );
90         else if( p_item->i_min || p_item->i_max )
91             p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
92                                                        l, line );
93         else
94             p_control = new IntegerConfigControl( p_this, p_item, parent,
95                                                   l, line );
96         break;
97     case CONFIG_ITEM_FILE:
98         fprintf( stderr, "Todo (CONFIG_ITEM_FILE)\n" );
99         break;
100     case CONFIG_ITEM_DIRECTORY:
101         fprintf( stderr, "Todo (CONFIG_ITEM_DIRECTORY)\n" );
102         break;
103     case CONFIG_ITEM_KEY:
104         p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
105         break;
106     case CONFIG_ITEM_BOOL:
107         p_control = new BoolConfigControl( p_this, p_item, parent, l, line );
108         break;
109     case CONFIG_ITEM_FLOAT:
110         if( p_item->f_min || p_item->f_max )
111             p_control = new FloatRangeConfigControl( p_this, p_item, parent,
112                                                      l, line );
113         else
114             p_control = new FloatConfigControl( p_this, p_item, parent,
115                                                   l, line );
116         break;
117     default:
118         break;
119     }
120     return p_control;
121 }
122
123 void ConfigControl::doApply( intf_thread_t *p_intf )
124 {
125     switch( getType() )
126     {
127         case 1:
128         {
129             VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
130             config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
131             break;
132         }
133         case 2:
134         {
135             VFloatConfigControl *vfcc =
136                                     qobject_cast<VFloatConfigControl *>(this);
137             config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
138             break;
139         }
140         case 3:
141         {
142             VStringConfigControl *vscc =
143                             qobject_cast<VStringConfigControl *>(this);
144             config_PutPsz( p_intf, vscc->getName(), qta( vscc->getValue() ) );
145         }
146         case 4:
147         {
148             KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
149             ksc->doApply();
150         }
151     }
152 }
153
154 /**************************************************************************
155  * String-based controls
156  *************************************************************************/
157
158 /*********** String **************/
159 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
160                                           module_config_t *_p_item,
161                                           QWidget *_parent, QGridLayout *l,
162                                           int &line, bool pwd ) :
163                            VStringConfigControl( _p_this, _p_item, _parent )
164 {
165     label = new QLabel( qfu(p_item->psz_text) );
166     text = new QLineEdit( qfu(p_item->psz_value) );
167     finish();
168
169     if( !l )
170     {
171         QHBoxLayout *layout = new QHBoxLayout();
172         layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
173         widget->setLayout( layout );
174     }
175     else
176     {
177         l->addWidget( label, line, 0 ); l->addWidget( text, line, 1 );
178     }
179 }
180
181 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
182                                    module_config_t *_p_item,
183                                    QLabel *_label, QLineEdit *_text, bool pwd ):
184                            VStringConfigControl( _p_this, _p_item )
185 {
186     text = _text;
187     label = _label;
188     finish( );
189 }
190
191 void StringConfigControl::finish()
192 {
193     text->setText( qfu(p_item->psz_value) );
194     text->setToolTip( qfu(p_item->psz_longtext) );
195     if( label )
196         label->setToolTip( qfu(p_item->psz_longtext) );
197 }
198
199 /********* String / choice list **********/
200 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
201                module_config_t *_p_item, QWidget *_parent, bool bycat,
202                QGridLayout *l, int &line) :
203                VStringConfigControl( _p_this, _p_item, _parent )
204 {
205     label = new QLabel( qfu(p_item->psz_text) );
206     combo = new QComboBox();
207     finish( bycat );
208     if( !l )
209     {
210         QHBoxLayout *layout = new QHBoxLayout();
211         layout->addWidget( label ); layout->addWidget( combo );
212         widget->setLayout( layout );
213     }
214     else
215     {
216         l->addWidget( label, line, 0 );
217         l->addWidget( combo, line, 1, Qt::AlignRight );
218     }
219 }
220 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
221                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
222                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
223 {
224     combo = _combo;
225     label = _label;
226     finish( bycat );
227 }
228
229 void StringListConfigControl::finish( bool bycat )
230 {
231     combo->setEditable( false );
232
233     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
234     {
235         combo->addItem( qfu(p_item->ppsz_list_text ?
236                             p_item->ppsz_list_text[i_index] :
237                             p_item->ppsz_list[i_index] ),
238                         QVariant( p_item->ppsz_list[i_index] ) );
239         if( p_item->psz_value && !strcmp( p_item->psz_value,
240                                           p_item->ppsz_list[i_index] ) )
241             combo->setCurrentIndex( combo->count() - 1 );
242     }
243     combo->setToolTip( qfu(p_item->psz_longtext) );
244     if( label )
245         label->setToolTip( qfu(p_item->psz_longtext) );
246 }
247
248 QString StringListConfigControl::getValue()
249 {
250     return combo->itemData( combo->currentIndex() ).toString();
251 }
252
253 /********* Module **********/
254 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
255                module_config_t *_p_item, QWidget *_parent, bool bycat,
256                QGridLayout *l, int &line) :
257                VStringConfigControl( _p_this, _p_item, _parent )
258 {
259     label = new QLabel( qfu(p_item->psz_text) );
260     combo = new QComboBox();
261     finish( bycat );
262     if( !l )
263     {
264         QHBoxLayout *layout = new QHBoxLayout();
265         layout->addWidget( label ); layout->addWidget( combo );
266         widget->setLayout( layout );
267     }
268     else
269     {
270         l->addWidget( label, line, 0 );
271         l->addWidget( combo, line, 1, Qt::AlignRight );
272     }
273 }
274 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
275                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
276                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
277 {
278     combo = _combo;
279     label = _label;
280     finish( bycat );
281 }
282
283 void ModuleConfigControl::finish( bool bycat )
284 {
285     vlc_list_t *p_list;
286     module_t *p_parser;
287
288     combo->setEditable( false );
289
290     /* build a list of available modules */
291     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
292     combo->addItem( qtr("Default") );
293     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
294     {
295         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
296
297         if( bycat )
298         {
299             if( !strcmp( p_parser->psz_object_name, "main" ) ) continue;
300
301             module_config_t *p_config = p_parser->p_config;
302             if( p_config ) do
303             {
304                 /* Hack: required subcategory is stored in i_min */
305                 if( p_config->i_type == CONFIG_SUBCATEGORY &&
306                     p_config->i_value == p_item->i_min )
307                     combo->addItem( qfu(p_parser->psz_longname),
308                                     QVariant( p_parser->psz_object_name ) );
309                 if( p_item->psz_value && !strcmp( p_item->psz_value,
310                                                   p_parser->psz_object_name) )
311                     combo->setCurrentIndex( combo->count() - 1 );
312             } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
313         }
314         else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
315         {
316             combo->addItem( qfu(p_parser->psz_longname),
317                             QVariant( p_parser->psz_object_name ) );
318             if( p_item->psz_value && !strcmp( p_item->psz_value,
319                                               p_parser->psz_object_name) )
320                 combo->setCurrentIndex( combo->count() - 1 );
321         }
322     }
323     vlc_list_release( p_list );
324     combo->setToolTip( qfu(p_item->psz_longtext) );
325     if( label )
326         label->setToolTip( qfu(p_item->psz_longtext) );
327 }
328
329 QString ModuleConfigControl::getValue()
330 {
331     return combo->itemData( combo->currentIndex() ).toString();
332 }
333
334 /********* Module list **********/
335 ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
336                module_config_t *_p_item, QWidget *_parent, bool bycat,
337                QGridLayout *l, int &line) :
338                VStringConfigControl( _p_this, _p_item, _parent )
339 {
340     label = new QLabel( qfu(p_item->psz_text) );
341     text = new QLineEdit();
342     finish( bycat );
343
344     bool pom = false;
345     if( !l )
346     {
347         l = new QGridLayout();
348         line = 0;
349         pom = true;
350     }
351     for( QVector<QCheckBox*>::iterator it = modules.begin();
352          it != modules.end(); it++ )
353     {
354         l->addWidget( *it, line++, 1 );
355     }
356     l->addWidget( label, line, 0 );
357     l->addWidget( text, line, 1 );
358     if( pom )
359         widget->setLayout( l );
360 }
361 #if 0
362 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
363                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
364                 bool bycat ) : VStringConfigControl( _p_this, _p_item )
365 {
366     combo = _combo;
367     label = _label;
368     finish( bycat );
369 }
370 #endif
371
372 ModuleListConfigControl::~ModuleListConfigControl()
373 {
374     for( QVector<QCheckBox*>::iterator it = modules.begin();
375          it != modules.end(); it++ )
376     {
377         delete *it;
378     }
379     delete label;
380     delete text;
381 }
382
383 void ModuleListConfigControl::finish( bool bycat )
384 {
385     vlc_list_t *p_list;
386     module_t *p_parser;
387
388     /* build a list of available modules */
389     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
390     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
391     {
392         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
393
394         if( bycat )
395         {
396             if( !strcmp( p_parser->psz_object_name, "main" ) ) continue;
397
398             module_config_t *p_config = p_parser->p_config;
399             if( p_config ) do
400             {
401                 /* Hack: required subcategory is stored in i_min */
402                 if( p_config->i_type == CONFIG_SUBCATEGORY &&
403                     p_config->i_value == p_item->i_min )
404                 {
405                     QCheckBox *cb =
406                         new QCheckBox( qfu( p_parser->psz_object_name ) );
407                     cb->setToolTip( qfu(p_parser->psz_longname) );
408                     modules.push_back( cb );
409                 }
410             } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
411         }
412         else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
413         {
414             QCheckBox *cb =
415                 new QCheckBox( qfu( p_parser->psz_object_name ) );
416             cb->setToolTip( qfu(p_parser->psz_longname) );
417             modules.push_back( cb );
418         }
419     }
420     vlc_list_release( p_list );
421     text->setToolTip( qfu(p_item->psz_longtext) );
422     if( label )
423         label->setToolTip( qfu(p_item->psz_longtext) );
424 }
425
426 QString ModuleListConfigControl::getValue()
427 {
428     return text->text();
429 }
430
431 void ModuleListConfigControl::hide()
432 {
433     for( QVector<QCheckBox*>::iterator it = modules.begin();
434          it != modules.end(); it++ )
435     {
436         (*it)->hide();
437     }
438     text->hide();
439     label->hide();
440 }
441
442 void ModuleListConfigControl::show()
443 {
444     for( QVector<QCheckBox*>::iterator it = modules.begin();
445          it != modules.end(); it++ )
446     {
447         (*it)->show();
448     }
449     text->show();
450     label->show();
451 }
452
453
454 void ModuleListConfigControl::wakeUp_TheUserJustClickedOnSomething( int value )
455 {
456     text->clear();
457     for( QVector<QCheckBox*>::iterator it = modules.begin();
458          it != modules.end(); it++ )
459     {
460     }
461 }
462
463 /**************************************************************************
464  * Integer-based controls
465  *************************************************************************/
466
467 /*********** Integer **************/
468 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
469                                             module_config_t *_p_item,
470                                             QWidget *_parent, QGridLayout *l,
471                                             int &line ) :
472                            VIntConfigControl( _p_this, _p_item, _parent )
473 {
474     label = new QLabel( qfu(p_item->psz_text) );
475     spin = new QSpinBox; spin->setMinimumWidth( 80 );
476     spin->setMaximumWidth( 90 );
477     finish();
478
479     if( !l )
480     {
481         QHBoxLayout *layout = new QHBoxLayout();
482         layout->addWidget( label, 0 ); layout->addWidget( spin, 1 );
483         widget->setLayout( layout );
484     }
485     else
486     {
487         l->addWidget( label, line, 0 );
488         l->addWidget( spin, line, 1, Qt::AlignRight );
489     }
490 }
491 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
492                                             module_config_t *_p_item,
493                                             QLabel *_label, QSpinBox *_spin ) :
494                                       VIntConfigControl( _p_this, _p_item )
495 {
496     spin = _spin;
497     label = _label;
498     finish();
499 }
500
501 void IntegerConfigControl::finish()
502 {
503     spin->setMaximum( 2000000000 );
504     spin->setMinimum( -2000000000 );
505     spin->setValue( p_item->i_value );
506     spin->setToolTip( qfu(p_item->psz_longtext) );
507     if( label )
508         label->setToolTip( qfu(p_item->psz_longtext) );
509 }
510
511 int IntegerConfigControl::getValue()
512 {
513     return spin->value();
514 }
515
516 /********* Integer range **********/
517 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
518                                             module_config_t *_p_item,
519                                             QWidget *_parent, QGridLayout *l,
520                                             int &line ) :
521             IntegerConfigControl( _p_this, _p_item, _parent, l, line )
522 {
523     finish();
524 }
525
526 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
527                                             module_config_t *_p_item,
528                                             QLabel *_label, QSpinBox *_spin ) :
529             IntegerConfigControl( _p_this, _p_item, _label, _spin )
530 {
531     finish();
532 }
533
534 void IntegerRangeConfigControl::finish()
535 {
536     spin->setMaximum( p_item->i_max );
537     spin->setMinimum( p_item->i_min );
538 }
539
540 /********* Integer / choice list **********/
541 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
542                module_config_t *_p_item, QWidget *_parent, bool bycat,
543                QGridLayout *l, int &line) :
544                VIntConfigControl( _p_this, _p_item, _parent )
545 {
546     label = new QLabel( qfu(p_item->psz_text) );
547     combo = new QComboBox();
548     finish( bycat );
549     if( !l )
550     {
551         QHBoxLayout *layout = new QHBoxLayout();
552         layout->addWidget( label ); layout->addWidget( combo );
553         widget->setLayout( layout );
554     }
555     else
556     {
557         l->addWidget( label, line, 0 );
558         l->addWidget( combo, line, 1, Qt::AlignRight );
559     }
560 }
561 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
562                 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
563                 bool bycat ) : VIntConfigControl( _p_this, _p_item )
564 {
565     combo = _combo;
566     label = _label;
567     finish( bycat );
568 }
569
570 void IntegerListConfigControl::finish( bool bycat )
571 {
572     combo->setEditable( false );
573
574     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
575     {
576         combo->addItem( qfu(p_item->ppsz_list_text[i_index] ),
577                         QVariant( p_item->pi_list[i_index] ) );
578         if( p_item->i_value == p_item->pi_list[i_index] )
579             combo->setCurrentIndex( combo->count() - 1 );
580     }
581     combo->setToolTip( qfu(p_item->psz_longtext) );
582     if( label )
583         label->setToolTip( qfu(p_item->psz_longtext) );
584 }
585
586 int IntegerListConfigControl::getValue()
587 {
588     return combo->itemData( combo->currentIndex() ).toInt();
589 }
590
591 /*********** Boolean **************/
592 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
593                                       module_config_t *_p_item,
594                                       QWidget *_parent, QGridLayout *l,
595                                       int &line ) :
596                     VIntConfigControl( _p_this, _p_item, _parent )
597 {
598     checkbox = new QCheckBox( qfu(p_item->psz_text) );
599     finish();
600
601     if( !l )
602     {
603         QHBoxLayout *layout = new QHBoxLayout();
604         layout->addWidget( checkbox, 0 );
605         widget->setLayout( layout );
606     }
607     else
608     {
609         l->addWidget( checkbox, line, 0 );
610     }
611 }
612 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
613                                       module_config_t *_p_item,
614                                       QLabel *_label,
615                                       QCheckBox *_checkbox,
616                                       bool bycat ) :
617                    VIntConfigControl( _p_this, _p_item )
618 {
619     checkbox = _checkbox;
620     finish();
621 }
622
623 void BoolConfigControl::finish()
624 {
625     checkbox->setCheckState( p_item->i_value == VLC_TRUE ? Qt::Checked
626                                                         : Qt::Unchecked );
627     checkbox->setToolTip( qfu(p_item->psz_longtext) );
628 }
629
630 int BoolConfigControl::getValue()
631 {
632     return checkbox->checkState() == Qt::Checked ? VLC_TRUE : VLC_FALSE;
633 }
634
635 /**************************************************************************
636  * Float-based controls
637  *************************************************************************/
638
639 /*********** Float **************/
640 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
641                                         module_config_t *_p_item,
642                                         QWidget *_parent, QGridLayout *l,
643                                         int &line ) :
644                     VFloatConfigControl( _p_this, _p_item, _parent )
645 {
646     label = new QLabel( qfu(p_item->psz_text) );
647     spin = new QDoubleSpinBox; spin->setMinimumWidth( 80 );
648     spin->setMaximumWidth( 90 );
649     finish();
650
651     if( !l )
652     {
653         QHBoxLayout *layout = new QHBoxLayout();
654         layout->addWidget( label, 0 ); layout->addWidget( spin, 1 );
655         widget->setLayout( layout );
656     }
657     else
658     {
659         l->addWidget( label, line, 0 );
660         l->addWidget( spin, line, 1, Qt::AlignRight );
661     }
662 }
663
664 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
665                                         module_config_t *_p_item,
666                                         QLabel *_label,
667                                         QDoubleSpinBox *_spin ) :
668                     VFloatConfigControl( _p_this, _p_item )
669 {
670     spin = _spin;
671     label = _label;
672     finish();
673 }
674
675 void FloatConfigControl::finish()
676 {
677     spin->setMaximum( 2000000000. );
678     spin->setMinimum( -2000000000. );
679     spin->setSingleStep( 0.1 );
680     spin->setValue( (double)p_item->f_value );
681     spin->setToolTip( qfu(p_item->psz_longtext) );
682     if( label )
683         label->setToolTip( qfu(p_item->psz_longtext) );
684 }
685
686 float FloatConfigControl::getValue()
687 {
688     return (float)spin->value();
689 }
690
691 /*********** Float with range **************/
692 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
693                                         module_config_t *_p_item,
694                                         QWidget *_parent, QGridLayout *l,
695                                         int &line ) :
696                 FloatConfigControl( _p_this, _p_item, _parent, l, line )
697 {
698     finish();
699 }
700
701 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
702                                         module_config_t *_p_item,
703                                         QLabel *_label,
704                                         QDoubleSpinBox *_spin ) :
705                 FloatConfigControl( _p_this, _p_item, _label, _spin )
706 {
707     finish();
708 }
709
710 void FloatRangeConfigControl::finish()
711 {
712     spin->setMaximum( (double)p_item->f_max );
713     spin->setMinimum( (double)p_item->f_min );
714 }
715
716
717 /**********************************************************************
718  * Key selector widget
719  **********************************************************************/
720 KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
721                                       module_config_t *_p_item,
722                                       QWidget *_parent, QGridLayout *l,
723                                       int &line ) :
724                                 ConfigControl( _p_this, _p_item, _parent )
725
726 {
727     label = new QLabel( qtr("Select an action to change the associated hotkey") );
728     table = new QTreeWidget( 0 );
729     finish();
730
731     if( !l )
732     {
733         QVBoxLayout *layout = new QVBoxLayout();
734         layout->addWidget( label, 0 ); layout->addWidget( table, 1 );
735         widget->setLayout( layout );
736     }
737     else
738     {
739         l->addWidget( label, line, 0, 1, 2 );
740         l->addWidget( table, line+1, 0, 1,2 );
741     }
742 }
743
744 void KeySelectorControl::finish()
745 {
746     if( label )
747         label->setToolTip( qfu(p_item->psz_longtext) );
748
749     /* Fill the table */
750     table->setColumnCount( 2 );
751     table->setAlternatingRowColors( true );
752
753     module_t *p_main = config_FindModule( p_this, "main" );
754     assert( p_main );
755     module_config_t *p_item = p_main->p_config;
756
757     if( p_item ) do
758     {
759         if( p_item->i_type & CONFIG_ITEM && p_item->psz_name &&
760             strstr( p_item->psz_name , "key-" ) )
761         {
762             QTreeWidgetItem *treeItem = new QTreeWidgetItem();
763             treeItem->setText( 0, qfu( p_item->psz_text ) );
764             treeItem->setText( 1, p_item->psz_value );
765             treeItem->setData( 0, Qt::UserRole, QVariant( p_item->psz_name ) );
766             table->addTopLevelItem( treeItem );
767         }
768     } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
769 }
770
771 void KeySelectorControl::doApply()
772 {
773
774 }