now uses the Qt native code for tray icons, the tray menu no longer hangs when the dialog is open, dialog updates as appropriate when tray is manipulated when the dialog is open, added in code for updating the dialog widgets when the backend changes
git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@112 c05e91a0-76c8-4ec0-b377-ef19ce7cc080
This commit is contained in:
committed by
virtuoussin13
parent
ea2be3b29b
commit
12cd906a46
@ -1,9 +1,9 @@
|
||||
#include "layout_edit.h"
|
||||
|
||||
//build the dialog
|
||||
LayoutEdit::LayoutEdit( LayoutManager* l ) {
|
||||
LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) {
|
||||
lm = l;
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle( NAME );
|
||||
setWindowIcon(QPixmap(ICON24));
|
||||
|
||||
@ -92,11 +92,12 @@ LayoutEdit::LayoutEdit( LayoutManager* l ) {
|
||||
connect( quit, SIGNAL( clicked() ), qApp, SLOT(quit()));
|
||||
h->addWidget(quit);
|
||||
LMain->addLayout(h);
|
||||
this->show();
|
||||
}
|
||||
|
||||
void LayoutEdit::setLayout(QString layout) {
|
||||
//change the text,
|
||||
CLayouts->setItemText(CLayouts->currentIndex(), layout);
|
||||
CLayouts->setCurrentIndex(lm->getLayoutNames().indexOf(layout));
|
||||
//update all the JoyPadWidgets.
|
||||
for (uint i = 0; i < available.count(); i++) {
|
||||
((JoyPadWidget*)PadStack->widget(i))->update();
|
||||
@ -111,6 +112,50 @@ void LayoutEdit::updateLayoutList() {
|
||||
CLayouts->setCurrentIndex(layouts.indexOf(lm->CurrentLayout));
|
||||
}
|
||||
|
||||
void LayoutEdit::updateJoypadWidgets() {
|
||||
int indexOfFlashRadio = LMain->indexOf(JoyButtons);
|
||||
FlashRadioArray *newJoyButtons;
|
||||
int padcount = available.count();
|
||||
QString names[padcount];
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
QHashIterator<int, JoyPad*> it( available );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
names[i] = it.value()->getName();
|
||||
++i;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
newJoyButtons = new FlashRadioArray(padcount, names, true, this );
|
||||
LMain->insertWidget(indexOfFlashRadio, newJoyButtons);
|
||||
LMain->removeWidget(JoyButtons);
|
||||
FlashRadioArray* oldJoyButtons = JoyButtons;
|
||||
JoyButtons = newJoyButtons;
|
||||
connect( JoyButtons, SIGNAL( changed( int ) ), PadStack, SLOT( setCurrentIndex( int )));
|
||||
oldJoyButtons->deleteLater();
|
||||
int numberOfJoypads = PadStack->count();
|
||||
for(int i = 0; i<numberOfJoypads; i++) {
|
||||
PadStack->removeWidget(PadStack->widget(0));
|
||||
}
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
QHashIterator<int, JoyPad*> it(available);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
//add a new JoyPadWidget to the stack
|
||||
PadStack->insertWidget( i,it.value()->widget(PadStack,i) );
|
||||
//every time it "flashes", flash the associated tab.
|
||||
connect( PadStack->widget(i), SIGNAL( flashed( int ) ), JoyButtons, SLOT( flash( int )));
|
||||
++i;
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void LayoutEdit::windowActivationChange( bool oldActive ) {
|
||||
if (oldActive) return;
|
||||
//whenever the window becomes active, release all pressed buttons! This way
|
||||
@ -124,3 +169,7 @@ void LayoutEdit::windowActivationChange( bool oldActive ) {
|
||||
}
|
||||
DEBUG("done releasing!\n");
|
||||
}
|
||||
void LayoutEdit::closeEvent(QCloseEvent *event) {
|
||||
lm->leWindowClosed();
|
||||
event->accept();
|
||||
}
|
||||
|
Reference in New Issue
Block a user