+/*********** File **************/
+FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item,
+ QWidget *_parent, QGridLayout *l,
+ int &line, bool pwd ) :
+ VStringConfigControl( _p_this, _p_item, _parent )
+{
+ label = new QLabel( qtr(p_item->psz_text) );
+ text = new QLineEdit( qfu(p_item->value.psz) );
+ browse = new QPushButton( qtr( "Browse..." ) );
+ QHBoxLayout *textAndButton = new QHBoxLayout();
+ textAndButton->setMargin( 0 );
+ textAndButton->addWidget( text, 2 );
+ textAndButton->addWidget( browse, 0 );
+
+ BUTTONACT( browse, updateField() );
+
+ finish();
+
+ if( !l )
+ {
+ QHBoxLayout *layout = new QHBoxLayout();
+ layout->addWidget( label, 0 );
+ layout->insertSpacing( 1, 10 );
+ layout->addLayout( textAndButton, LAST_COLUMN );
+ widget->setLayout( layout );
+ }
+ else
+ {
+ l->addWidget( label, line, 0 );
+ l->setColumnMinimumWidth( 1, 10 );
+ l->addLayout( textAndButton, line, LAST_COLUMN );
+ }
+}
+
+
+FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item,
+ QLabel *_label, QLineEdit *_text,
+ QPushButton *_button, bool pwd ):
+ VStringConfigControl( _p_this, _p_item )
+{
+ browse = _button;
+ text = _text;
+ label = _label;
+
+ BUTTONACT( browse, updateField() );
+
+ finish( );
+}
+
+void FileConfigControl::updateField()
+{
+ QString file = QFileDialog::getOpenFileName( NULL,
+ qtr( "Select File" ), qfu( config_GetHomeDir() ) );
+ if( file.isNull() ) return;
+ text->setText( file );
+}
+
+void FileConfigControl::finish()
+{
+ text->setText( qfu(p_item->value.psz) );
+ text->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
+ if( label )
+ label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
+}
+
+/********* String / Directory **********/
+DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item, QWidget *_p_widget,
+ QGridLayout *_p_layout, int& _int, bool _pwd ) :
+ FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd)
+{}
+
+DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item, QLabel *_p_label,
+ QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ):
+ FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
+{}
+
+void DirectoryConfigControl::updateField()
+{
+ QString dir = QFileDialog::getExistingDirectory( NULL,
+ qtr( "Select Directory" ),
+ text->text().isEmpty() ?
+ qfu( config_GetHomeDir() ) : text->text(),
+ QFileDialog::ShowDirsOnly |
+ QFileDialog::DontResolveSymlinks );
+ if( dir.isNull() ) return;
+ text->setText( dir );
+}
+
+#if 0
+#include <QFontDialog>
+
+/********* String / Font **********/
+FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item, QWidget *_p_widget,
+ QGridLayout *_p_layout, int& _int, bool _pwd ) :
+ FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int, _pwd)
+{}
+
+FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
+ module_config_t *_p_item, QLabel *_p_label,
+ QLineEdit *_p_line, QPushButton *_p_button, bool _pwd ):
+ FileConfigControl( _p_this, _p_item, _p_label, _p_line, _p_button, _pwd)
+{}
+
+void FontConfigControl::updateField()
+{
+ bool ok;
+ QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL );
+ if( !ok ) return;
+ text->setText( font.family() );
+}
+#endif
+