Commit 4c90cbe8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: update hotkey prefs to string items

This commit does not add support for multiples hotkeys though.
parent d4ab9ebe
...@@ -1296,39 +1296,39 @@ void KeySelectorControl::finish() ...@@ -1296,39 +1296,39 @@ void KeySelectorControl::finish()
module_config_t *p_item = p_config + i; module_config_t *p_item = p_config + i;
/* If we are a (non-global) key option not empty */ /* If we are a (non-global) key option not empty */
if( ((p_item->i_type & CONFIG_ITEM) == CONFIG_ITEM_KEY) && if( (p_item->i_type & CONFIG_ITEM) && p_item->psz_name != NULL
p_item->psz_name != NULL && && !strncmp( p_item->psz_name , "key-", 4 )
strncmp( p_item->psz_name , "global-", 7 ) && && !EMPTY_STR( p_item->psz_text ) )
!EMPTY_STR( p_item->psz_text ) )
{ {
/* /*
Each tree item has: Each tree item has:
- QString text in column 0 - QString text in column 0
- QString name in data of column 0 - QString name in data of column 0
- KeyValue in String in column 1 - KeyValue in String in column 1
- KeyValue in int64_t in column 1
*/ */
QTreeWidgetItem *treeItem = new QTreeWidgetItem(); QTreeWidgetItem *treeItem = new QTreeWidgetItem();
treeItem->setText( 0, qtr( p_item->psz_text ) ); treeItem->setText( 0, qtr( p_item->psz_text ) );
treeItem->setData( 0, Qt::UserRole, treeItem->setData( 0, Qt::UserRole,
QVariant( qfu( p_item->psz_name ) ) ); QVariant( qfu( p_item->psz_name ) ) );
treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
treeItem->setData( 1, Qt::UserRole, QVariant( qlonglong( p_item->value.i ) ) ); QString keys = qfu( p_item->value.psz );
treeItem->setText( 1, keys );
treeItem->setData( 1, Qt::UserRole, QVariant( keys ) );
table->addTopLevelItem( treeItem ); table->addTopLevelItem( treeItem );
continue; continue;
} }
if( p_item->i_type & CONFIG_ITEM && p_item->psz_name if( (p_item->i_type & CONFIG_ITEM) && p_item->psz_name != NULL
&& strstr( p_item->psz_name , "global-key" ) && !strncmp( p_item->psz_name , "global-key", 10 )
&& !EMPTY_STR( p_item->psz_text ) ) && !EMPTY_STR( p_item->psz_text ) )
{ {
QList<QTreeWidgetItem *> list = QList<QTreeWidgetItem *> list =
table->findItems( qtr( p_item->psz_text ), Qt::MatchExactly ); 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 ) ); QString keys = qfu( p_item->value.psz );
list[0]->setData( 2, Qt::UserRole, list[0]->setText( 2, keys );
QVariant( qlonglong( p_item->value.i ) ) ); list[0]->setData( 2, Qt::UserRole, keys );
} }
if( list.count() >= 2 ) if( list.count() >= 2 )
msg_Dbg( p_this, "This is probably wrong, %s", p_item->psz_text ); msg_Dbg( p_this, "This is probably wrong, %s", p_item->psz_text );
...@@ -1370,7 +1370,7 @@ void KeySelectorControl::select1Key() ...@@ -1370,7 +1370,7 @@ void KeySelectorControl::select1Key()
{ {
QTreeWidgetItem *keyItem = table->currentItem(); QTreeWidgetItem *keyItem = table->currentItem();
shortcutValue->setText( keyItem->text( 1 ) ); shortcutValue->setText( keyItem->text( 1 ) );
shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toInt() ); shortcutValue->setValue( keyItem->data( 1, Qt::UserRole ).toString() );
shortcutValue->setGlobal( false ); shortcutValue->setGlobal( false );
} }
...@@ -1394,9 +1394,9 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column ) ...@@ -1394,9 +1394,9 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
if( d->result() == QDialog::Accepted ) if( d->result() == QDialog::Accepted )
{ {
int newValue = d->keyValue; QString newKey = VLCKeyToString( d->keyValue );
shortcutValue->setText( VLCKeyToString( newValue ) ); shortcutValue->setText( newKey );
shortcutValue->setValue( newValue ); shortcutValue->setValue( newKey );
shortcutValue->setGlobal( b_global ); shortcutValue->setGlobal( b_global );
if( d->conflicts ) if( d->conflicts )
...@@ -1406,10 +1406,11 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column ) ...@@ -1406,10 +1406,11 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
{ {
it = table->topLevelItem(i); it = table->topLevelItem(i);
if( ( keyItem != it ) && if( ( keyItem != it ) &&
( it->data( b_global ? 2: 1, Qt::UserRole ).toInt() == newValue ) ) ( it->data( 1 + b_global, Qt::UserRole ).toString() == newKey ) )
{ {
it->setData( b_global ? 2 : 1, Qt::UserRole, QVariant( -1 ) ); it->setData( 1 + b_global, Qt::UserRole,
it->setText( b_global ? 2 : 1, qtr( "Unset" ) ); QVariant( qfu( "Unset" ) ) );
it->setText( 1 + b_global, qtr( "Unset" ) );
} }
} }
/* We already made an OK once. */ /* We already made an OK once. */
...@@ -1435,13 +1436,13 @@ void KeySelectorControl::doApply() ...@@ -1435,13 +1436,13 @@ void KeySelectorControl::doApply()
{ {
it = table->topLevelItem(i); it = table->topLevelItem(i);
if( it->data( 1, Qt::UserRole ).toInt() >= 0 ) if( it->data( 1, Qt::UserRole ).toInt() >= 0 )
config_PutInt( p_this, config_PutPsz( p_this,
qtu( it->data( 0, Qt::UserRole ).toString() ), qtu( it->data( 0, Qt::UserRole ).toString() ),
it->data( 1, Qt::UserRole ).toInt() ); qtu( it->data( 1, Qt::UserRole ).toString() ) );
if( it->data( 2, Qt::UserRole ).toInt() >= 0 ) if( it->data( 2, Qt::UserRole ).toInt() >= 0 )
config_PutInt( p_this, config_PutPsz( p_this,
qtu( "global-" + it->data( 0, Qt::UserRole ).toString() ), qtu( "global-" + it->data( 0, Qt::UserRole ).toString() ),
it->data( 2, Qt::UserRole ).toInt() ); qtu( it->data( 2, Qt::UserRole ).toString() ) );
} }
} }
......
...@@ -446,15 +446,15 @@ class KeyShortcutEdit: public QLineEdit ...@@ -446,15 +446,15 @@ class KeyShortcutEdit: public QLineEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
void setValue( int _value ){ value = _value; } void setValue( const QString& value ){ this->value = value; }
int getValue() const { return value; } QString getValue() const { return value; }
void setGlobal( bool _value ) { b_global = _value; } void setGlobal( bool _value ) { b_global = _value; }
bool getGlobal() const { return b_global; } bool getGlobal() const { return b_global; }
public slots: public slots:
virtual void clear(void) { value = 0; QLineEdit::clear(); } virtual void clear(void) { value = qfu(""); QLineEdit::clear(); }
private: private:
int value; QString value;
bool b_global; bool b_global;
virtual void mousePressEvent( QMouseEvent *event ); virtual void mousePressEvent( QMouseEvent *event );
signals: signals:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment