]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/keygrabber.cpp
Hooked up the UI/frontend controller #2 to the Jaguar core, final fixes to the
[virtualjaguar] / src / gui / keygrabber.cpp
1 //
2 // keygrabber.cpp - Widget to grab a key and dismiss itself
3 //
4 // by James L. Hammons
5 // (C) 2011 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -------------------------------------------------------------
11 // JLH  07/18/2011  Created this file
12 //
13
14 #include "keygrabber.h"
15
16
17 KeyGrabber::KeyGrabber(QWidget * parent/*= 0*/): QDialog(parent)
18 {
19         label = new QLabel(this);
20         QVBoxLayout * mainLayout = new QVBoxLayout;
21         mainLayout->addWidget(label);
22         setLayout(mainLayout);
23         setWindowTitle(tr("Grab"));
24 }
25
26 KeyGrabber::~KeyGrabber()
27 {
28 }
29
30 //void KeyGrabber::SetText(QString keyText)
31 void KeyGrabber::SetKeyText(int keyNum)
32 {
33         char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
34                 "*", "7", "4", "1", "0", "8", "5", "2", "#", "9", "6", "3",
35                 "A", "B", "C", "Option", "Pause" };
36
37         QString text = QString(tr("Press key for \"%1\"<br>(ESC to cancel)"))
38                 .arg(QString(jagButtonName[keyNum]));
39         label->setText(text);
40 }
41
42 void KeyGrabber::keyPressEvent(QKeyEvent * e)
43 {
44         key = e->key();
45         accept();
46 }