Qt4: use open file dialog for loadfile items (fix #4247)
[vlc/asuraparaju-public.git] / modules / gui / qt4 / components / preferences_widgets.cpp
blob718c187cbcfa0faeff93b3e760baa84dc8e89482
1 /*****************************************************************************
2 * preferences_widgets.cpp : Widgets for preferences displays
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
5 * $Id$
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
9 * Jean-Baptiste Kempf <jb@videolan.org>
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.
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.
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 *****************************************************************************/
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
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
37 #include "components/preferences_widgets.hpp"
38 #include "util/customwidgets.hpp"
39 #include "util/qt_dirs.hpp"
40 #include <vlc_keys.h>
41 #include <vlc_intf_strings.h>
42 #include <vlc_modules.h>
44 #include <QString>
45 #include <QVariant>
46 #include <QGridLayout>
47 #include <QSlider>
48 #include <QFileDialog>
49 #include <QGroupBox>
50 #include <QTreeWidgetItem>
51 #include <QSignalMapper>
52 #include <QDialogButtonBox>
53 #include <QKeyEvent>
55 #define MINWIDTH_BOX 90
56 #define LAST_COLUMN 10
58 QString formatTooltip(const QString & tooltip)
60 QString formatted =
61 "<html><head><meta name=\"qrichtext\" content=\"1\" />"
62 "<style type=\"text/css\"> p, li { white-space: pre-wrap; } </style></head>"
63 "<body style=\" font-family:'Sans Serif'; "
64 "font-style:normal; text-decoration:none;\">"
65 "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
66 "margin-right:0px; -qt-block-indent:0; text-indent:0px;\">" +
67 tooltip +
68 "</p></body></html>";
69 return formatted;
72 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
73 module_config_t *p_item,
74 QWidget *parent )
76 int i = 0;
77 return createControl( p_this, p_item, parent, NULL, i );
80 ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
81 module_config_t *p_item,
82 QWidget *parent,
83 QGridLayout *l, int &line )
85 ConfigControl *p_control = NULL;
87 switch( p_item->i_type )
89 case CONFIG_ITEM_MODULE:
90 p_control = new ModuleConfigControl( p_this, p_item, parent, false,
91 l, line );
92 break;
93 case CONFIG_ITEM_MODULE_CAT:
94 p_control = new ModuleConfigControl( p_this, p_item, parent, true,
95 l, line );
96 break;
97 case CONFIG_ITEM_MODULE_LIST:
98 p_control = new ModuleListConfigControl( p_this, p_item, parent, false,
99 l, line );
100 break;
101 case CONFIG_ITEM_MODULE_LIST_CAT:
102 p_control = new ModuleListConfigControl( p_this, p_item, parent, true,
103 l, line );
104 break;
105 case CONFIG_ITEM_STRING:
106 if( !p_item->i_list )
107 p_control = new StringConfigControl( p_this, p_item, parent,
108 l, line, false );
109 else
110 p_control = new StringListConfigControl( p_this, p_item,
111 parent, false, l, line );
112 break;
113 case CONFIG_ITEM_PASSWORD:
114 if( !p_item->i_list )
115 p_control = new StringConfigControl( p_this, p_item, parent,
116 l, line, true );
117 else
118 p_control = new StringListConfigControl( p_this, p_item,
119 parent, true, l, line );
120 break;
121 case CONFIG_ITEM_INTEGER:
122 if( p_item->i_list )
123 p_control = new IntegerListConfigControl( p_this, p_item,
124 parent, false, l, line );
125 else if( p_item->min.i || p_item->max.i )
126 p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
127 l, line );
128 else
129 p_control = new IntegerConfigControl( p_this, p_item, parent,
130 l, line );
131 break;
132 case CONFIG_ITEM_LOADFILE:
133 case CONFIG_ITEM_SAVEFILE:
134 p_control = new FileConfigControl( p_this, p_item, parent, l, line);
135 break;
136 case CONFIG_ITEM_DIRECTORY:
137 p_control = new DirectoryConfigControl( p_this, p_item, parent, l,
138 line );
139 break;
140 case CONFIG_ITEM_FONT:
141 p_control = new FontConfigControl( p_this, p_item, parent, l,
142 line);
143 break;
144 case CONFIG_ITEM_KEY:
145 p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
146 break;
147 case CONFIG_ITEM_BOOL:
148 p_control = new BoolConfigControl( p_this, p_item, parent, l, line );
149 break;
150 case CONFIG_ITEM_FLOAT:
151 if( p_item->min.f || p_item->max.f )
152 p_control = new FloatRangeConfigControl( p_this, p_item, parent,
153 l, line );
154 else
155 p_control = new FloatConfigControl( p_this, p_item, parent,
156 l, line );
157 break;
158 default:
159 break;
161 return p_control;
164 void ConfigControl::doApply( intf_thread_t *p_intf )
166 switch( getType() )
168 case CONFIG_ITEM_INTEGER:
169 case CONFIG_ITEM_BOOL:
171 VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
172 assert( vicc );
173 config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
174 break;
176 case CONFIG_ITEM_FLOAT:
178 VFloatConfigControl *vfcc =
179 qobject_cast<VFloatConfigControl *>(this);
180 assert( vfcc );
181 config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
182 break;
184 case CONFIG_ITEM_STRING:
186 VStringConfigControl *vscc =
187 qobject_cast<VStringConfigControl *>(this);
188 assert( vscc );
189 config_PutPsz( p_intf, vscc->getName(), qtu( vscc->getValue() ) );
190 break;
192 case CONFIG_ITEM_KEY:
194 KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
195 assert( ksc );
196 ksc->doApply();
201 /*******************************************************
202 * Simple widgets
203 *******************************************************/
204 InterfacePreviewWidget::InterfacePreviewWidget ( QWidget *parent ) : QLabel( parent )
206 setGeometry( 0, 0, 128, 100 );
207 setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
210 void InterfacePreviewWidget::setNormalPreview( bool b_minimal )
212 setPreview( ( b_minimal )?MINIMAL:COMPLETE );
215 void InterfacePreviewWidget::setPreview( enum_style e_style )
217 QString pixmapLocationString(":/prefsmenu/");
219 switch( e_style )
221 default:
222 case COMPLETE:
223 pixmapLocationString += "sample_complete";
224 break;
225 case MINIMAL:
226 pixmapLocationString += "sample_minimal";
227 break;
228 case SKINS:
229 pixmapLocationString += "sample_skins";
230 break;
233 setPixmap( QPixmap( pixmapLocationString ) );
234 update();
239 /**************************************************************************
240 * String-based controls
241 *************************************************************************/
243 /*********** String **************/
244 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
245 module_config_t *_p_item,
246 QWidget *_parent, QGridLayout *l,
247 int &line, bool pwd ) :
248 VStringConfigControl( _p_this, _p_item, _parent )
250 label = new QLabel( qtr(p_item->psz_text) );
251 text = new QLineEdit( qfu(p_item->value.psz) );
252 if( pwd ) text->setEchoMode( QLineEdit::Password );
253 finish();
255 if( !l )
257 QHBoxLayout *layout = new QHBoxLayout();
258 layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
259 layout->addWidget( text, LAST_COLUMN );
260 widget->setLayout( layout );
262 else
264 l->addWidget( label, line, 0 );
265 l->setColumnMinimumWidth( 1, 10 );
266 l->addWidget( text, line, LAST_COLUMN );
270 StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
271 module_config_t *_p_item,
272 QLabel *_label, QLineEdit *_text, bool pwd ):
273 VStringConfigControl( _p_this, _p_item )
275 text = _text;
276 if( pwd ) text->setEchoMode( QLineEdit::Password );
277 label = _label;
278 finish( );
281 void StringConfigControl::finish()
283 text->setText( qfu(p_item->value.psz) );
284 if( p_item->psz_longtext )
286 QString tipText = qtr(p_item->psz_longtext);
287 text->setToolTip( formatTooltip(tipText) );
288 if( label )
289 label->setToolTip( formatTooltip(tipText) );
291 if( label )
292 label->setBuddy( text );
295 /*********** File **************/
296 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
297 module_config_t *_p_item,
298 QWidget *_parent, QGridLayout *l,
299 int &line ) :
300 VStringConfigControl( _p_this, _p_item, _parent )
302 label = new QLabel( qtr(p_item->psz_text) );
303 text = new QLineEdit( qfu(p_item->value.psz) );
304 browse = new QPushButton( qtr( "Browse..." ) );
305 QHBoxLayout *textAndButton = new QHBoxLayout();
306 textAndButton->setMargin( 0 );
307 textAndButton->addWidget( text, 2 );
308 textAndButton->addWidget( browse, 0 );
310 BUTTONACT( browse, updateField() );
312 finish();
314 if( !l )
316 QHBoxLayout *layout = new QHBoxLayout();
317 layout->addWidget( label, 0 );
318 layout->insertSpacing( 1, 10 );
319 layout->addLayout( textAndButton, LAST_COLUMN );
320 widget->setLayout( layout );
322 else
324 l->addWidget( label, line, 0 );
325 l->setColumnMinimumWidth( 1, 10 );
326 l->addLayout( textAndButton, line, LAST_COLUMN );
331 FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
332 module_config_t *_p_item,
333 QLabel *_label, QLineEdit *_text,
334 QPushButton *_button ):
335 VStringConfigControl( _p_this, _p_item )
337 browse = _button;
338 text = _text;
339 label = _label;
341 BUTTONACT( browse, updateField() );
343 finish( );
346 void FileConfigControl::updateField()
348 QString file;
350 if (p_item->i_type == CONFIG_ITEM_SAVEFILE)
351 file = QFileDialog::getSaveFileName( NULL, qtr( "Save File" ),
352 QVLCUserDir( VLC_HOME_DIR ) );
353 else
354 file = QFileDialog::getOpenFileName( NULL, qtr( "Select File" ),
355 QVLCUserDir( VLC_HOME_DIR ) );
357 if( file.isNull() ) return;
358 text->setText( toNativeSeparators( file ) );
361 void FileConfigControl::finish()
363 text->setText( qfu(p_item->value.psz) );
364 if( p_item->psz_longtext )
366 QString tipText = qtr(p_item->psz_longtext);
367 text->setToolTip( formatTooltip(tipText) );
368 if( label )
369 label->setToolTip( formatTooltip(tipText) );
371 if( label )
372 label->setBuddy( text );
375 /********* String / Directory **********/
376 DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
377 module_config_t *_p_item, QWidget *_p_widget,
378 QGridLayout *_p_layout, int& _int ) :
379 FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int )
382 DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
383 module_config_t *_p_item, QLabel *_p_label,
384 QLineEdit *_p_line, QPushButton *_p_button ):
385 FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button)
388 void DirectoryConfigControl::updateField()
390 QString dir = QFileDialog::getExistingDirectory( NULL,
391 qtr( I_OP_SEL_DIR ),
392 text->text().isEmpty() ?
393 QVLCUserDir( VLC_HOME_DIR ) : text->text(),
394 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
396 if( dir.isNull() ) return;
397 text->setText( toNativeSepNoSlash( dir ) );
400 /********* String / Font **********/
401 FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
402 module_config_t *_p_item, QWidget *_parent,
403 QGridLayout *_p_layout, int& line) :
404 VStringConfigControl( _p_this, _p_item, _parent )
406 label = new QLabel( qtr(p_item->psz_text) );
407 font = new QFontComboBox( _parent );
408 font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
409 if( !_p_layout )
411 QHBoxLayout *layout = new QHBoxLayout();
412 layout->addWidget( label, 0 );
413 layout->addWidget( font, 1 );
414 widget->setLayout( layout );
416 else
418 _p_layout->addWidget( label, line, 0 );
419 _p_layout->addWidget( font, line, 1, 1, -1 );
423 FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
424 module_config_t *_p_item, QLabel *_p_label,
425 QFontComboBox *_p_font):
426 VStringConfigControl( _p_this, _p_item)
428 label = _p_label;
429 font = _p_font;
430 font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
433 /********* String / choice list **********/
434 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
435 module_config_t *_p_item, QWidget *_parent, bool bycat,
436 QGridLayout *l, int &line) :
437 VStringConfigControl( _p_this, _p_item, _parent )
439 label = new QLabel( qtr(p_item->psz_text) );
440 combo = new QComboBox();
441 combo->setMinimumWidth( MINWIDTH_BOX );
442 combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
444 module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
446 finish( p_module_config, bycat );
447 if( !l )
449 l = new QGridLayout();
450 l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN );
451 widget->setLayout( l );
453 else
455 l->addWidget( label, line, 0 );
456 l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
459 if( p_item->i_action )
461 QSignalMapper *signalMapper = new QSignalMapper(this);
463 /* Some stringLists like Capture listings have action associated */
464 for( int i = 0; i < p_item->i_action; i++ )
466 QPushButton *button =
467 new QPushButton( qtr( p_item->ppsz_action_text[i] ));
468 CONNECT( button, clicked(), signalMapper, map() );
469 signalMapper->setMapping( button, i );
470 l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
471 Qt::AlignRight );
473 CONNECT( signalMapper, mapped( int ),
474 this, actionRequested( int ) );
478 void StringListConfigControl::actionRequested( int i_action )
480 /* Supplementary check for boundaries */
481 if( i_action < 0 || i_action >= p_item->i_action ) return;
483 module_config_t *p_module_config = config_FindConfig( p_this, getName() );
484 if(!p_module_config) return;
486 vlc_value_t val;
487 val.psz_string = const_cast<char *>
488 qtu( (combo->itemData( combo->currentIndex() ).toString() ) );
490 p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
492 if( p_module_config->b_dirty )
494 combo->clear();
495 finish( p_module_config, true );
496 p_module_config->b_dirty = false;
499 StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
500 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
501 bool bycat ) : VStringConfigControl( _p_this, _p_item )
503 combo = _combo;
504 label = _label;
506 module_config_t *p_module_config = config_FindConfig( p_this, getName() );
508 finish( p_module_config, bycat );
511 void StringListConfigControl::finish(module_config_t *p_module_config, bool bycat )
513 combo->setEditable( false );
515 if(!p_module_config) return;
517 if( p_module_config->pf_update_list )
519 vlc_value_t val;
520 val.psz_string = strdup(p_module_config->value.psz);
522 p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
524 // assume in any case that dirty was set to true
525 // because lazy programmes will use the same callback for
526 // this, like the one behind the refresh push button?
527 p_module_config->b_dirty = false;
529 free( val.psz_string );
532 for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
534 if( !p_module_config->ppsz_list[i_index] )
536 combo->addItem( "", QVariant(""));
537 if( !p_item->value.psz )
538 combo->setCurrentIndex( combo->count() - 1 );
539 continue;
541 combo->addItem( qfu((p_module_config->ppsz_list_text &&
542 p_module_config->ppsz_list_text[i_index])?
543 _(p_module_config->ppsz_list_text[i_index]) :
544 p_module_config->ppsz_list[i_index] ),
545 QVariant( qfu(p_module_config->ppsz_list[i_index] )) );
546 if( p_item->value.psz && !strcmp( p_module_config->value.psz,
547 p_module_config->ppsz_list[i_index] ) )
548 combo->setCurrentIndex( combo->count() - 1 );
551 if( p_module_config->psz_longtext )
553 QString tipText = qtr(p_module_config->psz_longtext);
554 combo->setToolTip( formatTooltip(tipText) );
555 if( label )
556 label->setToolTip( formatTooltip(tipText) );
558 if( label )
559 label->setBuddy( combo );
562 QString StringListConfigControl::getValue()
564 return combo->itemData( combo->currentIndex() ).toString();
567 void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf,
568 QComboBox *combo )
570 module_config_t *p_config =
571 config_FindConfig( VLC_OBJECT(p_intf), configname );
572 if( p_config )
574 if(p_config->pf_update_list)
576 vlc_value_t val;
577 val.i_int = p_config->value.i;
578 p_config->pf_update_list(VLC_OBJECT(p_intf), configname, val, val, NULL);
579 // assume in any case that dirty was set to true
580 // because lazy programmes will use the same callback for
581 // this, like the one behind the refresh push button?
582 p_config->b_dirty = false;
585 for ( int i_index = 0; i_index < p_config->i_list; i_index++ )
587 combo->addItem( qtr(p_config->ppsz_list_text[i_index]),
588 QVariant( p_config->pi_list[i_index] ) );
589 if( p_config->value.i == p_config->pi_list[i_index] )
591 combo->setCurrentIndex( i_index );
595 if( p_config->psz_longtext )
596 combo->setToolTip( qfu( p_config->psz_longtext ) );
600 /********* Module **********/
601 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
602 module_config_t *_p_item, QWidget *_parent, bool bycat,
603 QGridLayout *l, int &line) :
604 VStringConfigControl( _p_this, _p_item, _parent )
606 label = new QLabel( qtr(p_item->psz_text) );
607 combo = new QComboBox();
608 combo->setMinimumWidth( MINWIDTH_BOX );
609 finish( bycat );
610 if( !l )
612 QHBoxLayout *layout = new QHBoxLayout();
613 layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
614 widget->setLayout( layout );
616 else
618 l->addWidget( label, line, 0 );
619 l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
623 ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
624 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
625 bool bycat ) : VStringConfigControl( _p_this, _p_item )
627 combo = _combo;
628 label = _label;
629 finish( bycat );
632 void ModuleConfigControl::finish( bool bycat )
634 module_t *p_parser;
636 combo->setEditable( false );
638 /* build a list of available modules */
639 module_t **p_list = module_list_get( NULL );
640 combo->addItem( qtr("Default") );
641 for( size_t i = 0; (p_parser = p_list[i]) != NULL; i++ )
643 if( bycat )
645 if( !strcmp( module_get_object( p_parser ), "main" ) ) continue;
647 unsigned confsize;
648 module_config_t *p_config;
650 p_config = module_config_get (p_parser, &confsize);
651 for (size_t i = 0; i < confsize; i++)
653 /* Hack: required subcategory is stored in i_min */
654 const module_config_t *p_cfg = p_config + i;
655 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
656 p_cfg->value.i == p_item->min.i )
657 combo->addItem( qtr( module_GetLongName( p_parser )),
658 QVariant( module_get_object( p_parser ) ) );
659 if( p_item->value.psz && !strcmp( p_item->value.psz,
660 module_get_object( p_parser ) ) )
661 combo->setCurrentIndex( combo->count() - 1 );
663 module_config_free (p_config);
665 else if( module_provides( p_parser, p_item->psz_type ) )
667 combo->addItem( qtr(module_GetLongName( p_parser ) ),
668 QVariant( module_get_object( p_parser ) ) );
669 if( p_item->value.psz && !strcmp( p_item->value.psz,
670 module_get_object( p_parser ) ) )
671 combo->setCurrentIndex( combo->count() - 1 );
674 module_list_free( p_list );
676 if( p_item->psz_longtext )
678 QString tipText = qtr(p_item->psz_longtext);
679 combo->setToolTip( formatTooltip(tipText) );
680 if( label )
681 label->setToolTip( formatTooltip(tipText) );
683 if( label )
684 label->setBuddy( combo );
687 QString ModuleConfigControl::getValue()
689 return combo->itemData( combo->currentIndex() ).toString();
692 /********* Module list **********/
693 ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
694 module_config_t *_p_item, QWidget *_parent, bool bycat,
695 QGridLayout *l, int &line) :
696 VStringConfigControl( _p_this, _p_item, _parent )
698 groupBox = NULL;
699 /* Special Hack */
700 if( !p_item->psz_text ) return;
702 groupBox = new QGroupBox ( qtr(p_item->psz_text), _parent );
703 text = new QLineEdit;
704 QGridLayout *layoutGroupBox = new QGridLayout( groupBox );
706 finish( bycat );
708 int boxline = 0;
709 for( QVector<checkBoxListItem*>::iterator it = modules.begin();
710 it != modules.end(); it++ )
712 layoutGroupBox->addWidget( (*it)->checkBox, boxline++, 0 );
714 layoutGroupBox->addWidget( text, boxline, 0 );
716 if( !l )
718 QVBoxLayout *layout = new QVBoxLayout();
719 layout->addWidget( groupBox, line, 0 );
720 widget->setLayout( layout );
722 else
724 l->addWidget( groupBox, line, 0, 1, -1 );
727 if( p_item->psz_longtext )
728 text->setToolTip( formatTooltip( qtr( p_item->psz_longtext) ) );
731 ModuleListConfigControl::~ModuleListConfigControl()
733 for( QVector<checkBoxListItem*>::iterator it = modules.begin();
734 it != modules.end(); it++ )
736 delete *it;
738 delete groupBox;
741 #define CHECKBOX_LISTS \
743 QCheckBox *cb = new QCheckBox( qtr( module_GetLongName( p_parser ) ) );\
744 checkBoxListItem *cbl = new checkBoxListItem; \
746 CONNECT( cb, stateChanged( int ), this, onUpdate() );\
747 const char *help = module_get_help( p_parser ); \
748 if( help != NULL ) \
749 cb->setToolTip( formatTooltip( qtr( help ) ) ); \
750 cbl->checkBox = cb; \
752 cbl->psz_module = strdup( module_get_object( p_parser ) ); \
753 modules.push_back( cbl ); \
755 if( p_item->value.psz && strstr( p_item->value.psz, cbl->psz_module ) ) \
756 cbl->checkBox->setChecked( true ); \
760 void ModuleListConfigControl::finish( bool bycat )
762 module_t *p_parser;
764 /* build a list of available modules */
765 module_t **p_list = module_list_get( NULL );
766 for( size_t i = 0; (p_parser = p_list[i]) != NULL; i++ )
768 if( bycat )
770 if( !strcmp( module_get_object( p_parser ), "main" ) ) continue;
772 unsigned confsize;
773 module_config_t *p_config = module_config_get (p_parser, &confsize);
775 for (size_t i = 0; i < confsize; i++)
777 module_config_t *p_cfg = p_config + i;
778 /* Hack: required subcategory is stored in i_min */
779 if( p_cfg->i_type == CONFIG_SUBCATEGORY &&
780 p_cfg->value.i == p_item->min.i )
782 CHECKBOX_LISTS;
785 module_config_free (p_config);
787 else if( module_provides( p_parser, p_item->psz_type ) )
789 CHECKBOX_LISTS;
792 module_list_free( p_list );
794 if( p_item->psz_longtext )
796 QString tipText = qtr(p_item->psz_longtext);
798 text->setToolTip( formatTooltip(tipText) );
799 assert( groupBox );
800 groupBox->setToolTip( formatTooltip(tipText) );
803 #undef CHECKBOX_LISTS
805 QString ModuleListConfigControl::getValue()
807 assert( text );
808 return text->text();
811 void ModuleListConfigControl::hide()
813 for( QVector<checkBoxListItem*>::iterator it = modules.begin();
814 it != modules.end(); it++ )
816 (*it)->checkBox->hide();
818 groupBox->hide();
821 void ModuleListConfigControl::show()
823 for( QVector<checkBoxListItem*>::iterator it = modules.begin();
824 it != modules.end(); it++ )
826 (*it)->checkBox->show();
828 groupBox->show();
832 void ModuleListConfigControl::onUpdate()
834 text->clear();
835 bool first = true;
837 for( QVector<checkBoxListItem*>::iterator it = modules.begin();
838 it != modules.end(); it++ )
840 if( (*it)->checkBox->isChecked() )
842 if( first )
844 text->setText( text->text() + (*it)->psz_module );
845 first = false;
847 else
849 text->setText( text->text() + ":" + (*it)->psz_module );
855 /**************************************************************************
856 * Integer-based controls
857 *************************************************************************/
859 /*********** Integer **************/
860 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
861 module_config_t *_p_item,
862 QWidget *_parent, QGridLayout *l,
863 int &line ) :
864 VIntConfigControl( _p_this, _p_item, _parent )
866 label = new QLabel( qtr(p_item->psz_text) );
867 spin = new QSpinBox; spin->setMinimumWidth( MINWIDTH_BOX );
868 spin->setAlignment( Qt::AlignRight );
869 spin->setMaximumWidth( MINWIDTH_BOX );
870 finish();
872 if( !l )
874 QHBoxLayout *layout = new QHBoxLayout();
875 layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
876 widget->setLayout( layout );
878 else
880 l->addWidget( label, line, 0 );
881 l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
884 IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
885 module_config_t *_p_item,
886 QLabel *_label, QSpinBox *_spin ) :
887 VIntConfigControl( _p_this, _p_item )
889 spin = _spin;
890 label = _label;
891 finish();
894 void IntegerConfigControl::finish()
896 spin->setMaximum( 2000000000 );
897 spin->setMinimum( -2000000000 );
898 spin->setValue( p_item->value.i );
900 if( p_item->psz_longtext )
902 QString tipText = qtr(p_item->psz_longtext);
903 spin->setToolTip( formatTooltip(tipText) );
904 if( label )
905 label->setToolTip( formatTooltip(tipText) );
907 if( label )
908 label->setBuddy( spin );
911 int IntegerConfigControl::getValue()
913 return spin->value();
916 /********* Integer range **********/
917 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
918 module_config_t *_p_item,
919 QWidget *_parent, QGridLayout *l,
920 int &line ) :
921 IntegerConfigControl( _p_this, _p_item, _parent, l, line )
923 finish();
926 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
927 module_config_t *_p_item,
928 QLabel *_label, QSpinBox *_spin ) :
929 IntegerConfigControl( _p_this, _p_item, _label, _spin )
931 finish();
934 void IntegerRangeConfigControl::finish()
936 spin->setMaximum( p_item->max.i );
937 spin->setMinimum( p_item->min.i );
940 IntegerRangeSliderConfigControl::IntegerRangeSliderConfigControl(
941 vlc_object_t *_p_this,
942 module_config_t *_p_item,
943 QLabel *_label, QSlider *_slider ):
944 VIntConfigControl( _p_this, _p_item )
946 slider = _slider;
947 label = _label;
948 slider->setMaximum( p_item->max.i );
949 slider->setMinimum( p_item->min.i );
950 slider->setValue( p_item->value.i );
951 if( p_item->psz_longtext )
953 QString tipText = qtr(p_item->psz_longtext);
954 slider->setToolTip( formatTooltip(tipText) );
955 if( label )
956 label->setToolTip( formatTooltip(tipText) );
958 if( label )
959 label->setBuddy( slider );
962 int IntegerRangeSliderConfigControl::getValue()
964 return slider->value();
968 /********* Integer / choice list **********/
969 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
970 module_config_t *_p_item, QWidget *_parent, bool bycat,
971 QGridLayout *l, int &line) :
972 VIntConfigControl( _p_this, _p_item, _parent )
974 label = new QLabel( qtr(p_item->psz_text) );
975 combo = new QComboBox();
976 combo->setMinimumWidth( MINWIDTH_BOX );
978 module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
980 finish( p_module_config, bycat );
981 if( !l )
983 QHBoxLayout *layout = new QHBoxLayout();
984 layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
985 widget->setLayout( layout );
987 else
989 l->addWidget( label, line, 0 );
990 l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
993 if( p_item->i_action )
995 QSignalMapper *signalMapper = new QSignalMapper(this);
997 /* Some stringLists like Capture listings have action associated */
998 for( int i = 0; i < p_item->i_action; i++ )
1000 QPushButton *button =
1001 new QPushButton( qfu( p_item->ppsz_action_text[i] ));
1002 CONNECT( button, clicked(), signalMapper, map() );
1003 signalMapper->setMapping( button, i );
1004 l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
1005 Qt::AlignRight );
1007 CONNECT( signalMapper, mapped( int ),
1008 this, actionRequested( int ) );
1012 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
1013 module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
1014 bool bycat ) : VIntConfigControl( _p_this, _p_item )
1016 combo = _combo;
1017 label = _label;
1019 module_config_t *p_module_config = config_FindConfig( p_this, getName() );
1021 finish( p_module_config, bycat );
1024 void IntegerListConfigControl::finish(module_config_t *p_module_config, bool bycat )
1026 combo->setEditable( false );
1028 if(!p_module_config) return;
1030 if( p_module_config->pf_update_list )
1032 vlc_value_t val;
1033 val.i_int = p_module_config->value.i;
1035 p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
1037 // assume in any case that dirty was set to true
1038 // because lazy programmes will use the same callback for
1039 // this, like the one behind the refresh push button?
1040 p_module_config->b_dirty = false;
1043 for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
1045 combo->addItem( qtr(p_module_config->ppsz_list_text[i_index] ),
1046 QVariant( p_module_config->pi_list[i_index] ) );
1047 if( p_module_config->value.i == p_module_config->pi_list[i_index] )
1048 combo->setCurrentIndex( combo->count() - 1 );
1050 if( p_item->psz_longtext )
1052 QString tipText = qtr(p_item->psz_longtext );
1053 combo->setToolTip( formatTooltip(tipText) );
1054 if( label )
1055 label->setToolTip( formatTooltip(tipText) );
1057 if( label )
1058 label->setBuddy( combo );
1061 void IntegerListConfigControl::actionRequested( int i_action )
1063 /* Supplementary check for boundaries */
1064 if( i_action < 0 || i_action >= p_item->i_action ) return;
1066 module_config_t *p_module_config = config_FindConfig( p_this, getName() );
1067 if(!p_module_config) return;
1070 vlc_value_t val;
1071 val.i_int = combo->itemData( combo->currentIndex() ).toInt();
1073 p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
1075 if( p_module_config->b_dirty )
1077 combo->clear();
1078 finish( p_module_config, true );
1079 p_module_config->b_dirty = false;
1083 int IntegerListConfigControl::getValue()
1085 return combo->itemData( combo->currentIndex() ).toInt();
1088 /*********** Boolean **************/
1089 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
1090 module_config_t *_p_item,
1091 QWidget *_parent, QGridLayout *l,
1092 int &line ) :
1093 VIntConfigControl( _p_this, _p_item, _parent )
1095 checkbox = new QCheckBox( qtr(p_item->psz_text) );
1096 finish();
1098 if( !l )
1100 QHBoxLayout *layout = new QHBoxLayout();
1101 layout->addWidget( checkbox, 0 );
1102 widget->setLayout( layout );
1104 else
1106 l->addWidget( checkbox, line, 0 );
1110 BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
1111 module_config_t *_p_item,
1112 QLabel *_label,
1113 QAbstractButton *_checkbox,
1114 bool bycat ) :
1115 VIntConfigControl( _p_this, _p_item )
1117 checkbox = _checkbox;
1118 VLC_UNUSED( _label );
1119 finish();
1122 void BoolConfigControl::finish()
1124 checkbox->setChecked( p_item->value.i == true );
1125 if( p_item->psz_longtext )
1126 checkbox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
1129 int BoolConfigControl::getValue()
1131 return checkbox->isChecked();
1134 /**************************************************************************
1135 * Float-based controls
1136 *************************************************************************/
1138 /*********** Float **************/
1139 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1140 module_config_t *_p_item,
1141 QWidget *_parent, QGridLayout *l,
1142 int &line ) :
1143 VFloatConfigControl( _p_this, _p_item, _parent )
1145 label = new QLabel( qtr(p_item->psz_text) );
1146 spin = new QDoubleSpinBox;
1147 spin->setMinimumWidth( MINWIDTH_BOX );
1148 spin->setMaximumWidth( MINWIDTH_BOX );
1149 spin->setAlignment( Qt::AlignRight );
1150 finish();
1152 if( !l )
1154 QHBoxLayout *layout = new QHBoxLayout();
1155 layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
1156 widget->setLayout( layout );
1158 else
1160 l->addWidget( label, line, 0 );
1161 l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
1165 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
1166 module_config_t *_p_item,
1167 QLabel *_label,
1168 QDoubleSpinBox *_spin ) :
1169 VFloatConfigControl( _p_this, _p_item )
1171 spin = _spin;
1172 label = _label;
1173 finish();
1176 void FloatConfigControl::finish()
1178 spin->setMaximum( 2000000000. );
1179 spin->setMinimum( -2000000000. );
1180 spin->setSingleStep( 0.1 );
1181 spin->setValue( (double)p_item->value.f );
1182 if( p_item->psz_longtext )
1184 QString tipText = qtr(p_item->psz_longtext);
1185 spin->setToolTip( formatTooltip(tipText) );
1186 if( label )
1187 label->setToolTip( formatTooltip(tipText) );
1189 if( label )
1190 label->setBuddy( spin );
1193 float FloatConfigControl::getValue()
1195 return (float)spin->value();
1198 /*********** Float with range **************/
1199 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1200 module_config_t *_p_item,
1201 QWidget *_parent, QGridLayout *l,
1202 int &line ) :
1203 FloatConfigControl( _p_this, _p_item, _parent, l, line )
1205 finish();
1208 FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
1209 module_config_t *_p_item,
1210 QLabel *_label,
1211 QDoubleSpinBox *_spin ) :
1212 FloatConfigControl( _p_this, _p_item, _label, _spin )
1214 finish();
1217 void FloatRangeConfigControl::finish()
1219 spin->setMaximum( (double)p_item->max.f );
1220 spin->setMinimum( (double)p_item->min.f );
1224 /**********************************************************************
1225 * Key selector widget
1226 **********************************************************************/
1227 KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
1228 module_config_t *_p_item,
1229 QWidget *_parent, QGridLayout *l,
1230 int &line ) :
1231 ConfigControl( _p_this, _p_item, _parent )
1234 QWidget *keyContainer = new QWidget;
1235 QGridLayout *gLayout = new QGridLayout( keyContainer );
1237 label = new QLabel(
1238 qtr( "Select an action to change the associated hotkey") );
1240 QLabel *searchLabel = new QLabel( qtr( "Search" ) );
1241 actionSearch = new SearchLineEdit( keyContainer );
1243 table = new QTreeWidget;
1244 table->setColumnCount(3);
1245 table->headerItem()->setText( 0, qtr( "Action" ) );
1246 table->headerItem()->setText( 1, qtr( "Hotkey" ) );
1247 table->headerItem()->setText( 2, qtr( "Global" ) );
1248 table->setAlternatingRowColors( true );
1249 table->setSelectionBehavior( QAbstractItemView::SelectItems );
1251 shortcutValue = new KeyShortcutEdit;
1252 shortcutValue->setReadOnly(true);
1254 QPushButton *clearButton = new QPushButton( qtr( "Clear" ) );
1255 QPushButton *setButton = new QPushButton( qtr( "Apply" ) );
1256 setButton->setDefault( true );
1257 finish();
1259 gLayout->addWidget( label, 0, 0, 1, 4 );
1260 gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
1261 gLayout->addWidget( actionSearch, 1, 2, 1, 2 );
1262 gLayout->addWidget( table, 2, 0, 1, 4 );
1263 gLayout->addWidget( clearButton, 3, 0, 1, 1 );
1264 gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
1265 gLayout->addWidget( setButton, 3, 3, 1, 1 );
1267 l->addWidget( keyContainer, line, 0, 1, -1 );
1269 CONNECT( clearButton, clicked(), shortcutValue, clear() );
1270 CONNECT( clearButton, clicked(), this, setTheKey() );
1271 BUTTONACT( setButton, setTheKey() );
1272 CONNECT( actionSearch, textChanged( const QString& ),
1273 this, filter( const QString& ) );
1276 void KeySelectorControl::finish()
1278 if( label && p_item->psz_longtext )
1279 label->setToolTip( formatTooltip( qtr( p_item->psz_longtext ) ) );
1281 /* Fill the table */
1283 /* Get the main Module */
1284 module_t *p_main = module_get_main();
1285 assert( p_main );
1287 /* Access to the module_config_t */
1288 unsigned confsize;
1289 module_config_t *p_config;
1291 p_config = module_config_get (p_main, &confsize);
1293 for (size_t i = 0; i < confsize; i++)
1295 module_config_t *p_item = p_config + i;
1297 /* If we are a key option not empty */
1298 if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
1299 && strstr( p_item->psz_name , "key-" )
1300 && !strstr( p_item->psz_name , "global-key" )
1301 && !EMPTY_STR( p_item->psz_text ) )
1304 Each tree item has:
1305 - QString text in column 0
1306 - QString name in data of column 0
1307 - KeyValue in String in column 1
1308 - KeyValue in int64_t in column 1
1310 QTreeWidgetItem *treeItem = new QTreeWidgetItem();
1311 treeItem->setText( 0, qtr( p_item->psz_text ) );
1312 treeItem->setData( 0, Qt::UserRole,
1313 QVariant( qfu( p_item->psz_name ) ) );
1314 treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
1315 treeItem->setData( 1, Qt::UserRole, QVariant( qlonglong( p_item->value.i ) ) );
1316 table->addTopLevelItem( treeItem );
1317 continue;
1320 if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
1321 && strstr( p_item->psz_name , "global-key" )
1322 && !EMPTY_STR( p_item->psz_text ) )
1324 QList<QTreeWidgetItem *> list =
1325 table->findItems( qtr( p_item->psz_text ), Qt::MatchExactly );
1326 if( list.count() >= 1 )
1328 list[0]->setText( 2, VLCKeyToString( p_item->value.i ) );
1329 list[0]->setData( 2, Qt::UserRole,
1330 QVariant( qlonglong( p_item->value.i ) ) );
1332 if( list.count() >= 2 )
1333 msg_Dbg( p_this, "This is probably wrong, %s", p_item->psz_text );
1336 module_config_free (p_config);
1337 module_release (p_main);
1339 table->resizeColumnToContents( 0 );
1341 CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ),
1342 this, selectKey( QTreeWidgetItem *, int ) );
1343 CONNECT( table, itemClicked( QTreeWidgetItem *, int ),
1344 this, select( QTreeWidgetItem *, int) );
1345 CONNECT( table, itemSelectionChanged(),
1346 this, select1Key() );
1348 CONNECT( shortcutValue, pressed(), this, selectKey() );
1351 void KeySelectorControl::filter( const QString &qs_search )
1353 QList<QTreeWidgetItem *> resultList =
1354 table->findItems( qs_search, Qt::MatchContains, 0 );
1355 for( int i = 0; i < table->topLevelItemCount(); i++ )
1357 table->topLevelItem( i )->setHidden(
1358 !resultList.contains( table->topLevelItem( i ) ) );
1362 void KeySelectorControl::select( QTreeWidgetItem *keyItem, int column )
1364 shortcutValue->setGlobal( column == 2 );
1367 /* Show the key selected from the table in the keySelector */
1368 void KeySelectorControl::select1Key()
1370 QTreeWidgetItem *keyItem = table->currentItem();
1371 shortcutValue->setText( keyItem->text( 1 ) );
1372 shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toInt() );
1373 shortcutValue->setGlobal( false );
1376 void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
1378 /* This happens when triggered by ClickEater */
1379 if( keyItem == NULL ) keyItem = table->currentItem();
1381 /* This can happen when nothing is selected on the treeView
1382 and the shortcutValue is clicked */
1383 if( !keyItem ) return;
1385 /* If clicked on the first column, assuming user wants the normal hotkey */
1386 if( column == 0 ) column = 1;
1388 bool b_global = ( column == 2 );
1390 /* Launch a small dialog to ask for a new key */
1391 KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget, b_global );
1392 d->exec();
1394 if( d->result() == QDialog::Accepted )
1396 int newValue = d->keyValue;
1397 shortcutValue->setText( VLCKeyToString( newValue ) );
1398 shortcutValue->setValue( newValue );
1399 shortcutValue->setGlobal( b_global );
1401 if( d->conflicts )
1403 QTreeWidgetItem *it;
1404 for( int i = 0; i < table->topLevelItemCount() ; i++ )
1406 it = table->topLevelItem(i);
1407 if( ( keyItem != it ) &&
1408 ( it->data( b_global ? 2: 1, Qt::UserRole ).toInt() == newValue ) )
1410 it->setData( b_global ? 2 : 1, Qt::UserRole, QVariant( -1 ) );
1411 it->setText( b_global ? 2 : 1, qtr( "Unset" ) );
1414 /* We already made an OK once. */
1415 setTheKey();
1418 delete d;
1421 void KeySelectorControl::setTheKey()
1423 if( !table->currentItem() ) return;
1424 table->currentItem()->setText( shortcutValue->getGlobal() ? 2 : 1,
1425 shortcutValue->text() );
1426 table->currentItem()->setData( shortcutValue->getGlobal() ? 2 : 1,
1427 Qt::UserRole, shortcutValue->getValue() );
1430 void KeySelectorControl::doApply()
1432 QTreeWidgetItem *it;
1433 for( int i = 0; i < table->topLevelItemCount() ; i++ )
1435 it = table->topLevelItem(i);
1436 if( it->data( 1, Qt::UserRole ).toInt() >= 0 )
1437 config_PutInt( p_this,
1438 qtu( it->data( 0, Qt::UserRole ).toString() ),
1439 it->data( 1, Qt::UserRole ).toInt() );
1440 if( it->data( 2, Qt::UserRole ).toInt() >= 0 )
1441 config_PutInt( p_this,
1442 qtu( "global-" + it->data( 0, Qt::UserRole ).toString() ),
1443 it->data( 2, Qt::UserRole ).toInt() );
1449 * Class KeyInputDialog
1451 KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
1452 const QString& keyToChange,
1453 QWidget *_parent,
1454 bool _b_global ) :
1455 QDialog( _parent ), keyValue(0), b_global( _b_global )
1457 setModal( true );
1458 conflicts = false;
1460 table = _table;
1461 setWindowTitle( b_global ? qtr( "Global" ): ""
1462 + qtr( "Hotkey for " ) + keyToChange );
1463 setWindowRole( "vlc-key-input" );
1465 vLayout = new QVBoxLayout( this );
1466 selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange );
1467 vLayout->addWidget( selected , Qt::AlignCenter );
1469 warning = new QLabel;
1470 warning->hide();
1471 vLayout->insertWidget( 1, warning );
1473 buttonBox = new QDialogButtonBox;
1474 QPushButton *ok = new QPushButton( qtr("OK") );
1475 QPushButton *cancel = new QPushButton( qtr("Cancel") );
1476 buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
1477 buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
1478 ok->setDefault( true );
1480 vLayout->addWidget( buttonBox );
1481 buttonBox->hide();
1483 CONNECT( buttonBox, accepted(), this, accept() );
1484 CONNECT( buttonBox, rejected(), this, reject() );
1487 void KeyInputDialog::checkForConflicts( int i_vlckey )
1489 QList<QTreeWidgetItem *> conflictList =
1490 table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly,
1491 b_global ? 2 : 1 );
1493 if( conflictList.size() &&
1494 conflictList[0]->data( b_global ? 2 : 1, Qt::UserRole ).toInt() > 1 )
1495 /* Avoid 0 or -1 that are the "Unset" states */
1497 warning->setText( qtr("Warning: the key is already assigned to \"") +
1498 conflictList[0]->text( 0 ) + "\"" );
1499 warning->show();
1500 buttonBox->show();
1502 conflicts = true;
1504 else accept();
1507 void KeyInputDialog::keyPressEvent( QKeyEvent *e )
1509 if( e->key() == Qt::Key_Tab ||
1510 e->key() == Qt::Key_Shift ||
1511 e->key() == Qt::Key_Control ||
1512 e->key() == Qt::Key_Meta ||
1513 e->key() == Qt::Key_Alt ||
1514 e->key() == Qt::Key_AltGr )
1515 return;
1516 int i_vlck = qtEventToVLCKey( e );
1517 selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1518 checkForConflicts( i_vlck );
1519 keyValue = i_vlck;
1522 void KeyInputDialog::wheelEvent( QWheelEvent *e )
1524 int i_vlck = qtWheelEventToVLCKey( e );
1525 selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
1526 checkForConflicts( i_vlck );
1527 keyValue = i_vlck;
1530 void KeyShortcutEdit::mousePressEvent( QMouseEvent *)
1532 emit pressed();