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
This commit is contained in:
John Toman
2009-12-15 02:22:27 +00:00
committed by virtuoussin13
parent 899b878dc8
commit 03f4297446
2 changed files with 22 additions and 18 deletions

View File

@ -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<int, JoyPad*> 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<int, JoyPad*> it( available );
while (it.hasNext())
{
debug_mesg("iterating and releasing\n");
it.next();
it.value()->release();
}
debug_mesg("done releasing!\n");
}
}

View File

@ -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;