| 1053 | } |
| 1054 | |
| 1055 | bool QuickOpenLineEdit::eventFilter(QObject* obj, QEvent* e) |
| 1056 | { |
| 1057 | if (!m_widget) { |
| 1058 | return QLineEdit::eventFilter(obj, e); |
| 1059 | } |
| 1060 | |
| 1061 | switch (e->type()) { |
| 1062 | case QEvent::KeyPress: |
| 1063 | case QEvent::ShortcutOverride: |
| 1064 | if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) { |
| 1065 | deactivate(); |
| 1066 | e->accept(); |
| 1067 | return true; // eat event |
| 1068 | } |
| 1069 | break; |
| 1070 | case QEvent::WindowActivate: |
| 1071 | case QEvent::WindowDeactivate: |
| 1072 | QMetaObject::invokeMethod(this, "checkFocus", Qt::QueuedConnection); |
| 1073 | break; |
| 1074 | // handle bug 260657 - "Outline menu doesn't follow main window on its move" |
| 1075 | case QEvent::Move: { |
| 1076 | if (QWidget* widget = qobject_cast<QWidget*>(obj)) { |
| 1077 | // close the outline menu in case a parent widget moved |
| 1078 | if (widget->isAncestorOf(this)) { |
| 1079 | qCDebug(PLUGIN_QUICKOPEN) << "closing because of parent widget move"; |
| 1080 | deactivate(); |
| 1081 | } |
| 1082 | } |
| 1083 | break; |
| 1084 | } |
| 1085 | case QEvent::FocusIn: |
| 1086 | if (qobject_cast<QWidget*>(obj)) { |
| 1087 | auto* focusEvent = dynamic_cast<QFocusEvent*>(e); |
| 1088 | Q_ASSERT(focusEvent); |
| 1089 | //Eat the focus event, keep the focus |
| 1090 | qCDebug(PLUGIN_QUICKOPEN) << "focus change" << "inside this: " << insideThis(obj) << "this" << this << "obj" << obj; |
| 1091 | if (obj == this) { |
| 1092 | break; |
| 1093 | } |
| 1094 | |
| 1095 | qCDebug(PLUGIN_QUICKOPEN) << "reason" << focusEvent->reason(); |
| 1096 | if (focusEvent->reason() != Qt::MouseFocusReason && focusEvent->reason() != Qt::ActiveWindowFocusReason) { |
| 1097 | QMetaObject::invokeMethod(this, "checkFocus", Qt::QueuedConnection); |
| 1098 | break; |
| 1099 | } |
| 1100 | if (!insideThis(obj)) { |
| 1101 | deactivate(); |
| 1102 | } |
| 1103 | } else if (obj != this) { |
| 1104 | QMetaObject::invokeMethod(this, "checkFocus", Qt::QueuedConnection); |
| 1105 | } |
| 1106 | break; |
| 1107 | default: |
| 1108 | break; |
| 1109 | } |
| 1110 | |
| 1111 | return QLineEdit::eventFilter(obj, e); |
| 1112 | } |
nothing calls this directly
no test coverage detected