1 /*****************************************************************************
2 * preferences_widgets.cpp : Widgets for preferences displays
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
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.
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.
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 *****************************************************************************/
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
34 #include "components/preferences_widgets.hpp"
35 #include "util/customwidgets.hpp"
41 #include <QDoubleSpinBox>
44 #include <QGridLayout>
45 #include <QPushButton>
47 #include <QFileDialog>
51 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
52 module_config_t *p_item,
56 return createControl( p_this, p_item, parent, NULL, i );
59 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
60 module_config_t *p_item,
62 QGridLayout *l, int &line )
64 ConfigControl *p_control = NULL;
65 if( p_item->psz_current ) return NULL;
67 switch( p_item->i_type )
69 case CONFIG_ITEM_MODULE:
70 p_control = new ModuleConfigControl( p_this, p_item, parent, false,
73 case CONFIG_ITEM_MODULE_CAT:
74 p_control = new ModuleConfigControl( p_this, p_item, parent, true,
77 case CONFIG_ITEM_MODULE_LIST:
78 p_control = new ModuleListConfigControl( p_this, p_item, parent, false,
81 case CONFIG_ITEM_MODULE_LIST_CAT:
82 p_control = new ModuleListConfigControl( p_this, p_item, parent, true,
85 case CONFIG_ITEM_STRING:
87 p_control = new StringConfigControl( p_this, p_item, parent,
90 p_control = new StringListConfigControl( p_this, p_item,
91 parent, false, l, line );
93 case CONFIG_ITEM_INTEGER:
95 p_control = new IntegerListConfigControl( p_this, p_item,
96 parent, false, l, line );
97 else if( p_item->min.i || p_item->max.i )
98 p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
101 p_control = new IntegerConfigControl( p_this, p_item, parent,
104 case CONFIG_ITEM_FILE:
105 p_control = new FileConfigControl( p_this, p_item, parent, l,
108 case CONFIG_ITEM_DIRECTORY:
109 fprintf( stderr, "Todo (CONFIG_ITEM_DIRECTORY)\n" );
111 case CONFIG_ITEM_KEY:
112 p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
114 case CONFIG_ITEM_BOOL:
115 p_control = new BoolConfigControl( p_this, p_item, parent, l, line );
117 case CONFIG_ITEM_FLOAT:
118 if( p_item->min.f || p_item->max.f )
119 p_control = new FloatRangeConfigControl( p_this, p_item, parent,
122 p_control = new FloatConfigControl( p_this, p_item, parent,
131 void ConfigControl::doApply( intf_thread_t *p_intf )
137 VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
139 config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
144 VFloatConfigControl *vfcc =
145 qobject_cast<VFloatConfigControl *>(this);
147 config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
152 VStringConfigControl *vscc =
153 qobject_cast<VStringConfigControl *>(this);
155 config_PutPsz( p_intf, vscc->getName(), qta( vscc->getValue() ) );
160 KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
167 /**************************************************************************
168 * String-based controls
169 *************************************************************************/
171 /*********** String **************/
172 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
173 module_config_t *_p_item,
174 QWidget *_parent, QGridLayout *l,
175 int &line, bool pwd ) :
176 VStringConfigControl( _p_this, _p_item, _parent )
178 label = new QLabel( qfu(p_item->psz_text) );
179 text = new QLineEdit( qfu(p_item->value.psz) );
184 QHBoxLayout *layout = new QHBoxLayout();
185 layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
186 widget->setLayout( layout );
190 l->addWidget( label, line, 0 ); l->addWidget( text, line, 1 );
194 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
195 module_config_t *_p_item,
196 QLabel *_label, QLineEdit *_text, bool pwd ):
197 VStringConfigControl( _p_this, _p_item )
204 void StringConfigControl::finish()
206 text->setText( qfu(p_item->value.psz) );
207 text->setToolTip( qfu(p_item->psz_longtext) );
209 label->setToolTip( qfu(p_item->psz_longtext) );
212 /*********** File **************/
213 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
214 module_config_t *_p_item,
215 QWidget *_parent, QGridLayout *l,
216 int &line, bool pwd ) :
217 VStringConfigControl( _p_this, _p_item, _parent )
219 label = new QLabel( qfu(p_item->psz_text) );
220 text = new QLineEdit( qfu(p_item->value.psz) );
221 browse = new QPushButton( qtr( "Browse" ) );
223 BUTTONACT( browse, updateField() );
229 QHBoxLayout *layout = new QHBoxLayout();
230 layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
231 layout->addWidget( browse, 2 );
232 widget->setLayout( layout );
236 l->addWidget( label, line, 0 ); l->addWidget( text, line, 1 );
237 l->addWidget( browse, line, 2 );
242 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
243 module_config_t *_p_item,
244 QLabel *_label, QLineEdit *_text, bool pwd ):
245 VStringConfigControl( _p_this, _p_item )
252 void FileConfigControl::updateField()
254 text->setText( QFileDialog::getOpenFileName( NULL,
255 qtr( "Select File" ), qfu( p_this->p_libvlc->psz_homedir ) ) );
258 void FileConfigControl::finish()
260 text->setText( qfu(p_item->value.psz) );
261 text->setToolTip( qfu(p_item->psz_longtext) );
263 label->setToolTip( qfu(p_item->psz_longtext) );
266 /********* String / choice list **********/
267 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
268 module_config_t *_p_item, QWidget *_parent, bool bycat,
269 QGridLayout *l, int &line) :
270 VStringConfigControl( _p_this, _p_item, _parent )
272 label = new QLabel( qfu(p_item->psz_text) );
273 combo = new QComboBox();
277 QHBoxLayout *layout = new QHBoxLayout();
278 layout->addWidget( label ); layout->addWidget( combo );
279 widget->setLayout( layout );
283 l->addWidget( label, line, 0 );
284 l->addWidget( combo, line, 1, Qt::AlignRight );
287 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
288 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
289 bool bycat ) : VStringConfigControl( _p_this, _p_item )
296 void StringListConfigControl::finish( bool bycat )
298 combo->setEditable( false );
300 for( int i_index = 0; i_index < p_item->i_list; i_index++ )
302 combo->addItem( qfu(p_item->ppsz_list_text ?
303 p_item->ppsz_list_text[i_index] :
304 p_item->ppsz_list[i_index] ),
305 QVariant( p_item->ppsz_list[i_index] ) );
306 if( p_item->value.psz && !strcmp( p_item->value.psz,
307 p_item->ppsz_list[i_index] ) )
308 combo->setCurrentIndex( combo->count() - 1 );
310 combo->setToolTip( qfu(p_item->psz_longtext) );
312 label->setToolTip( qfu(p_item->psz_longtext) );
315 QString StringListConfigControl::getValue()
317 return combo->itemData( combo->currentIndex() ).toString();
320 /********* Module **********/
321 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
322 module_config_t *_p_item, QWidget *_parent, bool bycat,
323 QGridLayout *l, int &line) :
324 VStringConfigControl( _p_this, _p_item, _parent )
326 label = new QLabel( qfu(p_item->psz_text) );
327 combo = new QComboBox();
331 QHBoxLayout *layout = new QHBoxLayout();
332 layout->addWidget( label ); layout->addWidget( combo );
333 widget->setLayout( layout );
337 l->addWidget( label, line, 0 );
338 l->addWidget( combo, line, 1, Qt::AlignRight );
341 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
342 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
343 bool bycat ) : VStringConfigControl( _p_this, _p_item )
350 void ModuleConfigControl::finish( bool bycat )
355 combo->setEditable( false );
357 /* build a list of available modules */
358 p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
359 combo->addItem( qtr("Default") );
360 for( int i_index = 0; i_index < p_list->i_count; i_index++ )
362 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
366 if( !strcmp( p_parser->psz_object_name, "main" ) ) continue;
368 for (size_t i = 0; i < p_parser->confsize; i++)
370 module_config_t *p_config = p_parser->p_config + i;
371 /* Hack: required subcategory is stored in i_min */
372 if( p_config->i_type == CONFIG_SUBCATEGORY &&
373 p_config->value.i == p_item->min.i )
374 combo->addItem( qfu(p_parser->psz_longname),
375 QVariant( p_parser->psz_object_name ) );
376 if( p_item->value.psz && !strcmp( p_item->value.psz,
377 p_parser->psz_object_name) )
378 combo->setCurrentIndex( combo->count() - 1 );
381 else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
383 combo->addItem( qfu(p_parser->psz_longname),
384 QVariant( p_parser->psz_object_name ) );
385 if( p_item->value.psz && !strcmp( p_item->value.psz,
386 p_parser->psz_object_name) )
387 combo->setCurrentIndex( combo->count() - 1 );
390 vlc_list_release( p_list );
391 combo->setToolTip( qfu(p_item->psz_longtext) );
393 label->setToolTip( qfu(p_item->psz_longtext) );
396 QString ModuleConfigControl::getValue()
398 return combo->itemData( combo->currentIndex() ).toString();
401 /********* Module list **********/
402 ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
403 module_config_t *_p_item, QWidget *_parent, bool bycat,
404 QGridLayout *l, int &line) :
405 VStringConfigControl( _p_this, _p_item, _parent )
407 label = new QLabel( qfu(p_item->psz_text) );
408 text = new QLineEdit();
414 l = new QGridLayout();
418 for( QVector<QCheckBox*>::iterator it = modules.begin();
419 it != modules.end(); it++ )
421 l->addWidget( *it, line++, 1 );
423 l->addWidget( label, line, 0 );
424 l->addWidget( text, line, 1 );
426 widget->setLayout( l );
429 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
430 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
431 bool bycat ) : VStringConfigControl( _p_this, _p_item )
439 ModuleListConfigControl::~ModuleListConfigControl()
441 for( QVector<QCheckBox*>::iterator it = modules.begin();
442 it != modules.end(); it++ )
450 void ModuleListConfigControl::finish( bool bycat )
455 /* build a list of available modules */
456 p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
457 for( int i_index = 0; i_index < p_list->i_count; i_index++ )
459 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
463 if( !strcmp( p_parser->psz_object_name, "main" ) ) continue;
465 for (size_t i = 0; i < p_parser->confsize; i++)
467 module_config_t *p_config = p_parser->p_config + i;
468 /* Hack: required subcategory is stored in i_min */
469 if( p_config->i_type == CONFIG_SUBCATEGORY &&
470 p_config->value.i == p_item->min.i )
473 new QCheckBox( qfu( p_parser->psz_object_name ) );
474 cb->setToolTip( qfu(p_parser->psz_longname) );
475 modules.push_back( cb );
479 else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
482 new QCheckBox( qfu( p_parser->psz_object_name ) );
483 cb->setToolTip( qfu(p_parser->psz_longname) );
484 modules.push_back( cb );
487 vlc_list_release( p_list );
488 text->setToolTip( qfu(p_item->psz_longtext) );
490 label->setToolTip( qfu(p_item->psz_longtext) );
493 QString ModuleListConfigControl::getValue()
498 void ModuleListConfigControl::hide()
500 for( QVector<QCheckBox*>::iterator it = modules.begin();
501 it != modules.end(); it++ )
509 void ModuleListConfigControl::show()
511 for( QVector<QCheckBox*>::iterator it = modules.begin();
512 it != modules.end(); it++ )
521 void ModuleListConfigControl::wakeUp_TheUserJustClickedOnSomething( int value )
524 for( QVector<QCheckBox*>::iterator it = modules.begin();
525 it != modules.end(); it++ )
530 /**************************************************************************
531 * Integer-based controls
532 *************************************************************************/
534 /*********** Integer **************/
535 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
536 module_config_t *_p_item,
537 QWidget *_parent, QGridLayout *l,
539 VIntConfigControl( _p_this, _p_item, _parent )
541 label = new QLabel( qfu(p_item->psz_text) );
542 spin = new QSpinBox; spin->setMinimumWidth( 80 );
543 spin->setMaximumWidth( 90 );
548 QHBoxLayout *layout = new QHBoxLayout();
549 layout->addWidget( label, 0 ); layout->addWidget( spin, 1 );
550 widget->setLayout( layout );
554 l->addWidget( label, line, 0 );
555 l->addWidget( spin, line, 1, Qt::AlignRight );
558 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
559 module_config_t *_p_item,
560 QLabel *_label, QSpinBox *_spin ) :
561 VIntConfigControl( _p_this, _p_item )
568 void IntegerConfigControl::finish()
570 spin->setMaximum( 2000000000 );
571 spin->setMinimum( -2000000000 );
572 spin->setValue( p_item->value.i );
573 spin->setToolTip( qfu(p_item->psz_longtext) );
575 label->setToolTip( qfu(p_item->psz_longtext) );
578 int IntegerConfigControl::getValue()
580 return spin->value();
583 /********* Integer range **********/
584 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
585 module_config_t *_p_item,
586 QWidget *_parent, QGridLayout *l,
588 IntegerConfigControl( _p_this, _p_item, _parent, l, line )
593 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
594 module_config_t *_p_item,
595 QLabel *_label, QSpinBox *_spin ) :
596 IntegerConfigControl( _p_this, _p_item, _label, _spin )
601 void IntegerRangeConfigControl::finish()
603 spin->setMaximum( p_item->max.i );
604 spin->setMinimum( p_item->min.i );
607 IntegerRangeSliderConfigControl::IntegerRangeSliderConfigControl(
608 vlc_object_t *_p_this,
609 module_config_t *_p_item,
610 QLabel *_label, QSlider *_slider ):
611 VIntConfigControl( _p_this, _p_item )
615 slider->setMaximum( p_item->max.i );
616 slider->setMinimum( p_item->min.i );
617 slider->setValue( p_item->value.i );
618 slider->setToolTip( qfu(p_item->psz_longtext) );
620 label->setToolTip( qfu(p_item->psz_longtext) );
623 int IntegerRangeSliderConfigControl::getValue()
625 return slider->value();
629 /********* Integer / choice list **********/
630 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
631 module_config_t *_p_item, QWidget *_parent, bool bycat,
632 QGridLayout *l, int &line) :
633 VIntConfigControl( _p_this, _p_item, _parent )
635 label = new QLabel( qfu(p_item->psz_text) );
636 combo = new QComboBox();
640 QHBoxLayout *layout = new QHBoxLayout();
641 layout->addWidget( label ); layout->addWidget( combo );
642 widget->setLayout( layout );
646 l->addWidget( label, line, 0 );
647 l->addWidget( combo, line, 1, Qt::AlignRight );
650 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
651 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
652 bool bycat ) : VIntConfigControl( _p_this, _p_item )
659 void IntegerListConfigControl::finish( bool bycat )
661 combo->setEditable( false );
663 for( int i_index = 0; i_index < p_item->i_list; i_index++ )
665 combo->addItem( qfu(p_item->ppsz_list_text[i_index] ),
666 QVariant( p_item->pi_list[i_index] ) );
667 if( p_item->value.i == p_item->pi_list[i_index] )
668 combo->setCurrentIndex( combo->count() - 1 );
670 combo->setToolTip( qfu(p_item->psz_longtext) );
672 label->setToolTip( qfu(p_item->psz_longtext) );
675 int IntegerListConfigControl::getValue()
677 return combo->itemData( combo->currentIndex() ).toInt();
680 /*********** Boolean **************/
681 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
682 module_config_t *_p_item,
683 QWidget *_parent, QGridLayout *l,
685 VIntConfigControl( _p_this, _p_item, _parent )
687 checkbox = new QCheckBox( qfu(p_item->psz_text) );
692 QHBoxLayout *layout = new QHBoxLayout();
693 layout->addWidget( checkbox, 0 );
694 widget->setLayout( layout );
698 l->addWidget( checkbox, line, 0 );
701 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
702 module_config_t *_p_item,
704 QCheckBox *_checkbox,
706 VIntConfigControl( _p_this, _p_item )
708 checkbox = _checkbox;
712 void BoolConfigControl::finish()
714 checkbox->setCheckState( p_item->value.i == VLC_TRUE ? Qt::Checked
716 checkbox->setToolTip( qfu(p_item->psz_longtext) );
719 int BoolConfigControl::getValue()
721 return checkbox->checkState() == Qt::Checked ? VLC_TRUE : VLC_FALSE;
724 /**************************************************************************
725 * Float-based controls
726 *************************************************************************/
728 /*********** Float **************/
729 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
730 module_config_t *_p_item,
731 QWidget *_parent, QGridLayout *l,
733 VFloatConfigControl( _p_this, _p_item, _parent )
735 label = new QLabel( qfu(p_item->psz_text) );
736 spin = new QDoubleSpinBox; spin->setMinimumWidth( 80 );
737 spin->setMaximumWidth( 90 );
742 QHBoxLayout *layout = new QHBoxLayout();
743 layout->addWidget( label, 0 ); layout->addWidget( spin, 1 );
744 widget->setLayout( layout );
748 l->addWidget( label, line, 0 );
749 l->addWidget( spin, line, 1, Qt::AlignRight );
753 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
754 module_config_t *_p_item,
756 QDoubleSpinBox *_spin ) :
757 VFloatConfigControl( _p_this, _p_item )
764 void FloatConfigControl::finish()
766 spin->setMaximum( 2000000000. );
767 spin->setMinimum( -2000000000. );
768 spin->setSingleStep( 0.1 );
769 spin->setValue( (double)p_item->value.f );
770 spin->setToolTip( qfu(p_item->psz_longtext) );
772 label->setToolTip( qfu(p_item->psz_longtext) );
775 float FloatConfigControl::getValue()
777 return (float)spin->value();
780 /*********** Float with range **************/
781 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
782 module_config_t *_p_item,
783 QWidget *_parent, QGridLayout *l,
785 FloatConfigControl( _p_this, _p_item, _parent, l, line )
790 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
791 module_config_t *_p_item,
793 QDoubleSpinBox *_spin ) :
794 FloatConfigControl( _p_this, _p_item, _label, _spin )
799 void FloatRangeConfigControl::finish()
801 spin->setMaximum( (double)p_item->max.f );
802 spin->setMinimum( (double)p_item->min.f );
806 /**********************************************************************
807 * Key selector widget
808 **********************************************************************/
809 KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
810 module_config_t *_p_item,
811 QWidget *_parent, QGridLayout *l,
813 ConfigControl( _p_this, _p_item, _parent )
816 label = new QLabel( qtr("Select an action to change the associated hotkey") );
817 table = new QTreeWidget( 0 );
822 QVBoxLayout *layout = new QVBoxLayout();
823 layout->addWidget( label, 0 ); layout->addWidget( table, 1 );
824 widget->setLayout( layout );
828 l->addWidget( label, line, 0, 1, 2 );
829 l->addWidget( table, line+1, 0, 1,2 );
833 void KeySelectorControl::finish()
836 label->setToolTip( qfu(p_item->psz_longtext) );
839 table->setColumnCount( 2 );
840 table->setAlternatingRowColors( true );
842 module_t *p_main = config_FindModule( p_this, "main" );
845 for (size_t i = 0; i < p_main->confsize; i++)
847 module_config_t *p_item = p_main->p_config + i;
849 if( p_item->i_type & CONFIG_ITEM && p_item->psz_name &&
850 strstr( p_item->psz_name , "key-" ) )
852 QTreeWidgetItem *treeItem = new QTreeWidgetItem();
853 treeItem->setText( 0, qfu( p_item->psz_text ) );
854 treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
855 treeItem->setData( 0, Qt::UserRole,
856 QVariant::fromValue( (void*)p_item ) );
858 table->addTopLevelItem( treeItem );
861 table->resizeColumnToContents( 0 );
863 CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ),
864 this, selectKey( QTreeWidgetItem * ) );
867 void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem )
869 module_config_t *p_keyItem = static_cast<module_config_t*>
870 (keyItem->data( 0, Qt::UserRole ).value<void*>());
872 KeyInputDialog *d = new KeyInputDialog( values, p_keyItem->psz_text );
874 if( d->result() == QDialog::Accepted )
876 p_keyItem->value.i = d->keyValue;
879 for( int i = 0; i < table->topLevelItemCount() ; i++ )
881 QTreeWidgetItem *it = table->topLevelItem(i);
882 module_config_t *p_item = static_cast<module_config_t*>
883 (it->data( 0, Qt::UserRole ).value<void*>());
884 it->setText( 1, VLCKeyToString( p_item->value.i ) );
888 keyItem->setText( 1, VLCKeyToString( p_keyItem->value.i ) );
893 void KeySelectorControl::doApply()
895 foreach( module_config_t *p_current, values )
897 config_PutInt( p_this, p_current->psz_name, p_current->value.i );
901 KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values,
902 const char * _keyToChange ) :
903 QDialog(0), keyValue(0)
908 keyToChange = _keyToChange;
909 setWindowTitle( qtr( "Hotkey for " ) + qfu( keyToChange) );
911 QVBoxLayout *l = new QVBoxLayout( this );
912 selected = new QLabel( qtr("Press the new keys for ") + qfu(keyToChange) );
913 warning = new QLabel();
914 l->addWidget( selected , Qt::AlignCenter );
915 l->addWidget( warning, Qt::AlignCenter );
917 QHBoxLayout *l2 = new QHBoxLayout();
918 QPushButton *ok = new QPushButton( qtr("OK") );
920 QPushButton *cancel = new QPushButton( qtr("Cancel") );
921 l2->addWidget( cancel );
923 BUTTONACT( ok, accept() );
924 BUTTONACT( cancel, reject() );
929 void KeyInputDialog::keyPressEvent( QKeyEvent *e )
931 if( e->key() == Qt::Key_Tab ) return;
932 int i_vlck = qtEventToVLCKey( e );
933 selected->setText( VLCKeyToString( i_vlck ) );
935 module_config_t *p_current = NULL;
936 foreach( p_current, values )
938 if( p_current->value.i == i_vlck && strcmp( p_current->psz_text,
941 p_current->value.i = 0;
949 qtr("Warning: the key is already assigned to \"") +
950 QString( p_current->psz_text ) + "\"" );
952 else warning->setText( "" );