SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CommandKeyReceiver Class Reference

#include <commandkeyreceiver.h>

Inherits QObject.

Signals

void capturedKey (Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
 

Public Member Functions

 CommandKeyReceiver ()
 
void setRelease (bool release)
 
void setPass (bool release)
 

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event)
 

Private Member Functions

void keyEventHandler (QKeyEvent *e, Qt::Key &key, Qt::KeyboardModifiers &keyModifiers)
 
bool isComposeKey (Qt::Key key)
 

Private Attributes

bool m_release
 check release events More...
 
bool m_pass
 do not block events just tap them More...
 

Static Private Attributes

static const std::vector< Qt::Key > m_composeKeys = {Qt::Key_Shift, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Alt, Qt::Key_AltGr}
 

Detailed Description

Definition at line 27 of file commandkeyreceiver.h.

Constructor & Destructor Documentation

◆ CommandKeyReceiver()

CommandKeyReceiver::CommandKeyReceiver ( )

Definition at line 24 of file commandkeyreceiver.cpp.

24  :
25  m_release(false),
26  m_pass(true)
27 {
28 }
bool m_release
check release events
bool m_pass
do not block events just tap them

Member Function Documentation

◆ capturedKey

void CommandKeyReceiver::capturedKey ( Qt::Key  key,
Qt::KeyboardModifiers  keyModifiers,
bool  release 
)
signal

Referenced by eventFilter().

+ Here is the caller graph for this function:

◆ eventFilter()

bool CommandKeyReceiver::eventFilter ( QObject *  obj,
QEvent *  event 
)
protected

Definition at line 30 of file commandkeyreceiver.cpp.

References capturedKey(), isComposeKey(), keyEventHandler(), m_pass, and m_release.

31 {
32  if (event->type() == QEvent::KeyPress)
33  {
34  QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
35 
36  if ((!keyEvent->isAutoRepeat()) && (!isComposeKey(static_cast<Qt::Key>(keyEvent->key()))))
37  {
38 // qDebug("KeyReceiver::eventFilter: KeyPress");
39  Qt::Key key;
40  Qt::KeyboardModifiers keyModifiers;
41  keyEventHandler(keyEvent, key, keyModifiers);
42  emit capturedKey(key, keyModifiers, false);
43 
44  if (!m_pass) { // do not pass the event
45  return true;
46  }
47  }
48  }
49  else if (m_release && (event->type()==QEvent::KeyRelease))
50  {
51  QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
52 
53  if ((!keyEvent->isAutoRepeat()) && (!isComposeKey(static_cast<Qt::Key>(keyEvent->key()))))
54  {
55 // qDebug("KeyReceiver::eventFilter: KeyRelease");
56  Qt::Key key;
57  Qt::KeyboardModifiers keyModifiers;
58  keyEventHandler(keyEvent, key, keyModifiers);
59  emit capturedKey(key, keyModifiers, true);
60 
61  if (!m_pass) { // do not pass the event
62  return true;
63  }
64  }
65  }
66 
67  return QObject::eventFilter(obj, event); // pass the event on
68 }
bool m_release
check release events
void keyEventHandler(QKeyEvent *e, Qt::Key &key, Qt::KeyboardModifiers &keyModifiers)
bool m_pass
do not block events just tap them
void capturedKey(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
bool isComposeKey(Qt::Key key)
+ Here is the call graph for this function:

◆ isComposeKey()

bool CommandKeyReceiver::isComposeKey ( Qt::Key  key)
private

Definition at line 84 of file commandkeyreceiver.cpp.

References m_composeKeys.

Referenced by eventFilter().

85 {
86  auto it = std::find(m_composeKeys.begin(), m_composeKeys.end(), key);
87  return it != m_composeKeys.end();
88 }
static const std::vector< Qt::Key > m_composeKeys
+ Here is the caller graph for this function:

◆ keyEventHandler()

void CommandKeyReceiver::keyEventHandler ( QKeyEvent *  e,
Qt::Key &  key,
Qt::KeyboardModifiers &  keyModifiers 
)
private

Definition at line 70 of file commandkeyreceiver.cpp.

Referenced by eventFilter().

71 {
72  key = static_cast<Qt::Key>(e->key());
73 
74  if (e->modifiers())
75  {
76  keyModifiers = e->modifiers();
77  }
78  else
79  {
80  keyModifiers = Qt::NoModifier;
81  }
82 }
+ Here is the caller graph for this function:

◆ setPass()

void CommandKeyReceiver::setPass ( bool  release)
inline

Definition at line 34 of file commandkeyreceiver.h.

34 { m_release = release; }
bool m_release
check release events

◆ setRelease()

void CommandKeyReceiver::setRelease ( bool  release)
inline

Definition at line 33 of file commandkeyreceiver.h.

Referenced by CWKeyerGUI::commandKeyPressed(), CWKeyerGUI::CWKeyerGUI(), MainWindow::MainWindow(), and CWKeyerGUI::on_keyDashCapture_toggled().

33 { m_release = release; }
bool m_release
check release events
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_composeKeys

const std::vector< Qt::Key > CommandKeyReceiver::m_composeKeys = {Qt::Key_Shift, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Alt, Qt::Key_AltGr}
staticprivate

Definition at line 46 of file commandkeyreceiver.h.

Referenced by isComposeKey().

◆ m_pass

bool CommandKeyReceiver::m_pass
private

do not block events just tap them

Definition at line 41 of file commandkeyreceiver.h.

Referenced by eventFilter().

◆ m_release

bool CommandKeyReceiver::m_release
private

check release events

Definition at line 40 of file commandkeyreceiver.h.

Referenced by eventFilter().


The documentation for this class was generated from the following files: