MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / eventFilter

Method eventFilter

Src/Hook.cpp:123–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123bool CHook::eventFilter(QObject *watched, QEvent *event)
124{
125 if(QEvent::KeyPress == event->type() || QEvent::KeyRelease == event->type())
126 {
127 if(m_pParameterPlugin && m_pParameterPlugin->GetCaptureAllKeyboard()) {
128
129 bool bProcess = false;
130 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
131 int key = keyEvent->key();
132 switch (key) {
133 case Qt::Key_Meta:
134 case Qt::Key_Alt:
135 case Qt::Key_Super_L:
136 case Qt::Key_Super_R:
137 bProcess = true;
138 break;
139 default:
140 bProcess = false;
141 break;
142 }
143
144 CFrmViewer* focus = qobject_cast<CFrmViewer*>(QApplication::focusWidget());
145 qDebug(log) << "eventFilter:" << keyEvent
146 << watched << focus << bProcess;
147 if(focus) {
148 if(focus == watched) {
149 if(bProcess)
150 return false;
151 }
152
153 /*
154 QKeyEvent* ke = new QKeyEvent(
155 keyEvent->type(), keyEvent->key(),
156 keyEvent->modifiers(), keyEvent->text());
157 QApplication::postEvent(focus, ke);
158 return true;//*/
159 switch(keyEvent->type())
160 {
161 case QKeyEvent::KeyPress:
162 emit focus->sigKeyPressEvent(keyEvent);
163 break;
164 case QKeyEvent::KeyRelease:
165 emit focus->sigKeyReleaseEvent(keyEvent);
166 break;
167 default:
168 break;
169 }
170 return true;
171 }
172 }
173 }
174 return false;
175}
176
177bool CHook::RunCommand(const QString &program, const QStringList &args, int timeout)
178{

Callers

nothing calls this directly

Calls 1

GetCaptureAllKeyboardMethod · 0.80

Tested by

no test coverage detected