}
}
+/*******************************************************
+ * Simple widgets
+ *******************************************************/
+InterfacePreviewWidget::InterfacePreviewWidget
+ ( QWidget *parent ) : QLabel( parent, 0 )
+{
+ 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
+ */
+ char * pixmaps[] = { ":/prefsmenu/sample_classic",
+ ":/prefsmenu/sample_complete",
+ ":/prefsmenu/sample_minimal" };
+ setPixmap( QPixmap( pixmaps[ comboid ] ) );
+}
+
+
+
/**************************************************************************
* String-based controls
*************************************************************************/
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();
}
/**************************************************************************
label = new QLabel(
qtr( "Select an action to change the associated hotkey") );
- /* Deactivated for now
QLabel *searchLabel = new QLabel( qtr( "Search" ) );
- QLineEdit *actionSearch = new QLineEdit;*/
+ actionSearch = new SearchLineEdit( keyContainer );
table = new QTreeWidget;
table->setColumnCount(3);
finish();
gLayout->addWidget( label, 0, 0, 1, 4 );
- /* deactivated for now
gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
- gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */
+ gLayout->addWidget( actionSearch, 1, 2, 1, 2 );
gLayout->addWidget( table, 2, 0, 1, 4 );
gLayout->addWidget( clearButton, 3, 0, 1, 1 );
gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
CONNECT( clearButton, clicked(), shortcutValue, clear() );
CONNECT( clearButton, clicked(), this, setTheKey() );
BUTTONACT( setButton, setTheKey() );
+ CONNECT( actionSearch, textChanged( const QString& ),
+ this, filter( const QString& ) );
}
void KeySelectorControl::finish()
{
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() );
}
+void KeySelectorControl::filter( const QString &qs_search )
+{
+ QList<QTreeWidgetItem *> resultList =
+ table->findItems( qs_search, Qt::MatchContains, 0 );
+ for( int i = 0; i < table->topLevelItemCount(); i++ )
+ {
+ table->topLevelItem( i )->setHidden(
+ !resultList.contains( table->topLevelItem( i ) ) );
+ }
+}
+
/* Show the key selected from the table in the keySelector */
void KeySelectorControl::select1Key()
{
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 );
vLayout = new QVBoxLayout( this );
selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange );
vLayout->addWidget( selected , Qt::AlignCenter );
+ warning = new QLabel;
+ warning->hide();
+ vLayout->insertWidget( 1, warning );
+
buttonBox = new QDialogButtonBox;
QPushButton *ok = new QPushButton( qtr("OK") );
QPushButton *cancel = new QPushButton( qtr("Cancel") );
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() )
+ if( conflictList.size() &&
+ conflictList[0]->data( b_global ? 2 : 1, Qt::UserRole ).toInt() > 1 )
+ /* Avoid 0 or -1 that are the "Unset" states */
{
- QLabel *warning = new QLabel(
- qtr("Warning: the key is already assigned to \"") +
- conflictList[0]->text( 0 ) + "\"" );
- vLayout->insertWidget( 1, warning );
+ warning->setText( qtr("Warning: the key is already assigned to \"") +
+ conflictList[0]->text( 0 ) + "\"" );
+ warning->show();
buttonBox->show();
conflicts = true;