From 03f4297446ec9b6ce88f49bcfe656ab59e05d3d3 Mon Sep 17 00:00:00 2001 From: John Toman Date: Tue, 15 Dec 2009 02:22:27 +0000 Subject: [PATCH] fixes up an error that occured when joypad events were not being passed when a dialog window that had the main configuration window as its parent was opened, removed dependence on an undocumented function git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@123 c05e91a0-76c8-4ec0-b377-ef19ce7cc080 --- src/layout_edit.cpp | 34 +++++++++++++++++++--------------- src/layout_edit.h | 6 +++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/layout_edit.cpp b/src/layout_edit.cpp index e7b5a93..8365104 100644 --- a/src/layout_edit.cpp +++ b/src/layout_edit.cpp @@ -48,7 +48,7 @@ LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) { { it.next(); names[i] = it.value()->getName(); - connect(this, SIGNAL(focusChange(bool)), it.value(), SLOT(focusChange(bool))); + connect(this, SIGNAL(focusStateChanged(bool)), it.value(), SLOT(focusChange(bool))); ++i; } } while (0); @@ -93,6 +93,8 @@ LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) { connect( quit, SIGNAL( clicked() ), qApp, SLOT(quit())); h->addWidget(quit); LMain->addLayout(h); + connect(qApp, SIGNAL(focusChanged ( QWidget * , QWidget * ) ), this, + SLOT(appFocusChanged(QWidget *, QWidget *))); this->show(); } @@ -157,21 +159,23 @@ void LayoutEdit::updateJoypadWidgets() { } while (0); } -void LayoutEdit::windowActivationChange( bool oldActive ) { - emit focusChange(oldActive); - if (oldActive) return; - //whenever the window becomes active, release all pressed buttons! This way - //you don't get any presses without releases to confuse things. - QHashIterator it( available ); - while (it.hasNext()) - { - debug_mesg("iterating and releasing\n"); - it.next(); - it.value()->release(); - } - debug_mesg("done releasing!\n"); -} void LayoutEdit::closeEvent(QCloseEvent *event) { lm->leWindowClosed(); event->accept(); } + +void LayoutEdit::appFocusChanged(QWidget *old, QWidget *now) { + if(now!=NULL && old==NULL) { + emit focusStateChanged(false); + } else if(old!=NULL && now==NULL) { + emit focusStateChanged(true); + QHashIterator it( available ); + while (it.hasNext()) + { + debug_mesg("iterating and releasing\n"); + it.next(); + it.value()->release(); + } + debug_mesg("done releasing!\n"); + } +} diff --git a/src/layout_edit.h b/src/layout_edit.h index adb9035..11c9309 100644 --- a/src/layout_edit.h +++ b/src/layout_edit.h @@ -25,13 +25,13 @@ class LayoutEdit : public QWidget { void updateLayoutList(); void updateJoypadWidgets(); signals: - void focusChange(bool); + void focusStateChanged(bool); + public slots: + void appFocusChanged(QWidget *old, QWidget *now); protected: //the layout manager this represents LayoutManager* lm; virtual void closeEvent(QCloseEvent *event); - //find out when the window is activated. - virtual void windowActivationChange( bool oldActive ); //parts of the dialog: QVBoxLayout *LMain; QStackedWidget *PadStack;