Changeset 3e8d0beb2925c3b2cf6eaa1a45186d5094c40569
- Timestamp:
- 11/06/07 00:01:15
(10 months ago)
- Author:
- Jean-Baptiste Kempf <jb@videolan.org>
- git-committer:
- Jean-Baptiste Kempf <jb@videolan.org> 1194303675 +0000
- git-parent:
[d5107810595354bd93f6bf65713c039d1bc7cb8b]
- git-author:
- Jean-Baptiste Kempf <jb@videolan.org> 1194303675 +0000
- Message:
Qt4 - Improve the hotkeys preferences.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2088806 |
r3e8d0be |
|
| 979 | 979 | QWidget *keyContainer = new QWidget; |
|---|
| 980 | 980 | QGridLayout *gLayout = new QGridLayout( keyContainer ); |
|---|
| | 981 | |
|---|
| | 982 | label = new QLabel( |
|---|
| | 983 | qtr( "Select an action to change the associated hotkey") ); |
|---|
| 981 | 984 | |
|---|
| 982 | | label = new QLabel( qtr("Select an action to change the associated hotkey") ); |
|---|
| | 985 | /* Deactivated for now |
|---|
| 983 | 986 | QLabel *searchLabel = new QLabel( qtr( "Search" ) ); |
|---|
| | 987 | QLineEdit *actionSearch = new QLineEdit;*/ |
|---|
| 984 | 988 | |
|---|
| 985 | 989 | table = new QTreeWidget; |
|---|
| … | … | |
| 987 | 991 | table->headerItem()->setText( 0, qtr( "Action" ) ); |
|---|
| 988 | 992 | table->headerItem()->setText( 1, qtr( "Shortcut" ) ); |
|---|
| 989 | | |
|---|
| 990 | | QLineEdit *shortcutValue = new QLineEdit; |
|---|
| | 993 | |
|---|
| | 994 | shortcutValue = new KeyShortcutEdit; |
|---|
| 991 | 995 | shortcutValue->setReadOnly(true); |
|---|
| 992 | | QLineEdit *actionSearch = new QLineEdit; |
|---|
| 993 | | |
|---|
| | 996 | |
|---|
| 994 | 997 | QPushButton *clearButton = new QPushButton( qtr( "Clear" ) ); |
|---|
| 995 | 998 | QPushButton *setButton = new QPushButton( qtr( "Set" ) ); |
|---|
| 996 | 999 | finish(); |
|---|
| 997 | | |
|---|
| | 1000 | |
|---|
| 998 | 1001 | gLayout->addWidget( label, 0, 0, 1, 4 ); |
|---|
| | 1002 | /* deactivated for now |
|---|
| 999 | 1003 | gLayout->addWidget( searchLabel, 1, 0, 1, 2 ); |
|---|
| 1000 | | gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); |
|---|
| | 1004 | gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */ |
|---|
| 1001 | 1005 | gLayout->addWidget( table, 2, 0, 1, 4 ); |
|---|
| 1002 | 1006 | gLayout->addWidget( clearButton, 3, 0, 1, 1 ); |
|---|
| 1003 | 1007 | gLayout->addWidget( shortcutValue, 3, 1, 1, 2 ); |
|---|
| 1004 | 1008 | gLayout->addWidget( setButton, 3, 3, 1, 1 ); |
|---|
| 1005 | | |
|---|
| | 1009 | |
|---|
| 1006 | 1010 | if( !l ) /* This shouldn't happen */ |
|---|
| 1007 | 1011 | { |
|---|
| … | … | |
| 1014 | 1018 | l->addWidget( keyContainer, 0, 0, 1, 2 ); |
|---|
| 1015 | 1019 | } |
|---|
| | 1020 | CONNECT( clearButton, clicked(), shortcutValue, clear() ); |
|---|
| | 1021 | BUTTONACT( setButton, setTheKey() ); |
|---|
| 1016 | 1022 | } |
|---|
| 1017 | 1023 | |
|---|
| … | … | |
| 1046 | 1052 | table->resizeColumnToContents( 0 ); |
|---|
| 1047 | 1053 | |
|---|
| | 1054 | CONNECT( table, itemClicked( QTreeWidgetItem *, int ), |
|---|
| | 1055 | this, select1Key( QTreeWidgetItem * ) ); |
|---|
| 1048 | 1056 | CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ), |
|---|
| 1049 | 1057 | this, selectKey( QTreeWidgetItem * ) ); |
|---|
| | 1058 | CONNECT( shortcutValue, pressed(), this, selectKey() ); |
|---|
| | 1059 | } |
|---|
| | 1060 | |
|---|
| | 1061 | void KeySelectorControl::select1Key( QTreeWidgetItem *keyItem ) |
|---|
| | 1062 | { |
|---|
| | 1063 | shortcutValue->setText( keyItem->text( 1 ) ); |
|---|
| 1050 | 1064 | } |
|---|
| 1051 | 1065 | |
|---|
| 1052 | 1066 | void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem ) |
|---|
| 1053 | 1067 | { |
|---|
| 1054 | | module_config_t *p_keyItem = static_cast<module_config_t*> |
|---|
| | 1068 | /* This happens when triggered by ClickEater */ |
|---|
| | 1069 | if( keyItem == NULL ) keyItem = table->currentItem(); |
|---|
| | 1070 | |
|---|
| | 1071 | /* This can happen when nothing is selected on the treeView |
|---|
| | 1072 | and the shortcutValue is clicked */ |
|---|
| | 1073 | if( !keyItem ) return; |
|---|
| | 1074 | |
|---|
| | 1075 | module_config_t *p_keyItem = static_cast<module_config_t*> |
|---|
| 1055 | 1076 | (keyItem->data( 0, Qt::UserRole ).value<void*>()); |
|---|
| 1056 | 1077 | |
|---|
| 1057 | | KeyInputDialog *d = new KeyInputDialog( values, p_keyItem->psz_text ); |
|---|
| | 1078 | KeyInputDialog *d = new KeyInputDialog( values, p_keyItem->psz_text, widget ); |
|---|
| 1058 | 1079 | d->exec(); |
|---|
| 1059 | 1080 | if( d->result() == QDialog::Accepted ) |
|---|
| … | … | |
| 1069 | 1090 | if( p_keyItem != p_item && p_item->value.i == d->keyValue ) |
|---|
| 1070 | 1091 | p_item->value.i = 0; |
|---|
| 1071 | | it->setText( 1, VLCKeyToString( p_item->value.i ) ); |
|---|
| | 1092 | shortcutValue->setText( VLCKeyToString( p_item->value.i ) ); |
|---|
| 1072 | 1093 | } |
|---|
| 1073 | 1094 | } |
|---|
| 1074 | 1095 | else |
|---|
| 1075 | | keyItem->setText( 1, VLCKeyToString( p_keyItem->value.i ) ); |
|---|
| | 1096 | shortcutValue->setText( VLCKeyToString( p_keyItem->value.i ) ); |
|---|
| 1076 | 1097 | } |
|---|
| 1077 | 1098 | delete d; |
|---|
| 1078 | 1099 | } |
|---|
| 1079 | 1100 | |
|---|
| | 1101 | void KeySelectorControl::setTheKey() |
|---|
| | 1102 | { |
|---|
| | 1103 | table->currentItem()->setText( 1, shortcutValue->text() ); |
|---|
| | 1104 | } |
|---|
| | 1105 | |
|---|
| 1080 | 1106 | void KeySelectorControl::doApply() |
|---|
| 1081 | 1107 | { |
|---|
| … | … | |
| 1087 | 1113 | |
|---|
| 1088 | 1114 | KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values, |
|---|
| 1089 | | const char * _keyToChange ) : |
|---|
| 1090 | | QDialog(0), keyValue(0) |
|---|
| | 1115 | const char * _keyToChange, |
|---|
| | 1116 | QWidget *_parent ) : |
|---|
| | 1117 | QDialog( _parent ), keyValue(0) |
|---|
| 1091 | 1118 | { |
|---|
| 1092 | 1119 | setModal( true ); |
|---|
| … | … | |
| 1152 | 1179 | keyValue = i_vlck; |
|---|
| 1153 | 1180 | } |
|---|
| | 1181 | |
|---|
| | 1182 | void KeyShortcutEdit::mousePressEvent( QMouseEvent *) |
|---|
| | 1183 | { |
|---|
| | 1184 | emit pressed(); |
|---|
| | 1185 | } |
|---|
| rcacd39b |
r3e8d0be |
|
| 413 | 413 | { |
|---|
| 414 | 414 | public: |
|---|
| 415 | | KeyInputDialog( QList<module_config_t *> &, const char * ); |
|---|
| | 415 | KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * ); |
|---|
| 416 | 416 | int keyValue; |
|---|
| 417 | 417 | bool conflicts; |
|---|
| … | … | |
| 426 | 426 | }; |
|---|
| 427 | 427 | |
|---|
| | 428 | class KeyShortcutEdit: public QLineEdit |
|---|
| | 429 | { |
|---|
| | 430 | Q_OBJECT |
|---|
| | 431 | private: |
|---|
| | 432 | virtual void mousePressEvent( QMouseEvent *event ); |
|---|
| | 433 | signals: |
|---|
| | 434 | void pressed(); |
|---|
| | 435 | }; |
|---|
| | 436 | |
|---|
| 428 | 437 | class KeySelectorControl : public ConfigControl |
|---|
| 429 | 438 | { |
|---|
| … | … | |
| 441 | 450 | QLabel *label; |
|---|
| 442 | 451 | QTreeWidget *table; |
|---|
| | 452 | KeyShortcutEdit *shortcutValue; |
|---|
| 443 | 453 | QList<module_config_t *> values; |
|---|
| | 454 | //QWidget *parent; |
|---|
| 444 | 455 | private slots: |
|---|
| 445 | | void selectKey( QTreeWidgetItem *); |
|---|
| | 456 | void setTheKey(); |
|---|
| | 457 | void selectKey( QTreeWidgetItem * = NULL ); |
|---|
| | 458 | void select1Key( QTreeWidgetItem *); |
|---|
| 446 | 459 | }; |
|---|
| 447 | 460 | |
|---|