MCPcopy Create free account
hub / github.com/KLayout/klayout / eventFilter

Method eventFilter

src/laybasic/laybasic/gtf.cc:1466–1641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1464*/
1465
1466bool
1467Recorder::eventFilter (QObject *object, QEvent *event)
1468{
1469 // do not handle events that are not targeted towards widgets
1470 QWidget *rec = dynamic_cast <QWidget *> (object);
1471 if (! rec) {
1472 return false;
1473 }
1474
1475 if (Player::instance () && Player::instance ()->playing ()) {
1476
1477 // handling in playing mode:
1478
1479 // suppress spontaneous input events in playing mode - the user may not interact
1480 if (! Player::instance ()->event_issued () && dynamic_cast <QInputEvent *> (event) != 0) {
1481 return true;
1482 }
1483
1484 // only log events issued by the player
1485 if (event->type () != QEvent::Resize &&
1486 (Player::instance ()->event_issued () != event || Player::instance ()->event_target () != object)) {
1487 return false;
1488 }
1489
1490 } else {
1491
1492 // only log key events that are targeted towards widgets that do not have the focus
1493 // this propagation of events is done automatically on replay in the same fashion.
1494 if (dynamic_cast <QKeyEvent *> (event) != 0 && ! rec->hasFocus ()) {
1495 return false;
1496 }
1497
1498 // do not log propagation events for mouse events
1499 if (dynamic_cast <QMouseEvent *> (event) != 0 && ! event->spontaneous ()) {
1500 return false;
1501 }
1502
1503 }
1504
1505 if (event->type() == QEvent::KeyPress || event->type () == QEvent::KeyRelease) {
1506
1507 QKeyEvent *keyEvent = dynamic_cast <QKeyEvent *> (event);
1508
1509 // Do not log Shift, Ctrl or Alt key events
1510 if (keyEvent &&
1511 keyEvent->key () != Qt::Key_Control &&
1512 keyEvent->key () != Qt::Key_Alt &&
1513 keyEvent->key () != Qt::Key_Shift &&
1514 is_valid_widget (rec)) {
1515 m_events.add (new LogKeyEvent (widget_to_path (rec), *keyEvent));
1516 if (m_save_incremental) {
1517 save ();
1518 }
1519 }
1520
1521 } else if (event->type() == QEvent::MouseButtonDblClick ||
1522 event->type() == QEvent::MouseButtonPress ||
1523 event->type() == QEvent::MouseButtonRelease) {

Callers

nothing calls this directly

Calls 15

is_valid_widgetFunction · 0.85
widget_to_pathFunction · 0.85
spontaneousMethod · 0.80
old_sizeMethod · 0.80
instanceFunction · 0.70
saveFunction · 0.70
to_stringFunction · 0.50
trFunction · 0.50
typeMethod · 0.45
keyMethod · 0.45
addMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected