Allows the user to close the get key dialog without it overwriting their
current set button. git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@129 c05e91a0-76c8-4ec0-b377-ef19ce7cc080
This commit is contained in:
committed by
virtuoussin13
parent
6e0954ea38
commit
79874c14cf
@ -29,7 +29,6 @@ bool GetKey::x11Event( XEvent* e )
|
|||||||
{
|
{
|
||||||
//keep Qt from closing the dialog upon seeing Esc pressed.
|
//keep Qt from closing the dialog upon seeing Esc pressed.
|
||||||
if (e->type == KeyPress) return true;
|
if (e->type == KeyPress) return true;
|
||||||
|
|
||||||
//On a key press, return the key and quit
|
//On a key press, return the key and quit
|
||||||
//Ctrl+X == [No Key]
|
//Ctrl+X == [No Key]
|
||||||
if (e->type == KeyRelease) {
|
if (e->type == KeyRelease) {
|
||||||
@ -51,6 +50,11 @@ bool GetKey::x11Event( XEvent* e )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetKey::closeEvent(QCloseEvent *e) {
|
||||||
|
e->ignore();
|
||||||
|
done(-1);
|
||||||
|
}
|
||||||
|
|
||||||
void GetKey::paintEvent ( QPaintEvent * ) {
|
void GetKey::paintEvent ( QPaintEvent * ) {
|
||||||
//whenever we need to repaint, draw in our text.
|
//whenever we need to repaint, draw in our text.
|
||||||
QPainter paint( this );
|
QPainter paint( this );
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QCloseEvent>
|
||||||
#include "constant.h"
|
#include "constant.h"
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
//The KeySym for "x"
|
//The KeySym for "x"
|
||||||
@ -20,6 +21,7 @@ class GetKey : public QDialog {
|
|||||||
//to avoid focus issues, there is only the dialog widget, all the
|
//to avoid focus issues, there is only the dialog widget, all the
|
||||||
//rest is painted on. So, I need to know when to repaint.
|
//rest is painted on. So, I need to know when to repaint.
|
||||||
void paintEvent ( QPaintEvent * );
|
void paintEvent ( QPaintEvent * );
|
||||||
|
void closeEvent (QCloseEvent *);
|
||||||
private:
|
private:
|
||||||
//the dialog's message
|
//the dialog's message
|
||||||
QString Text;
|
QString Text;
|
||||||
|
@ -89,7 +89,14 @@ KeyButton::KeyButton( QString name, int val, QWidget* parent, bool m, bool nowMo
|
|||||||
|
|
||||||
void KeyButton::onClick() {
|
void KeyButton::onClick() {
|
||||||
//when clicked, ask for a key!
|
//when clicked, ask for a key!
|
||||||
value = GetKey( buttonname, mouse ).exec();
|
int retValue = GetKey( buttonname, mouse ).exec();
|
||||||
|
// -1 is a special value meaning that the window was simply
|
||||||
|
// closed so we can ignore this
|
||||||
|
if(retValue == -1) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
value = retValue;
|
||||||
|
}
|
||||||
//if the return value was a mouse click...
|
//if the return value was a mouse click...
|
||||||
if (value > MOUSE_OFFSET) {
|
if (value > MOUSE_OFFSET) {
|
||||||
mouseClicked = true;
|
mouseClicked = true;
|
||||||
|
Reference in New Issue
Block a user