2 // keygrabber.cpp - Widget to grab a key and dismiss itself
5 // (C) 2011 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 07/18/2011 Created this file
14 #include "keygrabber.h"
17 KeyGrabber::KeyGrabber(QWidget * parent/*= 0*/): QDialog(parent)
19 label = new QLabel(this);
20 QVBoxLayout * mainLayout = new QVBoxLayout;
21 mainLayout->addWidget(label);
22 setLayout(mainLayout);
23 setWindowTitle(tr("Grab"));
25 // Will this make Mac OSX work???
26 setFocusPolicy(Qt::StrongFocus);
29 KeyGrabber::~KeyGrabber()
33 //void KeyGrabber::SetText(QString keyText)
34 void KeyGrabber::SetKeyText(int keyNum)
36 char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
37 "*", "7", "4", "1", "0", "8", "5", "2", "#", "9", "6", "3",
38 "A", "B", "C", "Option", "Pause" };
40 QString text = QString(tr("Press key for \"%1\"<br>(ESC to cancel)"))
41 .arg(QString(jagButtonName[keyNum]));
45 void KeyGrabber::keyPressEvent(QKeyEvent * e)
49 // Since this is problematic, we don't allow this key...
50 if (key != Qt::Key_Alt)