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 );
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 \"") +
**********************************************************************/
class KeyShortcutEdit: public QLineEdit
{
- Q_OBJECT
+ Q_OBJECT;
public:
void setValue( int _value ){ value = _value; }
int getValue() const { return value; }
+
+ void setGlobal( bool _value ) { b_global = _value; }
+ bool getGlobal() const { return b_global; }
public slots:
- virtual void clear(void) { value = 0; QLineEdit::clear(); }
+ virtual void clear(void) { value = 0; QLineEdit::clear(); b_global = false;}
private:
int value;
+ bool b_global;
virtual void mousePressEvent( QMouseEvent *event );
signals:
void pressed();
SearchLineEdit *actionSearch;
private slots:
void setTheKey();
- void selectKey( QTreeWidgetItem * = NULL );
+ void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
void select1Key();
void filter( const QString & );
};
class KeyInputDialog : public QDialog
{
public:
- KeyInputDialog( QTreeWidget *, const QString&, QWidget * );
+ KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
int keyValue;
bool conflicts;
private:
QLabel *selected, *warning;
QVBoxLayout *vLayout;
QDialogButtonBox *buttonBox;
+ bool b_global;
};
#endif