| 72 | } |
| 73 | |
| 74 | void HotkeyLineEdit::keyPressEvent(QKeyEvent* event) |
| 75 | { |
| 76 | int key = event->key(); // 获取按键编码 |
| 77 | Qt::KeyboardModifiers modifiers = event->modifiers(); |
| 78 | |
| 79 | if (key != Qt::Key_unknown && key != Qt::Key_Control && key != Qt::Key_Shift && |
| 80 | key != Qt::Key_Alt && key != Qt::Key_Meta) { |
| 81 | _key_sequence = QKeySequence(modifiers | key).toString(); |
| 82 | } else { |
| 83 | _key_sequence = QKeySequence(modifiers).toString(); |
| 84 | } |
| 85 | |
| 86 | setText(_key_sequence); |
| 87 | |
| 88 | _pressed_keys.insert(key); |
| 89 | |
| 90 | QLineEdit::keyPressEvent(event); |
| 91 | } |
| 92 | |
| 93 | void HotkeyLineEdit::keyReleaseEvent(QKeyEvent* event) |
| 94 | { |
nothing calls this directly
no outgoing calls
no test coverage detected