MythTV  master
mythmainwindowprivate.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QKeyEvent>
3 
4 // MythTV
6 
7 // Make keynum in QKeyEvent be equivalent to what's in QKeySequence
9 {
10  if (Event == nullptr)
11  return Qt::Key_unknown;
12 
13  int keynum = Event->key();
14 
15  if ((keynum != Qt::Key_Shift ) && (keynum !=Qt::Key_Control ) &&
16  (keynum != Qt::Key_Meta ) && (keynum !=Qt::Key_Alt ) &&
17  (keynum != Qt::Key_Super_L) && (keynum !=Qt::Key_Super_R ) &&
18  (keynum != Qt::Key_Hyper_L) && (keynum !=Qt::Key_Hyper_R ) &&
19  (keynum != Qt::Key_AltGr ) && (keynum !=Qt::Key_CapsLock ) &&
20  (keynum != Qt::Key_NumLock) && (keynum !=Qt::Key_ScrollLock ))
21  {
22  Qt::KeyboardModifiers modifiers;
23  // if modifiers have been pressed, rebuild keynum
24  if ((modifiers = Event->modifiers()) != Qt::NoModifier)
25  {
26  int modnum = Qt::NoModifier;
27  if (((modifiers & Qt::ShiftModifier) != 0U) &&
28  (keynum > 0x7f) &&
29  (keynum != Qt::Key_Backtab))
30  modnum |= Qt::SHIFT;
31  if ((modifiers & Qt::ControlModifier) != 0U)
32  modnum |= Qt::CTRL;
33  if ((modifiers & Qt::MetaModifier) != 0U)
34  modnum |= Qt::META;
35  if ((modifiers & Qt::AltModifier) != 0U)
36  modnum |= Qt::ALT;
37  return (keynum | modnum);
38  }
39  }
40 
41  return keynum;
42 }
mythmainwindowprivate.h
MythMainWindowPrivate::TranslateKeyNum
static int TranslateKeyNum(QKeyEvent *Event)
Definition: mythmainwindowprivate.cpp:8
Event
Event details.
Definition: zmdefines.h:26