MCPcopy Create free account
hub / github.com/clementgallet/libTAS / keyPressEvent

Method keyPressEvent

src/program/ui/InputEditorView.cpp:544–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544void InputEditorView::keyPressEvent(QKeyEvent *event)
545{
546 /* Check for the Home and End keys */
547 if ((event->key() == Qt::Key_End) && (event->modifiers() == Qt::NoModifier)) {
548 /* Select the last frame */
549 QModelIndex newSel = inputEditorModel->index(inputEditorModel->rowCount()-1, 0);
550 selectionModel()->clear();
551 setCurrentIndex(newSel);
552 selectionModel()->select(newSel, QItemSelectionModel::Select | QItemSelectionModel::Rows);
553 event->accept();
554 }
555 else if ((event->key() == Qt::Key_Home) && (event->modifiers() == Qt::NoModifier)) {
556 /* Select the first frame */
557 QModelIndex newSel = inputEditorModel->index(0, 0);
558 selectionModel()->clear();
559 setCurrentIndex(newSel);
560 selectionModel()->select(newSel, QItemSelectionModel::Select | QItemSelectionModel::Rows);
561 event->accept();
562 }
563
564 /* Ignore auto-repeat events for hotkeys */
565 if (event->isAutoRepeat())
566 return QTableView::keyPressEvent(event);
567
568 /* We accept hotkeys when this window has focus */
569 keysym_t mod = convertQtModifiers(event->modifiers());
570 keysym_t ks = context->config.km->nativeToKeysym(event->nativeVirtualKey());
571
572 /* Special case for <tab> key where event->nativeVirtualKey() returns 0 */
573 if (event->key() == Qt::Key_Tab)
574 ks = 0xff09; /* XK_Tab */
575
576 if (context->config.km->hotkey_mapping.find(ks | mod) != context->config.km->hotkey_mapping.end()) {
577 HotKey hk = context->config.km->hotkey_mapping[ks | mod];
578 context->hotkey_pressed_queue.push(hk.type);
579 return;
580 }
581 if (context->config.km->hotkey_mapping.find(ks) != context->config.km->hotkey_mapping.end()) {
582 HotKey hk = context->config.km->hotkey_mapping[ks];
583 context->hotkey_pressed_queue.push(hk.type);
584 return;
585 }
586
587 return QTableView::keyPressEvent(event);
588}
589
590void InputEditorView::keyReleaseEvent(QKeyEvent *event)
591{

Callers

nothing calls this directly

Calls 9

convertQtModifiersFunction · 0.85
indexMethod · 0.80
selectMethod · 0.80
rowCountMethod · 0.45
clearMethod · 0.45
nativeToKeysymMethod · 0.45
findMethod · 0.45
endMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected