p_control = new DirectoryConfigControl( p_this, p_item, parent, l,
line );
break;
-#if 0
case CONFIG_ITEM_FONT:
p_control = new FontConfigControl( p_this, p_item, parent, l,
- line, false );
+ line);
break;
-#endif
case CONFIG_ITEM_KEY:
p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
break;
}
}
+/*******************************************************
+ * Simple widgets
+ *******************************************************/
+InterfacePreviewWidget::InterfacePreviewWidget ( QWidget *parent ) : QLabel( parent )
+{
+ setGeometry( 0, 0, 128, 100 );
+ setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
+}
+
+void InterfacePreviewWidget::setPreview( int comboid )
+{
+ /* Need to move resources references as soon as qt4.cpp
+ local defines has been moved somewhere else
+ */
+ const char * pixmaps[] = { ":/prefsmenu/sample_classic",
+ ":/prefsmenu/sample_complete",
+ ":/prefsmenu/sample_minimal",
+ ":/prefsmenu/sample_skins" };
+ setPixmap( QPixmap( pixmaps[ comboid ] ) );
+}
+
+
+
/**************************************************************************
* String-based controls
*************************************************************************/
void FileConfigControl::updateField()
{
QString file = QFileDialog::getOpenFileName( NULL,
- qtr( "Select File" ), qfu( config_GetHomeDir() ) );
+ qtr( "Select File" ), QVLCUserDir( VLC_HOME_DIR ) );
if( file.isNull() ) return;
text->setText( toNativeSeparators( file ) );
}
QString dir = QFileDialog::getExistingDirectory( NULL,
qtr( "Select Directory" ),
text->text().isEmpty() ?
- qfu( config_GetHomeDir() ) : text->text(),
+ QVLCUserDir( VLC_HOME_DIR ) : text->text(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
if( dir.isNull() ) return;
text->setText( toNativeSepNoSlash( 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)
-{}
+ module_config_t *_p_item, QWidget *_parent,
+ QGridLayout *_p_layout, int& line) :
+ VStringConfigControl( _p_this, _p_item, _parent )
+{
+ label = new QLabel( qtr(p_item->psz_text) );
+ font = new QFontComboBox( _parent );
+ font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
+ if( !_p_layout )
+ {
+ QHBoxLayout *layout = new QHBoxLayout();
+ layout->addWidget( label, 0 );
+ layout->addWidget( font, 1 );
+ widget->setLayout( layout );
+ }
+ else
+ {
+ _p_layout->addWidget( label, line, 0 );
+ _p_layout->addWidget( font, line, 1, 1, -1 );
+ }
+}
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()
+ QFontComboBox *_p_font):
+ VStringConfigControl( _p_this, _p_item)
{
- bool ok;
- QFont font = QFontDialog::getFont( &ok, QFont( text->text() ), NULL );
- if( !ok ) return;
- text->setText( font.family() );
+ label = _p_label;
+ font = _p_font;
+ font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
}
-#endif
/********* String / choice list **********/
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label,
- QCheckBox *_checkbox,
+ QAbstractButton *_checkbox,
bool bycat ) :
VIntConfigControl( _p_this, _p_item )
{
void BoolConfigControl::finish()
{
- checkbox->setCheckState( p_item->value.i == true ? Qt::Checked
- : Qt::Unchecked );
+ checkbox->setChecked( p_item->value.i == true );
checkbox->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) );
}
int BoolConfigControl::getValue()
{
- return checkbox->checkState() == Qt::Checked ? true : false;
+ return checkbox->isChecked();
}
/**************************************************************************
{
QList<QTreeWidgetItem *> list =
table->findItems( qtr( p_item->psz_text ), Qt::MatchExactly );
- if( list.count() > 1 )
+ if( list.count() >= 1 )
{
list[0]->setText( 2, VLCKeyToString( p_item->value.i ) );
list[0]->setData( 2, Qt::UserRole,
QVariant( p_item->value.i ) );
}
+ if( list.count() >= 2 )
+ msg_Dbg( p_this, "This is probably wrong, %s", p_item->psz_text );
}
}
module_config_free (p_config);
table->resizeColumnToContents( 0 );
CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ),
- this, selectKey( QTreeWidgetItem * ) );
- CONNECT( table, itemSelectionChanged (),
+ this, selectKey( QTreeWidgetItem *, int ) );
+ CONNECT( table, itemSelectionChanged(),
this, select1Key() );
CONNECT( shortcutValue, pressed(), this, selectKey() );
QTreeWidgetItem *keyItem = table->currentItem();
shortcutValue->setText( keyItem->text( 1 ) );
shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toInt() );
+ shortcutValue->setGlobal( false );
}
-void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem )
+void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
{
/* This happens when triggered by ClickEater */
if( keyItem == NULL ) keyItem = table->currentItem();
and the shortcutValue is clicked */
if( !keyItem ) return;
+ /* If clicked on the first column, assuming user wants the normal hotkey */
+ if( column == 0 ) column = 1;
+
+ bool b_global = ( column == 2 );
+
/* Launch a small dialog to ask for a new key */
- KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget );
+ KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget, b_global );
d->exec();
if( d->result() == QDialog::Accepted )
int newValue = d->keyValue;
shortcutValue->setText( VLCKeyToString( newValue ) );
shortcutValue->setValue( newValue );
+ shortcutValue->setGlobal( b_global );
if( d->conflicts )
{
for( int i = 0; i < table->topLevelItemCount() ; i++ )
{
it = table->topLevelItem(i);
- if( ( keyItem != it )
- && ( it->data( 1, Qt::UserRole ).toInt() == newValue ) )
+ if( ( keyItem != it ) &&
+ ( it->data( b_global ? 2: 1, Qt::UserRole ).toInt() == newValue ) )
{
- it->setData( 1, Qt::UserRole, QVariant( -1 ) );
- it->setText( 1, qtr( "Unset" ) );
+ it->setData( b_global ? 2 : 1, Qt::UserRole, QVariant( -1 ) );
+ it->setText( b_global ? 2 : 1, qtr( "Unset" ) );
}
}
/* We already made an OK once. */
void KeySelectorControl::setTheKey()
{
if( !table->currentItem() ) return;
- table->currentItem()->setText( 1, shortcutValue->text() );
- table->currentItem()->setData( 1, Qt::UserRole, shortcutValue->getValue() );
+ table->currentItem()->setText( shortcutValue->getGlobal() ? 2 : 1,
+ shortcutValue->text() );
+ table->currentItem()->setData( shortcutValue->getGlobal() ? 2 : 1,
+ Qt::UserRole, shortcutValue->getValue() );
}
void KeySelectorControl::doApply()
config_PutInt( p_this,
qtu( it->data( 0, Qt::UserRole ).toString() ),
it->data( 1, Qt::UserRole ).toInt() );
+ if( it->data( 2, Qt::UserRole ).toInt() >= 0 )
+ config_PutInt( p_this,
+ qtu( "global-" + it->data( 0, Qt::UserRole ).toString() ),
+ it->data( 2, Qt::UserRole ).toInt() );
+
}
}
+/**
+ * Class KeyInputDialog
+ **/
KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
const QString& keyToChange,
- QWidget *_parent ) :
- QDialog( _parent ), keyValue(0)
+ QWidget *_parent,
+ bool _b_global ) :
+ QDialog( _parent ), keyValue(0), b_global( _b_global )
{
setModal( true );
conflicts = false;
table = _table;
- setWindowTitle( qtr( "Hotkey for " ) + keyToChange );
+ setWindowTitle( b_global ? qtr( "Global" ): ""
+ + qtr( "Hotkey for " ) + keyToChange );
+ setWindowRole( "vlc-key-input" );
vLayout = new QVBoxLayout( this );
selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange );
void KeyInputDialog::checkForConflicts( int i_vlckey )
{
QList<QTreeWidgetItem *> conflictList =
- table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly, 1 );
+ table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly,
+ b_global ? 2 : 1 );
if( conflictList.size() &&
- conflictList[0]->data( 1, Qt::UserRole ).toInt() > 1 )
+ conflictList[0]->data( b_global ? 2 : 1, Qt::UserRole ).toInt() > 1 )
/* Avoid 0 or -1 that are the "Unset" states */
{
warning->setText( qtr("Warning: the key is already assigned to \"") +