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