diff --git a/src/drivers/Qt/AboutWindow.cpp b/src/drivers/Qt/AboutWindow.cpp index df28508d..3d6897e4 100644 --- a/src/drivers/Qt/AboutWindow.cpp +++ b/src/drivers/Qt/AboutWindow.cpp @@ -59,18 +59,19 @@ AboutWindow::AboutWindow(QWidget *parent) { int i; QVBoxLayout *mainLayout; - QHBoxLayout *hbox1; + QHBoxLayout *hbox1, *hbox; QPixmap pm(":fceux1.png"); QPixmap pm2; QLabel *lbl; QTextEdit *credits; + QPushButton *closeButton; char stmp[256]; pm2 = pm.scaled( 64, 64 ); setWindowTitle( tr("About fceuX") ); - resize( 512, 512 ); + resize( 512, 600 ); mainLayout = new QVBoxLayout(); @@ -162,7 +163,19 @@ AboutWindow::AboutWindow(QWidget *parent) mainLayout->addWidget( credits ); + closeButton = new QPushButton( tr("OK") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + setLayout( mainLayout ); + + closeButton->setFocus(); + closeButton->setDefault(true); } //---------------------------------------------------------------------------- AboutWindow::~AboutWindow(void) @@ -170,3 +183,18 @@ AboutWindow::~AboutWindow(void) } //---------------------------------------------------------------------------- +void AboutWindow::closeEvent(QCloseEvent *event) +{ + printf("About Window Close Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------------------------------- +void AboutWindow::closeWindow(void) +{ + //printf("Close Window\n"); + done(0); + deleteLater(); +} +//---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/AboutWindow.h b/src/drivers/Qt/AboutWindow.h index e8ebb10c..07241285 100644 --- a/src/drivers/Qt/AboutWindow.h +++ b/src/drivers/Qt/AboutWindow.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "Qt/main.h" @@ -27,9 +28,11 @@ class AboutWindow : public QDialog ~AboutWindow(void); protected: + void closeEvent(QCloseEvent *event); private: - private slots: + public slots: + void closeWindow(void); }; diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index 20329240..deb4b437 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -48,49 +48,50 @@ static GuiCheatsDialog_t *win = NULL; //---------------------------------------------------------------------------- void openCheatDialog(QWidget *parent) { - if ( win != NULL ) - { - return; - } - win = new GuiCheatsDialog_t(parent); - - win->show(); + if (win != NULL) + { + return; + } + win = new GuiCheatsDialog_t(parent); + + win->show(); } //---------------------------------------------------------------------------- void updateCheatDialog(void) { - if ( win == NULL ) - { - return; - } - win->showActiveCheatList( true ); + if (win == NULL) + { + return; + } + win->showActiveCheatList(true); } //---------------------------------------------------------------------------- GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) - : QDialog( parent, Qt::Window ) + : QDialog(parent, Qt::Window) { QHBoxLayout *mainLayout, *hbox, *hbox1; QVBoxLayout *vbox, *vbox1, *vbox2, *vbox3; QTreeWidgetItem *item; QLabel *lbl; QGroupBox *groupBox; + QPushButton *closeButton; QFrame *frame; font.setFamily("Courier New"); - font.setStyle( QFont::StyleNormal ); - font.setStyleHint( QFont::Monospace ); + font.setStyle(QFont::StyleNormal); + font.setStyleHint(QFont::Monospace); QFontMetrics fm(font); #if QT_VERSION > QT_VERSION_CHECK(5, 11, 0) - fontCharWidth = 2 * fm.horizontalAdvance(QLatin1Char('2')); + fontCharWidth = 2 * fm.horizontalAdvance(QLatin1Char('2')); #else - fontCharWidth = 2 * fm.width(QLatin1Char('2')); + fontCharWidth = 2 * fm.width(QLatin1Char('2')); #endif setWindowTitle("Cheat Search"); - pauseWhileActive = false; + pauseWhileActive = false; wasPausedByCheats = false; //resize( 512, 512 ); @@ -100,344 +101,351 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) //------------------------------------------------------- // Left Side Active Cheats Frame - actCheatFrame = new QGroupBox( tr("Active Cheats") ); + actCheatFrame = new QGroupBox(tr("Active Cheats")); vbox1 = new QVBoxLayout(); - mainLayout->addWidget( actCheatFrame ); - + mainLayout->addWidget(actCheatFrame); + actvCheatList = new QTreeWidget(); actvCheatList->setColumnCount(2); item = new QTreeWidgetItem(); - item->setFont( 0, font ); - item->setFont( 1, font ); - item->setText( 0, QString::fromStdString( "Code" ) ); - item->setText( 1, QString::fromStdString( "Name" ) ); - item->setTextAlignment( 0, Qt::AlignCenter); - item->setTextAlignment( 1, Qt::AlignCenter); + item->setFont(0, font); + item->setFont(1, font); + item->setText(0, QString::fromStdString("Code")); + item->setText(1, QString::fromStdString("Name")); + item->setTextAlignment(0, Qt::AlignCenter); + item->setTextAlignment(1, Qt::AlignCenter); - actvCheatList->setHeaderItem( item ); + actvCheatList->setHeaderItem(item); - actvCheatList->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); + actvCheatList->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - connect( actvCheatList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), - this, SLOT(actvCheatItemClicked( QTreeWidgetItem*, int)) ); + connect(actvCheatList, SIGNAL(itemClicked(QTreeWidgetItem *, int)), + this, SLOT(actvCheatItemClicked(QTreeWidgetItem *, int))); hbox = new QHBoxLayout(); - enaCheats = new QCheckBox( tr("Enable Cheats") ); - autoSave = new QCheckBox( tr("Auto Load / Save with Game") ); + enaCheats = new QCheckBox(tr("Enable Cheats")); + autoSave = new QCheckBox(tr("Auto Load / Save with Game")); - enaCheats->setChecked( !globalCheatDisabled ); - autoSave->setChecked( !disableAutoLSCheats ); + enaCheats->setChecked(!globalCheatDisabled); + autoSave->setChecked(!disableAutoLSCheats); - hbox->addWidget( enaCheats ); - hbox->addWidget( autoSave ); + hbox->addWidget(enaCheats); + hbox->addWidget(autoSave); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); - vbox1->addWidget( actvCheatList ); + vbox1->addWidget(actvCheatList); hbox = new QHBoxLayout(); - lbl = new QLabel( tr("Name:") ); + lbl = new QLabel(tr("Name:")); cheatNameEntry = new QLineEdit(); - cheatNameEntry->setFont( font ); + cheatNameEntry->setFont(font); //cheatNameEntry->setMaxLength(64); - hbox->addWidget( lbl ); - hbox->addWidget( cheatNameEntry ); + hbox->addWidget(lbl); + hbox->addWidget(cheatNameEntry); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); hbox = new QHBoxLayout(); - lbl = new QLabel( tr("Address:") ); + lbl = new QLabel(tr("Address:")); cheatAddrEntry = new QLineEdit(); cheatAddrEntry->setMaxLength(4); - cheatAddrEntry->setInputMask( ">HHHH;0" ); - cheatAddrEntry->setFont( font ); + cheatAddrEntry->setInputMask(">HHHH;0"); + cheatAddrEntry->setFont(font); cheatAddrEntry->setCursorPosition(0); cheatAddrEntry->setAlignment(Qt::AlignCenter); - cheatAddrEntry->setMaximumWidth( 5 * fontCharWidth ); + cheatAddrEntry->setMaximumWidth(5 * fontCharWidth); - hbox->addWidget( lbl ); - hbox->addWidget( cheatAddrEntry ); + hbox->addWidget(lbl); + hbox->addWidget(cheatAddrEntry); - lbl = new QLabel( tr("Value:") ); + lbl = new QLabel(tr("Value:")); cheatValEntry = new QLineEdit(); cheatValEntry->setMaxLength(2); - cheatValEntry->setInputMask( ">HH;0" ); - cheatValEntry->setFont( font ); + cheatValEntry->setInputMask(">HH;0"); + cheatValEntry->setFont(font); cheatValEntry->setCursorPosition(0); cheatValEntry->setAlignment(Qt::AlignCenter); - cheatValEntry->setMaximumWidth( 3 * fontCharWidth ); + cheatValEntry->setMaximumWidth(3 * fontCharWidth); - hbox->addWidget( lbl ); - hbox->addWidget( cheatValEntry ); + hbox->addWidget(lbl); + hbox->addWidget(cheatValEntry); - lbl = new QLabel( tr("Compare:") ); + lbl = new QLabel(tr("Compare:")); cheatCmpEntry = new QLineEdit(); cheatCmpEntry->setMaxLength(2); - cheatCmpEntry->setInputMask( ">HH;X" ); - cheatCmpEntry->setFont( font ); + cheatCmpEntry->setInputMask(">HH;X"); + cheatCmpEntry->setFont(font); cheatCmpEntry->setCursorPosition(0); cheatCmpEntry->setAlignment(Qt::AlignCenter); - cheatCmpEntry->setMaximumWidth( 3 * fontCharWidth ); + cheatCmpEntry->setMaximumWidth(3 * fontCharWidth); - hbox->addWidget( lbl ); - hbox->addWidget( cheatCmpEntry ); + hbox->addWidget(lbl); + hbox->addWidget(cheatCmpEntry); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); hbox = new QHBoxLayout(); - addCheatBtn = new QPushButton( tr("Add") ); - delCheatBtn = new QPushButton( tr("Delete") ); - modCheatBtn = new QPushButton( tr("Update") ); + addCheatBtn = new QPushButton(tr("Add")); + delCheatBtn = new QPushButton(tr("Delete")); + modCheatBtn = new QPushButton(tr("Update")); - hbox->addWidget( addCheatBtn ); - hbox->addWidget( delCheatBtn ); - hbox->addWidget( modCheatBtn ); + hbox->addWidget(addCheatBtn); + hbox->addWidget(delCheatBtn); + hbox->addWidget(modCheatBtn); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); hbox = new QHBoxLayout(); - importCheatFileBtn = new QPushButton( tr("Import") ); - exportCheatFileBtn = new QPushButton( tr("Export") ); - importCheatFileBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - exportCheatFileBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + importCheatFileBtn = new QPushButton(tr("Import")); + exportCheatFileBtn = new QPushButton(tr("Export")); + importCheatFileBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + exportCheatFileBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - hbox->addWidget( importCheatFileBtn ); - hbox->addWidget( exportCheatFileBtn ); + hbox->addWidget(importCheatFileBtn); + hbox->addWidget(exportCheatFileBtn); - vbox1->addLayout( hbox ); + vbox1->addLayout(hbox); - actCheatFrame->setLayout( vbox1 ); + actCheatFrame->setLayout(vbox1); - cheatSearchFrame = new QGroupBox( tr("Cheat Search") ); - cheatResultFrame = new QGroupBox( tr("Possibilities") ); + cheatSearchFrame = new QGroupBox(tr("Cheat Search")); + cheatResultFrame = new QGroupBox(tr("Possibilities")); srchResults = new QTreeWidget(); srchResults->setColumnCount(3); item = new QTreeWidgetItem(); - item->setFont( 0, font ); - item->setFont( 1, font ); - item->setFont( 2, font ); - item->setText( 0, QString::fromStdString( "Addr" ) ); - item->setText( 1, QString::fromStdString( "Pre" ) ); - item->setText( 2, QString::fromStdString( "Cur" ) ); - item->setTextAlignment( 0, Qt::AlignCenter); - item->setTextAlignment( 1, Qt::AlignCenter); - item->setTextAlignment( 2, Qt::AlignCenter); + item->setFont(0, font); + item->setFont(1, font); + item->setFont(2, font); + item->setText(0, QString::fromStdString("Addr")); + item->setText(1, QString::fromStdString("Pre")); + item->setText(2, QString::fromStdString("Cur")); + item->setTextAlignment(0, Qt::AlignCenter); + item->setTextAlignment(1, Qt::AlignCenter); + item->setTextAlignment(2, Qt::AlignCenter); - srchResults->setHeaderItem( item ); + srchResults->setHeaderItem(item); //srchResults->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); - srchResults->header()->setSectionResizeMode( QHeaderView::Interactive ); + srchResults->header()->setSectionResizeMode(QHeaderView::Interactive); //srchResults->header()->setSectionResizeMode( QHeaderView::Fixed ); - srchResults->header()->resizeSection( 0, 10 * fontCharWidth ); - srchResults->header()->resizeSection( 1, 6 * fontCharWidth ); - srchResults->header()->resizeSection( 2, 6 * fontCharWidth ); + srchResults->header()->resizeSection(0, 10 * fontCharWidth); + srchResults->header()->resizeSection(1, 6 * fontCharWidth); + srchResults->header()->resizeSection(2, 6 * fontCharWidth); //srchResults->header()->setSectionResizeMode( QHeaderView::Stretch ); //srchResults->header()->setDefaultSectionSize( 200 ); //srchResults->header()->setDefaultSectionSize( 200 ); //srchResults->setReadOnly(true); vbox = new QVBoxLayout(); - vbox->addWidget( srchResults ); - cheatResultFrame->setLayout( vbox ); + vbox->addWidget(srchResults); + cheatResultFrame->setLayout(vbox); hbox1 = new QHBoxLayout(); vbox2 = new QVBoxLayout(); - hbox1->addLayout( vbox2 ); - hbox1->addWidget( cheatResultFrame ); + hbox1->addLayout(vbox2); + hbox1->addWidget(cheatResultFrame); - cheatSearchFrame->setLayout( hbox1 ); + cheatSearchFrame->setLayout(hbox1); - srchResetBtn = new QPushButton( tr("Reset") ); - srchResetBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + srchResetBtn = new QPushButton(tr("Reset")); + srchResetBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - vbox2->addWidget( srchResetBtn ); + vbox2->addWidget(srchResetBtn); frame = new QFrame(); - frame->setFrameShape( QFrame::Box ); - frame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - vbox2->addWidget( frame ); + frame->setFrameShape(QFrame::Box); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + vbox2->addWidget(frame); vbox = new QVBoxLayout(); - frame->setLayout( vbox ); + frame->setLayout(vbox); - knownValBtn = new QPushButton( tr("Known Value:") ); - knownValBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + knownValBtn = new QPushButton(tr("Known Value:")); + knownValBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); knownValBtn->setEnabled(false); - vbox->addWidget( knownValBtn ); + vbox->addWidget(knownValBtn); hbox1 = new QHBoxLayout(); - vbox->addLayout( hbox1 ); + vbox->addLayout(hbox1); - lbl = new QLabel( tr("0x") ); - lbl->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + lbl = new QLabel(tr("0x")); + lbl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); knownValEntry = new QLineEdit(); knownValEntry->setMaxLength(2); - knownValEntry->setInputMask( ">HH;0" ); - knownValEntry->setFont( font ); + knownValEntry->setInputMask(">HH;0"); + knownValEntry->setFont(font); knownValEntry->setCursorPosition(0); - knownValEntry->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - knownValEntry->setMaximumWidth( 3 * fontCharWidth ); + knownValEntry->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + knownValEntry->setMaximumWidth(3 * fontCharWidth); knownValEntry->setAlignment(Qt::AlignCenter); knownValEntry->setEnabled(false); - hbox1->addWidget( lbl, 0, Qt::AlignRight ); - hbox1->addWidget( knownValEntry, 0, Qt::AlignLeft ); + hbox1->addWidget(lbl, 0, Qt::AlignRight); + hbox1->addWidget(knownValEntry, 0, Qt::AlignLeft); - groupBox = new QGroupBox( tr("Previous Compare") ); - vbox2->addWidget( groupBox ); - groupBox->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + groupBox = new QGroupBox(tr("Previous Compare")); + vbox2->addWidget(groupBox); + groupBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); vbox3 = new QVBoxLayout(); frame = new QFrame(); - frame->setFrameShape( QFrame::Box ); - frame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - vbox3->addWidget( frame ); + frame->setFrameShape(QFrame::Box); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + vbox3->addWidget(frame); vbox = new QVBoxLayout(); - eqValBtn = new QPushButton( tr("Equal") ); - eqValBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + eqValBtn = new QPushButton(tr("Equal")); + eqValBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); eqValBtn->setEnabled(false); - vbox->addWidget( eqValBtn ); + vbox->addWidget(eqValBtn); - frame->setLayout( vbox ); + frame->setLayout(vbox); frame = new QFrame(); - frame->setFrameShape( QFrame::Box ); - frame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - vbox3->addWidget( frame ); + frame->setFrameShape(QFrame::Box); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + vbox3->addWidget(frame); vbox = new QVBoxLayout(); - neValBtn = new QPushButton( tr("Not Equal") ); - neValBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + neValBtn = new QPushButton(tr("Not Equal")); + neValBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); neValBtn->setEnabled(false); hbox = new QHBoxLayout(); - useNeVal = new QCheckBox( tr("By:") ); - useNeVal->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + useNeVal = new QCheckBox(tr("By:")); + useNeVal->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); useNeVal->setEnabled(false); neValEntry = new QLineEdit(); neValEntry->setMaxLength(2); - neValEntry->setInputMask( ">HH;0" ); - neValEntry->setFont( font ); + neValEntry->setInputMask(">HH;0"); + neValEntry->setFont(font); neValEntry->setCursorPosition(0); - neValEntry->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - neValEntry->setMaximumWidth( 3 * fontCharWidth ); + neValEntry->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + neValEntry->setMaximumWidth(3 * fontCharWidth); neValEntry->setAlignment(Qt::AlignCenter); neValEntry->setEnabled(false); - hbox->addWidget( useNeVal, 0, Qt::AlignRight ); - hbox->addWidget( neValEntry, 0, Qt::AlignLeft ); + hbox->addWidget(useNeVal, 0, Qt::AlignRight); + hbox->addWidget(neValEntry, 0, Qt::AlignLeft); - vbox->addWidget( neValBtn ); - vbox->addLayout( hbox ); - frame->setLayout( vbox ); + vbox->addWidget(neValBtn); + vbox->addLayout(hbox); + frame->setLayout(vbox); frame = new QFrame(); - frame->setFrameShape( QFrame::Box ); - frame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - vbox3->addWidget( frame ); + frame->setFrameShape(QFrame::Box); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + vbox3->addWidget(frame); vbox = new QVBoxLayout(); - grValBtn = new QPushButton( tr("Greater Than") ); - grValBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + grValBtn = new QPushButton(tr("Greater Than")); + grValBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); grValBtn->setEnabled(false); hbox = new QHBoxLayout(); - useGrVal = new QCheckBox( tr("By:") ); - useGrVal->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + useGrVal = new QCheckBox(tr("By:")); + useGrVal->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); useGrVal->setEnabled(false); grValEntry = new QLineEdit(); grValEntry->setMaxLength(2); - grValEntry->setInputMask( ">HH;0" ); - grValEntry->setFont( font ); + grValEntry->setInputMask(">HH;0"); + grValEntry->setFont(font); grValEntry->setCursorPosition(0); - grValEntry->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - grValEntry->setMaximumWidth( 3 * fontCharWidth ); + grValEntry->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + grValEntry->setMaximumWidth(3 * fontCharWidth); grValEntry->setAlignment(Qt::AlignCenter); grValEntry->setEnabled(false); - hbox->addWidget( useGrVal, 0, Qt::AlignRight ); - hbox->addWidget( grValEntry, 0, Qt::AlignLeft ); + hbox->addWidget(useGrVal, 0, Qt::AlignRight); + hbox->addWidget(grValEntry, 0, Qt::AlignLeft); - vbox->addWidget( grValBtn ); - vbox->addLayout( hbox ); - frame->setLayout( vbox ); + vbox->addWidget(grValBtn); + vbox->addLayout(hbox); + frame->setLayout(vbox); frame = new QFrame(); - frame->setFrameShape( QFrame::Box ); - frame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - vbox3->addWidget( frame ); + frame->setFrameShape(QFrame::Box); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + vbox3->addWidget(frame); vbox = new QVBoxLayout(); - ltValBtn = new QPushButton( tr("Less Than") ); - ltValBtn->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + ltValBtn = new QPushButton(tr("Less Than")); + ltValBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); ltValBtn->setEnabled(false); hbox = new QHBoxLayout(); - useLtVal = new QCheckBox( tr("By:") ); - useLtVal->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + useLtVal = new QCheckBox(tr("By:")); + useLtVal->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); useLtVal->setEnabled(false); ltValEntry = new QLineEdit(); ltValEntry->setMaxLength(2); - ltValEntry->setInputMask( ">HH;0" ); - ltValEntry->setFont( font ); + ltValEntry->setInputMask(">HH;0"); + ltValEntry->setFont(font); ltValEntry->setCursorPosition(0); - ltValEntry->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - ltValEntry->setMaximumWidth( 3 * fontCharWidth ); + ltValEntry->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + ltValEntry->setMaximumWidth(3 * fontCharWidth); ltValEntry->setAlignment(Qt::AlignCenter); ltValEntry->setEnabled(false); - hbox->addWidget( useLtVal, 0, Qt::AlignRight ); - hbox->addWidget( ltValEntry, 0, Qt::AlignLeft ); + hbox->addWidget(useLtVal, 0, Qt::AlignRight); + hbox->addWidget(ltValEntry, 0, Qt::AlignLeft); - vbox->addWidget( ltValBtn ); - vbox->addLayout( hbox ); - frame->setLayout( vbox ); + vbox->addWidget(ltValBtn); + vbox->addLayout(hbox); + frame->setLayout(vbox); - groupBox->setLayout( vbox3 ); + groupBox->setLayout(vbox3); vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); - pauseBox = new QCheckBox( tr("Pause emulation when this window is active") ); + pauseBox = new QCheckBox(tr("Pause emulation when this window is active")); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); - vbox->addWidget( cheatSearchFrame ); - vbox->addWidget( pauseBox ); + hbox->addWidget(pauseBox, 5); + hbox->addWidget(closeButton, 1); - mainLayout->addLayout( vbox ); + vbox->addWidget(cheatSearchFrame); + vbox->addLayout(hbox); - setLayout( mainLayout ); + mainLayout->addLayout(vbox); - connect( srchResetBtn, SIGNAL(clicked(void)), this, SLOT(resetSearchCallback(void)) ); - connect( knownValBtn , SIGNAL(clicked(void)), this, SLOT(knownValueCallback(void)) ); - connect( eqValBtn , SIGNAL(clicked(void)), this, SLOT(equalValueCallback(void)) ); - connect( neValBtn , SIGNAL(clicked(void)), this, SLOT(notEqualValueCallback(void)) ); - connect( ltValBtn , SIGNAL(clicked(void)), this, SLOT(lessThanValueCallback(void)) ); - connect( grValBtn , SIGNAL(clicked(void)), this, SLOT(greaterThanValueCallback(void)) ); - connect( addCheatBtn , SIGNAL(clicked(void)), this, SLOT(addActvCheat(void)) ); - connect( delCheatBtn , SIGNAL(clicked(void)), this, SLOT(deleteActvCheat(void)) ); - connect( modCheatBtn , SIGNAL(clicked(void)), this, SLOT(updateCheatParameters(void)) ); + setLayout(mainLayout); - connect( enaCheats, SIGNAL(stateChanged(int)), this, SLOT(globalEnableCheats(int)) ); - connect( autoSave , SIGNAL(stateChanged(int)), this, SLOT(autoLoadSaveCheats(int)) ); - connect( pauseBox , SIGNAL(stateChanged(int)), this, SLOT(pauseWindowState(int)) ); + connect(srchResetBtn, SIGNAL(clicked(void)), this, SLOT(resetSearchCallback(void))); + connect(knownValBtn, SIGNAL(clicked(void)), this, SLOT(knownValueCallback(void))); + connect(eqValBtn, SIGNAL(clicked(void)), this, SLOT(equalValueCallback(void))); + connect(neValBtn, SIGNAL(clicked(void)), this, SLOT(notEqualValueCallback(void))); + connect(ltValBtn, SIGNAL(clicked(void)), this, SLOT(lessThanValueCallback(void))); + connect(grValBtn, SIGNAL(clicked(void)), this, SLOT(greaterThanValueCallback(void))); + connect(addCheatBtn, SIGNAL(clicked(void)), this, SLOT(addActvCheat(void))); + connect(delCheatBtn, SIGNAL(clicked(void)), this, SLOT(deleteActvCheat(void))); + connect(modCheatBtn, SIGNAL(clicked(void)), this, SLOT(updateCheatParameters(void))); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); - connect( importCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(openCheatFile(void)) ); - connect( exportCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(saveCheatFile(void)) ); + connect(enaCheats, SIGNAL(stateChanged(int)), this, SLOT(globalEnableCheats(int))); + connect(autoSave, SIGNAL(stateChanged(int)), this, SLOT(autoLoadSaveCheats(int))); + connect(pauseBox, SIGNAL(stateChanged(int)), this, SLOT(pauseWindowState(int))); + + connect(importCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(openCheatFile(void))); + connect(exportCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(saveCheatFile(void))); showActiveCheatList(true); } @@ -447,60 +455,60 @@ GuiCheatsDialog_t::~GuiCheatsDialog_t(void) if (EmulationPaused && wasPausedByCheats) { EmulationPaused = 0; - FCEU_printf ("Emulation paused: %d\n", EmulationPaused); + FCEU_printf("Emulation paused: %d\n", EmulationPaused); } wasPausedByCheats = false; - win = NULL; - printf("Destroy Cheat Window Event\n"); + win = NULL; + printf("Destroy Cheat Window Event\n"); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::closeEvent(QCloseEvent *event) { - printf("Cheat Close Window Event\n"); - done(0); + printf("Cheat Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- -int GuiCheatsDialog_t::addSearchResult (uint32_t a, uint8_t last, uint8_t current) +int GuiCheatsDialog_t::addSearchResult(uint32_t a, uint8_t last, uint8_t current) { QTreeWidgetItem *item; char addrStr[8], lastStr[8], curStr[8]; item = new QTreeWidgetItem(); - sprintf (addrStr, "$%04X", a); - sprintf (lastStr, "%02X", last); - sprintf (curStr , "%02X", current); + sprintf(addrStr, "$%04X", a); + sprintf(lastStr, "%02X", last); + sprintf(curStr, "%02X", current); //item->setFont( 0, font ); //item->setFont( 1, font ); //item->setFont( 2, font ); - item->setText( 0, tr(addrStr) ); - item->setText( 1, tr(lastStr) ); - item->setText( 2, tr(curStr) ); + item->setText(0, tr(addrStr)); + item->setText(1, tr(lastStr)); + item->setText(2, tr(curStr)); - item->setTextAlignment( 0, Qt::AlignCenter); - item->setTextAlignment( 1, Qt::AlignCenter); - item->setTextAlignment( 2, Qt::AlignCenter); + item->setTextAlignment(0, Qt::AlignCenter); + item->setTextAlignment(1, Qt::AlignCenter); + item->setTextAlignment(2, Qt::AlignCenter); - srchResults->addTopLevelItem( item ); + srchResults->addTopLevelItem(item); return 1; } //---------------------------------------------------------------------------- -static int ShowCheatSearchResultsCallB (uint32 a, uint8 last, uint8 current) +static int ShowCheatSearchResultsCallB(uint32 a, uint8 last, uint8 current) { - return win->addSearchResult( a, last, current ); + return win->addSearchResult(a, last, current); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::showCheatSearchResults(void) @@ -511,19 +519,19 @@ void GuiCheatsDialog_t::showCheatSearchResults(void) srchResults->clear(); - total_matches = FCEUI_CheatSearchGetCount (); + total_matches = FCEUI_CheatSearchGetCount(); - FCEUI_CheatSearchGetRange (0, total_matches, - ShowCheatSearchResultsCallB); + FCEUI_CheatSearchGetRange(0, total_matches, + ShowCheatSearchResultsCallB); - printf("Num Matches: %i \n", total_matches ); + printf("Num Matches: %i \n", total_matches); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::resetSearchCallback(void) { fceuWrapperLock(); - FCEUI_CheatSearchBegin (); + FCEUI_CheatSearchBegin(); showCheatSearchResults(); @@ -553,9 +561,9 @@ void GuiCheatsDialog_t::knownValueCallback(void) //printf("%s\n", knownValEntry->text().toStdString().c_str() ); - value = strtol( knownValEntry->text().toStdString().c_str(), NULL, 16 ); + value = strtol(knownValEntry->text().toStdString().c_str(), NULL, 16); - FCEUI_CheatSearchEnd (FCEU_SEARCH_NEWVAL_KNOWN, value, 0); + FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_KNOWN, value, 0); showCheatSearchResults(); @@ -567,7 +575,7 @@ void GuiCheatsDialog_t::equalValueCallback(void) //printf("Cheat Search Equal!\n"); fceuWrapperLock(); - FCEUI_CheatSearchEnd (FCEU_SEARCH_PUERLY_RELATIVE_CHANGE, 0, 0); + FCEUI_CheatSearchEnd(FCEU_SEARCH_PUERLY_RELATIVE_CHANGE, 0, 0); showCheatSearchResults(); @@ -584,13 +592,13 @@ void GuiCheatsDialog_t::notEqualValueCallback(void) if (checked) { - value = strtol( neValEntry->text().toStdString().c_str(), NULL, 16 ); + value = strtol(neValEntry->text().toStdString().c_str(), NULL, 16); - FCEUI_CheatSearchEnd (FCEU_SEARCH_PUERLY_RELATIVE_CHANGE, 0, value); + FCEUI_CheatSearchEnd(FCEU_SEARCH_PUERLY_RELATIVE_CHANGE, 0, value); } else { - FCEUI_CheatSearchEnd (FCEU_SEARCH_ANY_CHANGE, 0, 0); + FCEUI_CheatSearchEnd(FCEU_SEARCH_ANY_CHANGE, 0, 0); } showCheatSearchResults(); @@ -608,13 +616,13 @@ void GuiCheatsDialog_t::greaterThanValueCallback(void) if (checked) { - value = strtol( grValEntry->text().toStdString().c_str(), NULL, 16 ); + value = strtol(grValEntry->text().toStdString().c_str(), NULL, 16); - FCEUI_CheatSearchEnd (FCEU_SEARCH_NEWVAL_GT_KNOWN, 0, value); + FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_GT_KNOWN, 0, value); } else { - FCEUI_CheatSearchEnd (FCEU_SEARCH_NEWVAL_GT, 0, 0); + FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_GT, 0, 0); } showCheatSearchResults(); @@ -632,13 +640,13 @@ void GuiCheatsDialog_t::lessThanValueCallback(void) if (checked) { - value = strtol( ltValEntry->text().toStdString().c_str(), NULL, 16 ); + value = strtol(ltValEntry->text().toStdString().c_str(), NULL, 16); - FCEUI_CheatSearchEnd (FCEU_SEARCH_NEWVAL_LT_KNOWN, 0, value); + FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_LT_KNOWN, 0, value); } else { - FCEUI_CheatSearchEnd (FCEU_SEARCH_NEWVAL_LT, 0, 0); + FCEUI_CheatSearchEnd(FCEU_SEARCH_NEWVAL_LT, 0, 0); } showCheatSearchResults(); @@ -646,49 +654,49 @@ void GuiCheatsDialog_t::lessThanValueCallback(void) fceuWrapperUnLock(); } //---------------------------------------------------------------------------- -int GuiCheatsDialog_t::activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data) +int GuiCheatsDialog_t::activeCheatListCB(char *name, uint32 a, uint8 v, int c, int s, int type, void *data) { QTreeWidgetItem *item; char codeStr[32]; if (c >= 0) { - sprintf (codeStr, "$%04X?%02X:%02X", a,c,v); + sprintf(codeStr, "$%04X?%02X:%02X", a, c, v); } else { - sprintf (codeStr, "$%04X:%02X ", a,v); + sprintf(codeStr, "$%04X:%02X ", a, v); } item = actvCheatList->topLevelItem(actvCheatIdx); - if ( item == NULL ) + if (item == NULL) { item = new QTreeWidgetItem(); - actvCheatList->addTopLevelItem( item ); + actvCheatList->addTopLevelItem(item); } //item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable ); - item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren ); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren); - item->setCheckState( 0, s ? Qt::Checked : Qt::Unchecked ); + item->setCheckState(0, s ? Qt::Checked : Qt::Unchecked); - item->setText( 0, tr(codeStr)); - item->setText( 1, tr(name) ); + item->setText(0, tr(codeStr)); + item->setText(1, tr(name)); - item->setTextAlignment( 0, Qt::AlignLeft); - item->setTextAlignment( 1, Qt::AlignLeft); - item->setTextAlignment( 2, Qt::AlignLeft); + item->setTextAlignment(0, Qt::AlignLeft); + item->setTextAlignment(1, Qt::AlignLeft); + item->setTextAlignment(2, Qt::AlignLeft); actvCheatIdx++; return 1; } //---------------------------------------------------------------------------- -static int activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data) +static int activeCheatListCB(char *name, uint32 a, uint8 v, int c, int s, int type, void *data) { - return win->activeCheatListCB( name, a, v, c, s, type, data ); + return win->activeCheatListCB(name, a, v, c, s, type, data); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::showActiveCheatList(bool redraw) @@ -697,13 +705,13 @@ void GuiCheatsDialog_t::showActiveCheatList(bool redraw) actvCheatRedraw = redraw; - if ( redraw ) + if (redraw) { actvCheatList->clear(); } actvCheatIdx = 0; - FCEUI_ListCheats (::activeCheatListCB, (void *) this); + FCEUI_ListCheats(::activeCheatListCB, (void *)this); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::openCheatFile(void) @@ -713,62 +721,62 @@ void GuiCheatsDialog_t::openCheatFile(void) QString filename; std::string last; char dir[512]; - QFileDialog dialog(this, tr("Open Cheat File") ); + QFileDialog dialog(this, tr("Open Cheat File")); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("Cheat files (*.cht *.CHT) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Open") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Open")); - g_config->getOption ("SDL.LastOpenFile", &last ); + g_config->getOption("SDL.LastOpenFile", &last); - getDirFromFile( last.c_str(), dir ); + getDirFromFile(last.c_str(), dir); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } qDebug() << "selected file path : " << filename.toUtf8(); - g_config->setOption ("SDL.LastOpenFile", filename.toStdString().c_str() ); + g_config->setOption("SDL.LastOpenFile", filename.toStdString().c_str()); fceuWrapperLock(); - fp = fopen (filename.toStdString().c_str(), "r"); + fp = fopen(filename.toStdString().c_str(), "r"); if (fp != NULL) { - FCEU_LoadGameCheats (fp, 0); - fclose (fp); + FCEU_LoadGameCheats(fp, 0); + fclose(fp); } fceuWrapperUnLock(); showActiveCheatList(true); - return; + return; } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::saveCheatFile(void) @@ -777,87 +785,87 @@ void GuiCheatsDialog_t::saveCheatFile(void) int ret, useNativeFileDialogVal; QString filename; char dir[512]; - QFileDialog dialog(this, tr("Save Cheat File") ); + QFileDialog dialog(this, tr("Save Cheat File")); dialog.setFileMode(QFileDialog::AnyFile); dialog.setNameFilter(tr("Cheat files (*.cht *.CHT) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Save") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Save")); - if ( GameInfo ) + if (GameInfo) { - getFileBaseName( GameInfo->filename, dir ); + getFileBaseName(GameInfo->filename, dir); - strcat( dir, ".cht"); + strcat(dir, ".cht"); - dialog.selectFile( dir ); + dialog.selectFile(dir); } - sprintf( dir, "%s/cheats", FCEUI_GetBaseDirectory() ); + sprintf(dir, "%s/cheats", FCEUI_GetBaseDirectory()); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } qDebug() << "selected file path : " << filename.toUtf8(); //g_config->setOption ("SDL.LastOpenFile", filename.toStdString().c_str() ); fceuWrapperLock(); - fp = FCEUD_UTF8fopen (filename.toStdString().c_str(), "wb"); + fp = FCEUD_UTF8fopen(filename.toStdString().c_str(), "wb"); if (fp != NULL) { - FCEU_SaveGameCheats (fp); - fclose (fp); + FCEU_SaveGameCheats(fp); + fclose(fp); } fceuWrapperUnLock(); showActiveCheatList(true); - return; + return; } //---------------------------------------------------------------------------- -void GuiCheatsDialog_t::addActvCheat(void) +void GuiCheatsDialog_t::addActvCheat(void) { uint32 a = 0; uint8 v = 0; int c = -1; std::string name, cmpStr; - a = strtoul( cheatAddrEntry->text().toStdString().c_str(), NULL, 16 ); + a = strtoul(cheatAddrEntry->text().toStdString().c_str(), NULL, 16); - v = strtoul( cheatValEntry->text().toStdString().c_str(), NULL, 16 ); + v = strtoul(cheatValEntry->text().toStdString().c_str(), NULL, 16); cmpStr = cheatCmpEntry->text().toStdString(); - if ( isdigit( cmpStr[0] ) ) + if (isdigit(cmpStr[0])) { - c = strtoul( cmpStr.c_str(), NULL, 16 ); + c = strtoul(cmpStr.c_str(), NULL, 16); } else { @@ -867,39 +875,39 @@ void GuiCheatsDialog_t::addActvCheat(void) name = cheatNameEntry->text().toStdString(); fceuWrapperLock(); - FCEUI_AddCheat( name.c_str(), a, v, c, 1 ); + FCEUI_AddCheat(name.c_str(), a, v, c, 1); fceuWrapperUnLock(); showActiveCheatList(true); } //---------------------------------------------------------------------------- -void GuiCheatsDialog_t::deleteActvCheat(void) +void GuiCheatsDialog_t::deleteActvCheat(void) { QTreeWidgetItem *item; item = actvCheatList->currentItem(); - if ( item == NULL ) + if (item == NULL) { - printf( "No Item Selected\n"); + printf("No Item Selected\n"); return; } int row = actvCheatList->indexOfTopLevelItem(item); fceuWrapperLock(); - FCEUI_DelCheat (row); + FCEUI_DelCheat(row); fceuWrapperUnLock(); showActiveCheatList(true); - cheatNameEntry->setText( tr("") ); - cheatAddrEntry->setText( tr("") ); - cheatValEntry->setText( tr("") ); - cheatCmpEntry->setText( tr("") ); + cheatNameEntry->setText(tr("")); + cheatAddrEntry->setText(tr("")); + cheatValEntry->setText(tr("")); + cheatCmpEntry->setText(tr("")); } //---------------------------------------------------------------------------- -void GuiCheatsDialog_t::updateCheatParameters(void) +void GuiCheatsDialog_t::updateCheatParameters(void) { uint32 a = 0; uint8 v = 0; @@ -909,29 +917,29 @@ void GuiCheatsDialog_t::updateCheatParameters(void) item = actvCheatList->currentItem(); - if ( item == NULL ) + if (item == NULL) { - printf( "No Item Selected\n"); + printf("No Item Selected\n"); return; } int row = actvCheatList->indexOfTopLevelItem(item); - if ( FCEUI_GetCheat( row, NULL, &a, &v, &c, &s, &type) == 0 ) + if (FCEUI_GetCheat(row, NULL, &a, &v, &c, &s, &type) == 0) { return; } //printf("Row: %i \n", row ); - a = strtoul( cheatAddrEntry->text().toStdString().c_str(), NULL, 16 ); + a = strtoul(cheatAddrEntry->text().toStdString().c_str(), NULL, 16); - v = strtoul( cheatValEntry->text().toStdString().c_str(), NULL, 16 ); + v = strtoul(cheatValEntry->text().toStdString().c_str(), NULL, 16); cmpStr = cheatCmpEntry->text().toStdString(); - if ( isdigit( cmpStr[0] ) ) + if (isdigit(cmpStr[0])) { - c = strtoul( cmpStr.c_str(), NULL, 16 ); + c = strtoul(cmpStr.c_str(), NULL, 16); } else { @@ -944,14 +952,14 @@ void GuiCheatsDialog_t::updateCheatParameters(void) fceuWrapperLock(); - FCEUI_SetCheat( row, name.c_str(), a, v, c, s, type); + FCEUI_SetCheat(row, name.c_str(), a, v, c, s, type); fceuWrapperUnLock(); showActiveCheatList(false); } //---------------------------------------------------------------------------- -void GuiCheatsDialog_t::actvCheatItemClicked( QTreeWidgetItem *item, int column) +void GuiCheatsDialog_t::actvCheatItemClicked(QTreeWidgetItem *item, int column) { uint32 a = 0; uint8 v = 0; @@ -963,57 +971,57 @@ void GuiCheatsDialog_t::actvCheatItemClicked( QTreeWidgetItem *item, int column //printf("Row: %i Column: %i \n", row, column ); - if ( FCEUI_GetCheat( row, &name, &a, &v, &c, &s, &type) == 0 ) + if (FCEUI_GetCheat(row, &name, &a, &v, &c, &s, &type) == 0) { return; } - if ( column == 0 ) + if (column == 0) { - int isChecked = item->checkState( column ) != Qt::Unchecked; + int isChecked = item->checkState(column) != Qt::Unchecked; - if ( isChecked != s ) + if (isChecked != s) { //printf("Toggle Cheat: %i\n", isChecked); - FCEUI_ToggleCheat( row ); + FCEUI_ToggleCheat(row); } } - sprintf( stmp, "%04X", a ); - cheatAddrEntry->setText( tr(stmp) ); + sprintf(stmp, "%04X", a); + cheatAddrEntry->setText(tr(stmp)); - sprintf( stmp, "%02X", v ); - cheatValEntry->setText( tr(stmp) ); + sprintf(stmp, "%02X", v); + cheatValEntry->setText(tr(stmp)); - if ( c >= 0 ) + if (c >= 0) { - sprintf( stmp, "%02X", c ); - cheatCmpEntry->setText( tr(stmp) ); + sprintf(stmp, "%02X", c); + cheatCmpEntry->setText(tr(stmp)); } else { - cheatCmpEntry->setText( tr("") ); + cheatCmpEntry->setText(tr("")); } - if ( name != NULL ) + if (name != NULL) { - cheatNameEntry->setText( tr(name) ); + cheatNameEntry->setText(tr(name)); } else { - cheatNameEntry->setText( tr("") ); + cheatNameEntry->setText(tr("")); } } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::globalEnableCheats(int state) { fceuWrapperLock(); - FCEUI_GlobalToggleCheat( state != Qt::Unchecked ); + FCEUI_GlobalToggleCheat(state != Qt::Unchecked); fceuWrapperUnLock(); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::autoLoadSaveCheats(int state) { - if ( state == Qt::Unchecked ) + if (state == Qt::Unchecked) { printf("If this option is unchecked, you must manually save the cheats by yourself, or all the changes you made to the cheat list would be discarded silently without any asking once you close the game!\nDo you really want to do it in this way?"); disableAutoLSCheats = 2; @@ -1044,6 +1052,6 @@ void GuiCheatsDialog_t::pauseWindowState(int state) } wasPausedByCheats = false; } - FCEU_printf ("Emulation paused: %d\n", EmulationPaused); + FCEU_printf("Emulation paused: %d\n", EmulationPaused); } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index 9b86631b..40b2836a 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -22,81 +22,80 @@ class GuiCheatsDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - GuiCheatsDialog_t(QWidget *parent = 0); - ~GuiCheatsDialog_t(void); +public: + GuiCheatsDialog_t(QWidget *parent = 0); + ~GuiCheatsDialog_t(void); - int addSearchResult( uint32_t a, uint8_t last, uint8_t current ); + int addSearchResult(uint32_t a, uint8_t last, uint8_t current); - int activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data); + int activeCheatListCB(char *name, uint32 a, uint8 v, int c, int s, int type, void *data); - void showActiveCheatList(bool redraw); + void showActiveCheatList(bool redraw); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QGroupBox *actCheatFrame; - QGroupBox *cheatSearchFrame; - QGroupBox *cheatResultFrame; - QPushButton *addCheatBtn; - QPushButton *delCheatBtn; - QPushButton *modCheatBtn; - QPushButton *importCheatFileBtn; - QPushButton *exportCheatFileBtn; - QPushButton *srchResetBtn; - QPushButton *knownValBtn; - QPushButton *eqValBtn; - QPushButton *neValBtn; - QPushButton *grValBtn; - QPushButton *ltValBtn; - QCheckBox *useNeVal; - QCheckBox *useGrVal; - QCheckBox *useLtVal; - QCheckBox *enaCheats; - QCheckBox *autoSave; - QCheckBox *pauseBox; - QTreeWidget *actvCheatList; - QTreeWidget *srchResults; - QLineEdit *cheatNameEntry; - QLineEdit *cheatAddrEntry; - QLineEdit *cheatValEntry; - QLineEdit *cheatCmpEntry; - QLineEdit *knownValEntry; - QLineEdit *neValEntry; - QLineEdit *grValEntry; - QLineEdit *ltValEntry; - QFont font; + QGroupBox *actCheatFrame; + QGroupBox *cheatSearchFrame; + QGroupBox *cheatResultFrame; + QPushButton *addCheatBtn; + QPushButton *delCheatBtn; + QPushButton *modCheatBtn; + QPushButton *importCheatFileBtn; + QPushButton *exportCheatFileBtn; + QPushButton *srchResetBtn; + QPushButton *knownValBtn; + QPushButton *eqValBtn; + QPushButton *neValBtn; + QPushButton *grValBtn; + QPushButton *ltValBtn; + QCheckBox *useNeVal; + QCheckBox *useGrVal; + QCheckBox *useLtVal; + QCheckBox *enaCheats; + QCheckBox *autoSave; + QCheckBox *pauseBox; + QTreeWidget *actvCheatList; + QTreeWidget *srchResults; + QLineEdit *cheatNameEntry; + QLineEdit *cheatAddrEntry; + QLineEdit *cheatValEntry; + QLineEdit *cheatCmpEntry; + QLineEdit *knownValEntry; + QLineEdit *neValEntry; + QLineEdit *grValEntry; + QLineEdit *ltValEntry; + QFont font; - int fontCharWidth; - int actvCheatIdx; - bool actvCheatRedraw; - bool pauseWhileActive; - bool wasPausedByCheats; + int fontCharWidth; + int actvCheatIdx; + bool actvCheatRedraw; + bool pauseWhileActive; + bool wasPausedByCheats; - private: - void showCheatSearchResults(void); - - public slots: - void closeWindow(void); - private slots: - void resetSearchCallback(void); - void knownValueCallback(void); - void equalValueCallback(void); - void notEqualValueCallback(void); - void lessThanValueCallback(void); - void greaterThanValueCallback(void); - void openCheatFile(void); - void saveCheatFile(void); - void addActvCheat(void); - void deleteActvCheat(void); - void updateCheatParameters(void); - void autoLoadSaveCheats(int state); - void globalEnableCheats(int state); - void pauseWindowState(int state); - void actvCheatItemClicked( QTreeWidgetItem *item, int column); +private: + void showCheatSearchResults(void); +public slots: + void closeWindow(void); +private slots: + void resetSearchCallback(void); + void knownValueCallback(void); + void equalValueCallback(void); + void notEqualValueCallback(void); + void lessThanValueCallback(void); + void greaterThanValueCallback(void); + void openCheatFile(void); + void saveCheatFile(void); + void addActvCheat(void); + void deleteActvCheat(void); + void updateCheatParameters(void); + void autoLoadSaveCheats(int state); + void globalEnableCheats(int state); + void pauseWindowState(int state); + void actvCheatItemClicked(QTreeWidgetItem *item, int column); }; void openCheatDialog(QWidget *parent); diff --git a/src/drivers/Qt/ConsoleSoundConf.cpp b/src/drivers/Qt/ConsoleSoundConf.cpp index 51a98a53..9f5c913e 100644 --- a/src/drivers/Qt/ConsoleSoundConf.cpp +++ b/src/drivers/Qt/ConsoleSoundConf.cpp @@ -31,53 +31,55 @@ //---------------------------------------------------- ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { int buf; - QHBoxLayout *hbox1, *hbox2; - QVBoxLayout *vbox1, *vbox2; + QHBoxLayout *hbox, *hbox1, *hbox2; + QVBoxLayout *mainLayout, *vbox1, *vbox2; + QPushButton *closeButton; QLabel *lbl; QGroupBox *frame; QSlider *vslider; - setWindowTitle( tr("Sound Config") ); + setWindowTitle(tr("Sound Config")); + mainLayout = new QVBoxLayout(); hbox1 = new QHBoxLayout(); vbox1 = new QVBoxLayout(); // Enable Sound Select - enaChkbox = new QCheckBox( tr("Enable Sound") ); + enaChkbox = new QCheckBox(tr("Enable Sound")); // Enable Low Pass Filter Select - enaLowPass = new QCheckBox( tr("Enable Low Pass Filter") ); + enaLowPass = new QCheckBox(tr("Enable Low Pass Filter")); - setCheckBoxFromProperty( enaChkbox , "SDL.Sound" ); - setCheckBoxFromProperty( enaLowPass, "SDL.Sound.LowPass" ); + setCheckBoxFromProperty(enaChkbox, "SDL.Sound"); + setCheckBoxFromProperty(enaLowPass, "SDL.Sound.LowPass"); - connect(enaChkbox , SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int)) ); - connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int)) ); + connect(enaChkbox, SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int))); + connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int))); - vbox1->addWidget( enaChkbox ); - vbox1->addWidget( enaLowPass ); + vbox1->addWidget(enaChkbox); + vbox1->addWidget(enaLowPass); // Audio Quality Select hbox2 = new QHBoxLayout(); - lbl = new QLabel( tr("Quality:") ); + lbl = new QLabel(tr("Quality:")); qualitySelect = new QComboBox(); - qualitySelect->addItem( tr("Low") , 0 ); - qualitySelect->addItem( tr("High") , 1 ); - qualitySelect->addItem( tr("Very High"), 2 ); + qualitySelect->addItem(tr("Low"), 0); + qualitySelect->addItem(tr("High"), 1); + qualitySelect->addItem(tr("Very High"), 2); - setComboBoxFromProperty( qualitySelect, "SDL.Sound.Quality" ); + setComboBoxFromProperty(qualitySelect, "SDL.Sound.Quality"); - connect(qualitySelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundQualityChanged(int)) ); + connect(qualitySelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundQualityChanged(int))); - hbox2->addWidget( lbl ); - hbox2->addWidget( qualitySelect ); + hbox2->addWidget(lbl); + hbox2->addWidget(qualitySelect); - vbox1->addLayout( hbox2 ); + vbox1->addLayout(hbox2); // Sample Rate Select hbox2 = new QHBoxLayout(); @@ -86,222 +88,234 @@ ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent) rateSelect = new QComboBox(); - rateSelect->addItem( tr("11025"), 11025 ); - rateSelect->addItem( tr("22050"), 22050 ); - rateSelect->addItem( tr("44100"), 44100 ); - rateSelect->addItem( tr("48000"), 48000 ); - rateSelect->addItem( tr("96000"), 96000 ); + rateSelect->addItem(tr("11025"), 11025); + rateSelect->addItem(tr("22050"), 22050); + rateSelect->addItem(tr("44100"), 44100); + rateSelect->addItem(tr("48000"), 48000); + rateSelect->addItem(tr("96000"), 96000); - setComboBoxFromProperty( rateSelect, "SDL.Sound.Rate" ); + setComboBoxFromProperty(rateSelect, "SDL.Sound.Rate"); - connect(rateSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundRateChanged(int)) ); + connect(rateSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(soundRateChanged(int))); - g_config->getOption ("SDL.Sound.Rate", &buf); + g_config->getOption("SDL.Sound.Rate", &buf); - hbox2->addWidget( lbl ); - hbox2->addWidget( rateSelect ); + hbox2->addWidget(lbl); + hbox2->addWidget(rateSelect); - vbox1->addLayout( hbox2 ); + vbox1->addLayout(hbox2); // Buffer Size Select // hbox2 = new QHBoxLayout(); - lbl = new QLabel( tr("Buffer Size (in ms):") ); + lbl = new QLabel(tr("Buffer Size (in ms):")); - bufSizeLabel = new QLabel("128"); - bufSizeSlider = new QSlider( Qt::Horizontal ); + bufSizeLabel = new QLabel("128"); + bufSizeSlider = new QSlider(Qt::Horizontal); - bufSizeSlider->setMinimum( 15); + bufSizeSlider->setMinimum(15); bufSizeSlider->setMaximum(200); //bufSizeSlider->setSliderPosition(128); - setSliderFromProperty( bufSizeSlider, bufSizeLabel, "SDL.Sound.BufSize" ); + setSliderFromProperty(bufSizeSlider, bufSizeLabel, "SDL.Sound.BufSize"); - hbox2->addWidget( lbl ); - hbox2->addWidget( bufSizeLabel ); + hbox2->addWidget(lbl); + hbox2->addWidget(bufSizeLabel); - vbox1->addLayout( hbox2 ); - vbox1->addWidget( bufSizeSlider ); + vbox1->addLayout(hbox2); + vbox1->addWidget(bufSizeSlider); + + connect(bufSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(bufSizeChanged(int))); - connect(bufSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(bufSizeChanged(int)) ); - // Swap Duty Cycles - swapDutyChkbox = new QCheckBox( tr("Swap Duty Cycles") ); - vbox1->addWidget( swapDutyChkbox ); + swapDutyChkbox = new QCheckBox(tr("Swap Duty Cycles")); + vbox1->addWidget(swapDutyChkbox); - setCheckBoxFromProperty( swapDutyChkbox , "SDL.SwapDuty" ); + setCheckBoxFromProperty(swapDutyChkbox, "SDL.SwapDuty"); - connect(swapDutyChkbox , SIGNAL(stateChanged(int)), this, SLOT(swapDutyCallback(int)) ); + connect(swapDutyChkbox, SIGNAL(stateChanged(int)), this, SLOT(swapDutyCallback(int))); - hbox1->addLayout( vbox1 ); + hbox1->addLayout(vbox1); frame = new QGroupBox(tr("Mixer:")); hbox2 = new QHBoxLayout(); - frame->setLayout( hbox2 ); + frame->setLayout(hbox2); - hbox1->addWidget( frame ); + hbox1->addWidget(frame); - frame = new QGroupBox(tr("Volume")); - vbox2 = new QVBoxLayout(); - volLbl = new QLabel("150"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + frame = new QGroupBox(tr("Volume")); + vbox2 = new QVBoxLayout(); + volLbl = new QLabel("150"); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, volLbl, "SDL.Sound.Volume" ); + setSliderFromProperty(vslider, volLbl, "SDL.Sound.Volume"); - vbox2->addWidget( volLbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(volLbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)) ); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); - frame = new QGroupBox(tr("Triangle")); - vbox2 = new QVBoxLayout(); - triLbl = new QLabel("255"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + frame = new QGroupBox(tr("Triangle")); + vbox2 = new QVBoxLayout(); + triLbl = new QLabel("255"); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, triLbl, "SDL.Sound.TriangleVolume" ); + setSliderFromProperty(vslider, triLbl, "SDL.Sound.TriangleVolume"); - vbox2->addWidget( triLbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(triLbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(triangleChanged(int)) ); - - frame = new QGroupBox(tr("Square1")); - vbox2 = new QVBoxLayout(); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(triangleChanged(int))); + + frame = new QGroupBox(tr("Square1")); + vbox2 = new QVBoxLayout(); sqr1Lbl = new QLabel("255"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, sqr1Lbl, "SDL.Sound.Square1Volume" ); + setSliderFromProperty(vslider, sqr1Lbl, "SDL.Sound.Square1Volume"); - vbox2->addWidget( sqr1Lbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(sqr1Lbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square1Changed(int)) ); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square1Changed(int))); - frame = new QGroupBox(tr("Square2")); - vbox2 = new QVBoxLayout(); + frame = new QGroupBox(tr("Square2")); + vbox2 = new QVBoxLayout(); sqr2Lbl = new QLabel("255"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, sqr2Lbl, "SDL.Sound.Square2Volume" ); + setSliderFromProperty(vslider, sqr2Lbl, "SDL.Sound.Square2Volume"); - vbox2->addWidget( sqr2Lbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(sqr2Lbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square2Changed(int)) ); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(square2Changed(int))); - frame = new QGroupBox(tr("Noise")); - vbox2 = new QVBoxLayout(); - nseLbl = new QLabel("255"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + frame = new QGroupBox(tr("Noise")); + vbox2 = new QVBoxLayout(); + nseLbl = new QLabel("255"); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, nseLbl, "SDL.Sound.NoiseVolume" ); + setSliderFromProperty(vslider, nseLbl, "SDL.Sound.NoiseVolume"); - vbox2->addWidget( nseLbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(nseLbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(noiseChanged(int)) ); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(noiseChanged(int))); - frame = new QGroupBox(tr("PCM")); - vbox2 = new QVBoxLayout(); - pcmLbl = new QLabel("255"); - vslider = new QSlider( Qt::Vertical ); - vslider->setMinimum( 0); + frame = new QGroupBox(tr("PCM")); + vbox2 = new QVBoxLayout(); + pcmLbl = new QLabel("255"); + vslider = new QSlider(Qt::Vertical); + vslider->setMinimum(0); vslider->setMaximum(255); - setSliderFromProperty( vslider, pcmLbl, "SDL.Sound.PCMVolume" ); + setSliderFromProperty(vslider, pcmLbl, "SDL.Sound.PCMVolume"); - vbox2->addWidget( pcmLbl ); - vbox2->addWidget( vslider ); - frame->setLayout( vbox2 ); - hbox2->addWidget( frame ); + vbox2->addWidget(pcmLbl); + vbox2->addWidget(vslider); + frame->setLayout(vbox2); + hbox2->addWidget(frame); - connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(pcmChanged(int)) ); + connect(vslider, SIGNAL(valueChanged(int)), this, SLOT(pcmChanged(int))); + + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + + mainLayout->addLayout(hbox1); + mainLayout->addLayout( hbox ); // Set Final Layout - setLayout( hbox1 ); + setLayout(mainLayout); } //---------------------------------------------------- ConsoleSndConfDialog_t::~ConsoleSndConfDialog_t(void) { - printf("Destroy Sound Config Window\n"); + printf("Destroy Sound Config Window\n"); } //---------------------------------------------------------------------------- void ConsoleSndConfDialog_t::closeEvent(QCloseEvent *event) { - printf("Sound Config Close Window Event\n"); - done(0); + printf("Sound Config Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void ConsoleSndConfDialog_t::closeWindow(void) { - //printf("Sound Close Window\n"); - done(0); + //printf("Sound Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- -void ConsoleSndConfDialog_t::setCheckBoxFromProperty( QCheckBox *cbx, const char *property ) +void ConsoleSndConfDialog_t::setCheckBoxFromProperty(QCheckBox *cbx, const char *property) { - int pval; - g_config->getOption (property, &pval); + int pval; + g_config->getOption(property, &pval); - cbx->setCheckState( pval ? Qt::Checked : Qt::Unchecked ); + cbx->setCheckState(pval ? Qt::Checked : Qt::Unchecked); } //---------------------------------------------------- -void ConsoleSndConfDialog_t::setComboBoxFromProperty( QComboBox *cbx, const char *property ) +void ConsoleSndConfDialog_t::setComboBoxFromProperty(QComboBox *cbx, const char *property) { - int i, pval; - g_config->getOption (property, &pval); + int i, pval; + g_config->getOption(property, &pval); - for (i=0; icount(); i++) + for (i = 0; i < cbx->count(); i++) { - if ( pval == cbx->itemData(i).toInt() ) + if (pval == cbx->itemData(i).toInt()) { - cbx->setCurrentIndex(i); break; + cbx->setCurrentIndex(i); + break; } } } //---------------------------------------------------- -void ConsoleSndConfDialog_t::setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property ) +void ConsoleSndConfDialog_t::setSliderFromProperty(QSlider *slider, QLabel *lbl, const char *property) { - int pval; + int pval; char stmp[32]; - g_config->getOption (property, &pval); - slider->setValue( pval ); - sprintf( stmp, "%i", pval ); - lbl->setText( stmp ); + g_config->getOption(property, &pval); + slider->setValue(pval); + sprintf(stmp, "%i", pval); + lbl->setText(stmp); } //---------------------------------------------------- void ConsoleSndConfDialog_t::bufSizeChanged(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); bufSizeLabel->setText(stmp); - g_config->setOption ("SDL.Sound.BufSize", value); + g_config->setOption("SDL.Sound.BufSize", value); // reset sound subsystem for changes to take effect - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - KillSound (); - InitSound (); + KillSound(); + InitSound(); fceuWrapperUnLock(); } } @@ -310,15 +324,15 @@ void ConsoleSndConfDialog_t::volumeChanged(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); volLbl->setText(stmp); - g_config->setOption ("SDL.Sound.Volume", value); + g_config->setOption("SDL.Sound.Volume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetSoundVolume (value); + FCEUI_SetSoundVolume(value); fceuWrapperUnLock(); } } @@ -327,15 +341,15 @@ void ConsoleSndConfDialog_t::triangleChanged(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); triLbl->setText(stmp); - g_config->setOption ("SDL.Sound.TriangleVolume", value); + g_config->setOption("SDL.Sound.TriangleVolume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetTriangleVolume (value); + FCEUI_SetTriangleVolume(value); fceuWrapperUnLock(); } } @@ -344,15 +358,15 @@ void ConsoleSndConfDialog_t::square1Changed(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); sqr1Lbl->setText(stmp); - g_config->setOption ("SDL.Sound.Square1Volume", value); + g_config->setOption("SDL.Sound.Square1Volume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetSquare1Volume (value); + FCEUI_SetSquare1Volume(value); fceuWrapperUnLock(); } } @@ -361,15 +375,15 @@ void ConsoleSndConfDialog_t::square2Changed(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); sqr2Lbl->setText(stmp); - g_config->setOption ("SDL.Sound.Square2Volume", value); + g_config->setOption("SDL.Sound.Square2Volume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetSquare2Volume (value); + FCEUI_SetSquare2Volume(value); fceuWrapperUnLock(); } } @@ -378,15 +392,15 @@ void ConsoleSndConfDialog_t::noiseChanged(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); nseLbl->setText(stmp); - g_config->setOption ("SDL.Sound.NoiseVolume", value); + g_config->setOption("SDL.Sound.NoiseVolume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetNoiseVolume (value); + FCEUI_SetNoiseVolume(value); fceuWrapperUnLock(); } } @@ -395,41 +409,41 @@ void ConsoleSndConfDialog_t::pcmChanged(int value) { char stmp[32]; - sprintf( stmp, "%i", value ); + sprintf(stmp, "%i", value); pcmLbl->setText(stmp); - g_config->setOption ("SDL.Sound.PCMVolume", value); + g_config->setOption("SDL.Sound.PCMVolume", value); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetPCMVolume (value); + FCEUI_SetPCMVolume(value); fceuWrapperUnLock(); } } //---------------------------------------------------- void ConsoleSndConfDialog_t::enaSoundStateChange(int value) { - if ( value ) + if (value) { int last_soundopt; - g_config->getOption ("SDL.Sound", &last_soundopt); - g_config->setOption ("SDL.Sound", 1); + g_config->getOption("SDL.Sound", &last_soundopt); + g_config->setOption("SDL.Sound", 1); fceuWrapperLock(); if (GameInfo && !last_soundopt) { - InitSound (); + InitSound(); } fceuWrapperUnLock(); } else { - g_config->setOption ("SDL.Sound", 0); + g_config->setOption("SDL.Sound", 0); fceuWrapperLock(); - KillSound (); + KillSound(); fceuWrapperUnLock(); } } @@ -438,66 +452,66 @@ void ConsoleSndConfDialog_t::enaSoundLowPassChange(int value) { if (value) { - g_config->setOption ("SDL.Sound.LowPass", 1); + g_config->setOption("SDL.Sound.LowPass", 1); fceuWrapperLock(); - FCEUI_SetLowPass (1); + FCEUI_SetLowPass(1); fceuWrapperUnLock(); } else { - g_config->setOption ("SDL.Sound.LowPass", 0); + g_config->setOption("SDL.Sound.LowPass", 0); fceuWrapperLock(); - FCEUI_SetLowPass (0); + FCEUI_SetLowPass(0); fceuWrapperUnLock(); } - g_config->save (); + g_config->save(); } //---------------------------------------------------- void ConsoleSndConfDialog_t::swapDutyCallback(int value) { if (value) { - g_config->setOption ("SDL.SwapDuty", 1); + g_config->setOption("SDL.SwapDuty", 1); swapDuty = 1; } else { - g_config->setOption ("SDL.SwapDuty", 0); + g_config->setOption("SDL.SwapDuty", 0); swapDuty = 0; } - g_config->save (); + g_config->save(); } //---------------------------------------------------- void ConsoleSndConfDialog_t::soundQualityChanged(int index) { //printf("Sound Quality: %i : %i \n", index, qualitySelect->itemData(index).toInt() ); - g_config->setOption ("SDL.Sound.Quality", qualitySelect->itemData(index).toInt() ); + g_config->setOption("SDL.Sound.Quality", qualitySelect->itemData(index).toInt()); // reset sound subsystem for changes to take effect - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - KillSound (); - InitSound (); + KillSound(); + InitSound(); fceuWrapperUnLock(); } - g_config->save (); + g_config->save(); } //---------------------------------------------------- void ConsoleSndConfDialog_t::soundRateChanged(int index) { //printf("Sound Rate: %i : %i \n", index, rateSelect->itemData(index).toInt() ); - g_config->setOption ("SDL.Sound.Rate", rateSelect->itemData(index).toInt() ); + g_config->setOption("SDL.Sound.Rate", rateSelect->itemData(index).toInt()); // reset sound subsystem for changes to take effect - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - KillSound (); - InitSound (); + KillSound(); + InitSound(); fceuWrapperUnLock(); } - g_config->save (); + g_config->save(); } //---------------------------------------------------- diff --git a/src/drivers/Qt/ConsoleSoundConf.h b/src/drivers/Qt/ConsoleSoundConf.h index 40f8de1f..92bf677e 100644 --- a/src/drivers/Qt/ConsoleSoundConf.h +++ b/src/drivers/Qt/ConsoleSoundConf.h @@ -18,48 +18,47 @@ class ConsoleSndConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - ConsoleSndConfDialog_t(QWidget *parent = 0); - ~ConsoleSndConfDialog_t(void); +public: + ConsoleSndConfDialog_t(QWidget *parent = 0); + ~ConsoleSndConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QCheckBox *enaChkbox; - QCheckBox *enaLowPass; - QCheckBox *swapDutyChkbox; - QComboBox *qualitySelect; - QComboBox *rateSelect; - QSlider *bufSizeSlider; - QLabel *bufSizeLabel; - QLabel *volLbl; - QLabel *triLbl; - QLabel *sqr1Lbl; - QLabel *sqr2Lbl; - QLabel *nseLbl; - QLabel *pcmLbl; + QCheckBox *enaChkbox; + QCheckBox *enaLowPass; + QCheckBox *swapDutyChkbox; + QComboBox *qualitySelect; + QComboBox *rateSelect; + QSlider *bufSizeSlider; + QLabel *bufSizeLabel; + QLabel *volLbl; + QLabel *triLbl; + QLabel *sqr1Lbl; + QLabel *sqr2Lbl; + QLabel *nseLbl; + QLabel *pcmLbl; - void setCheckBoxFromProperty( QCheckBox *cbx, const char *property ); - void setComboBoxFromProperty( QComboBox *cbx, const char *property ); - void setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property ); - - private slots: - void closeWindow(void); - void bufSizeChanged(int value); - void volumeChanged(int value); - void triangleChanged(int value); - void square1Changed(int value); - void square2Changed(int value); - void noiseChanged(int value); - void pcmChanged(int value); - void enaSoundStateChange(int value); - void enaSoundLowPassChange(int value); - void swapDutyCallback(int value); - void soundQualityChanged(int index); - void soundRateChanged(int index); + void setCheckBoxFromProperty(QCheckBox *cbx, const char *property); + void setComboBoxFromProperty(QComboBox *cbx, const char *property); + void setSliderFromProperty(QSlider *slider, QLabel *lbl, const char *property); +private slots: + void closeWindow(void); + void bufSizeChanged(int value); + void volumeChanged(int value); + void triangleChanged(int value); + void square1Changed(int value); + void square2Changed(int value); + void noiseChanged(int value); + void pcmChanged(int value); + void enaSoundStateChange(int value); + void enaSoundLowPassChange(int value); + void swapDutyCallback(int value); + void soundQualityChanged(int index); + void soundRateChanged(int index); }; #endif diff --git a/src/drivers/Qt/FrameTimingStats.cpp b/src/drivers/Qt/FrameTimingStats.cpp index 205906e5..73ffaadd 100644 --- a/src/drivers/Qt/FrameTimingStats.cpp +++ b/src/drivers/Qt/FrameTimingStats.cpp @@ -39,118 +39,127 @@ //---------------------------------------------------------------------------- FrameTimingDialog_t::FrameTimingDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout, *vbox; QHBoxLayout *hbox; QTreeWidgetItem *item; - QPushButton *resetBtn; + QPushButton *resetBtn, *closeButton; struct frameTimingStat_t stats; - getFrameTimingStats( &stats ); + getFrameTimingStats(&stats); setWindowTitle("Frame Timing Statistics"); - resize( 512, 512 ); + resize(512, 512); mainLayout = new QVBoxLayout(); - vbox = new QVBoxLayout(); - statFrame = new QGroupBox( tr("Timing Statistics") ); - statFrame->setLayout( vbox ); + vbox = new QVBoxLayout(); + statFrame = new QGroupBox(tr("Timing Statistics")); + statFrame->setLayout(vbox); tree = new QTreeWidget(); - vbox->addWidget( tree ); + vbox->addWidget(tree); tree->setColumnCount(4); item = new QTreeWidgetItem(); - item->setText( 0, tr( "Parameter" ) ); - item->setText( 1, tr( "Target" ) ); - item->setText( 2, tr( "Current" ) ); - item->setText( 3, tr( "Minimum" ) ); - item->setText( 4, tr( "Maximum" ) ); - item->setTextAlignment( 0, Qt::AlignLeft); - item->setTextAlignment( 1, Qt::AlignCenter); - item->setTextAlignment( 2, Qt::AlignCenter); - item->setTextAlignment( 3, Qt::AlignCenter); - item->setTextAlignment( 4, Qt::AlignCenter); + item->setText(0, tr("Parameter")); + item->setText(1, tr("Target")); + item->setText(2, tr("Current")); + item->setText(3, tr("Minimum")); + item->setText(4, tr("Maximum")); + item->setTextAlignment(0, Qt::AlignLeft); + item->setTextAlignment(1, Qt::AlignCenter); + item->setTextAlignment(2, Qt::AlignCenter); + item->setTextAlignment(3, Qt::AlignCenter); + item->setTextAlignment(4, Qt::AlignCenter); - tree->setHeaderItem( item ); - tree->header()->setSectionResizeMode( QHeaderView::Stretch ); - tree->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); + tree->setHeaderItem(item); + tree->header()->setSectionResizeMode(QHeaderView::Stretch); + tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - frameTimeAbs = new QTreeWidgetItem(); - frameTimeDel = new QTreeWidgetItem(); - frameTimeWork = new QTreeWidgetItem(); - frameTimeIdle = new QTreeWidgetItem(); + frameTimeAbs = new QTreeWidgetItem(); + frameTimeDel = new QTreeWidgetItem(); + frameTimeWork = new QTreeWidgetItem(); + frameTimeIdle = new QTreeWidgetItem(); frameTimeWorkPct = new QTreeWidgetItem(); frameTimeIdlePct = new QTreeWidgetItem(); - frameLateCount = new QTreeWidgetItem(); + frameLateCount = new QTreeWidgetItem(); - tree->addTopLevelItem( frameTimeAbs ); - tree->addTopLevelItem( frameTimeDel ); - tree->addTopLevelItem( frameTimeWork ); - tree->addTopLevelItem( frameTimeIdle ); - tree->addTopLevelItem( frameTimeWorkPct ); - tree->addTopLevelItem( frameTimeIdlePct ); - tree->addTopLevelItem( frameLateCount ); + tree->addTopLevelItem(frameTimeAbs); + tree->addTopLevelItem(frameTimeDel); + tree->addTopLevelItem(frameTimeWork); + tree->addTopLevelItem(frameTimeIdle); + tree->addTopLevelItem(frameTimeWorkPct); + tree->addTopLevelItem(frameTimeIdlePct); + tree->addTopLevelItem(frameLateCount); - frameTimeAbs->setFlags( Qt::ItemIsEnabled | Qt::ItemNeverHasChildren ); - frameTimeDel->setFlags( Qt::ItemIsEnabled | Qt::ItemNeverHasChildren ); + frameTimeAbs->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren); + frameTimeDel->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren); - frameTimeAbs->setText( 0, tr("Frame Period ms") ); - frameTimeDel->setText( 0, tr("Frame Delta ms") ); - frameTimeWork->setText( 0, tr("Frame Work ms") ); - frameTimeIdle->setText( 0, tr("Frame Idle ms") ); - frameTimeWorkPct->setText( 0, tr("Frame Work %") ); - frameTimeIdlePct->setText( 0, tr("Frame Idle %") ); - frameLateCount->setText( 0, tr("Frame Late Count") ); + frameTimeAbs->setText(0, tr("Frame Period ms")); + frameTimeDel->setText(0, tr("Frame Delta ms")); + frameTimeWork->setText(0, tr("Frame Work ms")); + frameTimeIdle->setText(0, tr("Frame Idle ms")); + frameTimeWorkPct->setText(0, tr("Frame Work %")); + frameTimeIdlePct->setText(0, tr("Frame Idle %")); + frameLateCount->setText(0, tr("Frame Late Count")); - frameTimeAbs->setTextAlignment( 0, Qt::AlignLeft); - frameTimeDel->setTextAlignment( 0, Qt::AlignLeft); - frameTimeWork->setTextAlignment( 0, Qt::AlignLeft); - frameTimeIdle->setTextAlignment( 0, Qt::AlignLeft); - frameTimeWorkPct->setTextAlignment( 0, Qt::AlignLeft); - frameTimeIdlePct->setTextAlignment( 0, Qt::AlignLeft); - frameLateCount->setTextAlignment( 0, Qt::AlignLeft); + frameTimeAbs->setTextAlignment(0, Qt::AlignLeft); + frameTimeDel->setTextAlignment(0, Qt::AlignLeft); + frameTimeWork->setTextAlignment(0, Qt::AlignLeft); + frameTimeIdle->setTextAlignment(0, Qt::AlignLeft); + frameTimeWorkPct->setTextAlignment(0, Qt::AlignLeft); + frameTimeIdlePct->setTextAlignment(0, Qt::AlignLeft); + frameLateCount->setTextAlignment(0, Qt::AlignLeft); - for (int i=0; i<4; i++) + for (int i = 0; i < 4; i++) { - frameTimeAbs->setTextAlignment( i+1, Qt::AlignCenter); - frameTimeDel->setTextAlignment( i+1, Qt::AlignCenter); - frameTimeWork->setTextAlignment( i+1, Qt::AlignCenter); - frameTimeIdle->setTextAlignment( i+1, Qt::AlignCenter); - frameTimeWorkPct->setTextAlignment( i+1, Qt::AlignCenter); - frameTimeIdlePct->setTextAlignment( i+1, Qt::AlignCenter); - frameLateCount->setTextAlignment( i+1, Qt::AlignCenter); + frameTimeAbs->setTextAlignment(i + 1, Qt::AlignCenter); + frameTimeDel->setTextAlignment(i + 1, Qt::AlignCenter); + frameTimeWork->setTextAlignment(i + 1, Qt::AlignCenter); + frameTimeIdle->setTextAlignment(i + 1, Qt::AlignCenter); + frameTimeWorkPct->setTextAlignment(i + 1, Qt::AlignCenter); + frameTimeIdlePct->setTextAlignment(i + 1, Qt::AlignCenter); + frameLateCount->setTextAlignment(i + 1, Qt::AlignCenter); } - hbox = new QHBoxLayout(); - timingEnable = new QCheckBox( tr("Enable Timing Statistics Calculations") ); - resetBtn = new QPushButton( tr("Reset") ); + hbox = new QHBoxLayout(); + timingEnable = new QCheckBox(tr("Enable Timing Statistics Calculations")); + resetBtn = new QPushButton(tr("Reset")); + resetBtn->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton)); - timingEnable->setChecked( stats.enabled ); - statFrame->setEnabled( stats.enabled ); + timingEnable->setChecked(stats.enabled); + statFrame->setEnabled(stats.enabled); - hbox->addWidget( timingEnable ); - hbox->addWidget( resetBtn ); + hbox->addWidget(timingEnable); + hbox->addWidget(resetBtn); - connect( timingEnable, SIGNAL(stateChanged(int)), this, SLOT(timingEnableChanged(int)) ); - connect( resetBtn , SIGNAL(clicked(void)) , this, SLOT(resetTimingClicked(void)) ); + connect(timingEnable, SIGNAL(stateChanged(int)), this, SLOT(timingEnableChanged(int))); + connect(resetBtn, SIGNAL(clicked(void)), this, SLOT(resetTimingClicked(void))); - mainLayout->addLayout( hbox ); - mainLayout->addWidget( statFrame ); + mainLayout->addLayout(hbox); + mainLayout->addWidget(statFrame); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); updateTimingStats(); - updateTimer = new QTimer( this ); + updateTimer = new QTimer(this); - connect( updateTimer, &QTimer::timeout, this, &FrameTimingDialog_t::updatePeriodic ); - - updateTimer->start( 200 ); // 5hz + connect(updateTimer, &QTimer::timeout, this, &FrameTimingDialog_t::updatePeriodic); + updateTimer->start(200); // 5hz } //---------------------------------------------------------------------------- FrameTimingDialog_t::~FrameTimingDialog_t(void) @@ -179,92 +188,92 @@ void FrameTimingDialog_t::updateTimingStats(void) char stmp[128]; struct frameTimingStat_t stats; - getFrameTimingStats( &stats ); + getFrameTimingStats(&stats); // Absolute - sprintf( stmp, "%.3f", stats.frameTimeAbs.tgt * 1e3 ); - frameTimeAbs->setText( 1, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeAbs.tgt * 1e3); + frameTimeAbs->setText(1, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeAbs.cur * 1e3 ); - frameTimeAbs->setText( 2, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeAbs.cur * 1e3); + frameTimeAbs->setText(2, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeAbs.min * 1e3 ); - frameTimeAbs->setText( 3, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeAbs.min * 1e3); + frameTimeAbs->setText(3, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeAbs.max * 1e3 ); - frameTimeAbs->setText( 4, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeAbs.max * 1e3); + frameTimeAbs->setText(4, tr(stmp)); // Delta - sprintf( stmp, "%.3f", stats.frameTimeDel.tgt * 1e3 ); - frameTimeDel->setText( 1, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeDel.tgt * 1e3); + frameTimeDel->setText(1, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeDel.cur * 1e3 ); - frameTimeDel->setText( 2, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeDel.cur * 1e3); + frameTimeDel->setText(2, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeDel.min * 1e3 ); - frameTimeDel->setText( 3, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeDel.min * 1e3); + frameTimeDel->setText(3, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeDel.max * 1e3 ); - frameTimeDel->setText( 4, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeDel.max * 1e3); + frameTimeDel->setText(4, tr(stmp)); // Work - sprintf( stmp, "lt %.3f", stats.frameTimeWork.tgt * 1e3 ); - frameTimeWork->setText( 1, tr(stmp) ); + sprintf(stmp, "lt %.3f", stats.frameTimeWork.tgt * 1e3); + frameTimeWork->setText(1, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeWork.cur * 1e3 ); - frameTimeWork->setText( 2, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeWork.cur * 1e3); + frameTimeWork->setText(2, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeWork.min * 1e3 ); - frameTimeWork->setText( 3, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeWork.min * 1e3); + frameTimeWork->setText(3, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeWork.max * 1e3 ); - frameTimeWork->setText( 4, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeWork.max * 1e3); + frameTimeWork->setText(4, tr(stmp)); // Idle - sprintf( stmp, "gt %.3f", stats.frameTimeIdle.tgt * 1e3 ); - frameTimeIdle->setText( 1, tr(stmp) ); + sprintf(stmp, "gt %.3f", stats.frameTimeIdle.tgt * 1e3); + frameTimeIdle->setText(1, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeIdle.cur * 1e3 ); - frameTimeIdle->setText( 2, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeIdle.cur * 1e3); + frameTimeIdle->setText(2, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeIdle.min * 1e3 ); - frameTimeIdle->setText( 3, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeIdle.min * 1e3); + frameTimeIdle->setText(3, tr(stmp)); - sprintf( stmp, "%.3f", stats.frameTimeIdle.max * 1e3 ); - frameTimeIdle->setText( 4, tr(stmp) ); + sprintf(stmp, "%.3f", stats.frameTimeIdle.max * 1e3); + frameTimeIdle->setText(4, tr(stmp)); // Work % - sprintf( stmp, "lt %.1f", 100.0 * stats.frameTimeWork.tgt / stats.frameTimeAbs.tgt ); - frameTimeWorkPct->setText( 1, tr(stmp) ); + sprintf(stmp, "lt %.1f", 100.0 * stats.frameTimeWork.tgt / stats.frameTimeAbs.tgt); + frameTimeWorkPct->setText(1, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.cur / stats.frameTimeAbs.tgt ); - frameTimeWorkPct->setText( 2, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.cur / stats.frameTimeAbs.tgt); + frameTimeWorkPct->setText(2, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.min / stats.frameTimeAbs.tgt ); - frameTimeWorkPct->setText( 3, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.min / stats.frameTimeAbs.tgt); + frameTimeWorkPct->setText(3, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeWork.max / stats.frameTimeAbs.tgt ); - frameTimeWorkPct->setText( 4, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeWork.max / stats.frameTimeAbs.tgt); + frameTimeWorkPct->setText(4, tr(stmp)); // Idle % - sprintf( stmp, "gt %.1f", 100.0 * stats.frameTimeIdle.tgt / stats.frameTimeAbs.tgt ); - frameTimeIdlePct->setText( 1, tr(stmp) ); + sprintf(stmp, "gt %.1f", 100.0 * stats.frameTimeIdle.tgt / stats.frameTimeAbs.tgt); + frameTimeIdlePct->setText(1, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.cur / stats.frameTimeAbs.tgt ); - frameTimeIdlePct->setText( 2, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.cur / stats.frameTimeAbs.tgt); + frameTimeIdlePct->setText(2, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.min / stats.frameTimeAbs.tgt ); - frameTimeIdlePct->setText( 3, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.min / stats.frameTimeAbs.tgt); + frameTimeIdlePct->setText(3, tr(stmp)); - sprintf( stmp, "%.1f", 100.0 * stats.frameTimeIdle.max / stats.frameTimeAbs.tgt ); - frameTimeIdlePct->setText( 4, tr(stmp) ); + sprintf(stmp, "%.1f", 100.0 * stats.frameTimeIdle.max / stats.frameTimeAbs.tgt); + frameTimeIdlePct->setText(4, tr(stmp)); // Late Count - sprintf( stmp, "%u", stats.lateCount ); - frameLateCount->setText( 1, tr("0") ); - frameLateCount->setText( 2, tr(stmp) ); + sprintf(stmp, "%u", stats.lateCount); + frameLateCount->setText(1, tr("0")); + frameLateCount->setText(2, tr(stmp)); - statFrame->setEnabled( stats.enabled ); + statFrame->setEnabled(stats.enabled); tree->viewport()->update(); } @@ -276,7 +285,7 @@ void FrameTimingDialog_t::updatePeriodic(void) //---------------------------------------------------------------------------- void FrameTimingDialog_t::timingEnableChanged(int state) { - setFrameTimingEnable( state != Qt::Unchecked ); + setFrameTimingEnable(state != Qt::Unchecked); } //---------------------------------------------------------------------------- void FrameTimingDialog_t::resetTimingClicked(void) diff --git a/src/drivers/Qt/FrameTimingStats.h b/src/drivers/Qt/FrameTimingStats.h index 8014fce5..3b59962f 100644 --- a/src/drivers/Qt/FrameTimingStats.h +++ b/src/drivers/Qt/FrameTimingStats.h @@ -21,36 +21,35 @@ class FrameTimingDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - FrameTimingDialog_t(QWidget *parent = 0); - ~FrameTimingDialog_t(void); +public: + FrameTimingDialog_t(QWidget *parent = 0); + ~FrameTimingDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QTimer *updateTimer; - QCheckBox *timingEnable; - QTreeWidgetItem *frameTimeAbs; - QTreeWidgetItem *frameTimeDel; - QTreeWidgetItem *frameTimeWork; - QTreeWidgetItem *frameTimeWorkPct; - QTreeWidgetItem *frameTimeIdle; - QTreeWidgetItem *frameTimeIdlePct; - QTreeWidgetItem *frameLateCount; - QGroupBox *statFrame; + QTimer *updateTimer; + QCheckBox *timingEnable; + QTreeWidgetItem *frameTimeAbs; + QTreeWidgetItem *frameTimeDel; + QTreeWidgetItem *frameTimeWork; + QTreeWidgetItem *frameTimeWorkPct; + QTreeWidgetItem *frameTimeIdle; + QTreeWidgetItem *frameTimeIdlePct; + QTreeWidgetItem *frameLateCount; + QGroupBox *statFrame; - QTreeWidget *tree; + QTreeWidget *tree; - private: - void updateTimingStats(void); - - public slots: - void closeWindow(void); - private slots: - void updatePeriodic(void); - void resetTimingClicked(void); - void timingEnableChanged(int state); +private: + void updateTimingStats(void); +public slots: + void closeWindow(void); +private slots: + void updatePeriodic(void); + void resetTimingClicked(void); + void timingEnableChanged(int state); }; diff --git a/src/drivers/Qt/GamePadConf.cpp b/src/drivers/Qt/GamePadConf.cpp index cd5a497f..0497289a 100644 --- a/src/drivers/Qt/GamePadConf.cpp +++ b/src/drivers/Qt/GamePadConf.cpp @@ -37,10 +37,11 @@ struct GamePadConfigLocalData_t { - std::string guid; - std::string profile; + std::string guid; + std::string profile; - struct { + struct + { char needsSave; @@ -48,12 +49,11 @@ struct GamePadConfigLocalData_t GamePadConfigLocalData_t(void) { - for (int i=0; icloseWindow(); + gamePadConfWin->closeWindow(); } return 0; } //---------------------------------------------------- GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) - : QDialog( parent ) - , changeSeqStatus(0) + : QDialog(parent), changeSeqStatus(0) { //QWidget *mainWidget; QVBoxLayout *mainLayoutV; @@ -105,7 +104,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) QPushButton *changeSeqButton = nullptr; QPushButton *clearButton[GAMEPAD_NUM_BUTTONS]; QScrollArea *scroll = NULL; - QStyle *style; + QStyle *style; std::string prefix; char stmp[256]; bool useScroll = false; @@ -117,7 +116,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) // Ensure that joysticks are enabled, no harm calling init again. InitJoysticks(); - if ( useScroll ) + if (useScroll) { scroll = new QScrollArea(this); } @@ -125,268 +124,267 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) portNum = 0; buttonConfigStatus = 1; - - inputTimer = new QTimer( this ); - - connect( inputTimer, &QTimer::timeout, this, &GamePadConfDialog_t::updatePeriodic ); - - setWindowTitle( tr("GamePad Config") ); + + inputTimer = new QTimer(this); + + connect(inputTimer, &QTimer::timeout, this, &GamePadConfDialog_t::updatePeriodic); + + setWindowTitle(tr("GamePad Config")); grid1 = new QGridLayout(); - grid1->setColumnStretch( 0, 1 ); - grid1->setColumnStretch( 1, 10 ); + grid1->setColumnStretch(0, 1); + grid1->setColumnStretch(1, 10); hbox1 = new QHBoxLayout(); hbox2 = new QHBoxLayout(); label = new QLabel(tr("Console Port:")); portSel = new QComboBox(); - grid1->addWidget( label , 0, 0 ); - grid1->addWidget( portSel, 0, 1 ); + grid1->addWidget(label, 0, 0); + grid1->addWidget(portSel, 0, 1); - portSel->addItem( tr("1"), 0 ); - portSel->addItem( tr("2"), 1 ); - portSel->addItem( tr("3"), 2 ); - portSel->addItem( tr("4"), 3 ); + portSel->addItem(tr("1"), 0); + portSel->addItem(tr("2"), 1); + portSel->addItem(tr("3"), 2); + portSel->addItem(tr("4"), 3); label = new QLabel(tr("Device:")); devSel = new QComboBox(); - grid1->addWidget( label , 1, 0 ); - grid1->addWidget( devSel, 1, 1 ); + grid1->addWidget(label, 1, 0); + grid1->addWidget(devSel, 1, 1); - devSel->addItem( tr("Keyboard"), -1 ); + devSel->addItem(tr("Keyboard"), -1); - for (int i=0; iisConnected() ) + if (js->isConnected()) { - sprintf( stmp, "%i: %s", i, js->getName() ); - devSel->addItem( tr(stmp), i ); + sprintf(stmp, "%i: %s", i, js->getName()); + devSel->addItem(tr(stmp), i); } } } - for (int i=0; icount(); i++) + for (int i = 0; i < devSel->count(); i++) { - if ( devSel->itemData(i).toInt() == GamePad[portNum].getDeviceIndex() ) + if (devSel->itemData(i).toInt() == GamePad[portNum].getDeviceIndex()) { - devSel->setCurrentIndex( i ); + devSel->setCurrentIndex(i); } } label = new QLabel(tr("GUID:")); guidLbl = new QLabel(); - grid1->addWidget( label , 2, 0 ); - grid1->addWidget( guidLbl, 2, 1 ); + grid1->addWidget(label, 2, 0); + grid1->addWidget(guidLbl, 2, 1); - guidLbl->setText( GamePad[portNum].getGUID() ); + guidLbl->setText(GamePad[portNum].getGUID()); frame1 = new QGroupBox(tr("Mapping Profile:")); //grid = new QGridLayout(); - vbox = new QVBoxLayout(); - + vbox = new QVBoxLayout(); + //frame1->setLayout( grid ); - frame1->setLayout( vbox ); + frame1->setLayout(vbox); hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); + vbox->addLayout(hbox); mapSel = new QComboBox(); - hbox->addWidget( mapSel ); + hbox->addWidget(mapSel); - mapSel->setWhatsThis( tr("Combo box for selection of a saved button mapping profile for the selected device")); - mapSel->addItem( tr("default"), 0 ); + mapSel->setWhatsThis(tr("Combo box for selection of a saved button mapping profile for the selected device")); + mapSel->addItem(tr("default"), 0); hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); + vbox->addLayout(hbox); - applyProfileButton = new QPushButton( tr("Load") ); + applyProfileButton = new QPushButton(tr("Load")); applyProfileButton->setWhatsThis(tr("Sets Current Active Map to the Selected Profile")); - applyProfileButton->setIcon( style->standardIcon( QStyle::SP_DialogApplyButton ) ); - hbox->addWidget( applyProfileButton ); + applyProfileButton->setIcon(style->standardIcon(QStyle::SP_DialogApplyButton)); + hbox->addWidget(applyProfileButton); - saveProfileButton = new QPushButton( tr("Save") ); + saveProfileButton = new QPushButton(tr("Save")); saveProfileButton->setWhatsThis(tr("Stores Current Active Map to the Selected Profile")); - saveProfileButton->setIcon( style->standardIcon( QStyle::SP_DialogSaveButton ) ); - hbox->addWidget( saveProfileButton ); + saveProfileButton->setIcon(style->standardIcon(QStyle::SP_DialogSaveButton)); + hbox->addWidget(saveProfileButton); hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); + vbox->addLayout(hbox); - newProfileButton = new QPushButton( tr("New") ); + newProfileButton = new QPushButton(tr("New")); newProfileButton->setWhatsThis(tr("Create a New Map Profile")); - newProfileButton->setIcon( style->standardIcon( QStyle::SP_FileIcon ) ); - hbox->addWidget( newProfileButton ); + newProfileButton->setIcon(style->standardIcon(QStyle::SP_FileIcon)); + hbox->addWidget(newProfileButton); - removeProfileButton = new QPushButton( tr("Delete") ); + removeProfileButton = new QPushButton(tr("Delete")); removeProfileButton->setWhatsThis(tr("Deletes the Selected Map Profile")); - removeProfileButton->setIcon( style->standardIcon( QStyle::SP_TrashIcon ) ); - hbox->addWidget( removeProfileButton ); + removeProfileButton->setIcon(style->standardIcon(QStyle::SP_TrashIcon)); + hbox->addWidget(removeProfileButton); mapMsg = new QLabel(); vbox->addWidget(mapMsg); - efs_chkbox = new QCheckBox( tr("Enable Four Score") ); - udlr_chkbox = new QCheckBox( tr("Allow Up+Down/Left+Right") ); + efs_chkbox = new QCheckBox(tr("Enable Four Score")); + udlr_chkbox = new QCheckBox(tr("Allow Up+Down/Left+Right")); int fourScore; g_config->getOption("SDL.FourScore", &fourScore); - efs_chkbox->setChecked( fourScore ); + efs_chkbox->setChecked(fourScore); int opposite_dirs; g_config->getOption("SDL.Input.EnableOppositeDirectionals", &opposite_dirs); - udlr_chkbox->setChecked( opposite_dirs ); + udlr_chkbox->setChecked(opposite_dirs); frame2 = new QGroupBox(tr("Current Active Button Mappings:")); - grid = new QGridLayout(); - + grid = new QGridLayout(); + //grid-> setHorizontalSpacing(10); - - frame2->setLayout( grid ); - - for (int i=0; isetLayout(grid); + + for (int i = 0; i < GAMEPAD_NUM_BUTTONS; i++) { char text[64]; - QLabel *buttonName; - - sprintf( text, "%s:", GamePadNames[i] ); - - //hbox2 = new QHBoxLayout(); - + QLabel *buttonName; + + sprintf(text, "%s:", GamePadNames[i]); + + //hbox2 = new QHBoxLayout(); + //hbox2->setAlignment(Qt::AlignCenter); - - buttonName = new QLabel(tr(text)); - keyName[i] = new QLabel(); - //keyState[i] = new QLabel( tr("F") ); - //label = new QLabel( tr("State:") ); - button[i] = new GamePadConfigButton_t(i); - clearButton[i] = new QPushButton( tr("Clear") ); - - grid->addWidget( buttonName , i, 0, Qt::AlignCenter ); - grid->addWidget( keyName[i] , i, 1, Qt::AlignCenter ); + + buttonName = new QLabel(tr(text)); + keyName[i] = new QLabel(); + //keyState[i] = new QLabel( tr("F") ); + //label = new QLabel( tr("State:") ); + button[i] = new GamePadConfigButton_t(i); + clearButton[i] = new QPushButton(tr("Clear")); + + grid->addWidget(buttonName, i, 0, Qt::AlignCenter); + grid->addWidget(keyName[i], i, 1, Qt::AlignCenter); //grid->addWidget( label , i, 2, Qt::AlignCenter ); //grid->addWidget( keyState[i] , i, 3, Qt::AlignCenter ); - grid->addWidget( button[i] , i, 2, Qt::AlignCenter ); - grid->addWidget( clearButton[i], i, 3, Qt::AlignCenter ); + grid->addWidget(button[i], i, 2, Qt::AlignCenter); + grid->addWidget(clearButton[i], i, 3, Qt::AlignCenter); } updateCntrlrDpy(); - - clearAllButton = new QPushButton(tr("Clear All")); - closebutton = new QPushButton(tr("Close")); - changeSeqButton = new QPushButton(tr("Change Sequentially")); - clearAllButton->setIcon( style->standardIcon( QStyle::SP_LineEditClearButton ) ); - closebutton->setIcon( style->standardIcon( QStyle::SP_DialogCloseButton ) ); - changeSeqButton->setIcon( style->standardIcon( QStyle::QStyle::SP_ArrowDown ) ); + clearAllButton = new QPushButton(tr("Clear All")); + closebutton = new QPushButton(tr("Close")); + changeSeqButton = new QPushButton(tr("Change Sequentially")); - hbox1->addWidget( clearAllButton ); - hbox1->addWidget( changeSeqButton ); - hbox1->addWidget( closebutton ); + clearAllButton->setIcon(style->standardIcon(QStyle::SP_LineEditClearButton)); + closebutton->setIcon(style->standardIcon(QStyle::SP_DialogCloseButton)); + changeSeqButton->setIcon(style->standardIcon(QStyle::QStyle::SP_ArrowDown)); - connect(button[0], SIGNAL(clicked()), this, SLOT(changeButton0(void)) ); - connect(button[1], SIGNAL(clicked()), this, SLOT(changeButton1(void)) ); - connect(button[2], SIGNAL(clicked()), this, SLOT(changeButton2(void)) ); - connect(button[3], SIGNAL(clicked()), this, SLOT(changeButton3(void)) ); - connect(button[4], SIGNAL(clicked()), this, SLOT(changeButton4(void)) ); - connect(button[5], SIGNAL(clicked()), this, SLOT(changeButton5(void)) ); - connect(button[6], SIGNAL(clicked()), this, SLOT(changeButton6(void)) ); - connect(button[7], SIGNAL(clicked()), this, SLOT(changeButton7(void)) ); - connect(button[8], SIGNAL(clicked()), this, SLOT(changeButton8(void)) ); - connect(button[9], SIGNAL(clicked()), this, SLOT(changeButton9(void)) ); + hbox1->addWidget(clearAllButton); + hbox1->addWidget(changeSeqButton); + hbox1->addWidget(closebutton); - connect(clearButton[0], SIGNAL(clicked()), this, SLOT(clearButton0(void)) ); - connect(clearButton[1], SIGNAL(clicked()), this, SLOT(clearButton1(void)) ); - connect(clearButton[2], SIGNAL(clicked()), this, SLOT(clearButton2(void)) ); - connect(clearButton[3], SIGNAL(clicked()), this, SLOT(clearButton3(void)) ); - connect(clearButton[4], SIGNAL(clicked()), this, SLOT(clearButton4(void)) ); - connect(clearButton[5], SIGNAL(clicked()), this, SLOT(clearButton5(void)) ); - connect(clearButton[6], SIGNAL(clicked()), this, SLOT(clearButton6(void)) ); - connect(clearButton[7], SIGNAL(clicked()), this, SLOT(clearButton7(void)) ); - connect(clearButton[8], SIGNAL(clicked()), this, SLOT(clearButton8(void)) ); - connect(clearButton[9], SIGNAL(clicked()), this, SLOT(clearButton9(void)) ); - - connect(newProfileButton , SIGNAL(clicked()), this, SLOT(newProfileCallback(void)) ); - connect(applyProfileButton , SIGNAL(clicked()), this, SLOT(loadProfileCallback(void)) ); - connect(saveProfileButton , SIGNAL(clicked()), this, SLOT(saveProfileCallback(void)) ); - connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(deleteProfileCallback(void)) ); - - connect(clearAllButton , SIGNAL(clicked()), this, SLOT(clearAllCallback(void)) ); - connect(closebutton , SIGNAL(clicked()), this, SLOT(closeWindow(void)) ); - connect(changeSeqButton , SIGNAL(clicked()), this, SLOT(changeSequentallyCallback(void)) ); - - connect(portSel , SIGNAL(activated(int)), this, SLOT(portSelect(int)) ); - connect(devSel , SIGNAL(activated(int)), this, SLOT(deviceSelect(int)) ); - connect(efs_chkbox , SIGNAL(stateChanged(int)), this, SLOT(ena4score(int)) ); - connect(udlr_chkbox, SIGNAL(stateChanged(int)), this, SLOT(oppDirEna(int)) ); + connect(button[0], SIGNAL(clicked()), this, SLOT(changeButton0(void))); + connect(button[1], SIGNAL(clicked()), this, SLOT(changeButton1(void))); + connect(button[2], SIGNAL(clicked()), this, SLOT(changeButton2(void))); + connect(button[3], SIGNAL(clicked()), this, SLOT(changeButton3(void))); + connect(button[4], SIGNAL(clicked()), this, SLOT(changeButton4(void))); + connect(button[5], SIGNAL(clicked()), this, SLOT(changeButton5(void))); + connect(button[6], SIGNAL(clicked()), this, SLOT(changeButton6(void))); + connect(button[7], SIGNAL(clicked()), this, SLOT(changeButton7(void))); + connect(button[8], SIGNAL(clicked()), this, SLOT(changeButton8(void))); + connect(button[9], SIGNAL(clicked()), this, SLOT(changeButton9(void))); + + connect(clearButton[0], SIGNAL(clicked()), this, SLOT(clearButton0(void))); + connect(clearButton[1], SIGNAL(clicked()), this, SLOT(clearButton1(void))); + connect(clearButton[2], SIGNAL(clicked()), this, SLOT(clearButton2(void))); + connect(clearButton[3], SIGNAL(clicked()), this, SLOT(clearButton3(void))); + connect(clearButton[4], SIGNAL(clicked()), this, SLOT(clearButton4(void))); + connect(clearButton[5], SIGNAL(clicked()), this, SLOT(clearButton5(void))); + connect(clearButton[6], SIGNAL(clicked()), this, SLOT(clearButton6(void))); + connect(clearButton[7], SIGNAL(clicked()), this, SLOT(clearButton7(void))); + connect(clearButton[8], SIGNAL(clicked()), this, SLOT(clearButton8(void))); + connect(clearButton[9], SIGNAL(clicked()), this, SLOT(clearButton9(void))); + + connect(newProfileButton, SIGNAL(clicked()), this, SLOT(newProfileCallback(void))); + connect(applyProfileButton, SIGNAL(clicked()), this, SLOT(loadProfileCallback(void))); + connect(saveProfileButton, SIGNAL(clicked()), this, SLOT(saveProfileCallback(void))); + connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(deleteProfileCallback(void))); + + connect(clearAllButton, SIGNAL(clicked()), this, SLOT(clearAllCallback(void))); + connect(closebutton, SIGNAL(clicked()), this, SLOT(closeWindow(void))); + connect(changeSeqButton, SIGNAL(clicked()), this, SLOT(changeSequentallyCallback(void))); + + connect(portSel, SIGNAL(activated(int)), this, SLOT(portSelect(int))); + connect(devSel, SIGNAL(activated(int)), this, SLOT(deviceSelect(int))); + connect(efs_chkbox, SIGNAL(stateChanged(int)), this, SLOT(ena4score(int))); + connect(udlr_chkbox, SIGNAL(stateChanged(int)), this, SLOT(oppDirEna(int))); mainLayoutH = new QHBoxLayout(); mainLayoutV = new QVBoxLayout(); - vbox1 = new QVBoxLayout(); - vbox2 = new QVBoxLayout(); + vbox1 = new QVBoxLayout(); + vbox2 = new QVBoxLayout(); - hbox2->addWidget( efs_chkbox ); - hbox2->addWidget( udlr_chkbox ); + hbox2->addWidget(efs_chkbox); + hbox2->addWidget(udlr_chkbox); - vbox1->addLayout( grid1 ); + vbox1->addLayout(grid1); //vbox1->addLayout( hbox2 ); //vbox1->addLayout( hbox3 ); - vbox1->addWidget( frame1); - vbox1->addLayout( hbox2 ); + vbox1->addWidget(frame1); + vbox1->addLayout(hbox2); - vbox2->addWidget( frame2 ); - vbox2->addLayout( hbox1 ); + vbox2->addWidget(frame2); + vbox2->addLayout(hbox1); gpView = new GamePadView_t(this); - mainLayoutV->addLayout( vbox1 ); - mainLayoutV->addWidget( gpView ); + mainLayoutV->addLayout(vbox1); + mainLayoutV->addWidget(gpView); - mainLayoutH->addLayout( mainLayoutV ); - mainLayoutH->addLayout( vbox2 ); + mainLayoutH->addLayout(mainLayoutV); + mainLayoutH->addLayout(vbox2); - mainWidget->setLayout( mainLayoutH ); - mainWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + mainWidget->setLayout(mainLayoutH); + mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - if ( useScroll ) + if (useScroll) { - scroll->setWidget( mainWidget ); + scroll->setWidget(mainWidget); scroll->setWidgetResizable(true); - scroll->setSizeAdjustPolicy( QAbstractScrollArea::AdjustToContents ); - scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); - scroll->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); + scroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } - + QHBoxLayout *dialogLayout = new QHBoxLayout(); - if ( useScroll ) + if (useScroll) { - dialogLayout->addWidget( scroll ); + dialogLayout->addWidget(scroll); } else { - dialogLayout->addWidget( mainWidget ); + dialogLayout->addWidget(mainWidget); } - setLayout( dialogLayout ); + setLayout(dialogLayout); - inputTimer->start( 33 ); // 30hz + inputTimer->start(33); // 30hz - for (int i=0; igetOption(prefix + "Profile", &lcl[i].profile ); + g_config->getOption(prefix + "Profile", &lcl[i].profile); - lcl[i].guid.assign( GamePad[i].getGUID() ); + lcl[i].guid.assign(GamePad[i].getGUID()); } loadMapList(); - } //---------------------------------------------------- @@ -406,114 +404,116 @@ void GamePadConfDialog_t::resizeEvent(QResizeEvent *event) void GamePadConfDialog_t::keyPressEvent(QKeyEvent *event) { - //printf("GamePad Window Key Press: 0x%x \n", event->key() ); - pushKeyEvent( event, 1 ); + //printf("GamePad Window Key Press: 0x%x \n", event->key() ); + pushKeyEvent(event, 1); } void GamePadConfDialog_t::keyReleaseEvent(QKeyEvent *event) { - //printf("GamePad Window Key Release: 0x%x \n", event->key() ); - pushKeyEvent( event, 0 ); + //printf("GamePad Window Key Release: 0x%x \n", event->key() ); + pushKeyEvent(event, 0); } //---------------------------------------------------- void GamePadConfDialog_t::loadMapList(void) { - QDir dir; - QStringList filters, fileList; - const char *baseDir = FCEUI_GetBaseDirectory(); - const char *guid; - std::string path; + QDir dir; + QStringList filters, fileList; + const char *baseDir = FCEUI_GetBaseDirectory(); + const char *guid; + std::string path; std::string prefix, mapName; - int index, devIdx; - jsDev_t *js; - size_t n=0; + int index, devIdx; + jsDev_t *js; + size_t n = 0; char stmp[256]; - index = devSel->currentIndex(); + index = devSel->currentIndex(); devIdx = devSel->itemData(index).toInt(); - if ( devIdx < 0 ) - { - guid = "keyboard"; - } - else - { - js = getJoystickDevice( devIdx ); + if (devIdx < 0) + { + guid = "keyboard"; + } + else + { + js = getJoystickDevice(devIdx); - guid = js->getGUID(); - } + guid = js->getGUID(); + } - if ( guid == NULL ) - { - return; - } + if (guid == NULL) + { + return; + } - path = std::string(baseDir) + "/input/" + std::string(guid); + path = std::string(baseDir) + "/input/" + std::string(guid); - dir.setPath( QString::fromStdString(path) ); + dir.setPath(QString::fromStdString(path)); - filters << "*.txt"; - dir.setNameFilters(filters); - - fileList = dir.entryList( filters, QDir::Files, QDir::NoSort ); + filters << "*.txt"; + dir.setNameFilters(filters); - sprintf( stmp, "SDL.Input.GamePad.%u.", portNum ); + fileList = dir.entryList(filters, QDir::Files, QDir::NoSort); + + sprintf(stmp, "SDL.Input.GamePad.%u.", portNum); prefix = stmp; - g_config->getOption(prefix + "Profile", &mapName ); + g_config->getOption(prefix + "Profile", &mapName); - mapSel->clear(); - mapSel->addItem( tr("default"), 0 ); n=1; + mapSel->clear(); + mapSel->addItem(tr("default"), 0); + n = 1; - for (size_t i=0; i < fileList.size(); i++) - { - size_t suffixIdx; - std::string fileName = fileList[i].toStdString(); + for (size_t i = 0; i < fileList.size(); i++) + { + size_t suffixIdx; + std::string fileName = fileList[i].toStdString(); - suffixIdx = fileName.find_last_of('.'); + suffixIdx = fileName.find_last_of('.'); - fileName.erase( suffixIdx ); + fileName.erase(suffixIdx); - //printf("File: %s \n", fileName.c_str() ); - // + //printf("File: %s \n", fileName.c_str() ); + // - if ( fileName.compare("default") == 0 ) continue; + if (fileName.compare("default") == 0) + continue; - mapSel->addItem( tr(fileName.c_str()), (int)i+1 ); + mapSel->addItem(tr(fileName.c_str()), (int)i + 1); - if ( mapName.compare( fileName ) == 0 ) + if (mapName.compare(fileName) == 0) { mapSel->setCurrentIndex(n); } n++; - } + } } //---------------------------------------------------- void GamePadConfDialog_t::updateCntrlrDpy(void) { - char keyNameStr[128]; + char keyNameStr[128]; - for (int i=0; isetText( tr(keyNameStr) ); + keyName[i]->setText(tr(keyNameStr)); //if ( lcl[portNum].btn[i].needsSave ) //{ - // keyName[i]->setStyleSheet("color: red;"); + // keyName[i]->setStyleSheet("color: red;"); //} //else //{ - // keyName[i]->setStyleSheet("color: black;"); + // keyName[i]->setStyleSheet("color: black;"); //} } } @@ -524,16 +524,16 @@ void GamePadConfDialog_t::portSelect(int index) portNum = index; updateCntrlrDpy(); - for (int i=0; icount(); i++) + for (int i = 0; i < devSel->count(); i++) { - if ( devSel->itemData(i).toInt() == GamePad[portNum].getDeviceIndex() ) + if (devSel->itemData(i).toInt() == GamePad[portNum].getDeviceIndex()) { - devSel->setCurrentIndex( i ); + devSel->setCurrentIndex(i); } } - guidLbl->setText( GamePad[portNum].getGUID() ); + guidLbl->setText(GamePad[portNum].getGUID()); - loadMapList(); + loadMapList(); } //---------------------------------------------------- void GamePadConfDialog_t::deviceSelect(int index) @@ -541,25 +541,25 @@ void GamePadConfDialog_t::deviceSelect(int index) jsDev_t *js; int devIdx = devSel->itemData(index).toInt(); - js = getJoystickDevice( devIdx ); + js = getJoystickDevice(devIdx); - if ( js != NULL ) + if (js != NULL) { - if ( js->isConnected() ) + if (js->isConnected()) { - guidLbl->setText( js->getGUID() ); + guidLbl->setText(js->getGUID()); } } else { guidLbl->setText(""); } - GamePad[portNum].setDeviceIndex( devIdx ); + GamePad[portNum].setDeviceIndex(devIdx); - lcl[portNum].guid.assign( GamePad[portNum].getGUID() ); + lcl[portNum].guid.assign(GamePad[portNum].getGUID()); lcl[portNum].profile.assign("default"); - loadMapList(); + loadMapList(); updateCntrlrDpy(); } @@ -580,195 +580,195 @@ void GamePadConfDialog_t::oppDirEna(int state) //---------------------------------------------------- void GamePadConfDialog_t::changeButton(int padNo, int x) { - //char buf[256]; - //std::string prefix; - const char *keyNameStr; + //char buf[256]; + //std::string prefix; + const char *keyNameStr; - if ( buttonConfigStatus == 2 ) - { - buttonConfigStatus = 0; - return; - } - buttonConfigStatus = 2; + if (buttonConfigStatus == 2) + { + buttonConfigStatus = 0; + return; + } + buttonConfigStatus = 2; - ButtonConfigBegin (); + ButtonConfigBegin(); - button[x]->setText("Waiting" ); - button[x]->setStyleSheet("background-color: green; color: white;"); + button[x]->setText("Waiting"); + button[x]->setStyleSheet("background-color: green; color: white;"); - DWaitButton (NULL, &GamePad[padNo].bmap[x], &buttonConfigStatus ); + DWaitButton(NULL, &GamePad[padNo].bmap[x], &buttonConfigStatus); - button[x]->setText("Change"); - button[x]->setStyleSheet(""); + button[x]->setText("Change"); + button[x]->setStyleSheet(""); - if (buttonConfigStatus != 0) - { - keyNameStr = ButtonName( &GamePad[padNo].bmap[x] ); - keyName[x]->setText( keyNameStr ); - lcl[padNo].btn[x].needsSave = 1; - } + if (buttonConfigStatus != 0) + { + keyNameStr = ButtonName(&GamePad[padNo].bmap[x]); + keyName[x]->setText(keyNameStr); + lcl[padNo].btn[x].needsSave = 1; + } - ButtonConfigEnd (); + ButtonConfigEnd(); - buttonConfigStatus = 1; + buttonConfigStatus = 1; } //---------------------------------------------------- -void GamePadConfDialog_t::clearButton( int padNo, int x ) +void GamePadConfDialog_t::clearButton(int padNo, int x) { GamePad[padNo].bmap[x].ButtonNum = -1; - keyName[x]->setText(""); + keyName[x]->setText(""); lcl[padNo].btn[x].needsSave = 1; } //---------------------------------------------------- void GamePadConfDialog_t::closeEvent(QCloseEvent *event) { - if (changeSeqStatus != 0) - { - // change sequentially still in progress - // now try to abort its progress - changeSeqStatus = -1; - // ... out from waiting gamepad button event loop - buttonConfigStatus = 0; - // and ignore this event - event->ignore(); - return; - } + if (changeSeqStatus != 0) + { + // change sequentially still in progress + // now try to abort its progress + changeSeqStatus = -1; + // ... out from waiting gamepad button event loop + buttonConfigStatus = 0; + // and ignore this event + event->ignore(); + return; + } promptToSave(); - printf("GamePad Close Window Event\n"); - buttonConfigStatus = 0; - done(0); + printf("GamePad Close Window Event\n"); + buttonConfigStatus = 0; + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void GamePadConfDialog_t::closeWindow(void) { - if (changeSeqStatus != 0) - { - // change sequentially still in progress - // now try to abort its progress - changeSeqStatus = -1; - // ... out from waiting gamepad button event loop - buttonConfigStatus = 0; - return; - } + if (changeSeqStatus != 0) + { + // change sequentially still in progress + // now try to abort its progress + changeSeqStatus = -1; + // ... out from waiting gamepad button event loop + buttonConfigStatus = 0; + return; + } - promptToSave(); + promptToSave(); - printf("Close Window\n"); - buttonConfigStatus = 0; - done(0); + printf("Close Window\n"); + buttonConfigStatus = 0; + done(0); deleteLater(); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton0(void) { - changeButton( portNum, 0 ); + changeButton(portNum, 0); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton1(void) { - changeButton( portNum, 1 ); + changeButton(portNum, 1); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton2(void) { - changeButton( portNum, 2 ); + changeButton(portNum, 2); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton3(void) { - changeButton( portNum, 3 ); + changeButton(portNum, 3); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton4(void) { - changeButton( portNum, 4 ); + changeButton(portNum, 4); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton5(void) { - changeButton( portNum, 5 ); + changeButton(portNum, 5); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton6(void) { - changeButton( portNum, 6 ); + changeButton(portNum, 6); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton7(void) { - changeButton( portNum, 7 ); + changeButton(portNum, 7); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton8(void) { - changeButton( portNum, 8 ); + changeButton(portNum, 8); } //---------------------------------------------------- void GamePadConfDialog_t::changeButton9(void) { - changeButton( portNum, 9 ); + changeButton(portNum, 9); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton0(void) { - clearButton( portNum, 0 ); + clearButton(portNum, 0); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton1(void) { - clearButton( portNum, 1 ); + clearButton(portNum, 1); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton2(void) { - clearButton( portNum, 2 ); + clearButton(portNum, 2); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton3(void) { - clearButton( portNum, 3 ); + clearButton(portNum, 3); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton4(void) { - clearButton( portNum, 4 ); + clearButton(portNum, 4); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton5(void) { - clearButton( portNum, 5 ); + clearButton(portNum, 5); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton6(void) { - clearButton( portNum, 6 ); + clearButton(portNum, 6); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton7(void) { - clearButton( portNum, 7 ); + clearButton(portNum, 7); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton8(void) { - clearButton( portNum, 8 ); + clearButton(portNum, 8); } //---------------------------------------------------- void GamePadConfDialog_t::clearButton9(void) { - clearButton( portNum, 9 ); + clearButton(portNum, 9); } //---------------------------------------------------- void GamePadConfDialog_t::clearAllCallback(void) { - for (int i=0; icurrentText().toStdString(); + mapName = mapSel->currentText().toStdString(); - g_config->setOption(prefix + "DeviceGUID", GamePad[portNum].getGUID() ); - g_config->setOption(prefix + "Profile" , mapName.c_str() ); + g_config->setOption(prefix + "DeviceGUID", GamePad[portNum].getGUID()); + g_config->setOption(prefix + "Profile", mapName.c_str()); - for (i=0; isave(); } //---------------------------------------------------- -void GamePadConfDialog_t::createNewProfile( const char *name ) +void GamePadConfDialog_t::createNewProfile(const char *name) { char stmp[256]; - //printf("Creating: %s \n", name ); + //printf("Creating: %s \n", name ); - GamePad[portNum].createProfile(name); + GamePad[portNum].createProfile(name); - mapSel->addItem( tr(name) ); + mapSel->addItem(tr(name)); - mapSel->setCurrentIndex( mapSel->count() - 1 ); + mapSel->setCurrentIndex(mapSel->count() - 1); saveConfig(); - sprintf( stmp, "Mapping Created: %s/%s \n", GamePad[portNum].getGUID(), name ); - mapMsg->setText( tr(stmp) ); + sprintf(stmp, "Mapping Created: %s/%s \n", GamePad[portNum].getGUID(), name); + mapMsg->setText(tr(stmp)); } //---------------------------------------------------- void GamePadConfDialog_t::newProfileCallback(void) { - int ret; - QInputDialog dialog(this); + int ret; + QInputDialog dialog(this); - dialog.setWindowTitle( tr("New Profile") ); - dialog.setLabelText( tr("Specify New Profile Name") ); - dialog.setOkButtonText( tr("Create") ); + dialog.setWindowTitle(tr("New Profile")); + dialog.setLabelText(tr("Specify New Profile Name")); + dialog.setOkButtonText(tr("Create")); - ret = dialog.exec(); + ret = dialog.exec(); - if ( QDialog::Accepted == ret ) - { - createNewProfile( dialog.textValue().toStdString().c_str() ); - } + if (QDialog::Accepted == ret) + { + createNewProfile(dialog.textValue().toStdString().c_str()); + } } //---------------------------------------------------- void GamePadConfDialog_t::loadProfileCallback(void) { - char stmp[256]; - int index, devIdx, ret; - std::string mapName; + char stmp[256]; + int index, devIdx, ret; + std::string mapName; - index = devSel->currentIndex(); + index = devSel->currentIndex(); devIdx = devSel->itemData(index).toInt(); - mapName = mapSel->currentText().toStdString(); + mapName = mapSel->currentText().toStdString(); - GamePad[portNum].setDeviceIndex( devIdx ); + GamePad[portNum].setDeviceIndex(devIdx); - if ( mapName.compare("default") == 0 ) - { - ret =GamePad[portNum].loadDefaults(); - } - else - { - ret = GamePad[portNum].loadProfile( mapName.c_str() ); - } - if ( ret == 0 ) - { + if (mapName.compare("default") == 0) + { + ret = GamePad[portNum].loadDefaults(); + } + else + { + ret = GamePad[portNum].loadProfile(mapName.c_str()); + } + if (ret == 0) + { saveConfig(); - sprintf( stmp, "Mapping Loaded: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() ); - } - else - { - sprintf( stmp, "Error: Failed to Load Mapping: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() ); - } - mapMsg->setText( tr(stmp) ); + sprintf(stmp, "Mapping Loaded: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str()); + } + else + { + sprintf(stmp, "Error: Failed to Load Mapping: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str()); + } + mapMsg->setText(tr(stmp)); updateCntrlrDpy(); } //---------------------------------------------------- void GamePadConfDialog_t::saveProfileCallback(void) { - int ret; - std::string mapName; - char stmp[256]; + int ret; + std::string mapName; + char stmp[256]; - mapName = mapSel->currentText().toStdString(); + mapName = mapSel->currentText().toStdString(); - ret = GamePad[portNum].saveCurrentMapToFile( mapName.c_str() ); + ret = GamePad[portNum].saveCurrentMapToFile(mapName.c_str()); - if ( ret == 0 ) - { + if (ret == 0) + { saveConfig(); - sprintf( stmp, "Mapping Saved: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() ); - } - else - { - sprintf( stmp, "Error: Failed to Save Mapping: %s \n", mapName.c_str() ); - } - mapMsg->setText( tr(stmp) ); - + sprintf(stmp, "Mapping Saved: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str()); + } + else + { + sprintf(stmp, "Error: Failed to Save Mapping: %s \n", mapName.c_str()); + } + mapMsg->setText(tr(stmp)); } //---------------------------------------------------- void GamePadConfDialog_t::deleteProfileCallback(void) { - int ret; - std::string mapName; - char stmp[256]; + int ret; + std::string mapName; + char stmp[256]; - mapName = mapSel->currentText().toStdString(); + mapName = mapSel->currentText().toStdString(); - ret = GamePad[portNum].deleteMapping( mapName.c_str() ); + ret = GamePad[portNum].deleteMapping(mapName.c_str()); - if ( ret == 0 ) - { - sprintf( stmp, "Mapping Deleted: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() ); - } - else - { - sprintf( stmp, "Error: Failed to Delete Mapping: %s \n", mapName.c_str() ); - } - mapMsg->setText( tr(stmp) ); + if (ret == 0) + { + sprintf(stmp, "Mapping Deleted: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str()); + } + else + { + sprintf(stmp, "Error: Failed to Delete Mapping: %s \n", mapName.c_str()); + } + mapMsg->setText(tr(stmp)); - loadMapList(); + loadMapList(); } //---------------------------------------------------- void GamePadConfDialog_t::promptToSave(void) { - int i,j,n; + int i, j, n; std::string msg; QMessageBox msgBox(this); char saveRequired = 0; char padNeedsSave[GAMEPAD_NUM_DEVICES]; char stmp[256]; - n=0; - for (i=0; i 1) ? 's':' '); + sprintf(stmp, "Warning: Gamepad mappings have not been saved for port%c ", (n > 1) ? 's' : ' '); - msg.assign( stmp ); + msg.assign(stmp); - j=n; - for (i=0; i 1 ) + if (j > 1) { msg.append(", "); - } - else if ( j == 1 ) + } + else if (j == 1) { msg.append(" and "); } @@ -966,8 +965,8 @@ void GamePadConfDialog_t::promptToSave(void) } msg.append("."); - msgBox.setIcon( QMessageBox::Warning ); - msgBox.setText( tr(msg.c_str()) ); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr(msg.c_str())); msgBox.show(); msgBox.exec(); @@ -975,7 +974,7 @@ void GamePadConfDialog_t::promptToSave(void) //---------------------------------------------------- void GamePadConfDialog_t::updatePeriodic(void) { - for (int i=0; isetText( tr(txt) ); //keyState[i]->setStyleSheet( style ); - if ( lcl[portNum].btn[i].needsSave ) + if (lcl[portNum].btn[i].needsSave) { keyName[i]->setStyleSheet("color: red;"); } @@ -1003,12 +1002,12 @@ void GamePadConfDialog_t::updatePeriodic(void) int fourScore; g_config->getOption("SDL.FourScore", &fourScore); - if ( fourScore != efs_chkbox->isChecked() ) + if (fourScore != efs_chkbox->isChecked()) { - efs_chkbox->setChecked( fourScore ); + efs_chkbox->setChecked(fourScore); } - gpView->setPort( portNum ); + gpView->setPort(portNum); gpView->update(); } @@ -1016,27 +1015,30 @@ void GamePadConfDialog_t::updatePeriodic(void) void GamePadConfDialog_t::changeSequentallyCallback(void) { - // get pointer to button - QPushButton* changeSeqButton = qobject_cast(sender()); - if (!changeSeqButton) - return; + // get pointer to button + QPushButton *changeSeqButton = qobject_cast(sender()); + if (!changeSeqButton) + return; - // disable it for user input - changeSeqButton->setEnabled(false); + // disable it for user input + changeSeqButton->setEnabled(false); - // change button for every button on gamepad - for (int i = 0; i < GAMEPAD_NUM_BUTTONS; ++i) - { - changeSeqStatus += 1; - if (this->isHidden()) break; - changeButton(portNum, i); - if (this->isHidden()) break; - // abort? - if (changeSeqStatus == -1) break; - } - // return all back - changeSeqStatus = 0; - changeSeqButton->setEnabled(true); + // change button for every button on gamepad + for (int i = 0; i < GAMEPAD_NUM_BUTTONS; ++i) + { + changeSeqStatus += 1; + if (this->isHidden()) + break; + changeButton(portNum, i); + if (this->isHidden()) + break; + // abort? + if (changeSeqStatus == -1) + break; + } + // return all back + changeSeqStatus = 0; + changeSeqButton->setEnabled(true); } //---------------------------------------------------- @@ -1048,41 +1050,41 @@ GamePadConfigButton_t::GamePadConfigButton_t(int i) //---------------------------------------------------- void GamePadConfigButton_t::keyPressEvent(QKeyEvent *event) { - //printf("GamePad Button Key Press: 0x%x \n", event->key() ); - pushKeyEvent( event, 1 ); + //printf("GamePad Button Key Press: 0x%x \n", event->key() ); + pushKeyEvent(event, 1); } void GamePadConfigButton_t::keyReleaseEvent(QKeyEvent *event) { - //printf("GamePad Button Key Release: 0x%x \n", event->key() ); - pushKeyEvent( event, 0 ); + //printf("GamePad Button Key Release: 0x%x \n", event->key() ); + pushKeyEvent(event, 0); } //---------------------------------------------------- //---------------------------------------------------- // Game Pad Viewer //---------------------------------------------------- //---------------------------------------------------- -GamePadView_t::GamePadView_t( QWidget *parent) +GamePadView_t::GamePadView_t(QWidget *parent) : QWidget(parent) { this->setFocusPolicy(Qt::StrongFocus); - this->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setMouseTracking(true); - viewWidth = 128*3; + viewWidth = 128 * 3; viewHeight = 128; - setMinimumWidth( viewWidth ); - setMinimumHeight( viewHeight ); + setMinimumWidth(viewWidth); + setMinimumHeight(viewHeight); font.setFamily("Courier New"); - font.setStyle( QFont::StyleNormal ); - font.setStyleHint( QFont::Monospace ); + font.setStyle(QFont::StyleNormal); + font.setStyleHint(QFont::Monospace); QFontMetrics fm(font); - #if QT_VERSION > QT_VERSION_CHECK(5, 11, 0) +#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0) pxCharWidth = fm.horizontalAdvance(QLatin1Char('2')); - #else +#else pxCharWidth = fm.width(QLatin1Char('2')); - #endif +#endif pxCharHeight = fm.lineSpacing(); portNum = 0; @@ -1090,7 +1092,6 @@ GamePadView_t::GamePadView_t( QWidget *parent) //---------------------------------------------------- GamePadView_t::~GamePadView_t(void) { - } //---------------------------------------------------- void GamePadView_t::setPort(int port) @@ -1100,7 +1101,7 @@ void GamePadView_t::setPort(int port) //---------------------------------------------------- void GamePadView_t::resizeEvent(QResizeEvent *event) { - viewWidth = event->size().width(); + viewWidth = event->size().width(); viewHeight = event->size().height(); //printf("%ix%i\n", event->size().width(), event->size().height() ); @@ -1108,37 +1109,35 @@ void GamePadView_t::resizeEvent(QResizeEvent *event) //---------------------------------------------------- void GamePadView_t::keyPressEvent(QKeyEvent *event) { - pushKeyEvent( event, 1 ); + pushKeyEvent(event, 1); } //---------------------------------------------------- void GamePadView_t::keyReleaseEvent(QKeyEvent *event) { - pushKeyEvent( event, 0 ); + pushKeyEvent(event, 0); } //---------------------------------------------------- void GamePadView_t::mouseMoveEvent(QMouseEvent *event) { - } //---------------------------------------------------- -void GamePadView_t::mousePressEvent(QMouseEvent * event) +void GamePadView_t::mousePressEvent(QMouseEvent *event) { - } //---------------------------------------------------- -void GamePadView_t::drawLetterOnButton( QPainter &painter, QRect &rect, QColor &color, int ch ) +void GamePadView_t::drawLetterOnButton(QPainter &painter, QRect &rect, QColor &color, int ch) { - int x,y; + int x, y; char c[2]; c[0] = ch; c[1] = 0; - x = rect.x() + (rect.width() - pxCharWidth) / 2; + x = rect.x() + (rect.width() - pxCharWidth) / 2; y = rect.y() + (rect.height() - pxCharHeight) / 2; - painter.setPen( color ); - painter.drawText( x, y+pxCharHeight, tr(c) ); + painter.setPen(color); + painter.drawText(x, y + pxCharHeight, tr(c)); } //---------------------------------------------------- void GamePadView_t::paintEvent(QPaintEvent *event) @@ -1146,157 +1145,157 @@ void GamePadView_t::paintEvent(QPaintEvent *event) int w, h, x, y, b = 5; int w3, bw, bh, ws, hs, ht, ws2; QPainter painter(this); - QColor white(255,255,255); - QColor black( 0, 0, 0); - QColor clear( 0, 0, 0, 0); - QColor gray (128,128,128); - QColor green( 0,255, 0); - QRect gp1, gp2; - QRect upBtn, dnBtn, lBtn, rBtn, cBtn; - QRect selBtn, stBtn; - QRect bBtn, aBtn, tbBtn, taBtn, tBox; + QColor white(255, 255, 255); + QColor black(0, 0, 0); + QColor clear(0, 0, 0, 0); + QColor gray(128, 128, 128); + QColor green(0, 255, 0); + QRect gp1, gp2; + QRect upBtn, dnBtn, lBtn, rBtn, cBtn; + QRect selBtn, stBtn; + QRect bBtn, aBtn, tbBtn, taBtn, tBox; w = viewWidth; h = viewHeight; - if ( w > (3*h) ) + if (w > (3 * h)) { - w = 3*h; + w = 3 * h; } else { - h = w/3; + h = w / 3; } - x = (viewWidth - w) / 2; + x = (viewWidth - w) / 2; y = (viewHeight - h) / 2; - gp1.setRect( x, y, w, h ); - - painter.fillRect( gp1, gray ); + gp1.setRect(x, y, w, h); - x = x+b; - y = y+b; - w = w-(2*b); - h = h-(2*b); + painter.fillRect(gp1, gray); - gp2.setRect( x, y, w, h ); + x = x + b; + y = y + b; + w = w - (2 * b); + h = h - (2 * b); - painter.fillRect( gp2, black ); + gp2.setRect(x, y, w, h); + + painter.fillRect(gp2, black); w3 = w / 3; bw = w3 / 5; bh = bw; x = gp2.x() + bw; - y = gp2.y() + (h/5); + y = gp2.y() + (h / 5); - upBtn.setRect( x+bw , y , bw, bh ); - dnBtn.setRect( x+bw , y+(bh*2), bw, bh ); - lBtn.setRect( x , y+bh, bw, bh ); - rBtn.setRect( x+(bw*2) , y+bh, bw, bh ); - cBtn.setRect( x+bw , y+bh, bw, bh ); + upBtn.setRect(x + bw, y, bw, bh); + dnBtn.setRect(x + bw, y + (bh * 2), bw, bh); + lBtn.setRect(x, y + bh, bw, bh); + rBtn.setRect(x + (bw * 2), y + bh, bw, bh); + cBtn.setRect(x + bw, y + bh, bw, bh); - painter.fillRect( upBtn.x()-b, upBtn.y()-b, upBtn.width()+(2*b), 3*upBtn.height()+(2*b), gray ); - painter.fillRect( lBtn.x()-b , lBtn.y()-b, 3*lBtn.width()+(2*b), lBtn.height()+(2*b), gray ); + painter.fillRect(upBtn.x() - b, upBtn.y() - b, upBtn.width() + (2 * b), 3 * upBtn.height() + (2 * b), gray); + painter.fillRect(lBtn.x() - b, lBtn.y() - b, 3 * lBtn.width() + (2 * b), lBtn.height() + (2 * b), gray); - painter.fillRect( cBtn, black ); + painter.fillRect(cBtn, black); - if ( GamePad[portNum].bmap[4].state ) + if (GamePad[portNum].bmap[4].state) { - painter.fillRect( upBtn, green ); + painter.fillRect(upBtn, green); } else { - painter.fillRect( upBtn, black ); + painter.fillRect(upBtn, black); } - if ( GamePad[portNum].bmap[5].state ) + if (GamePad[portNum].bmap[5].state) { - painter.fillRect( dnBtn, green ); + painter.fillRect(dnBtn, green); } else { - painter.fillRect( dnBtn, black ); + painter.fillRect(dnBtn, black); } - if ( GamePad[portNum].bmap[6].state ) + if (GamePad[portNum].bmap[6].state) { - painter.fillRect( lBtn, green ); + painter.fillRect(lBtn, green); } else { - painter.fillRect( lBtn, black ); + painter.fillRect(lBtn, black); } - if ( GamePad[portNum].bmap[7].state ) + if (GamePad[portNum].bmap[7].state) { - painter.fillRect( rBtn, green ); + painter.fillRect(rBtn, green); } else { - painter.fillRect( rBtn, black ); + painter.fillRect(rBtn, black); } bw = w3 / 3; bh = bw / 2; x = gp2.x() + w3; - y = gp2.y() + (3*h/5); + y = gp2.y() + (3 * h / 5); - selBtn.setRect( x+(bw/3) , y , bw, bh ); - stBtn.setRect( x+(5*bw)/3, y , bw, bh ); + selBtn.setRect(x + (bw / 3), y, bw, bh); + stBtn.setRect(x + (5 * bw) / 3, y, bw, bh); - if ( GamePad[portNum].bmap[2].state ) + if (GamePad[portNum].bmap[2].state) { - painter.fillRect( selBtn, green ); + painter.fillRect(selBtn, green); } else { - painter.fillRect( selBtn, gray ); + painter.fillRect(selBtn, gray); } - if ( GamePad[portNum].bmap[3].state ) + if (GamePad[portNum].bmap[3].state) { - painter.fillRect( stBtn, green ); + painter.fillRect(stBtn, green); } else { - painter.fillRect( stBtn, gray ); + painter.fillRect(stBtn, gray); } //bw = w3 / 3; - bh = h / 3; + bh = h / 3; bw = bh; ht = pxCharHeight; - bh = (h-ht)/ 3; + bh = (h - ht) / 3; bw = bh; - hs = (ht-pxCharHeight)/2; - ws = (w3 - (5*pxCharWidth))/2; + hs = (ht - pxCharHeight) / 2; + ws = (w3 - (5 * pxCharWidth)) / 2; - painter.setPen( white ); + painter.setPen(white); - x = gp2.x() + (2*w3) + ws; - y = gp2.y() + (ht-hs); + x = gp2.x() + (2 * w3) + ws; + y = gp2.y() + (ht - hs); - painter.drawText( x, y, tr("Turbo") ); + painter.drawText(x, y, tr("Turbo")); - ws = (w3 - (2*bw)) / 3; - hs = (h - (2*bh) - ht) / 3; + ws = (w3 - (2 * bw)) / 3; + hs = (h - (2 * bh) - ht) / 3; ws2 = (ws / 2); - x = gp2.x() + (2*w3); - y = gp2.y() + (ht+hs); + x = gp2.x() + (2 * w3); + y = gp2.y() + (ht + hs); - tbBtn.setRect( x+ws , y , bw, bh ); - taBtn.setRect( x+bw+(2*ws), y , bw, bh ); + tbBtn.setRect(x + ws, y, bw, bh); + taBtn.setRect(x + bw + (2 * ws), y, bw, bh); - y = gp2.y() + (ht+bh+(2*hs)); + y = gp2.y() + (ht + bh + (2 * hs)); - bBtn.setRect( x+ws , y , bw, bh ); - aBtn.setRect( x+bw+(2*ws), y , bw, bh ); + bBtn.setRect(x + ws, y, bw, bh); + aBtn.setRect(x + bw + (2 * ws), y, bw, bh); - if ( GamePad[portNum].bmap[9].state ) + if (GamePad[portNum].bmap[9].state) { painter.setBrush(Qt::green); } @@ -1304,11 +1303,11 @@ void GamePadView_t::paintEvent(QPaintEvent *event) { painter.setBrush(Qt::red); } - painter.setPen( white ); - painter.drawEllipse( tbBtn ); - drawLetterOnButton( painter, tbBtn, black, 'B'); + painter.setPen(white); + painter.drawEllipse(tbBtn); + drawLetterOnButton(painter, tbBtn, black, 'B'); - if ( GamePad[portNum].bmap[8].state ) + if (GamePad[portNum].bmap[8].state) { painter.setBrush(Qt::green); } @@ -1316,11 +1315,11 @@ void GamePadView_t::paintEvent(QPaintEvent *event) { painter.setBrush(Qt::red); } - painter.setPen( white ); - painter.drawEllipse( taBtn ); - drawLetterOnButton( painter, taBtn, black, 'A'); + painter.setPen(white); + painter.drawEllipse(taBtn); + drawLetterOnButton(painter, taBtn, black, 'A'); - if ( GamePad[portNum].bmap[1].state ) + if (GamePad[portNum].bmap[1].state) { painter.setBrush(Qt::green); } @@ -1328,11 +1327,11 @@ void GamePadView_t::paintEvent(QPaintEvent *event) { painter.setBrush(Qt::red); } - painter.setPen( white ); - painter.drawEllipse( bBtn ); - drawLetterOnButton( painter, bBtn, black, 'B'); + painter.setPen(white); + painter.drawEllipse(bBtn); + drawLetterOnButton(painter, bBtn, black, 'B'); - if ( GamePad[portNum].bmap[0].state ) + if (GamePad[portNum].bmap[0].state) { painter.setBrush(Qt::green); } @@ -1340,18 +1339,18 @@ void GamePadView_t::paintEvent(QPaintEvent *event) { painter.setBrush(Qt::red); } - painter.setPen( white ); - painter.drawEllipse( aBtn ); - drawLetterOnButton( painter, aBtn, black, 'A'); + painter.setPen(white); + painter.drawEllipse(aBtn); + drawLetterOnButton(painter, aBtn, black, 'A'); painter.setBrush(clear); - tBox.setTop( gp2.y()+2 ); - tBox.setLeft( gp2.x()+(2*w3)+ws2 ); - tBox.setWidth( w3-ws ); - tBox.setBottom( taBtn.y() + (aBtn.y() - taBtn.y() + bh)/2 ); + tBox.setTop(gp2.y() + 2); + tBox.setLeft(gp2.x() + (2 * w3) + ws2); + tBox.setWidth(w3 - ws); + tBox.setBottom(taBtn.y() + (aBtn.y() - taBtn.y() + bh) / 2); - painter.setPen( white ); - painter.drawRect( tBox ); + painter.setPen(white); + painter.drawRect(tBox); } //---------------------------------------------------- diff --git a/src/drivers/Qt/GamePadConf.h b/src/drivers/Qt/GamePadConf.h index f3c2405d..42e60070 100644 --- a/src/drivers/Qt/GamePadConf.h +++ b/src/drivers/Qt/GamePadConf.h @@ -19,127 +19,128 @@ #include "Qt/main.h" class GamePadConfigButton_t : public QPushButton -{ - public: - GamePadConfigButton_t(int i); +{ +public: + GamePadConfigButton_t(int i); - protected: - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); - int idx; + int idx; }; class GamePadView_t : public QWidget { Q_OBJECT - public: - GamePadView_t( QWidget *parent = 0); - ~GamePadView_t(void); +public: + GamePadView_t(QWidget *parent = 0); + ~GamePadView_t(void); - void setPort( int port ); - protected: - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent * event); - //void contextMenuEvent(QContextMenuEvent *event); + void setPort(int port); - void drawLetterOnButton( QPainter &painter, QRect &rect, QColor &color, int ch ); +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + //void contextMenuEvent(QContextMenuEvent *event); - int portNum; - int viewWidth; - int viewHeight; - int pxCharWidth; - int pxCharHeight; + void drawLetterOnButton(QPainter &painter, QRect &rect, QColor &color, int ch); - QFont font; + int portNum; + int viewWidth; + int viewHeight; + int pxCharWidth; + int pxCharHeight; + + QFont font; }; class GamePadConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - GamePadConfDialog_t(QWidget *parent = 0); - ~GamePadConfDialog_t(void); +public: + GamePadConfDialog_t(QWidget *parent = 0); + ~GamePadConfDialog_t(void); - protected: - void resizeEvent(QResizeEvent *event); +protected: + void resizeEvent(QResizeEvent *event); - QWidget *mainWidget; - QTimer *inputTimer; - QComboBox *portSel; - QComboBox *devSel; - QComboBox *mapSel; - QComboBox *profSel; - QCheckBox *efs_chkbox; - QLabel *guidLbl; - QLabel *mapMsg; - QLabel *keyName[GAMEPAD_NUM_BUTTONS]; - QLabel *keyState[GAMEPAD_NUM_BUTTONS]; - GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS]; - GamePadView_t *gpView; + QWidget *mainWidget; + QTimer *inputTimer; + QComboBox *portSel; + QComboBox *devSel; + QComboBox *mapSel; + QComboBox *profSel; + QCheckBox *efs_chkbox; + QLabel *guidLbl; + QLabel *mapMsg; + QLabel *keyName[GAMEPAD_NUM_BUTTONS]; + QLabel *keyState[GAMEPAD_NUM_BUTTONS]; + GamePadConfigButton_t *button[GAMEPAD_NUM_BUTTONS]; + GamePadView_t *gpView; - int portNum; - int buttonConfigStatus; - int changeSeqStatus; // status of sequentally changing buttons mechanism - // 0 - we can start new change process - // 1-10 - changing in progress - // -1 - changing is aborted - - void changeButton( int port, int button ); - void clearButton( int port, int button ); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); - void closeEvent(QCloseEvent *bar); - private: - void updateCntrlrDpy(void); - void createNewProfile( const char *name ); - void loadMapList(void); - void saveConfig(void); - void promptToSave(void); + int portNum; + int buttonConfigStatus; + int changeSeqStatus; // status of sequentally changing buttons mechanism + // 0 - we can start new change process + // 1-10 - changing in progress + // -1 - changing is aborted - public slots: - void closeWindow(void); - private slots: - void changeButton0(void); - void changeButton1(void); - void changeButton2(void); - void changeButton3(void); - void changeButton4(void); - void changeButton5(void); - void changeButton6(void); - void changeButton7(void); - void changeButton8(void); - void changeButton9(void); - void clearButton0(void); - void clearButton1(void); - void clearButton2(void); - void clearButton3(void); - void clearButton4(void); - void clearButton5(void); - void clearButton6(void); - void clearButton7(void); - void clearButton8(void); - void clearButton9(void); - void clearAllCallback(void); - void ena4score(int state); - void oppDirEna(int state); - void portSelect(int index); - void deviceSelect(int index); - void newProfileCallback(void); - void loadProfileCallback(void); - void saveProfileCallback(void); - void deleteProfileCallback(void); - void updatePeriodic(void); - void changeSequentallyCallback(void); + void changeButton(int port, int button); + void clearButton(int port, int button); + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + void closeEvent(QCloseEvent *bar); +private: + void updateCntrlrDpy(void); + void createNewProfile(const char *name); + void loadMapList(void); + void saveConfig(void); + void promptToSave(void); + +public slots: + void closeWindow(void); +private slots: + void changeButton0(void); + void changeButton1(void); + void changeButton2(void); + void changeButton3(void); + void changeButton4(void); + void changeButton5(void); + void changeButton6(void); + void changeButton7(void); + void changeButton8(void); + void changeButton9(void); + void clearButton0(void); + void clearButton1(void); + void clearButton2(void); + void clearButton3(void); + void clearButton4(void); + void clearButton5(void); + void clearButton6(void); + void clearButton7(void); + void clearButton8(void); + void clearButton9(void); + void clearAllCallback(void); + void ena4score(int state); + void oppDirEna(int state); + void portSelect(int index); + void deviceSelect(int index); + void newProfileCallback(void); + void loadProfileCallback(void); + void saveProfileCallback(void); + void deleteProfileCallback(void); + void updatePeriodic(void); + void changeSequentallyCallback(void); }; -int openGamePadConfWindow( QWidget *parent ); +int openGamePadConfWindow(QWidget *parent); int closeGamePadConfWindow(void); diff --git a/src/drivers/Qt/GuiConf.cpp b/src/drivers/Qt/GuiConf.cpp index 6691b9f9..15af0aea 100644 --- a/src/drivers/Qt/GuiConf.cpp +++ b/src/drivers/Qt/GuiConf.cpp @@ -31,55 +31,67 @@ //---------------------------------------------------- GuiConfDialog_t::GuiConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { int useNativeFileDialogVal; int useNativeMenuBarVal; QVBoxLayout *mainLayout; + QHBoxLayout *hbox; + QPushButton *closeButton; //resize( 512, 600 ); // sync with config - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); - g_config->getOption ("SDL.UseNativeMenuBar", &useNativeMenuBarVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeMenuBar", &useNativeMenuBarVal); - setWindowTitle( tr("GUI Config") ); + setWindowTitle(tr("GUI Config")); mainLayout = new QVBoxLayout(); - useNativeFileDialog = new QCheckBox( tr("Use Native OS File Dialog") ); - useNativeMenuBar = new QCheckBox( tr("Use Native OS Menu Bar") ); + useNativeFileDialog = new QCheckBox(tr("Use Native OS File Dialog")); + useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar")); - useNativeFileDialog->setChecked( useNativeFileDialogVal ); - useNativeMenuBar->setChecked( useNativeMenuBarVal ); + useNativeFileDialog->setChecked(useNativeFileDialogVal); + useNativeMenuBar->setChecked(useNativeMenuBarVal); - connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) ); - connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)) ); + connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int))); + connect(useNativeMenuBar, SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int))); - mainLayout->addWidget( useNativeFileDialog ); - mainLayout->addWidget( useNativeMenuBar ); + mainLayout->addWidget(useNativeFileDialog); + mainLayout->addWidget(useNativeMenuBar); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(3); + hbox->addWidget( closeButton, 3 ); + hbox->addStretch(3); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); } //---------------------------------------------------- GuiConfDialog_t::~GuiConfDialog_t(void) { - printf("Destroy GUI Config Close Window\n"); + printf("Destroy GUI Config Close Window\n"); } //---------------------------------------------------------------------------- void GuiConfDialog_t::closeEvent(QCloseEvent *event) { - printf("GUI Config Close Window Event\n"); - done(0); + printf("GUI Config Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void GuiConfDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- @@ -87,15 +99,15 @@ void GuiConfDialog_t::useNativeFileDialogChanged(int state) { int value = (state == Qt::Unchecked) ? 0 : 1; - g_config->setOption ("SDL.UseNativeFileDialog", value); + g_config->setOption("SDL.UseNativeFileDialog", value); } //---------------------------------------------------- void GuiConfDialog_t::useNativeMenuBarChanged(int state) { int value = (state == Qt::Unchecked) ? 0 : 1; - g_config->setOption ("SDL.UseNativeMenuBar", value); + g_config->setOption("SDL.UseNativeMenuBar", value); - consoleWindow->menuBar()->setNativeMenuBar( value ); + consoleWindow->menuBar()->setNativeMenuBar(value); } //---------------------------------------------------- diff --git a/src/drivers/Qt/GuiConf.h b/src/drivers/Qt/GuiConf.h index aa0bcc84..0055f344 100644 --- a/src/drivers/Qt/GuiConf.h +++ b/src/drivers/Qt/GuiConf.h @@ -19,23 +19,22 @@ class GuiConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - GuiConfDialog_t(QWidget *parent = 0); - ~GuiConfDialog_t(void); +public: + GuiConfDialog_t(QWidget *parent = 0); + ~GuiConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QCheckBox *useNativeFileDialog; - QCheckBox *useNativeMenuBar; - private: - - public slots: - void closeWindow(void); - private slots: - void useNativeFileDialogChanged(int v); - void useNativeMenuBarChanged(int v); + QCheckBox *useNativeFileDialog; + QCheckBox *useNativeMenuBar; +private: +public slots: + void closeWindow(void); +private slots: + void useNativeFileDialogChanged(int v); + void useNativeMenuBarChanged(int v); }; diff --git a/src/drivers/Qt/HotKeyConf.cpp b/src/drivers/Qt/HotKeyConf.cpp index df60e4e5..eff0e626 100644 --- a/src/drivers/Qt/HotKeyConf.cpp +++ b/src/drivers/Qt/HotKeyConf.cpp @@ -38,15 +38,17 @@ //---------------------------------------------------------------------------- HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout; + QHBoxLayout *hbox; + QPushButton *closeButton; QTreeWidgetItem *item; std::string prefix = "SDL.Hotkeys."; setWindowTitle("Hotkey Configuration"); - resize( 512, 512 ); + resize(512, 512); mainLayout = new QVBoxLayout(); @@ -55,36 +57,45 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent) tree->setColumnCount(2); item = new QTreeWidgetItem(); - item->setText( 0, QString::fromStdString( "Command" ) ); - item->setText( 1, QString::fromStdString( "Key" ) ); - item->setTextAlignment( 0, Qt::AlignLeft); - item->setTextAlignment( 1, Qt::AlignCenter); + item->setText(0, QString::fromStdString("Command")); + item->setText(1, QString::fromStdString("Key")); + item->setTextAlignment(0, Qt::AlignLeft); + item->setTextAlignment(1, Qt::AlignCenter); - tree->setHeaderItem( item ); + tree->setHeaderItem(item); - tree->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); + tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - for (int i=0; igetOption (optionName.c_str (), &keycode); - Hotkeys[i].getString( keyName ); + Hotkeys[i].getString(keyName); item = new QTreeWidgetItem(); - item->setText( 0, QString::fromStdString( optionName ) ); - item->setText( 1, QString::fromStdString( keyName ) ); + item->setText(0, QString::fromStdString(optionName)); + item->setText(1, QString::fromStdString(keyName)); - item->setTextAlignment( 0, Qt::AlignLeft); - item->setTextAlignment( 1, Qt::AlignCenter); + item->setTextAlignment(0, Qt::AlignLeft); + item->setTextAlignment(1, Qt::AlignCenter); - tree->addTopLevelItem( item ); + tree->addTopLevelItem(item); } - mainLayout->addWidget( tree ); + mainLayout->addWidget(tree); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); } //---------------------------------------------------------------------------- HotKeyConfDialog_t::~HotKeyConfDialog_t(void) @@ -94,94 +105,96 @@ HotKeyConfDialog_t::~HotKeyConfDialog_t(void) //---------------------------------------------------------------------------- void HotKeyConfDialog_t::closeEvent(QCloseEvent *event) { - printf("Hot Key Close Window Event\n"); - done(0); + printf("Hot Key Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void HotKeyConfDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event) { bool keyIsModifier; - SDL_Keycode k = convQtKey2SDLKeyCode( (Qt::Key)event->key() ); - SDL_Keymod m = convQtKey2SDLModifier( event->modifiers() ); - - keyIsModifier = (k == SDLK_LCTRL ) || (k == SDLK_RCTRL ) || - (k == SDLK_LSHIFT) || (k == SDLK_RSHIFT) || - (k == SDLK_LALT ) || (k == SDLK_RALT ) || - (k == SDLK_LGUI ) || (k == SDLK_RGUI ) || - (k == SDLK_CAPSLOCK); + SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)event->key()); + SDL_Keymod m = convQtKey2SDLModifier(event->modifiers()); - if ( (k != SDLK_UNKNOWN) && !keyIsModifier ) + keyIsModifier = (k == SDLK_LCTRL) || (k == SDLK_RCTRL) || + (k == SDLK_LSHIFT) || (k == SDLK_RSHIFT) || + (k == SDLK_LALT) || (k == SDLK_RALT) || + (k == SDLK_LGUI) || (k == SDLK_RGUI) || + (k == SDLK_CAPSLOCK); + + if ((k != SDLK_UNKNOWN) && !keyIsModifier) { - QList l; - + QList l; + l = tree->selectedItems(); - for (size_t i=0; i < l.size(); i++) + for (size_t i = 0; i < l.size(); i++) { - int j,idx; + int j, idx; QString qs; QTreeWidgetItem *item; std::string keyText; char keyName[128]; char buf[256]; - keyText.assign(" mod="); - j=0; - if ( m & (KMOD_LSHIFT | KMOD_RSHIFT) ) + j = 0; + if (m & (KMOD_LSHIFT | KMOD_RSHIFT)) { - if ( j > 0 ) + if (j > 0) { - keyText.append("+"); + keyText.append("+"); } - keyText.append("Shift"); j++; + keyText.append("Shift"); + j++; } - if ( m & (KMOD_LALT | KMOD_RALT) ) + if (m & (KMOD_LALT | KMOD_RALT)) { - if ( j > 0 ) + if (j > 0) { - keyText.append("+"); + keyText.append("+"); } - keyText.append("Alt"); j++; + keyText.append("Alt"); + j++; } - if ( m & (KMOD_LCTRL | KMOD_RCTRL) ) + if (m & (KMOD_LCTRL | KMOD_RCTRL)) { - if ( j > 0 ) + if (j > 0) { - keyText.append("+"); + keyText.append("+"); } - keyText.append("Ctrl"); j++; + keyText.append("Ctrl"); + j++; } - sprintf( buf, " key=%s", SDL_GetKeyName( k ) ); + sprintf(buf, " key=%s", SDL_GetKeyName(k)); - keyText.append( buf ); + keyText.append(buf); item = l.at(i); - idx = tree->indexOfTopLevelItem( item ); + idx = tree->indexOfTopLevelItem(item); qs = item->text(0); - g_config->setOption ( qs.toStdString(), keyText ); + g_config->setOption(qs.toStdString(), keyText); setHotKeys(); - Hotkeys[idx].getString( keyName ); + Hotkeys[idx].getString(keyName); - item->setText( 1, QString::fromStdString( keyName ) ); + item->setText(1, QString::fromStdString(keyName)); - //printf("Hotkey Window Key Press: 0x%x item:%p\n '%s' : %i\n", + //printf("Hotkey Window Key Press: 0x%x item:%p\n '%s' : %i\n", // k, item, qs.toStdString().c_str(), idx ); } } @@ -189,13 +202,13 @@ void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event) //---------------------------------------------------------------------------- void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event) { - //printf("Hotkey Window Key Press: 0x%x \n", event->key() ); - assignHotkey( event ); + //printf("Hotkey Window Key Press: 0x%x \n", event->key() ); + assignHotkey(event); } //---------------------------------------------------------------------------- void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event) { - //printf("Hotkey Window Key Release: 0x%x \n", event->key() ); - assignHotkey( event ); + //printf("Hotkey Window Key Release: 0x%x \n", event->key() ); + assignHotkey(event); } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/HotKeyConf.h b/src/drivers/Qt/HotKeyConf.h index 859896a3..740df4e5 100644 --- a/src/drivers/Qt/HotKeyConf.h +++ b/src/drivers/Qt/HotKeyConf.h @@ -20,24 +20,22 @@ class HotKeyConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - HotKeyConfDialog_t(QWidget *parent = 0); - ~HotKeyConfDialog_t(void); +public: + HotKeyConfDialog_t(QWidget *parent = 0); + ~HotKeyConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); - void assignHotkey(QKeyEvent *event); +protected: + void closeEvent(QCloseEvent *event); + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + void assignHotkey(QKeyEvent *event); - QTreeWidget *tree; - - private: - - public slots: - void closeWindow(void); - private slots: + QTreeWidget *tree; +private: +public slots: + void closeWindow(void); +private slots: }; diff --git a/src/drivers/Qt/InputConf.cpp b/src/drivers/Qt/InputConf.cpp index 6c05fd40..24e77c04 100644 --- a/src/drivers/Qt/InputConf.cpp +++ b/src/drivers/Qt/InputConf.cpp @@ -42,9 +42,9 @@ static InputConfDialog_t *win = NULL; //---------------------------------------------------------------------------- -void openInputConfWindow( QWidget *parent ) +void openInputConfWindow(QWidget *parent) { - if ( win != NULL ) + if (win != NULL) { return; } @@ -54,194 +54,204 @@ void openInputConfWindow( QWidget *parent ) } //---------------------------------------------------------------------------- InputConfDialog_t::InputConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout, *vbox1, *vbox; QHBoxLayout *hbox; - QGroupBox *nesInputFrame, *port1Frame, *port2Frame; - QGroupBox *presetFrame, *expansionPortFrame; - QPalette pal; - QColor color; + QGroupBox *nesInputFrame, *port1Frame, *port2Frame; + QGroupBox *presetFrame, *expansionPortFrame; + QPushButton *closeButton; + QPalette pal; + QColor color; char stmp[256]; - int fourscore, autoInputPreset; + int fourscore, autoInputPreset; pal = this->palette(); - inputTimer = new QTimer( this ); + inputTimer = new QTimer(this); - connect( inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic ); + connect(inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic); setWindowTitle("Input Configuration"); mainLayout = new QVBoxLayout(); - nesInputFrame = new QGroupBox( tr("NES-Style Input Ports") ); - vbox1 = new QVBoxLayout(); - hbox = new QHBoxLayout(); - fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") ); - port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") ); - autoPreset = new QCheckBox( tr("Auto Load/Save Presets at ROM Open/Close") ); + nesInputFrame = new QGroupBox(tr("NES-Style Input Ports")); + vbox1 = new QVBoxLayout(); + hbox = new QHBoxLayout(); + fourScoreEna = new QCheckBox(tr("Attach 4-Score (Implies four gamepads)")); + port2Mic = new QCheckBox(tr("Replace Port 2 Start with Microphone")); + autoPreset = new QCheckBox(tr("Auto Load/Save Presets at ROM Open/Close")); g_config->getOption("SDL.FourScore", &fourscore); - fourScoreEna->setChecked( fourscore ); - port2Mic->setChecked( replaceP2StartWithMicrophone ); + fourScoreEna->setChecked(fourscore); + port2Mic->setChecked(replaceP2StartWithMicrophone); - g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset ); - autoPreset->setChecked( autoInputPreset ); + g_config->getOption("SDL.AutoInputPreset", &autoInputPreset); + autoPreset->setChecked(autoInputPreset); - hbox->addWidget( fourScoreEna ); - hbox->addWidget( port2Mic ); - vbox1->addLayout( hbox ); + hbox->addWidget(fourScoreEna); + hbox->addWidget(port2Mic); + vbox1->addLayout(hbox); - hbox = new QHBoxLayout(); - port1Frame = new QGroupBox( tr("Port 1:") ); - port2Frame = new QGroupBox( tr("Port 2:") ); + hbox = new QHBoxLayout(); + port1Frame = new QGroupBox(tr("Port 1:")); + port2Frame = new QGroupBox(tr("Port 2:")); - hbox->addWidget( port1Frame ); - hbox->addWidget( port2Frame ); - vbox1->addLayout( hbox ); + hbox->addWidget(port1Frame); + hbox->addWidget(port2Frame); + vbox1->addLayout(hbox); nesPortComboxBox[0] = new QComboBox(); nesPortComboxBox[1] = new QComboBox(); - expPortComboxBox = new QComboBox(); + expPortComboxBox = new QComboBox(); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); - hbox->addWidget( nesPortLabel[0] = new QLabel( tr("") ) ); - hbox->addWidget( nesPortConfButton[0] = new QPushButton( tr("Configure") ) ); - vbox->addWidget( nesPortComboxBox[0] ); + vbox->addLayout(hbox); + hbox->addWidget(nesPortLabel[0] = new QLabel(tr(""))); + hbox->addWidget(nesPortConfButton[0] = new QPushButton(tr("Configure"))); + vbox->addWidget(nesPortComboxBox[0]); - port1Frame->setLayout( vbox ); + port1Frame->setLayout(vbox); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); - hbox->addWidget( nesPortLabel[1] = new QLabel( tr("") ) ); - hbox->addWidget( nesPortConfButton[1] = new QPushButton( tr("Configure") ) ); - vbox->addWidget( nesPortComboxBox[1] ); + vbox->addLayout(hbox); + hbox->addWidget(nesPortLabel[1] = new QLabel(tr(""))); + hbox->addWidget(nesPortConfButton[1] = new QPushButton(tr("Configure"))); + vbox->addWidget(nesPortComboxBox[1]); - port2Frame->setLayout( vbox ); + port2Frame->setLayout(vbox); - nesInputFrame->setLayout( vbox1 ); + nesInputFrame->setLayout(vbox1); nesPortConfButton[0]->setEnabled(false); nesPortConfButton[1]->setEnabled(false); - mainLayout->addWidget( nesInputFrame ); + mainLayout->addWidget(nesInputFrame); - hbox = new QHBoxLayout(); - presetFrame = new QGroupBox( tr("Input Presets:") ); - expansionPortFrame = new QGroupBox( tr("Famicom Expansion Port:") ); + hbox = new QHBoxLayout(); + presetFrame = new QGroupBox(tr("Input Presets:")); + expansionPortFrame = new QGroupBox(tr("Famicom Expansion Port:")); - hbox->addWidget( presetFrame ); - hbox->addWidget( expansionPortFrame ); + hbox->addWidget(presetFrame); + hbox->addWidget(expansionPortFrame); - mainLayout->addLayout( hbox ); + mainLayout->addLayout(hbox); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); - hbox->addWidget( autoPreset ); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); + vbox->addLayout(hbox); + hbox->addWidget(autoPreset); - hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); - hbox->addWidget( loadConfigButton = new QPushButton( tr("Load") ) ); - hbox->addWidget( saveConfigButton = new QPushButton( tr("Save") ) ); + hbox = new QHBoxLayout(); + vbox->addLayout(hbox); + hbox->addWidget(loadConfigButton = new QPushButton(tr("Load"))); + hbox->addWidget(saveConfigButton = new QPushButton(tr("Save"))); - presetFrame->setLayout( vbox ); + presetFrame->setLayout(vbox); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); - vbox->addLayout( hbox ); - hbox->addWidget( expPortLabel = new QLabel( tr("") ) ); - hbox->addWidget( expPortConfButton = new QPushButton( tr("Configure") ) ); - vbox->addWidget( expPortComboxBox ); + vbox->addLayout(hbox); + hbox->addWidget(expPortLabel = new QLabel(tr(""))); + hbox->addWidget(expPortConfButton = new QPushButton(tr("Configure"))); + vbox->addWidget(expPortComboxBox); expPortConfButton->setEnabled(false); - expansionPortFrame->setLayout( vbox ); + expansionPortFrame->setLayout(vbox); color = pal.color(QPalette::WindowText); - sprintf( stmp, "border: 2px solid #%02X%02X%02X", color.red(), color.green(), color.blue() ); - + sprintf(stmp, "border: 2px solid #%02X%02X%02X", color.red(), color.green(), color.blue()); + //printf("%s\n", stmp); nesPortLabel[0]->setAlignment(Qt::AlignCenter); nesPortLabel[1]->setAlignment(Qt::AlignCenter); expPortLabel->setAlignment(Qt::AlignCenter); - nesPortLabel[0]->setStyleSheet( stmp ); - nesPortLabel[1]->setStyleSheet( stmp ); - expPortLabel->setStyleSheet( stmp ); + nesPortLabel[0]->setStyleSheet(stmp); + nesPortLabel[1]->setStyleSheet(stmp); + expPortLabel->setStyleSheet(stmp); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); - for (int i=0; i<2; i++) + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); + + for (int i = 0; i < 2; i++) { - getInputSelection( i, &curNesInput[i], &usrNesInput[i] ); - nesPortComboxBox[i]->addItem( tr("") , SI_NONE ); - nesPortComboxBox[i]->addItem( tr("Gamepad") , SI_GAMEPAD ); - nesPortComboxBox[i]->addItem( tr("Zapper") , SI_ZAPPER ); - nesPortComboxBox[i]->addItem( tr("Power Pad A") , SI_POWERPADA ); - nesPortComboxBox[i]->addItem( tr("Power Pad B") , SI_POWERPADB ); - nesPortComboxBox[i]->addItem( tr("Arkanoid Paddle") , SI_ARKANOID ); + getInputSelection(i, &curNesInput[i], &usrNesInput[i]); + nesPortComboxBox[i]->addItem(tr(""), SI_NONE); + nesPortComboxBox[i]->addItem(tr("Gamepad"), SI_GAMEPAD); + nesPortComboxBox[i]->addItem(tr("Zapper"), SI_ZAPPER); + nesPortComboxBox[i]->addItem(tr("Power Pad A"), SI_POWERPADA); + nesPortComboxBox[i]->addItem(tr("Power Pad B"), SI_POWERPADB); + nesPortComboxBox[i]->addItem(tr("Arkanoid Paddle"), SI_ARKANOID); - for (int j=0; jcount(); j++) + for (int j = 0; j < nesPortComboxBox[i]->count(); j++) { - if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] ) + if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i]) { - nesPortComboxBox[i]->setCurrentIndex( j ); + nesPortComboxBox[i]->setCurrentIndex(j); } - if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] ) + if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i]) { - nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) ); + nesPortLabel[i]->setText(nesPortComboxBox[i]->itemText(j)); } } } - getInputSelection( 2, &curNesInput[2], &usrNesInput[2] ); - expPortComboxBox->addItem( tr("") , SIFC_NONE ); - expPortComboxBox->addItem( tr("Arkanoid Paddle") , SIFC_ARKANOID ); - expPortComboxBox->addItem( tr("Shadow") , SIFC_SHADOW ); - expPortComboxBox->addItem( tr("Hyper Shot Gun") , SIFC_HYPERSHOT ); - expPortComboxBox->addItem( tr("Family Keyboard") , SIFC_FKB ); - expPortComboxBox->addItem( tr("Mahjong") , SIFC_MAHJONG ); - expPortComboxBox->addItem( tr("Quiz King Buzzers"), SIFC_QUIZKING ); - expPortComboxBox->addItem( tr("Family Trainer A") , SIFC_FTRAINERA ); - expPortComboxBox->addItem( tr("Family Trainer B") , SIFC_FTRAINERB ); - expPortComboxBox->addItem( tr("Oeka Kids Tablet") , SIFC_OEKAKIDS ); - expPortComboxBox->addItem( tr("Top Rider") , SIFC_TOPRIDER ); + getInputSelection(2, &curNesInput[2], &usrNesInput[2]); + expPortComboxBox->addItem(tr(""), SIFC_NONE); + expPortComboxBox->addItem(tr("Arkanoid Paddle"), SIFC_ARKANOID); + expPortComboxBox->addItem(tr("Shadow"), SIFC_SHADOW); + expPortComboxBox->addItem(tr("Hyper Shot Gun"), SIFC_HYPERSHOT); + expPortComboxBox->addItem(tr("Family Keyboard"), SIFC_FKB); + expPortComboxBox->addItem(tr("Mahjong"), SIFC_MAHJONG); + expPortComboxBox->addItem(tr("Quiz King Buzzers"), SIFC_QUIZKING); + expPortComboxBox->addItem(tr("Family Trainer A"), SIFC_FTRAINERA); + expPortComboxBox->addItem(tr("Family Trainer B"), SIFC_FTRAINERB); + expPortComboxBox->addItem(tr("Oeka Kids Tablet"), SIFC_OEKAKIDS); + expPortComboxBox->addItem(tr("Top Rider"), SIFC_TOPRIDER); - for (int j=0; jcount(); j++) + for (int j = 0; j < expPortComboxBox->count(); j++) { - if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] ) + if (expPortComboxBox->itemData(j).toInt() == curNesInput[2]) { - expPortComboxBox->setCurrentIndex( j ); + expPortComboxBox->setCurrentIndex(j); } - if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] ) + if (expPortComboxBox->itemData(j).toInt() == curNesInput[2]) { - expPortLabel->setText( expPortComboxBox->itemText(j) ); + expPortLabel->setText(expPortComboxBox->itemText(j)); } } - connect( fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)) ); - connect( port2Mic , SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)) ); - connect( autoPreset , SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int))); + connect(fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int))); + connect(port2Mic, SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int))); + connect(autoPreset, SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int))); - connect( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) ); - connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) ); - connect( expPortComboxBox , SIGNAL(activated(int)), this, SLOT(expSelect(int)) ); + connect(nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int))); + connect(nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int))); + connect(expPortComboxBox, SIGNAL(activated(int)), this, SLOT(expSelect(int))); - connect( nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)) ); - connect( nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)) ); + connect(nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void))); + connect(nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void))); - connect( loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)) ); - connect( saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)) ); + connect(loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void))); + connect(saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void))); + connect(closeButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); updatePortLabels(); - inputTimer->start( 500 ); // 2hz + inputTimer->start(500); // 2hz } //---------------------------------------------------------------------------- InputConfDialog_t::~InputConfDialog_t(void) @@ -249,7 +259,7 @@ InputConfDialog_t::~InputConfDialog_t(void) printf("Destroy Input Config Window\n"); inputTimer->stop(); - if ( win == this ) + if (win == this) { win = NULL; } @@ -257,23 +267,23 @@ InputConfDialog_t::~InputConfDialog_t(void) //---------------------------------------------------------------------------- void InputConfDialog_t::closeEvent(QCloseEvent *event) { - printf("Input Config Close Window Event\n"); - done(0); + printf("Input Config Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void InputConfDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- void InputConfDialog_t::setInputs(void) { int idx[3]; - ESI port[2]; + ESI port[2]; ESIFC fcexp; int fourscore = false, microphone = false; @@ -285,64 +295,64 @@ void InputConfDialog_t::setInputs(void) idx[1] = nesPortComboxBox[1]->currentIndex(); idx[2] = expPortComboxBox->currentIndex(); - port[0] = (ESI)nesPortComboxBox[0]->itemData( idx[0] ).toInt(); - port[1] = (ESI)nesPortComboxBox[1]->itemData( idx[1] ).toInt(); - fcexp = (ESIFC)expPortComboxBox->itemData( idx[2] ).toInt(); + port[0] = (ESI)nesPortComboxBox[0]->itemData(idx[0]).toInt(); + port[1] = (ESI)nesPortComboxBox[1]->itemData(idx[1]).toInt(); + fcexp = (ESIFC)expPortComboxBox->itemData(idx[2]).toInt(); - FCEUD_SetInput( fourscore, microphone, port[0], port[1], fcexp ); + FCEUD_SetInput(fourscore, microphone, port[0], port[1], fcexp); } //---------------------------------------------------------------------------- void InputConfDialog_t::updatePortLabels(void) { - for (int i=0; i<2; i++) + for (int i = 0; i < 2; i++) { - getInputSelection( i, &curNesInput[i], &usrNesInput[i] ); + getInputSelection(i, &curNesInput[i], &usrNesInput[i]); - for (int j=0; jcount(); j++) + for (int j = 0; j < nesPortComboxBox[i]->count(); j++) { - if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] ) + if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i]) { - nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) ); + nesPortLabel[i]->setText(nesPortComboxBox[i]->itemText(j)); } } - nesPortConfButton[i]->setEnabled( curNesInput[i] == SI_GAMEPAD ); + nesPortConfButton[i]->setEnabled(curNesInput[i] == SI_GAMEPAD); } - getInputSelection( 2, &curNesInput[2], &usrNesInput[2] ); + getInputSelection(2, &curNesInput[2], &usrNesInput[2]); - for (int j=0; jcount(); j++) + for (int j = 0; j < expPortComboxBox->count(); j++) { - if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] ) + if (expPortComboxBox->itemData(j).toInt() == curNesInput[2]) { - expPortLabel->setText( expPortComboxBox->itemText(j) ); + expPortLabel->setText(expPortComboxBox->itemText(j)); } } } //---------------------------------------------------------------------------- void InputConfDialog_t::updatePortComboBoxes(void) { - for (int i=0; i<2; i++) + for (int i = 0; i < 2; i++) { - getInputSelection( i, &curNesInput[i], &usrNesInput[i] ); + getInputSelection(i, &curNesInput[i], &usrNesInput[i]); - for (int j=0; jcount(); j++) + for (int j = 0; j < nesPortComboxBox[i]->count(); j++) { - if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] ) + if (nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i]) { - nesPortComboxBox[i]->setCurrentIndex( j ); + nesPortComboxBox[i]->setCurrentIndex(j); } } } - getInputSelection( 2, &curNesInput[2], &usrNesInput[2] ); + getInputSelection(2, &curNesInput[2], &usrNesInput[2]); - for (int j=0; jcount(); j++) + for (int j = 0; j < expPortComboxBox->count(); j++) { - if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] ) + if (expPortComboxBox->itemData(j).toInt() == curNesInput[2]) { - expPortComboxBox->setCurrentIndex( j ); + expPortComboxBox->setCurrentIndex(j); } } } @@ -395,15 +405,15 @@ void InputConfDialog_t::openPortConfig(int portNum) { updatePortLabels(); - switch ( curNesInput[portNum] ) + switch (curNesInput[portNum]) { - default: - case SI_NONE: - case SI_ZAPPER: - // Do Nothing + default: + case SI_NONE: + case SI_ZAPPER: + // Do Nothing break; - case SI_GAMEPAD: - consoleWindow->openGamePadConfWin(); + case SI_GAMEPAD: + consoleWindow->openGamePadConfWin(); break; } } @@ -420,56 +430,56 @@ void InputConfDialog_t::port2Configure(void) //---------------------------------------------------------------------------- void InputConfDialog_t::openLoadPresetFile(void) { - int ret, useNativeFileDialogVal; + int ret, useNativeFileDialogVal; QString filename; std::string last; std::string path; const char *baseDir; - QFileDialog dialog(this, tr("Load Preset From File") ); + QFileDialog dialog(this, tr("Load Preset From File")); QDir dir; baseDir = FCEUI_GetBaseDirectory(); path = std::string(baseDir) + "/input/presets/"; - dir.mkpath( QString::fromStdString(path) ); + dir.mkpath(QString::fromStdString(path)); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("Preset File (*.pre *.PRE) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Load") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Load")); - dialog.setDirectory( tr(path.c_str()) ); + dialog.setDirectory(tr(path.c_str())); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) + if (filename.isNull()) { - return; + return; } qDebug() << "selected file path : " << filename.toUtf8(); fceuWrapperLock(); - loadInputSettingsFromFile( filename.toStdString().c_str() ); + loadInputSettingsFromFile(filename.toStdString().c_str()); fceuWrapperUnLock(); updatePortLabels(); @@ -483,64 +493,64 @@ void InputConfDialog_t::openSavePresetFile(void) QString filename; std::string path; const char *baseDir, *romFile; - QFileDialog dialog(this, tr("Save Preset to File") ); + QFileDialog dialog(this, tr("Save Preset to File")); QDir dir; baseDir = FCEUI_GetBaseDirectory(); path = std::string(baseDir) + "/input/presets/"; - dir.mkpath( QString::fromStdString(path) ); + dir.mkpath(QString::fromStdString(path)); dialog.setFileMode(QFileDialog::AnyFile); dialog.setNameFilter(tr("Preset Files (*.pre *.PRE) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Save") ); - dialog.setDefaultSuffix( tr(".pre") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Save")); + dialog.setDefaultSuffix(tr(".pre")); romFile = getRomFile(); - if ( romFile != NULL ) + if (romFile != NULL) { char dirStr[256], base[256]; - parseFilepath( romFile, dirStr, base ); + parseFilepath(romFile, dirStr, base); - strcat( base, ".pre"); + strcat(base, ".pre"); - dialog.selectFile( tr(base) ); + dialog.selectFile(tr(base)); } - dialog.setDirectory( tr(path.c_str()) ); + dialog.setDirectory(tr(path.c_str())); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) + if (filename.isNull()) { - return; + return; } qDebug() << "selected file path : " << filename.toUtf8(); - saveInputSettingsToFile( filename.toStdString().c_str() ); + saveInputSettingsToFile(filename.toStdString().c_str()); } //---------------------------------------------------------------------------- void InputConfDialog_t::updatePeriodic(void) @@ -549,21 +559,21 @@ void InputConfDialog_t::updatePeriodic(void) int tmpCurInputType[3], tmpUsrInputType[3]; int fourScoreValue; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { - getInputSelection( i, &tmpCurInputType[i], &tmpUsrInputType[i] ); + getInputSelection(i, &tmpCurInputType[i], &tmpUsrInputType[i]); - if ( curNesInput[i] != tmpCurInputType[i] ) + if (curNesInput[i] != tmpCurInputType[i]) { updateNeeded = true; } - if ( usrNesInput[i] != tmpUsrInputType[i] ) + if (usrNesInput[i] != tmpUsrInputType[i]) { updateNeeded = true; } } - if ( updateNeeded ) + if (updateNeeded) { updatePortLabels(); updatePortComboBoxes(); @@ -571,9 +581,9 @@ void InputConfDialog_t::updatePeriodic(void) g_config->getOption("SDL.FourScore", &fourScoreValue); - if ( fourScoreValue != fourScoreEna->isChecked() ) + if (fourScoreValue != fourScoreEna->isChecked()) { - fourScoreEna->setChecked( fourScoreValue ); + fourScoreEna->setChecked(fourScoreValue); } } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/InputConf.h b/src/drivers/Qt/InputConf.h index cc72d0aa..ba4623f2 100644 --- a/src/drivers/Qt/InputConf.h +++ b/src/drivers/Qt/InputConf.h @@ -22,52 +22,51 @@ class InputConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - InputConfDialog_t(QWidget *parent = 0); - ~InputConfDialog_t(void); +public: + InputConfDialog_t(QWidget *parent = 0); + ~InputConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QTimer *inputTimer; - QCheckBox *fourScoreEna; - QCheckBox *port2Mic; - QCheckBox *autoPreset; - QLabel *nesPortLabel[2]; - QPushButton *nesPortConfButton[2]; - QComboBox *nesPortComboxBox[2]; - QLabel *expPortLabel; - QPushButton *expPortConfButton; - QComboBox *expPortComboxBox; - QPushButton *loadConfigButton; - QPushButton *saveConfigButton; + QTimer *inputTimer; + QCheckBox *fourScoreEna; + QCheckBox *port2Mic; + QCheckBox *autoPreset; + QLabel *nesPortLabel[2]; + QPushButton *nesPortConfButton[2]; + QComboBox *nesPortComboxBox[2]; + QLabel *expPortLabel; + QPushButton *expPortConfButton; + QComboBox *expPortComboxBox; + QPushButton *loadConfigButton; + QPushButton *saveConfigButton; - int curNesInput[3]; - int usrNesInput[3]; + int curNesInput[3]; + int usrNesInput[3]; - private: - void setInputs(void); - void updatePortLabels(void); - void updatePortComboBoxes(void); - void openPortConfig(int portNum); - - public slots: - void closeWindow(void); - private slots: - void port1Configure(void); - void port2Configure(void); - void port1Select(int index); - void port2Select(int index); - void expSelect(int index); - void fourScoreChanged(int state); - void port2MicChanged(int state); - void autoPresetChanged(int state); - void openLoadPresetFile(void); - void openSavePresetFile(void); - void updatePeriodic(void); +private: + void setInputs(void); + void updatePortLabels(void); + void updatePortComboBoxes(void); + void openPortConfig(int portNum); +public slots: + void closeWindow(void); +private slots: + void port1Configure(void); + void port2Configure(void); + void port1Select(int index); + void port2Select(int index); + void expSelect(int index); + void fourScoreChanged(int state); + void port2MicChanged(int state); + void autoPresetChanged(int state); + void openLoadPresetFile(void); + void openSavePresetFile(void); + void updatePeriodic(void); }; -void openInputConfWindow( QWidget *parent ); +void openInputConfWindow(QWidget *parent); diff --git a/src/drivers/Qt/LuaControl.cpp b/src/drivers/Qt/LuaControl.cpp index 7a6de684..a81ffc5d 100644 --- a/src/drivers/Qt/LuaControl.cpp +++ b/src/drivers/Qt/LuaControl.cpp @@ -50,151 +50,161 @@ static bool luaScriptRunning = false; static bool updateLuaDisplay = false; static bool openLuaKillMsgBox = false; -static int luaKillMsgBoxRetVal = 0; +static int luaKillMsgBoxRetVal = 0; struct luaConsoleOutputBuffer { - int head; - int tail; - int size; - char *buf; + int head; + int tail; + int size; + char *buf; - luaConsoleOutputBuffer(void) - { - tail = head = 0; - size = 4096; + luaConsoleOutputBuffer(void) + { + tail = head = 0; + size = 4096; - buf = (char*)malloc(size); - } + buf = (char *)malloc(size); + } - ~luaConsoleOutputBuffer(void) - { - if ( buf ) - { - free(buf); buf = NULL; - } - } - - void addLine( const char *l ) - { - int i=0; - //printf("Adding Line %i: '%s'\n", head, l ); - while ( l[i] != 0 ) + ~luaConsoleOutputBuffer(void) + { + if (buf) { - buf[head] = l[i]; i++; + free(buf); + buf = NULL; + } + } - head = (head + 1) % size; + void addLine(const char *l) + { + int i = 0; + //printf("Adding Line %i: '%s'\n", head, l ); + while (l[i] != 0) + { + buf[head] = l[i]; + i++; - if ( head == tail ) - { - tail = (tail + 1) % size; - } - } - } + head = (head + 1) % size; - void clear(void) - { - tail = head = 0; - } + if (head == tail) + { + tail = (tail + 1) % size; + } + } + } + + void clear(void) + { + tail = head = 0; + } }; static luaConsoleOutputBuffer outBuf; -static std::list winList; +static std::list winList; -static void updateLuaWindows( void ); +static void updateLuaWindows(void); //---------------------------------------------------- LuaControlDialog_t::LuaControlDialog_t(QWidget *parent) - : QDialog( parent, Qt::Window ) + : QDialog(parent, Qt::Window) { QVBoxLayout *mainLayout; QHBoxLayout *hbox; + QPushButton *closeButton; QLabel *lbl; std::string filename; - resize( 512, 512 ); + resize(512, 512); - setWindowTitle( tr("Lua Script Control") ); + setWindowTitle(tr("Lua Script Control")); mainLayout = new QVBoxLayout(); - lbl = new QLabel( tr("Script File:") ); + lbl = new QLabel(tr("Script File:")); scriptPath = new QLineEdit(); scriptArgs = new QLineEdit(); - g_config->getOption ("SDL.LastLoadLua", &filename ); + g_config->getOption("SDL.LastLoadLua", &filename); - scriptPath->setText( filename.c_str() ); + scriptPath->setText(filename.c_str()); luaOutput = new QTextEdit(); luaOutput->setReadOnly(true); hbox = new QHBoxLayout(); - browseButton = new QPushButton( tr("Browse") ); - stopButton = new QPushButton( tr("Stop") ); + browseButton = new QPushButton(tr("Browse")); + stopButton = new QPushButton(tr("Stop")); - if ( luaScriptRunning ) + if (luaScriptRunning) { - startButton = new QPushButton( tr("Restart") ); + startButton = new QPushButton(tr("Restart")); } else { - startButton = new QPushButton( tr("Start") ); + startButton = new QPushButton(tr("Start")); } - stopButton->setEnabled( luaScriptRunning ); + stopButton->setEnabled(luaScriptRunning); - connect(browseButton , SIGNAL(clicked()), this, SLOT(openLuaScriptFile(void)) ); - connect(stopButton , SIGNAL(clicked()), this, SLOT(stopLuaScript(void)) ); - connect(startButton , SIGNAL(clicked()), this, SLOT(startLuaScript(void)) ); - - hbox->addWidget( browseButton ); - hbox->addWidget( stopButton ); - hbox->addWidget( startButton ); + connect(browseButton, SIGNAL(clicked()), this, SLOT(openLuaScriptFile(void))); + connect(stopButton, SIGNAL(clicked()), this, SLOT(stopLuaScript(void))); + connect(startButton, SIGNAL(clicked()), this, SLOT(startLuaScript(void))); - mainLayout->addWidget( lbl ); - mainLayout->addWidget( scriptPath ); - mainLayout->addLayout( hbox ); + hbox->addWidget(browseButton); + hbox->addWidget(stopButton); + hbox->addWidget(startButton); + + mainLayout->addWidget(lbl); + mainLayout->addWidget(scriptPath); + mainLayout->addLayout(hbox); hbox = new QHBoxLayout(); - lbl = new QLabel( tr("Arguments:") ); + lbl = new QLabel(tr("Arguments:")); - hbox->addWidget( lbl ); - hbox->addWidget( scriptArgs ); + hbox->addWidget(lbl); + hbox->addWidget(scriptArgs); + mainLayout->addLayout(hbox); + + lbl = new QLabel(tr("Output Console:")); + mainLayout->addWidget(lbl); + mainLayout->addWidget(luaOutput); + + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); mainLayout->addLayout( hbox ); - lbl = new QLabel( tr("Output Console:") ); - mainLayout->addWidget( lbl ); - mainLayout->addWidget( luaOutput ); + setLayout(mainLayout); - //connect(useNativeFileDialog , SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)) ); + winList.push_back(this); - setLayout( mainLayout ); + periodicTimer = new QTimer(this); - winList.push_back( this ); + connect(periodicTimer, &QTimer::timeout, this, &LuaControlDialog_t::updatePeriodic); - periodicTimer = new QTimer( this ); - - connect( periodicTimer, &QTimer::timeout, this, &LuaControlDialog_t::updatePeriodic ); - - periodicTimer->start( 200 ); // 5hz + periodicTimer->start(200); // 5hz } //---------------------------------------------------- LuaControlDialog_t::~LuaControlDialog_t(void) { - std::list ::iterator it; - + std::list::iterator it; + printf("Destroy Lua Control Window\n"); - periodicTimer->stop(); + periodicTimer->stop(); for (it = winList.begin(); it != winList.end(); it++) { - if ( (*it) == this ) + if ((*it) == this) { winList.erase(it); //printf("Removing Lua Window\n"); @@ -205,29 +215,29 @@ LuaControlDialog_t::~LuaControlDialog_t(void) //---------------------------------------------------- void LuaControlDialog_t::closeEvent(QCloseEvent *event) { - printf("Lua Control Close Window Event\n"); - done(0); + printf("Lua Control Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void LuaControlDialog_t::closeWindow(void) { - //printf("Lua Control Close Window\n"); - done(0); + //printf("Lua Control Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- void LuaControlDialog_t::updatePeriodic(void) { - //printf("Update Lua\n"); - if ( updateLuaDisplay ) - { - updateLuaWindows(); - updateLuaDisplay = false; - } + //printf("Update Lua\n"); + if (updateLuaDisplay) + { + updateLuaWindows(); + updateLuaDisplay = false; + } - if ( openLuaKillMsgBox ) + if (openLuaKillMsgBox) { openLuaKillMessageBox(); openLuaKillMsgBox = false; @@ -241,15 +251,15 @@ void LuaControlDialog_t::openLuaKillMessageBox(void) luaKillMsgBoxRetVal = 0; - msgBox.setIcon( QMessageBox::Warning ); - msgBox.setText( tr("The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n") ); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr("The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n")); msgBox.setStandardButtons(QMessageBox::Yes); msgBox.addButton(QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); ret = msgBox.exec(); - if ( ret == QMessageBox::Yes ) + if (ret == QMessageBox::Yes) { luaKillMsgBoxRetVal = 1; } @@ -264,78 +274,79 @@ void LuaControlDialog_t::openLuaScriptFile(void) char dir[512]; char exePath[512]; const char *luaPath; - QFileDialog dialog(this, tr("Open LUA Script") ); + QFileDialog dialog(this, tr("Open LUA Script")); QList urls; - QDir d; + QDir d; - fceuExecutablePath( exePath, sizeof(exePath) ); + fceuExecutablePath(exePath, sizeof(exePath)); //urls = dialog.sidebarUrls(); - urls << QUrl::fromLocalFile( QDir::rootPath() ); + urls << QUrl::fromLocalFile(QDir::rootPath()); urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first()); urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first()); - urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() ); + urls << QUrl::fromLocalFile(QDir(FCEUI_GetBaseDirectory()).absolutePath()); - if ( exePath[0] != 0 ) + if (exePath[0] != 0) { - d.setPath( QString(exePath) + "/../luaScripts" ); + d.setPath(QString(exePath) + "/../luaScripts"); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); } } #ifndef WIN32 - d.setPath( "/usr/share/fceux/luaScripts" ); + d.setPath("/usr/share/fceux/luaScripts"); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); } #endif luaPath = getenv("LUA_PATH"); // Parse LUA_PATH and add to urls - if ( luaPath ) + if (luaPath) { - int i,j; + int i, j; char stmp[1024]; - i=j=0; - while ( luaPath[i] != 0 ) + i = j = 0; + while (luaPath[i] != 0) { - if ( luaPath[i] == ';' ) + if (luaPath[i] == ';') { stmp[j] = 0; - if ( j > 0 ) + if (j > 0) { d.setPath(stmp); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); } } - j=0; + j = 0; } else { - stmp[j] = luaPath[i]; j++; + stmp[j] = luaPath[i]; + j++; } i++; } stmp[j] = 0; - if ( j > 0 ) + if (j > 0) { d.setPath(stmp); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); } } } @@ -345,52 +356,52 @@ void LuaControlDialog_t::openLuaScriptFile(void) dialog.setNameFilter(tr("LUA Scripts (*.lua *.LUA) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Load") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Load")); - g_config->getOption ("SDL.LastLoadLua", &last ); + g_config->getOption("SDL.LastLoadLua", &last); - if ( last.size() == 0 ) + if (last.size() == 0) { #ifdef WIN32 - last.assign( FCEUI_GetBaseDirectory() ); + last.assign(FCEUI_GetBaseDirectory()); #else - last.assign( "/usr/share/fceux/luaScripts" ); + last.assign("/usr/share/fceux/luaScripts"); #endif } - getDirFromFile( last.c_str(), dir ); + getDirFromFile(last.c_str(), dir); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); dialog.setSidebarUrls(urls); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) + if (filename.isNull()) { - return; + return; } qDebug() << "selected file path : " << filename.toUtf8(); - g_config->setOption ("SDL.LastLoadLua", filename.toStdString().c_str() ); + g_config->setOption("SDL.LastLoadLua", filename.toStdString().c_str()); - scriptPath->setText( filename.toStdString().c_str() ); + scriptPath->setText(filename.toStdString().c_str()); #endif } @@ -400,9 +411,9 @@ void LuaControlDialog_t::startLuaScript(void) #ifdef _S9XLUA_H outBuf.clear(); fceuWrapperLock(); - if ( 0 == FCEU_LoadLuaCode( scriptPath->text().toStdString().c_str(), scriptArgs->text().toStdString().c_str() ) ) + if (0 == FCEU_LoadLuaCode(scriptPath->text().toStdString().c_str(), scriptArgs->text().toStdString().c_str())) { - printf("Error: Could not open the selected lua script: '%s'\n", scriptPath->text().toStdString().c_str() ); + printf("Error: Could not open the selected lua script: '%s'\n", scriptPath->text().toStdString().c_str()); } fceuWrapperUnLock(); #endif @@ -422,35 +433,35 @@ void LuaControlDialog_t::refreshState(void) int i; std::string luaOutputText; - if ( luaScriptRunning ) + if (luaScriptRunning) { - stopButton->setEnabled( true ); - startButton->setText( tr("Restart") ); + stopButton->setEnabled(true); + startButton->setText(tr("Restart")); } else { - stopButton->setEnabled( false ); - startButton->setText( tr("Start") ); + stopButton->setEnabled(false); + startButton->setText(tr("Start")); } i = outBuf.tail; - - while ( i != outBuf.head ) + + while (i != outBuf.head) { - luaOutputText.append( 1, outBuf.buf[i] ); - - i = (i + 1) % outBuf.size; + luaOutputText.append(1, outBuf.buf[i]); + + i = (i + 1) % outBuf.size; } - luaOutput->setText( luaOutputText.c_str() ); + luaOutput->setText(luaOutputText.c_str()); - luaOutput->moveCursor( QTextCursor::End ); + luaOutput->moveCursor(QTextCursor::End); } //---------------------------------------------------- -static void updateLuaWindows( void ) +static void updateLuaWindows(void) { - std::list ::iterator it; - + std::list::iterator it; + for (it = winList.begin(); it != winList.end(); it++) { (*it)->refreshState(); @@ -475,35 +486,35 @@ void WinLuaOnStop(intptr_t hDlgAsInt) updateLuaDisplay = true; } //---------------------------------------------------- -void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str) +void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str) { //printf("%s\n", str ); - outBuf.addLine( str ); - + outBuf.addLine(str); + updateLuaDisplay = true; } //---------------------------------------------------- -#ifdef WIN32 -int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char* format, ...) +#ifdef WIN32 +int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char *format, ...) #else -int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw() +int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw() #endif { - int retval; - va_list args; + int retval; + va_list args; char msg[2048]; - va_start( args, format ); - retval = ::vsnprintf( msg, sizeof(msg), format, args ); - va_end(args); + va_start(args, format); + retval = ::vsnprintf(msg, sizeof(msg), format, args); + va_end(args); - msg[ sizeof(msg)-1 ] = 0; + msg[sizeof(msg) - 1] = 0; - outBuf.addLine( msg ); + outBuf.addLine(msg); updateLuaDisplay = true; - return(retval); + return (retval); }; //---------------------------------------------------- int LuaKillMessageBox(void) @@ -513,11 +524,11 @@ int LuaKillMessageBox(void) openLuaKillMsgBox = true; - while ( openLuaKillMsgBox ) + while (openLuaKillMsgBox) { msleep(100); } - + return luaKillMsgBoxRetVal; } //---------------------------------------------------- diff --git a/src/drivers/Qt/LuaControl.h b/src/drivers/Qt/LuaControl.h index 1fe42011..7427e9bd 100644 --- a/src/drivers/Qt/LuaControl.h +++ b/src/drivers/Qt/LuaControl.h @@ -23,52 +23,50 @@ class LuaControlDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - LuaControlDialog_t(QWidget *parent = 0); - ~LuaControlDialog_t(void); +public: + LuaControlDialog_t(QWidget *parent = 0); + ~LuaControlDialog_t(void); - void refreshState(void); + void refreshState(void); - protected: - void closeEvent(QCloseEvent *bar); - void openLuaKillMessageBox(void); +protected: + void closeEvent(QCloseEvent *bar); + void openLuaKillMessageBox(void); - QTimer *periodicTimer; - QLineEdit *scriptPath; - QLineEdit *scriptArgs; - QPushButton *browseButton; - QPushButton *stopButton; - QPushButton *startButton; - QTextEdit *luaOutput; - private: - - public slots: - void closeWindow(void); - private slots: - void updatePeriodic(void); - void openLuaScriptFile(void); - void startLuaScript(void); - void stopLuaScript(void); + QTimer *periodicTimer; + QLineEdit *scriptPath; + QLineEdit *scriptArgs; + QPushButton *browseButton; + QPushButton *stopButton; + QPushButton *startButton; + QTextEdit *luaOutput; +private: +public slots: + void closeWindow(void); +private slots: + void updatePeriodic(void); + void openLuaScriptFile(void); + void startLuaScript(void); + void stopLuaScript(void); }; // Formatted print -#ifdef WIN32 - int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char* format, ...) ; -#elif __linux__ - #ifdef __THROWNL - int LuaPrintfToWindowConsole(const char *__restrict format, ...) - __THROWNL __attribute__ ((__format__ (__printf__, 1, 2))); - #else - int LuaPrintfToWindowConsole(const char *__restrict format, ...) - throw() __attribute__ ((__format__ (__printf__, 1, 2))); - #endif -#else - int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw(); +#ifdef WIN32 +int LuaPrintfToWindowConsole(_In_z_ _Printf_format_string_ const char *format, ...); +#elif __linux__ +#ifdef __THROWNL +int LuaPrintfToWindowConsole(const char *__restrict format, ...) + __THROWNL __attribute__((__format__(__printf__, 1, 2))); +#else +int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw() __attribute__((__format__(__printf__, 1, 2))); +#endif +#else +int LuaPrintfToWindowConsole(const char *__restrict format, ...) throw(); #endif -void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str); +void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str); int LuaKillMessageBox(void); diff --git a/src/drivers/Qt/MovieOptions.cpp b/src/drivers/Qt/MovieOptions.cpp index 74050999..82e09848 100644 --- a/src/drivers/Qt/MovieOptions.cpp +++ b/src/drivers/Qt/MovieOptions.cpp @@ -40,56 +40,67 @@ //---------------------------------------------------------------------------- MovieOptionsDialog_t::MovieOptionsDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QLabel *lbl; QVBoxLayout *mainLayout; + QHBoxLayout *hbox; + QPushButton *closeButton; setWindowTitle("Movie Options"); mainLayout = new QVBoxLayout(); - readOnlyReplay = new QCheckBox( tr("Always Suggest Read-Only Replay") ); - pauseAfterPlay = new QCheckBox( tr("Pause After Playback") ); - closeAfterPlay = new QCheckBox( tr("Close After Playback") ); - bindSaveStates = new QCheckBox( tr("Bind Save-States to Movies") ); - dpySubTitles = new QCheckBox( tr("Display Movie Sub Titles") ); - putSubTitlesAvi = new QCheckBox( tr("Put Movie Sub Titles in AVI") ); - autoBackUp = new QCheckBox( tr("Automatically Backup Movies") ); - loadFullStates = new QCheckBox( tr("Load Full Save-State Movies:") ); + readOnlyReplay = new QCheckBox(tr("Always Suggest Read-Only Replay")); + pauseAfterPlay = new QCheckBox(tr("Pause After Playback")); + closeAfterPlay = new QCheckBox(tr("Close After Playback")); + bindSaveStates = new QCheckBox(tr("Bind Save-States to Movies")); + dpySubTitles = new QCheckBox(tr("Display Movie Sub Titles")); + putSubTitlesAvi = new QCheckBox(tr("Put Movie Sub Titles in AVI")); + autoBackUp = new QCheckBox(tr("Automatically Backup Movies")); + loadFullStates = new QCheckBox(tr("Load Full Save-State Movies:")); - lbl = new QLabel( tr("Loading states in record mode will not immediately truncate movie, next frame input will. (VBA-rr and SNES9x style)") ); + lbl = new QLabel(tr("Loading states in record mode will not immediately truncate movie, next frame input will. (VBA-rr and SNES9x style)")); lbl->setWordWrap(true); - mainLayout->addWidget( readOnlyReplay ); - mainLayout->addWidget( pauseAfterPlay ); - mainLayout->addWidget( closeAfterPlay ); - mainLayout->addWidget( bindSaveStates ); - mainLayout->addWidget( dpySubTitles ); - mainLayout->addWidget( putSubTitlesAvi ); - mainLayout->addWidget( autoBackUp ); - mainLayout->addWidget( loadFullStates ); - mainLayout->addWidget( lbl ); + mainLayout->addWidget(readOnlyReplay); + mainLayout->addWidget(pauseAfterPlay); + mainLayout->addWidget(closeAfterPlay); + mainLayout->addWidget(bindSaveStates); + mainLayout->addWidget(dpySubTitles); + mainLayout->addWidget(putSubTitlesAvi); + mainLayout->addWidget(autoBackUp); + mainLayout->addWidget(loadFullStates); + mainLayout->addWidget(lbl); - readOnlyReplay->setChecked( suggestReadOnlyReplay ); - pauseAfterPlay->setChecked( pauseAfterPlayback ); - closeAfterPlay->setChecked( closeFinishedMovie ); - bindSaveStates->setChecked( bindSavestate ); - dpySubTitles->setChecked( movieSubtitles ); - putSubTitlesAvi->setChecked( subtitlesOnAVI ); - autoBackUp->setChecked( autoMovieBackup ); - loadFullStates->setChecked( fullSaveStateLoads ); + readOnlyReplay->setChecked(suggestReadOnlyReplay); + pauseAfterPlay->setChecked(pauseAfterPlayback); + closeAfterPlay->setChecked(closeFinishedMovie); + bindSaveStates->setChecked(bindSavestate); + dpySubTitles->setChecked(movieSubtitles); + putSubTitlesAvi->setChecked(subtitlesOnAVI); + autoBackUp->setChecked(autoMovieBackup); + loadFullStates->setChecked(fullSaveStateLoads); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); - connect( readOnlyReplay , SIGNAL(stateChanged(int)), this, SLOT(readOnlyReplayChanged(int)) ); - connect( pauseAfterPlay , SIGNAL(stateChanged(int)), this, SLOT(pauseAfterPlayChanged(int)) ); - connect( closeAfterPlay , SIGNAL(stateChanged(int)), this, SLOT(closeAfterPlayChanged(int)) ); - connect( bindSaveStates , SIGNAL(stateChanged(int)), this, SLOT(bindSaveStatesChanged(int)) ); - connect( dpySubTitles , SIGNAL(stateChanged(int)), this, SLOT(dpySubTitlesChanged(int)) ); - connect( putSubTitlesAvi, SIGNAL(stateChanged(int)), this, SLOT(putSubTitlesAviChanged(int)) ); - connect( autoBackUp , SIGNAL(stateChanged(int)), this, SLOT(autoBackUpChanged(int)) ); - connect( loadFullStates , SIGNAL(stateChanged(int)), this, SLOT(loadFullStatesChanged(int)) ); + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); + + connect(readOnlyReplay, SIGNAL(stateChanged(int)), this, SLOT(readOnlyReplayChanged(int))); + connect(pauseAfterPlay, SIGNAL(stateChanged(int)), this, SLOT(pauseAfterPlayChanged(int))); + connect(closeAfterPlay, SIGNAL(stateChanged(int)), this, SLOT(closeAfterPlayChanged(int))); + connect(bindSaveStates, SIGNAL(stateChanged(int)), this, SLOT(bindSaveStatesChanged(int))); + connect(dpySubTitles, SIGNAL(stateChanged(int)), this, SLOT(dpySubTitlesChanged(int))); + connect(putSubTitlesAvi, SIGNAL(stateChanged(int)), this, SLOT(putSubTitlesAviChanged(int))); + connect(autoBackUp, SIGNAL(stateChanged(int)), this, SLOT(autoBackUpChanged(int))); + connect(loadFullStates, SIGNAL(stateChanged(int)), this, SLOT(loadFullStatesChanged(int))); } //---------------------------------------------------------------------------- MovieOptionsDialog_t::~MovieOptionsDialog_t(void) @@ -99,57 +110,57 @@ MovieOptionsDialog_t::~MovieOptionsDialog_t(void) //---------------------------------------------------------------------------- void MovieOptionsDialog_t::closeEvent(QCloseEvent *event) { - printf("Movie Options Close Window Event\n"); - done(0); + printf("Movie Options Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void MovieOptionsDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::readOnlyReplayChanged( int state ) +void MovieOptionsDialog_t::readOnlyReplayChanged(int state) { suggestReadOnlyReplay = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::pauseAfterPlayChanged( int state ) +void MovieOptionsDialog_t::pauseAfterPlayChanged(int state) { pauseAfterPlayback = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::closeAfterPlayChanged( int state ) +void MovieOptionsDialog_t::closeAfterPlayChanged(int state) { closeFinishedMovie = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::bindSaveStatesChanged( int state ) +void MovieOptionsDialog_t::bindSaveStatesChanged(int state) { bindSavestate = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::dpySubTitlesChanged( int state ) +void MovieOptionsDialog_t::dpySubTitlesChanged(int state) { movieSubtitles = (state != Qt::Unchecked); g_config->setOption("SDL.SubtitleDisplay", movieSubtitles); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::putSubTitlesAviChanged( int state ) +void MovieOptionsDialog_t::putSubTitlesAviChanged(int state) { subtitlesOnAVI = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::autoBackUpChanged( int state ) +void MovieOptionsDialog_t::autoBackUpChanged(int state) { autoMovieBackup = (state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MovieOptionsDialog_t::loadFullStatesChanged( int state ) +void MovieOptionsDialog_t::loadFullStatesChanged(int state) { fullSaveStateLoads = (state != Qt::Unchecked); } diff --git a/src/drivers/Qt/MovieOptions.h b/src/drivers/Qt/MovieOptions.h index c229c846..ea4dcdd8 100644 --- a/src/drivers/Qt/MovieOptions.h +++ b/src/drivers/Qt/MovieOptions.h @@ -20,36 +20,34 @@ class MovieOptionsDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - MovieOptionsDialog_t(QWidget *parent = 0); - ~MovieOptionsDialog_t(void); +public: + MovieOptionsDialog_t(QWidget *parent = 0); + ~MovieOptionsDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QCheckBox *readOnlyReplay; - QCheckBox *pauseAfterPlay; - QCheckBox *closeAfterPlay; - QCheckBox *bindSaveStates; - QCheckBox *dpySubTitles; - QCheckBox *putSubTitlesAvi; - QCheckBox *autoBackUp; - QCheckBox *loadFullStates; - - private: - - public slots: - void closeWindow(void); - private slots: - void readOnlyReplayChanged( int state ); - void pauseAfterPlayChanged( int state ); - void closeAfterPlayChanged( int state ); - void bindSaveStatesChanged( int state ); - void dpySubTitlesChanged( int state ); - void putSubTitlesAviChanged( int state ); - void autoBackUpChanged( int state ); - void loadFullStatesChanged( int state ); + QCheckBox *readOnlyReplay; + QCheckBox *pauseAfterPlay; + QCheckBox *closeAfterPlay; + QCheckBox *bindSaveStates; + QCheckBox *dpySubTitles; + QCheckBox *putSubTitlesAvi; + QCheckBox *autoBackUp; + QCheckBox *loadFullStates; +private: +public slots: + void closeWindow(void); +private slots: + void readOnlyReplayChanged(int state); + void pauseAfterPlayChanged(int state); + void closeAfterPlayChanged(int state); + void bindSaveStatesChanged(int state); + void dpySubTitlesChanged(int state); + void putSubTitlesAviChanged(int state); + void autoBackUpChanged(int state); + void loadFullStatesChanged(int state); }; diff --git a/src/drivers/Qt/MoviePlay.cpp b/src/drivers/Qt/MoviePlay.cpp index 169b5ca8..db52e5a8 100644 --- a/src/drivers/Qt/MoviePlay.cpp +++ b/src/drivers/Qt/MoviePlay.cpp @@ -44,7 +44,7 @@ //---------------------------------------------------------------------------- MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout, *vbox; QHBoxLayout *hbox; @@ -57,96 +57,99 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent) setWindowTitle("Movie Play"); mainLayout = new QVBoxLayout(); - hbox = new QHBoxLayout(); + hbox = new QHBoxLayout(); - lbl = new QLabel( tr("File:") ); - movSelBox = new QComboBox(); - movBrowseBtn = new QPushButton( tr("Browse") ); + lbl = new QLabel(tr("File:")); + movSelBox = new QComboBox(); + movBrowseBtn = new QPushButton(tr("Browse")); - hbox->addWidget( lbl, 1 ); - hbox->addWidget( movSelBox, 100 ); - hbox->addWidget( movBrowseBtn, 1 ); + hbox->addWidget(lbl, 1); + hbox->addWidget(movSelBox, 100); + hbox->addWidget(movBrowseBtn, 1); - mainLayout->addLayout( hbox ); + mainLayout->addLayout(hbox); - frame = new QGroupBox( tr("Parameters:") ); - vbox = new QVBoxLayout(); - hbox = new QHBoxLayout(); + frame = new QGroupBox(tr("Parameters:")); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); - frame->setLayout( vbox ); + frame->setLayout(vbox); - openReadOnly = new QCheckBox( tr("Open Read-Only") ); - pauseAtFrame = new QCheckBox( tr("Pause Movie At Frame") ); + openReadOnly = new QCheckBox(tr("Open Read-Only")); + pauseAtFrame = new QCheckBox(tr("Pause Movie At Frame")); - validator = new fceuDecIntValidtor( 0, 100000000, this ); + validator = new fceuDecIntValidtor(0, 100000000, this); pauseAtFrameEntry = new QLineEdit(); - pauseAtFrameEntry->setValidator( validator ); + pauseAtFrameEntry->setValidator(validator); - vbox->addWidget( openReadOnly ); - vbox->addLayout( hbox ); - hbox->addWidget( pauseAtFrame ); - hbox->addWidget( pauseAtFrameEntry ); + vbox->addWidget(openReadOnly); + vbox->addLayout(hbox); + hbox->addWidget(pauseAtFrame); + hbox->addWidget(pauseAtFrameEntry); - mainLayout->addWidget( frame ); + mainLayout->addWidget(frame); grid = new QGridLayout(); - grid->setColumnStretch( 0, 1 ); - grid->setColumnStretch( 1, 10 ); + grid->setColumnStretch(0, 1); + grid->setColumnStretch(1, 10); - mainLayout->addLayout( grid ); + mainLayout->addLayout(grid); - movLenLbl = new QLabel(); - movFramesLbl = new QLabel(); - recCountLbl = new QLabel(); - recFromLbl = new QLabel(); - romUsedLbl = new QLabel(); - romCsumLbl = new QLabel(); - curCsumLbl = new QLabel(); - emuUsedLbl = new QLabel(); - palUsedLbl = new QLabel(); + movLenLbl = new QLabel(); + movFramesLbl = new QLabel(); + recCountLbl = new QLabel(); + recFromLbl = new QLabel(); + romUsedLbl = new QLabel(); + romCsumLbl = new QLabel(); + curCsumLbl = new QLabel(); + emuUsedLbl = new QLabel(); + palUsedLbl = new QLabel(); newppuUsedLbl = new QLabel(); - grid->addWidget( new QLabel( tr("Length:") ) , 0, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("Frames:") ) , 1, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("Record Count:") ) , 2, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("Recorded From:") ) , 3, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("ROM Used:") ) , 4, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("ROM Checksum:") ) , 5, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("Current ROM Sum:") ) , 6, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("Emulator Used:") ) , 7, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("PAL:") ) , 8, 0, Qt::AlignRight ); - grid->addWidget( new QLabel( tr("New PPU:") ) , 9, 0, Qt::AlignRight ); + grid->addWidget(new QLabel(tr("Length:")), 0, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("Frames:")), 1, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("Record Count:")), 2, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("Recorded From:")), 3, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("ROM Used:")), 4, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("ROM Checksum:")), 5, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("Current ROM Sum:")), 6, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("Emulator Used:")), 7, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("PAL:")), 8, 0, Qt::AlignRight); + grid->addWidget(new QLabel(tr("New PPU:")), 9, 0, Qt::AlignRight); - grid->addWidget( movLenLbl , 0, 1, Qt::AlignLeft ); - grid->addWidget( movFramesLbl , 1, 1, Qt::AlignLeft ); - grid->addWidget( recCountLbl , 2, 1, Qt::AlignLeft ); - grid->addWidget( recFromLbl , 3, 1, Qt::AlignLeft ); - grid->addWidget( romUsedLbl , 4, 1, Qt::AlignLeft ); - grid->addWidget( romCsumLbl , 5, 1, Qt::AlignLeft ); - grid->addWidget( curCsumLbl , 6, 1, Qt::AlignLeft ); - grid->addWidget( emuUsedLbl , 7, 1, Qt::AlignLeft ); - grid->addWidget( palUsedLbl , 8, 1, Qt::AlignLeft ); - grid->addWidget( newppuUsedLbl , 9, 1, Qt::AlignLeft ); + grid->addWidget(movLenLbl, 0, 1, Qt::AlignLeft); + grid->addWidget(movFramesLbl, 1, 1, Qt::AlignLeft); + grid->addWidget(recCountLbl, 2, 1, Qt::AlignLeft); + grid->addWidget(recFromLbl, 3, 1, Qt::AlignLeft); + grid->addWidget(romUsedLbl, 4, 1, Qt::AlignLeft); + grid->addWidget(romCsumLbl, 5, 1, Qt::AlignLeft); + grid->addWidget(curCsumLbl, 6, 1, Qt::AlignLeft); + grid->addWidget(emuUsedLbl, 7, 1, Qt::AlignLeft); + grid->addWidget(palUsedLbl, 8, 1, Qt::AlignLeft); + grid->addWidget(newppuUsedLbl, 9, 1, Qt::AlignLeft); - hbox = new QHBoxLayout(); - okButton = new QPushButton( tr("Play") ); - cancelButton = new QPushButton( tr("Cancel") ); - hbox->addWidget( cancelButton ); - hbox->addWidget( okButton ); + hbox = new QHBoxLayout(); + okButton = new QPushButton(tr("Play")); + cancelButton = new QPushButton(tr("Cancel")); + hbox->addWidget(cancelButton); + hbox->addWidget(okButton); okButton->setDefault(true); - mainLayout->addLayout( hbox ); + mainLayout->addLayout(hbox); - setLayout( mainLayout ); + setLayout(mainLayout); - connect( cancelButton , SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) ); - connect( okButton , SIGNAL(clicked(void)), this, SLOT(playMovie(void)) ); + okButton->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); + cancelButton->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) ); - connect( movBrowseBtn , SIGNAL(clicked(void)) , this, SLOT(openMovie(void)) ); - connect( movSelBox , SIGNAL(activated(int)), this, SLOT(movieSelect(int)) ); + connect(cancelButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + connect(okButton, SIGNAL(clicked(void)), this, SLOT(playMovie(void))); - connect( pauseAtFrame , SIGNAL(stateChanged(int)), this, SLOT(pauseAtFrameChange(int)) ); + connect(movBrowseBtn, SIGNAL(clicked(void)), this, SLOT(openMovie(void))); + connect(movSelBox, SIGNAL(activated(int)), this, SLOT(movieSelect(int))); + + connect(pauseAtFrame, SIGNAL(stateChanged(int)), this, SLOT(pauseAtFrameChange(int))); if (suggestReadOnlyReplay) { @@ -156,9 +159,9 @@ MoviePlayDialog_t::MoviePlayDialog_t(QWidget *parent) { replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly(); } - openReadOnly->setChecked( replayReadOnlySetting ); + openReadOnly->setChecked(replayReadOnlySetting); - pauseAtFrameEntry->setEnabled( pauseAtFrame->isChecked() ); + pauseAtFrameEntry->setEnabled(pauseAtFrame->isChecked()); doScan(); @@ -172,16 +175,16 @@ MoviePlayDialog_t::~MoviePlayDialog_t(void) //---------------------------------------------------------------------------- void MoviePlayDialog_t::closeEvent(QCloseEvent *event) { - printf("Movie Play Close Window Event\n"); - done(0); + printf("Movie Play Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void MoviePlayDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- @@ -197,10 +200,10 @@ void MoviePlayDialog_t::movieSelect(int index) //---------------------------------------------------------------------------- void MoviePlayDialog_t::pauseAtFrameChange(int state) { - pauseAtFrameEntry->setEnabled( state != Qt::Unchecked ); + pauseAtFrameEntry->setEnabled(state != Qt::Unchecked); } //---------------------------------------------------------------------------- -void MoviePlayDialog_t::clearMovieText(void) +void MoviePlayDialog_t::clearMovieText(void) { movLenLbl->clear(); movFramesLbl->clear(); @@ -215,16 +218,16 @@ void MoviePlayDialog_t::clearMovieText(void) pauseAtFrameEntry->clear(); } //---------------------------------------------------------------------------- -void MoviePlayDialog_t::updateMovieText(void) +void MoviePlayDialog_t::updateMovieText(void) { int idx; std::string path; - FCEUFILE* fp; + FCEUFILE *fp; MOVIE_INFO info; bool scanok; char stmp[256]; - if ( movSelBox->count() == 0 ) + if (movSelBox->count() == 0) { return; } @@ -232,30 +235,30 @@ void MoviePlayDialog_t::updateMovieText(void) path = movSelBox->itemText(idx).toStdString(); - fp = FCEU_fopen( path.c_str(),0,"rb",0); + fp = FCEU_fopen(path.c_str(), 0, "rb", 0); - if ( fp == NULL ) + if (fp == NULL) { - sprintf( stmp, "Error: Failed to open file '%s'", path.c_str() ); - showErrorMsgWindow( stmp ); + sprintf(stmp, "Error: Failed to open file '%s'", path.c_str()); + showErrorMsgWindow(stmp); clearMovieText(); return; } scanok = FCEUI_MovieGetInfo(fp, info, false); - if ( scanok ) + if (scanok) { double div; - validator->setMinMax( 0, info.num_frames ); + validator->setMinMax(0, info.num_frames); sprintf(stmp, "%u", (unsigned)info.num_frames); - movFramesLbl->setText( tr(stmp) ); - pauseAtFrameEntry->setText( tr(stmp) ); + movFramesLbl->setText(tr(stmp)); + pauseAtFrameEntry->setText(tr(stmp)); - div = (FCEUI_GetCurrentVidSystem(0,0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing - double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding + div = (FCEUI_GetCurrentVidSystem(0, 0)) ? 50.006977968268290849 : 60.098813897440515532; // PAL timing + double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding int num_seconds = (int)tempCount; int fraction = (int)((tempCount - num_seconds) * 100); int seconds = num_seconds % 60; @@ -263,56 +266,56 @@ void MoviePlayDialog_t::updateMovieText(void) int hours = (num_seconds / 60 / 60) % 60; sprintf(stmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction); - movLenLbl->setText( tr(stmp) ); + movLenLbl->setText(tr(stmp)); sprintf(stmp, "%u", (unsigned)info.rerecord_count); - recCountLbl->setText( tr(stmp) ); + recCountLbl->setText(tr(stmp)); - recFromLbl->setText( tr(info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate") ) ); + recFromLbl->setText(tr(info.poweron ? "Power-On" : (info.reset ? "Soft-Reset" : "Savestate"))); - romUsedLbl->setText( tr(info.name_of_rom_used.c_str()) ); + romUsedLbl->setText(tr(info.name_of_rom_used.c_str())); - romCsumLbl->setText( tr(md5_asciistr(info.md5_of_rom_used)) ); + romCsumLbl->setText(tr(md5_asciistr(info.md5_of_rom_used))); - if ( GameInfo ) + if (GameInfo) { - curCsumLbl->setText( tr(md5_asciistr(GameInfo->MD5)) ); + curCsumLbl->setText(tr(md5_asciistr(GameInfo->MD5))); } else { curCsumLbl->clear(); } - if (info.emu_version_used < 20000 ) + if (info.emu_version_used < 20000) { - sprintf( stmp, "FCEU %u.%02u.%02u%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : ""); + sprintf(stmp, "FCEU %u.%02u.%02u%s", info.emu_version_used / 10000, (info.emu_version_used / 100) % 100, (info.emu_version_used) % 100, info.emu_version_used < 9813 ? " (blip)" : ""); } - else + else { - sprintf( stmp, "FCEUX %u.%02u.%02u", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100); + sprintf(stmp, "FCEUX %u.%02u.%02u", info.emu_version_used / 10000, (info.emu_version_used / 100) % 100, (info.emu_version_used) % 100); } - emuUsedLbl->setText( tr(stmp) ); + emuUsedLbl->setText(tr(stmp)); - palUsedLbl->setText( tr(info.pal ? "On" : "Off") ); + palUsedLbl->setText(tr(info.pal ? "On" : "Off")); - newppuUsedLbl->setText( tr(info.ppuflag ? "On" : "Off") ); + newppuUsedLbl->setText(tr(info.ppuflag ? "On" : "Off")); - if ( GameInfo ) + if (GameInfo) { - strcpy( stmp, md5_asciistr(GameInfo->MD5) ); + strcpy(stmp, md5_asciistr(GameInfo->MD5)); - if ( strcmp( stmp, md5_asciistr(info.md5_of_rom_used) ) != 0 ) + if (strcmp(stmp, md5_asciistr(info.md5_of_rom_used)) != 0) { - sprintf( stmp, "Warning: Selected movie file '%s' may not have been created using the currently loaded ROM.", path.c_str() ); - showWarningMsgWindow( stmp ); + sprintf(stmp, "Warning: Selected movie file '%s' may not have been created using the currently loaded ROM.", path.c_str()); + showWarningMsgWindow(stmp); } } } else { - sprintf( stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str() ); - showErrorMsgWindow( stmp ); + sprintf(stmp, "Error: Selected file '%s' does not have a recognized movie format.", path.c_str()); + showErrorMsgWindow(stmp); clearMovieText(); } delete fp; @@ -320,27 +323,27 @@ void MoviePlayDialog_t::updateMovieText(void) return; } //---------------------------------------------------------------------------- -int MoviePlayDialog_t::addFileToList( const char *file, bool setActive ) +int MoviePlayDialog_t::addFileToList(const char *file, bool setActive) { - int n=0; + int n = 0; - for (int i=0; icount(); i++) + for (int i = 0; i < movSelBox->count(); i++) { - if ( strcmp( file, movSelBox->itemText(i).toStdString().c_str() ) == 0 ) - { - if ( setActive ) - { - movSelBox->setCurrentIndex(i); - } - return -1; - } + if (strcmp(file, movSelBox->itemText(i).toStdString().c_str()) == 0) + { + if (setActive) + { + movSelBox->setCurrentIndex(i); + } + return -1; + } } n = movSelBox->count(); - movSelBox->addItem( tr(file), n ); + movSelBox->addItem(tr(file), n); - if ( setActive ) + if (setActive) { movSelBox->setCurrentIndex(n); } @@ -348,23 +351,23 @@ int MoviePlayDialog_t::addFileToList( const char *file, bool setActive ) return 0; } //---------------------------------------------------------------------------- -bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 ) +bool MoviePlayDialog_t::checkMD5Sum(const char *path, const char *md5) { - FCEUFILE* fp; + FCEUFILE *fp; MOVIE_INFO info; bool scanok, md5Match = false; - - fp = FCEU_fopen( path,0,"rb",0); - if ( fp == NULL ) + fp = FCEU_fopen(path, 0, "rb", 0); + + if (fp == NULL) { return md5Match; } scanok = FCEUI_MovieGetInfo(fp, info, true); - if ( scanok ) + if (scanok) { - if ( strcmp( md5, md5_asciistr(info.md5_of_rom_used) ) == 0 ) + if (strcmp(md5, md5_asciistr(info.md5_of_rom_used)) == 0) { md5Match = true; } @@ -374,33 +377,32 @@ bool MoviePlayDialog_t::checkMD5Sum( const char *path, const char *md5 ) return md5Match; } //---------------------------------------------------------------------------- -void MoviePlayDialog_t::scanDirectory( const char *dirPath, const char *md5 ) +void MoviePlayDialog_t::scanDirectory(const char *dirPath, const char *md5) { QDir dir; QFileInfoList list; std::string path; - const QStringList filters( { "*.fm2" } ); + const QStringList filters({"*.fm2"}); - path.assign( dirPath ); + path.assign(dirPath); - dir.setPath( QString::fromStdString(path) ); + dir.setPath(QString::fromStdString(path)); - list = dir.entryInfoList( filters, QDir::Files ); + list = dir.entryInfoList(filters, QDir::Files); - for (int i = 0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); - path = std::string(dirPath) + fileInfo.fileName().toStdString(); + path = std::string(dirPath) + fileInfo.fileName().toStdString(); //printf("File: '%s'\n", path.c_str() ); - if ( checkMD5Sum( path.c_str(), md5 ) ) + if (checkMD5Sum(path.c_str(), md5)) { - addFileToList( path.c_str() ); + addFileToList(path.c_str()); } } - } //---------------------------------------------------------------------------- void MoviePlayDialog_t::doScan(void) @@ -413,31 +415,31 @@ void MoviePlayDialog_t::doScan(void) md5[0] = 0; - if ( GameInfo ) + if (GameInfo) { - strcpy( md5, md5_asciistr(GameInfo->MD5) ); + strcpy(md5, md5_asciistr(GameInfo->MD5)); } - - path = std::string(baseDir) + "/movies/"; - scanDirectory( path.c_str(), md5 ); + path = std::string(baseDir) + "/movies/"; + + scanDirectory(path.c_str(), md5); romFile = getRomFile(); - if ( romFile != NULL ) + if (romFile != NULL) { - parseFilepath( romFile, dir, base ); + parseFilepath(romFile, dir, base); - path = std::string(dir); + path = std::string(dir); - scanDirectory( path.c_str(), md5 ); + scanDirectory(path.c_str(), md5); } - g_config->getOption ("SDL.LastOpenMovie", &last ); + g_config->getOption("SDL.LastOpenMovie", &last); - getDirFromFile( last.c_str(), dir ); + getDirFromFile(last.c_str(), dir); - scanDirectory( dir, md5 ); + scanDirectory(dir, md5); } //---------------------------------------------------------------------------- void MoviePlayDialog_t::playMovie(void) @@ -445,7 +447,7 @@ void MoviePlayDialog_t::playMovie(void) int idx, pauseframe = 0; bool replayReadOnlySetting, movieLoadError = false; - if ( movSelBox->count() == 0 ) + if (movSelBox->count() == 0) { return; } @@ -457,24 +459,24 @@ void MoviePlayDialog_t::playMovie(void) replayReadOnlySetting = openReadOnly->isChecked(); - if ( pauseAtFrame->isChecked() ) + if (pauseAtFrame->isChecked()) { - pauseframe = strtol( pauseAtFrameEntry->text().toStdString().c_str(), NULL, 0 ); + pauseframe = strtol(pauseAtFrameEntry->text().toStdString().c_str(), NULL, 0); } fceuWrapperLock(); - if (FCEUI_LoadMovie( path.c_str(), - replayReadOnlySetting, pauseframe ? pauseframe : false) == false) + if (FCEUI_LoadMovie(path.c_str(), + replayReadOnlySetting, pauseframe ? pauseframe : false) == false) { movieLoadError = true; } fceuWrapperUnLock(); - if ( movieLoadError ) + if (movieLoadError) { char stmp[256]; - sprintf( stmp, "Error: Could not load movie file: %s \n", path.c_str() ); - showErrorMsgWindow( stmp ); + sprintf(stmp, "Error: Could not load movie file: %s \n", path.c_str()); + showErrorMsgWindow(stmp); } else { @@ -489,78 +491,78 @@ void MoviePlayDialog_t::openMovie(void) std::string last; char dir[512]; char md5Match = 0; - QFileDialog dialog(this, tr("Open FM2 Movie") ); + QFileDialog dialog(this, tr("Open FM2 Movie")); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("FM2 Movies (*.fm2) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Open") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Open")); - g_config->getOption ("SDL.LastOpenMovie", &last ); + g_config->getOption("SDL.LastOpenMovie", &last); - getDirFromFile( last.c_str(), dir ); + getDirFromFile(last.c_str(), dir); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) - { - return; - } + if (filename.isNull()) + { + return; + } qDebug() << "selected file path : " << filename.toUtf8(); - if ( GameInfo ) + if (GameInfo) { char md5[256]; - strcpy( md5, md5_asciistr(GameInfo->MD5) ); + strcpy(md5, md5_asciistr(GameInfo->MD5)); - if ( checkMD5Sum( filename.toStdString().c_str(), md5 ) ) + if (checkMD5Sum(filename.toStdString().c_str(), md5)) { md5Match = 1; } - if ( !md5Match ) + if (!md5Match) { printf("Warning MD5 Mismatch\n"); } } - addFileToList( filename.toStdString().c_str(), true ); + addFileToList(filename.toStdString().c_str(), true); updateMovieText(); - - g_config->setOption ("SDL.LastOpenMovie", filename.toStdString().c_str() ); - return; + g_config->setOption("SDL.LastOpenMovie", filename.toStdString().c_str()); + + return; } //---------------------------------------------------------------------------- void MoviePlayDialog_t::showErrorMsgWindow(const char *str) { QMessageBox msgBox(this); - msgBox.setIcon( QMessageBox::Critical ); - msgBox.setText( tr(str) ); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText(tr(str)); msgBox.show(); msgBox.exec(); } @@ -569,8 +571,8 @@ void MoviePlayDialog_t::showWarningMsgWindow(const char *str) { QMessageBox msgBox(this); - msgBox.setIcon( QMessageBox::Warning ); - msgBox.setText( tr(str) ); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(tr(str)); msgBox.show(); msgBox.exec(); } diff --git a/src/drivers/Qt/MoviePlay.h b/src/drivers/Qt/MoviePlay.h index 710e307e..274767ad 100644 --- a/src/drivers/Qt/MoviePlay.h +++ b/src/drivers/Qt/MoviePlay.h @@ -20,50 +20,49 @@ class MoviePlayDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - MoviePlayDialog_t(QWidget *parent = 0); - ~MoviePlayDialog_t(void); +public: + MoviePlayDialog_t(QWidget *parent = 0); + ~MoviePlayDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QComboBox *movSelBox; - QPushButton *movBrowseBtn; - QCheckBox *openReadOnly; - QCheckBox *pauseAtFrame; - QLineEdit *pauseAtFrameEntry; + QComboBox *movSelBox; + QPushButton *movBrowseBtn; + QCheckBox *openReadOnly; + QCheckBox *pauseAtFrame; + QLineEdit *pauseAtFrameEntry; - QLabel *movLenLbl; - QLabel *movFramesLbl; - QLabel *recCountLbl; - QLabel *recFromLbl; - QLabel *romUsedLbl; - QLabel *romCsumLbl; - QLabel *curCsumLbl; - QLabel *emuUsedLbl; - QLabel *palUsedLbl; - QLabel *newppuUsedLbl; + QLabel *movLenLbl; + QLabel *movFramesLbl; + QLabel *recCountLbl; + QLabel *recFromLbl; + QLabel *romUsedLbl; + QLabel *romCsumLbl; + QLabel *curCsumLbl; + QLabel *emuUsedLbl; + QLabel *palUsedLbl; + QLabel *newppuUsedLbl; - fceuDecIntValidtor *validator; + fceuDecIntValidtor *validator; - private: - void doScan(void); - void clearMovieText(void); - void updateMovieText(void); - int addFileToList( const char *file, bool setActive = false ); - bool checkMD5Sum( const char *path, const char *md5 ); - void scanDirectory( const char *dirPath, const char *md5 ); - void showErrorMsgWindow(const char *str); - void showWarningMsgWindow(const char *str); - - public slots: - void closeWindow(void); - private slots: - void openMovie(void); - void playMovie(void); - void movieSelect(int index); - void pauseAtFrameChange(int state); +private: + void doScan(void); + void clearMovieText(void); + void updateMovieText(void); + int addFileToList(const char *file, bool setActive = false); + bool checkMD5Sum(const char *path, const char *md5); + void scanDirectory(const char *dirPath, const char *md5); + void showErrorMsgWindow(const char *str); + void showWarningMsgWindow(const char *str); +public slots: + void closeWindow(void); +private slots: + void openMovie(void); + void playMovie(void); + void movieSelect(int index); + void pauseAtFrameChange(int state); }; diff --git a/src/drivers/Qt/MsgLogViewer.cpp b/src/drivers/Qt/MsgLogViewer.cpp index f29fc0cd..ffd3219d 100644 --- a/src/drivers/Qt/MsgLogViewer.cpp +++ b/src/drivers/Qt/MsgLogViewer.cpp @@ -41,40 +41,40 @@ #include "Qt/MsgLogViewer.h" #include "Qt/ConsoleWindow.h" -#define MSG_LOG_MAX_LINES 256 +#define MSG_LOG_MAX_LINES 256 class msgLogBuf_t { - public: +public: msgLogBuf_t(void) { char filename[512]; - #ifdef WIN32 - if ( GetTempPathA( sizeof(filename), filename ) > 0 ) +#ifdef WIN32 + if (GetTempPathA(sizeof(filename), filename) > 0) { //printf("PATH: %s \n", filename ); - strcat( filename, "fceux.log"); + strcat(filename, "fceux.log"); } else { - strcpy( filename, "fceux.log" ); + strcpy(filename, "fceux.log"); } - #else - strcpy( filename, "/tmp/fceux.log" ); - #endif +#else + strcpy(filename, "/tmp/fceux.log"); +#endif - fp = ::fopen( filename, "w+"); + fp = ::fopen(filename, "w+"); - if ( fp == NULL ) + if (fp == NULL) { printf("Error: Failed to open message log file: '%s'\n", filename); } - maxLines = MSG_LOG_MAX_LINES; + maxLines = MSG_LOG_MAX_LINES; totalLines = 0; head = tail = 0; - for (int i=0; i 0 ) + if ((nbytes = ::fread(buf, 1, sizeof(buf), fp)) > 0) { //printf("READ: %li \n", nbytes ); - buf[ nbytes ] = 0; - viewer->setPlainText( buf ); + buf[nbytes] = 0; + viewer->setPlainText(buf); } } - private: - FILE *fp; - size_t maxLines; - size_t totalLines; - size_t head; - size_t tail; +private: + FILE *fp; + size_t maxLines; + size_t totalLines; + size_t head; + size_t tail; - long fpOfsList[MSG_LOG_MAX_LINES]; + long fpOfsList[MSG_LOG_MAX_LINES]; }; static msgLogBuf_t msgLog; //---------------------------------------------------------------------------- MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout; QHBoxLayout *hbox; @@ -192,37 +194,41 @@ MsgLogViewDialog_t::MsgLogViewDialog_t(QWidget *parent) setWindowTitle("Message Log Viewer"); - resize( 512, 512 ); + resize(512, 512); mainLayout = new QVBoxLayout(); txtView = new QPlainTextEdit(); txtView->setReadOnly(true); - mainLayout->addWidget( txtView ); + mainLayout->addWidget(txtView); - hbox = new QHBoxLayout(); - clearBtn = new QPushButton( tr("Clear") ); - closeBtn = new QPushButton( tr("Close") ); - hbox->addWidget( clearBtn ); - hbox->addWidget( closeBtn ); + hbox = new QHBoxLayout(); + clearBtn = new QPushButton(tr("Clear")); + closeBtn = new QPushButton(tr("Close")); + hbox->addWidget(clearBtn,1); + hbox->addStretch(5); + hbox->addWidget(closeBtn,1); - connect( clearBtn, SIGNAL(clicked(void)), this, SLOT(clearLog(void)) ); - connect( closeBtn, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)) ); + clearBtn->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton)); + closeBtn->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); - mainLayout->addLayout( hbox ); + connect(clearBtn, SIGNAL(clicked(void)), this, SLOT(clearLog(void))); + connect(closeBtn, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); - setLayout( mainLayout ); + mainLayout->addLayout(hbox); + + setLayout(mainLayout); totalLines = 0; - updateTimer = new QTimer( this ); + updateTimer = new QTimer(this); - connect( updateTimer, &QTimer::timeout, this, &MsgLogViewDialog_t::updatePeriodic ); + connect(updateTimer, &QTimer::timeout, this, &MsgLogViewDialog_t::updatePeriodic); - updateTimer->start( 500 ); // 2hz + updateTimer->start(500); // 2hz - msgLog.loadTextViewer( txtView ); + msgLog.loadTextViewer(txtView); totalLines = msgLog.getTotalLineCount(); @@ -237,16 +243,16 @@ MsgLogViewDialog_t::~MsgLogViewDialog_t(void) //---------------------------------------------------------------------------- void MsgLogViewDialog_t::closeEvent(QCloseEvent *event) { - printf("Msg Log Key Close Window Event\n"); - done(0); + printf("Msg Log Key Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void MsgLogViewDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- @@ -263,11 +269,11 @@ void MsgLogViewDialog_t::clearLog(void) //---------------------------------------------------------------------------- void MsgLogViewDialog_t::updatePeriodic(void) { - if ( msgLog.getTotalLineCount() != totalLines ) + if (msgLog.getTotalLineCount() != totalLines) { fceuWrapperLock(); - msgLog.loadTextViewer( txtView ); + msgLog.loadTextViewer(txtView); totalLines = msgLog.getTotalLineCount(); @@ -289,7 +295,7 @@ void FCEUD_Message(const char *text) fputs(text, stdout); //fprintf(stdout, "\n"); // - msgLog.addLine( text, false ); + msgLog.addLine(text, false); } //---------------------------------------------------------------------------- /** @@ -304,11 +310,11 @@ void FCEUD_PrintError(const char *errormsg) { fprintf(stderr, "%s\n", errormsg); - msgLog.addLine( errormsg, true ); + msgLog.addLine(errormsg, true); - if ( consoleWindow ) + if (consoleWindow) { - consoleWindow->QueueErrorMsgWindow( errormsg ); + consoleWindow->QueueErrorMsgWindow(errormsg); } } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/MsgLogViewer.h b/src/drivers/Qt/MsgLogViewer.h index d43edcf8..1fe6e015 100644 --- a/src/drivers/Qt/MsgLogViewer.h +++ b/src/drivers/Qt/MsgLogViewer.h @@ -20,27 +20,24 @@ class MsgLogViewDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - MsgLogViewDialog_t(QWidget *parent = 0); - ~MsgLogViewDialog_t(void); +public: + MsgLogViewDialog_t(QWidget *parent = 0); + ~MsgLogViewDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QTimer *updateTimer; - QPlainTextEdit *txtView; + QTimer *updateTimer; + QPlainTextEdit *txtView; - size_t totalLines; - - private: - - public slots: - void closeWindow(void); - private slots: - void updatePeriodic(void); - void clearLog(void); + size_t totalLines; +private: +public slots: + void closeWindow(void); +private slots: + void updatePeriodic(void); + void clearLog(void); }; - diff --git a/src/drivers/Qt/PaletteConf.cpp b/src/drivers/Qt/PaletteConf.cpp index 15bdbcae..e3171590 100644 --- a/src/drivers/Qt/PaletteConf.cpp +++ b/src/drivers/Qt/PaletteConf.cpp @@ -35,8 +35,8 @@ extern bool force_grayscale; -static const char *commentText = -"Palette Selection uses the 1st Matching Condition:\n\ +static const char *commentText = + "Palette Selection uses the 1st Matching Condition:\n\ 1. Game type is NSF (always uses fixed palette) \n\ 2. Custom User Palette is Available and Enabled \n\ 3. NTSC Color Emulation is Enabled \n\ @@ -44,150 +44,158 @@ static const char *commentText = 5. Default Built-in Palette "; //---------------------------------------------------- PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { QVBoxLayout *mainLayout, *vbox; - QHBoxLayout *hbox1; - QGroupBox *frame; - //QPushButton *closebutton; + QHBoxLayout *hbox1, *hbox; + QGroupBox *frame; + QPushButton *closeButton; QPushButton *button; QTextEdit *comments; - QStyle *style; + QStyle *style; int hue, tint; char stmp[64]; std::string paletteFile; style = this->style(); - resize( 512, 600 ); + resize(512, 650); // sync with config - g_config->getOption ("SDL.Hue", &hue); - g_config->getOption ("SDL.Tint", &tint); + g_config->getOption("SDL.Hue", &hue); + g_config->getOption("SDL.Tint", &tint); - setWindowTitle( tr("Palette Config") ); + setWindowTitle(tr("Palette Config")); mainLayout = new QVBoxLayout(); - frame = new QGroupBox( tr("Custom Palette:") ); - vbox = new QVBoxLayout(); + frame = new QGroupBox(tr("Custom Palette:")); + vbox = new QVBoxLayout(); hbox1 = new QHBoxLayout(); - useCustom = new QCheckBox( tr("Use Custom Palette") ); - GrayScale = new QCheckBox( tr("Force Grayscale") ); - deemphSwap = new QCheckBox( tr("De-emphasis Bit Swap") ); + useCustom = new QCheckBox(tr("Use Custom Palette")); + GrayScale = new QCheckBox(tr("Force Grayscale")); + deemphSwap = new QCheckBox(tr("De-emphasis Bit Swap")); - useCustom->setChecked( FCEUI_GetUserPaletteAvail() ); - GrayScale->setChecked( force_grayscale ); - deemphSwap->setChecked( paldeemphswap ); + useCustom->setChecked(FCEUI_GetUserPaletteAvail()); + GrayScale->setChecked(force_grayscale); + deemphSwap->setChecked(paldeemphswap); - connect(useCustom , SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int)) ); - connect(GrayScale , SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)) ); - connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)) ); + connect(useCustom, SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int))); + connect(GrayScale, SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int))); + connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int))); - button = new QPushButton( tr("Open Palette") ); - button->setIcon( style->standardIcon( QStyle::SP_FileDialogStart ) ); - hbox1->addWidget( button ); + button = new QPushButton(tr("Open Palette")); + button->setIcon(style->standardIcon(QStyle::SP_FileDialogStart)); + hbox1->addWidget(button); - connect( button, SIGNAL(clicked(void)), this, SLOT(openPaletteFile(void)) ); + connect(button, SIGNAL(clicked(void)), this, SLOT(openPaletteFile(void))); - g_config->getOption ("SDL.Palette", &paletteFile); + g_config->getOption("SDL.Palette", &paletteFile); custom_palette_path = new QLineEdit(); custom_palette_path->setReadOnly(true); - custom_palette_path->setText( paletteFile.c_str() ); + custom_palette_path->setText(paletteFile.c_str()); - vbox->addWidget( useCustom ); - vbox->addLayout( hbox1 ); - vbox->addWidget( custom_palette_path ); - vbox->addWidget( GrayScale ); - vbox->addWidget( deemphSwap); + vbox->addWidget(useCustom); + vbox->addLayout(hbox1); + vbox->addWidget(custom_palette_path); + vbox->addWidget(GrayScale); + vbox->addWidget(deemphSwap); + button = new QPushButton(tr("Clear")); + button->setIcon(style->standardIcon(QStyle::SP_LineEditClearButton)); + hbox1->addWidget(button); - button = new QPushButton( tr("Clear") ); - button->setIcon( style->standardIcon( QStyle::SP_LineEditClearButton ) ); - hbox1->addWidget( button ); + connect(button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void))); - connect( button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)) ); + frame->setLayout(vbox); - frame->setLayout( vbox ); + mainLayout->addWidget(frame); - mainLayout->addWidget( frame ); + frame = new QGroupBox(tr("NTSC Palette Controls:")); - frame = new QGroupBox( tr("NTSC Palette Controls:") ); - - vbox = new QVBoxLayout(); - useNTSC = new QCheckBox( tr("Use NTSC Palette") ); + vbox = new QVBoxLayout(); + useNTSC = new QCheckBox(tr("Use NTSC Palette")); int ntscPaletteEnable; g_config->getOption("SDL.NTSCpalette", &ntscPaletteEnable); - useNTSC->setChecked( ntscPaletteEnable ); + useNTSC->setChecked(ntscPaletteEnable); - connect(useNTSC , SIGNAL(stateChanged(int)), this, SLOT(use_NTSC_Changed(int)) ); + connect(useNTSC, SIGNAL(stateChanged(int)), this, SLOT(use_NTSC_Changed(int))); - vbox->addWidget( useNTSC ); + vbox->addWidget(useNTSC); - sprintf( stmp, "Tint: %3i \n", tint ); - tintFrame = new QGroupBox( tr(stmp) ); + sprintf(stmp, "Tint: %3i \n", tint); + tintFrame = new QGroupBox(tr(stmp)); hbox1 = new QHBoxLayout(); - tintSlider = new QSlider( Qt::Horizontal ); - tintSlider->setMinimum( 0); + tintSlider = new QSlider(Qt::Horizontal); + tintSlider->setMinimum(0); tintSlider->setMaximum(128); - tintSlider->setValue( tint ); + tintSlider->setValue(tint); - connect( tintSlider, SIGNAL(valueChanged(int)), this, SLOT(tintChanged(int)) ); + connect(tintSlider, SIGNAL(valueChanged(int)), this, SLOT(tintChanged(int))); - hbox1->addWidget( tintSlider ); - tintFrame->setLayout( hbox1 ); - vbox->addWidget( tintFrame ); + hbox1->addWidget(tintSlider); + tintFrame->setLayout(hbox1); + vbox->addWidget(tintFrame); - sprintf( stmp, "Hue: %3i \n", hue ); - hueFrame = new QGroupBox( tr(stmp) ); + sprintf(stmp, "Hue: %3i \n", hue); + hueFrame = new QGroupBox(tr(stmp)); hbox1 = new QHBoxLayout(); - hueSlider = new QSlider( Qt::Horizontal ); - hueSlider->setMinimum( 0); + hueSlider = new QSlider(Qt::Horizontal); + hueSlider->setMinimum(0); hueSlider->setMaximum(128); - hueSlider->setValue( hue ); + hueSlider->setValue(hue); - connect( hueSlider, SIGNAL(valueChanged(int)), this, SLOT(hueChanged(int)) ); + connect(hueSlider, SIGNAL(valueChanged(int)), this, SLOT(hueChanged(int))); - hbox1->addWidget( hueSlider ); - hueFrame->setLayout( hbox1 ); - vbox->addWidget( hueFrame ); + hbox1->addWidget(hueSlider); + hueFrame->setLayout(hbox1); + vbox->addWidget(hueFrame); - frame->setLayout( vbox ); + frame->setLayout(vbox); - mainLayout->addWidget( frame ); + mainLayout->addWidget(frame); comments = new QTextEdit(); - comments->setText( commentText ); + comments->setText(commentText); comments->moveCursor(QTextCursor::Start); comments->setReadOnly(true); - mainLayout->addWidget( comments ); + mainLayout->addWidget(comments); - setLayout( mainLayout ); + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); + mainLayout->addLayout( hbox ); + + setLayout(mainLayout); } //---------------------------------------------------- PaletteConfDialog_t::~PaletteConfDialog_t(void) { - printf("Destroy Palette Config Window\n"); + printf("Destroy Palette Config Window\n"); } //---------------------------------------------------------------------------- void PaletteConfDialog_t::closeEvent(QCloseEvent *event) { - printf("Palette Config Close Window Event\n"); - done(0); + printf("Palette Config Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------- void PaletteConfDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------- @@ -196,18 +204,18 @@ void PaletteConfDialog_t::hueChanged(int v) int c, t; char stmp[64]; - sprintf( stmp, "Hue: %3i", v ); + sprintf(stmp, "Hue: %3i", v); hueFrame->setTitle(stmp); - g_config->setOption ("SDL.Hue", v); - g_config->save (); - g_config->getOption ("SDL.Tint", &t); - g_config->getOption ("SDL.NTSCpalette", &c); + g_config->setOption("SDL.Hue", v); + g_config->save(); + g_config->getOption("SDL.Tint", &t); + g_config->getOption("SDL.NTSCpalette", &c); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetNTSCTH (c, t, v); + FCEUI_SetNTSCTH(c, t, v); fceuWrapperUnLock(); } } @@ -217,18 +225,18 @@ void PaletteConfDialog_t::tintChanged(int v) int c, h; char stmp[64]; - sprintf( stmp, "Tint: %3i", v ); + sprintf(stmp, "Tint: %3i", v); tintFrame->setTitle(stmp); - g_config->setOption ("SDL.Tint", v); - g_config->save (); - g_config->getOption ("SDL.NTSCpalette", &c); - g_config->getOption ("SDL.Hue", &h); + g_config->setOption("SDL.Tint", v); + g_config->save(); + g_config->getOption("SDL.NTSCpalette", &c); + g_config->getOption("SDL.Hue", &h); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetNTSCTH (c, v, h); + FCEUI_SetNTSCTH(c, v, h); fceuWrapperUnLock(); } } @@ -240,17 +248,17 @@ void PaletteConfDialog_t::use_Custom_Changed(int state) //printf("Use Custom:%i \n", state ); - g_config->getOption ("SDL.Palette", &filename); + g_config->getOption("SDL.Palette", &filename); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - if ( value && (filename.size() > 0) ) + if (value && (filename.size() > 0)) { - LoadCPalette ( filename.c_str() ); + LoadCPalette(filename.c_str()); } else { - FCEUI_SetUserPalette( NULL, 0); + FCEUI_SetUserPalette(NULL, 0); } fceuWrapperUnLock(); } @@ -260,14 +268,14 @@ void PaletteConfDialog_t::force_GrayScale_Changed(int state) { int value = (state == Qt::Unchecked) ? 0 : 1; - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { int e, h, t; - g_config->getOption ("SDL.NTSCpalette", &e); - g_config->getOption ("SDL.Hue", &h); - g_config->getOption ("SDL.Tint", &t); + g_config->getOption("SDL.NTSCpalette", &e); + g_config->getOption("SDL.Hue", &h); + g_config->getOption("SDL.Tint", &t); force_grayscale = value ? true : false; - FCEUI_SetNTSCTH( e, t, h); + FCEUI_SetNTSCTH(e, t, h); fceuWrapperUnLock(); } } @@ -276,14 +284,14 @@ void PaletteConfDialog_t::deemphswap_Changed(int state) { int value = (state == Qt::Unchecked) ? 0 : 1; - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { int e, h, t; - g_config->getOption ("SDL.NTSCpalette", &e); - g_config->getOption ("SDL.Hue", &h); - g_config->getOption ("SDL.Tint", &t); + g_config->getOption("SDL.NTSCpalette", &e); + g_config->getOption("SDL.Hue", &h); + g_config->getOption("SDL.Tint", &t); paldeemphswap = value ? true : false; - FCEUI_SetNTSCTH( e, t, h); + FCEUI_SetNTSCTH(e, t, h); fceuWrapperUnLock(); } } @@ -293,15 +301,15 @@ void PaletteConfDialog_t::use_NTSC_Changed(int state) int h, t; int value = (state == Qt::Unchecked) ? 0 : 1; - g_config->setOption ("SDL.NTSCpalette", value); - g_config->save (); + g_config->setOption("SDL.NTSCpalette", value); + g_config->save(); - g_config->getOption ("SDL.Hue", &h); - g_config->getOption ("SDL.Tint", &t); + g_config->getOption("SDL.Hue", &h); + g_config->getOption("SDL.Tint", &t); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetNTSCTH (value, t, h); + FCEUI_SetNTSCTH(value, t, h); //UpdateEMUCore (g_config); fceuWrapperUnLock(); } @@ -309,12 +317,12 @@ void PaletteConfDialog_t::use_NTSC_Changed(int state) //---------------------------------------------------- void PaletteConfDialog_t::clearPalette(void) { - g_config->setOption ("SDL.Palette", ""); + g_config->setOption("SDL.Palette", ""); custom_palette_path->setText(""); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - FCEUI_SetUserPalette( NULL, 0); + FCEUI_SetUserPalette(NULL, 0); fceuWrapperUnLock(); useCustom->setChecked(false); } @@ -327,24 +335,24 @@ void PaletteConfDialog_t::openPaletteFile(void) std::string last, iniPath; char dir[512]; char exePath[512]; - QFileDialog dialog(this, tr("Open NES Palette") ); + QFileDialog dialog(this, tr("Open NES Palette")); QList urls; - QDir d; + QDir d; - fceuExecutablePath( exePath, sizeof(exePath) ); + fceuExecutablePath(exePath, sizeof(exePath)); //urls = dialog.sidebarUrls(); - urls << QUrl::fromLocalFile( QDir::rootPath() ); + urls << QUrl::fromLocalFile(QDir::rootPath()); urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first()); - urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() ); + urls << QUrl::fromLocalFile(QDir(FCEUI_GetBaseDirectory()).absolutePath()); - if ( exePath[0] != 0 ) + if (exePath[0] != 0) { - d.setPath( QString(exePath) + "/../palettes" ); + d.setPath(QString(exePath) + "/../palettes"); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); iniPath = d.absolutePath().toStdString(); } } @@ -353,9 +361,9 @@ void PaletteConfDialog_t::openPaletteFile(void) #else d.setPath("/usr/share/fceux/palettes"); - if ( d.exists() ) + if (d.exists()) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + urls << QUrl::fromLocalFile(d.absolutePath()); iniPath = d.absolutePath().toStdString(); } #endif @@ -365,62 +373,61 @@ void PaletteConfDialog_t::openPaletteFile(void) dialog.setNameFilter(tr("NES Palettes (*.pal *.PAL) ;; All files (*)")); dialog.setViewMode(QFileDialog::List); - dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden ); - dialog.setLabelText( QFileDialog::Accept, tr("Load") ); + dialog.setFilter(QDir::AllEntries | QDir::AllDirs | QDir::Hidden); + dialog.setLabelText(QFileDialog::Accept, tr("Load")); - g_config->getOption ("SDL.Palette", &last ); + g_config->getOption("SDL.Palette", &last); - if ( last.size() == 0 ) + if (last.size() == 0) { - last.assign( iniPath ); + last.assign(iniPath); } - getDirFromFile( last.c_str(), dir ); + getDirFromFile(last.c_str(), dir); - dialog.setDirectory( tr(dir) ); + dialog.setDirectory(tr(dir)); // Check config option to use native file dialog or not - g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal); + g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal); dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal); dialog.setSidebarUrls(urls); ret = dialog.exec(); - if ( ret ) + if (ret) { QStringList fileList; fileList = dialog.selectedFiles(); - if ( fileList.size() > 0 ) + if (fileList.size() > 0) { filename = fileList[0]; } } - if ( filename.isNull() ) + if (filename.isNull()) { - return; + return; } qDebug() << "selected file path : " << filename.toUtf8(); - if ( fceuWrapperTryLock() ) + if (fceuWrapperTryLock()) { - if ( LoadCPalette ( filename.toStdString().c_str() ) ) + if (LoadCPalette(filename.toStdString().c_str())) { - g_config->setOption ("SDL.Palette", filename.toStdString().c_str() ); - custom_palette_path->setText( filename.toStdString().c_str() ); + g_config->setOption("SDL.Palette", filename.toStdString().c_str()); + custom_palette_path->setText(filename.toStdString().c_str()); } else { - printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str() ); + printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str()); } fceuWrapperUnLock(); - useCustom->setChecked( FCEUI_GetUserPaletteAvail() ); + useCustom->setChecked(FCEUI_GetUserPaletteAvail()); } - - return; + return; } //---------------------------------------------------- diff --git a/src/drivers/Qt/PaletteConf.h b/src/drivers/Qt/PaletteConf.h index 5b28d9c0..4d540b26 100644 --- a/src/drivers/Qt/PaletteConf.h +++ b/src/drivers/Qt/PaletteConf.h @@ -19,36 +19,35 @@ class PaletteConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - PaletteConfDialog_t(QWidget *parent = 0); - ~PaletteConfDialog_t(void); +public: + PaletteConfDialog_t(QWidget *parent = 0); + ~PaletteConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QLineEdit *custom_palette_path; - QCheckBox *useCustom; - QCheckBox *GrayScale; - QCheckBox *deemphSwap; - QCheckBox *useNTSC; - QSlider *tintSlider; - QSlider *hueSlider; - QGroupBox *tintFrame; - QGroupBox *hueFrame; - private: - - public slots: - void closeWindow(void); - private slots: - void hueChanged(int value); - void tintChanged(int value); - void openPaletteFile(void); - void clearPalette(void); - void use_NTSC_Changed(int v); - void use_Custom_Changed(int v); - void force_GrayScale_Changed(int v); - void deemphswap_Changed(int v); + QLineEdit *custom_palette_path; + QCheckBox *useCustom; + QCheckBox *GrayScale; + QCheckBox *deemphSwap; + QCheckBox *useNTSC; + QSlider *tintSlider; + QSlider *hueSlider; + QGroupBox *tintFrame; + QGroupBox *hueFrame; +private: +public slots: + void closeWindow(void); +private slots: + void hueChanged(int value); + void tintChanged(int value); + void openPaletteFile(void); + void clearPalette(void); + void use_NTSC_Changed(int v); + void use_Custom_Changed(int v); + void force_GrayScale_Changed(int v); + void deemphswap_Changed(int v); }; diff --git a/src/drivers/Qt/PaletteEditor.cpp b/src/drivers/Qt/PaletteEditor.cpp index 8bd7929e..15be9a60 100644 --- a/src/drivers/Qt/PaletteEditor.cpp +++ b/src/drivers/Qt/PaletteEditor.cpp @@ -90,6 +90,16 @@ PaletteEditorDialog_t::PaletteEditorDialog_t(QWidget *parent) fileMenu->addAction(act); + fileMenu->addSeparator(); + + // File -> Close + act = new QAction(tr("&Close"), this); + act->setShortcut( QKeySequence::Close ); + act->setStatusTip(tr("Close Window")); + connect(act, SIGNAL(triggered()), this, SLOT(closeWindow(void)) ); + + fileMenu->addAction(act); + // Memory memMenu = menuBar->addMenu(tr("&Memory")); diff --git a/src/drivers/Qt/RamWatch.cpp b/src/drivers/Qt/RamWatch.cpp index b6a4db3d..fa1e90fe 100644 --- a/src/drivers/Qt/RamWatch.cpp +++ b/src/drivers/Qt/RamWatch.cpp @@ -148,9 +148,9 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent) fileMenu->addSeparator(); - // File -> Append + // File -> Close menuAct = new QAction(tr("&Close"), this); - menuAct->setShortcut( QKeySequence(tr("Alt+F4")) ); + menuAct->setShortcut( QKeySequence::Close ); menuAct->setStatusTip(tr("Close Window")); connect(menuAct, SIGNAL(triggered()), this, SLOT(closeWindow(void)) ); diff --git a/src/drivers/Qt/TimingConf.cpp b/src/drivers/Qt/TimingConf.cpp index 98e42f1d..5bb28a32 100644 --- a/src/drivers/Qt/TimingConf.cpp +++ b/src/drivers/Qt/TimingConf.cpp @@ -47,7 +47,7 @@ #include "Qt/TimingConf.h" //---------------------------------------------------------------------------- -static bool hasNicePermissions( int val ) +static bool hasNicePermissions(int val) { #ifndef WIN32 int usrID; @@ -57,18 +57,18 @@ static bool hasNicePermissions( int val ) usrRoot = (usrID == 0); - if ( usrRoot ) + if (usrRoot) { return true; } #ifdef __linux__ struct rlimit r; - if ( getrlimit( RLIMIT_NICE, &r ) == 0 ) + if (getrlimit(RLIMIT_NICE, &r) == 0) { int ncur = 20 - r.rlim_cur; - if ( val >= ncur ) + if (val >= ncur) { return true; } @@ -82,116 +82,126 @@ static bool hasNicePermissions( int val ) } //---------------------------------------------------------------------------- TimingConfDialog_t::TimingConfDialog_t(QWidget *parent) - : QDialog( parent ) + : QDialog(parent) { int opt; QVBoxLayout *mainLayout; QHBoxLayout *hbox; QGridLayout *grid; - QGroupBox *emuPrioBox, *guiPrioBox; + QPushButton *closeButton; + QGroupBox *emuPrioBox, *guiPrioBox; setWindowTitle("Timing Configuration"); mainLayout = new QVBoxLayout(); - emuPrioCtlEna = new QCheckBox( tr("Set Scheduling Parameters at Startup") ); + emuPrioCtlEna = new QCheckBox(tr("Set Scheduling Parameters at Startup")); - emuPrioBox = new QGroupBox( tr("EMU Thread Scheduling Parameters") ); - guiPrioBox = new QGroupBox( tr("GUI Thread Scheduling Parameters") ); - grid = new QGridLayout(); - emuPrioBox->setLayout( grid ); + emuPrioBox = new QGroupBox(tr("EMU Thread Scheduling Parameters")); + guiPrioBox = new QGroupBox(tr("GUI Thread Scheduling Parameters")); + grid = new QGridLayout(); + emuPrioBox->setLayout(grid); - mainLayout->addWidget( emuPrioCtlEna ); - mainLayout->addWidget( emuPrioBox ); - mainLayout->addWidget( guiPrioBox ); + mainLayout->addWidget(emuPrioCtlEna); + mainLayout->addWidget(emuPrioBox); + mainLayout->addWidget(guiPrioBox); #ifdef WIN32 - emuSchedPrioBox = new QComboBox(); - guiSchedPrioBox = new QComboBox(); + emuSchedPrioBox = new QComboBox(); + guiSchedPrioBox = new QComboBox(); - grid->addWidget( emuSchedPrioBox, 0, 0 ); + grid->addWidget(emuSchedPrioBox, 0, 0); - grid = new QGridLayout(); - guiPrioBox->setLayout( grid ); + grid = new QGridLayout(); + guiPrioBox->setLayout(grid); - grid->addWidget( guiSchedPrioBox, 0, 0 ); + grid->addWidget(guiSchedPrioBox, 0, 0); - emuSchedPrioBox->addItem( tr("Idle" ) , QThread::IdlePriority ); - emuSchedPrioBox->addItem( tr("Lowest") , QThread::LowestPriority ); - emuSchedPrioBox->addItem( tr("Low" ) , QThread::LowPriority ); - emuSchedPrioBox->addItem( tr("Normal") , QThread::NormalPriority ); - emuSchedPrioBox->addItem( tr("High") , QThread::HighPriority ); - emuSchedPrioBox->addItem( tr("Highest") , QThread::HighestPriority ); - emuSchedPrioBox->addItem( tr("Time Critical"), QThread::TimeCriticalPriority ); - emuSchedPrioBox->addItem( tr("Inherit") , QThread::InheritPriority ); + emuSchedPrioBox->addItem(tr("Idle"), QThread::IdlePriority); + emuSchedPrioBox->addItem(tr("Lowest"), QThread::LowestPriority); + emuSchedPrioBox->addItem(tr("Low"), QThread::LowPriority); + emuSchedPrioBox->addItem(tr("Normal"), QThread::NormalPriority); + emuSchedPrioBox->addItem(tr("High"), QThread::HighPriority); + emuSchedPrioBox->addItem(tr("Highest"), QThread::HighestPriority); + emuSchedPrioBox->addItem(tr("Time Critical"), QThread::TimeCriticalPriority); + emuSchedPrioBox->addItem(tr("Inherit"), QThread::InheritPriority); - guiSchedPrioBox->addItem( tr("Idle" ) , QThread::IdlePriority ); - guiSchedPrioBox->addItem( tr("Lowest") , QThread::LowestPriority ); - guiSchedPrioBox->addItem( tr("Low" ) , QThread::LowPriority ); - guiSchedPrioBox->addItem( tr("Normal") , QThread::NormalPriority ); - guiSchedPrioBox->addItem( tr("High") , QThread::HighPriority ); - guiSchedPrioBox->addItem( tr("Highest") , QThread::HighestPriority ); - guiSchedPrioBox->addItem( tr("Time Critical"), QThread::TimeCriticalPriority ); - guiSchedPrioBox->addItem( tr("Inherit") , QThread::InheritPriority ); + guiSchedPrioBox->addItem(tr("Idle"), QThread::IdlePriority); + guiSchedPrioBox->addItem(tr("Lowest"), QThread::LowestPriority); + guiSchedPrioBox->addItem(tr("Low"), QThread::LowPriority); + guiSchedPrioBox->addItem(tr("Normal"), QThread::NormalPriority); + guiSchedPrioBox->addItem(tr("High"), QThread::HighPriority); + guiSchedPrioBox->addItem(tr("Highest"), QThread::HighestPriority); + guiSchedPrioBox->addItem(tr("Time Critical"), QThread::TimeCriticalPriority); + guiSchedPrioBox->addItem(tr("Inherit"), QThread::InheritPriority); #else - emuSchedPolicyBox = new QComboBox(); - emuSchedPrioSlider = new QSlider( Qt::Horizontal ); - emuSchedNiceSlider = new QSlider( Qt::Horizontal ); - emuSchedPrioLabel = new QLabel( tr("Priority (RT)") ); - emuSchedNiceLabel = new QLabel( tr("Priority (Nice)") ); + emuSchedPolicyBox = new QComboBox(); + emuSchedPrioSlider = new QSlider(Qt::Horizontal); + emuSchedNiceSlider = new QSlider(Qt::Horizontal); + emuSchedPrioLabel = new QLabel(tr("Priority (RT)")); + emuSchedNiceLabel = new QLabel(tr("Priority (Nice)")); - emuSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER ); - emuSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO ); - emuSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR ); + emuSchedPolicyBox->addItem(tr("SCHED_OTHER"), SCHED_OTHER); + emuSchedPolicyBox->addItem(tr("SCHED_FIFO"), SCHED_FIFO); + emuSchedPolicyBox->addItem(tr("SCHED_RR"), SCHED_RR); - grid->addWidget( new QLabel( tr("Policy") ), 0, 0 ); - grid->addWidget( emuSchedPolicyBox, 0, 1 ); - grid->addWidget( emuSchedPrioLabel, 1, 0 ); - grid->addWidget( emuSchedPrioSlider, 1, 1 ); - grid->addWidget( emuSchedNiceLabel, 2, 0 ); - grid->addWidget( emuSchedNiceSlider, 2, 1 ); + grid->addWidget(new QLabel(tr("Policy")), 0, 0); + grid->addWidget(emuSchedPolicyBox, 0, 1); + grid->addWidget(emuSchedPrioLabel, 1, 0); + grid->addWidget(emuSchedPrioSlider, 1, 1); + grid->addWidget(emuSchedNiceLabel, 2, 0); + grid->addWidget(emuSchedNiceSlider, 2, 1); - grid = new QGridLayout(); - guiPrioBox->setLayout( grid ); + grid = new QGridLayout(); + guiPrioBox->setLayout(grid); - guiSchedPolicyBox = new QComboBox(); - guiSchedPrioSlider = new QSlider( Qt::Horizontal ); - guiSchedNiceSlider = new QSlider( Qt::Horizontal ); - guiSchedPrioLabel = new QLabel( tr("Priority (RT)") ); - guiSchedNiceLabel = new QLabel( tr("Priority (Nice)") ); + guiSchedPolicyBox = new QComboBox(); + guiSchedPrioSlider = new QSlider(Qt::Horizontal); + guiSchedNiceSlider = new QSlider(Qt::Horizontal); + guiSchedPrioLabel = new QLabel(tr("Priority (RT)")); + guiSchedNiceLabel = new QLabel(tr("Priority (Nice)")); - guiSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER ); - guiSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO ); - guiSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR ); + guiSchedPolicyBox->addItem(tr("SCHED_OTHER"), SCHED_OTHER); + guiSchedPolicyBox->addItem(tr("SCHED_FIFO"), SCHED_FIFO); + guiSchedPolicyBox->addItem(tr("SCHED_RR"), SCHED_RR); - grid->addWidget( new QLabel( tr("Policy") ), 0, 0 ); - grid->addWidget( guiSchedPolicyBox, 0, 1 ); - grid->addWidget( guiSchedPrioLabel, 1, 0 ); - grid->addWidget( guiSchedPrioSlider, 1, 1 ); - grid->addWidget( guiSchedNiceLabel, 2, 0 ); - grid->addWidget( guiSchedNiceSlider, 2, 1 ); + grid->addWidget(new QLabel(tr("Policy")), 0, 0); + grid->addWidget(guiSchedPolicyBox, 0, 1); + grid->addWidget(guiSchedPrioLabel, 1, 0); + grid->addWidget(guiSchedPrioSlider, 1, 1); + grid->addWidget(guiSchedNiceLabel, 2, 0); + grid->addWidget(guiSchedNiceSlider, 2, 1); #endif hbox = new QHBoxLayout(); timingDevSelBox = new QComboBox(); #ifdef WIN32 - timingDevSelBox->addItem( tr("SDL_Delay") , 0 ); + timingDevSelBox->addItem(tr("SDL_Delay"), 0); #else - timingDevSelBox->addItem( tr("NanoSleep") , 0 ); + timingDevSelBox->addItem(tr("NanoSleep"), 0); #endif #ifdef __linux__ - timingDevSelBox->addItem( tr("Timer FD") , 1 ); + timingDevSelBox->addItem(tr("Timer FD"), 1); #endif - hbox->addWidget( new QLabel( tr("Timing Mechanism:") ) ); - hbox->addWidget( timingDevSelBox ); + hbox->addWidget(new QLabel(tr("Timing Mechanism:"))); + hbox->addWidget(timingDevSelBox); + mainLayout->addLayout(hbox); + + closeButton = new QPushButton( tr("Close") ); + closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); + connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); + + hbox = new QHBoxLayout(); + hbox->addStretch(5); + hbox->addWidget( closeButton, 1 ); mainLayout->addLayout( hbox ); - setLayout( mainLayout ); + setLayout(mainLayout); - g_config->getOption( "SDL.SetSchedParam", &opt ); - - emuPrioCtlEna->setChecked( opt ); + g_config->getOption("SDL.SetSchedParam", &opt); + + emuPrioCtlEna->setChecked(opt); updatePolicyBox(); updateSliderLimits(); @@ -199,18 +209,18 @@ TimingConfDialog_t::TimingConfDialog_t(QWidget *parent) updateTimingMech(); #ifdef WIN32 - connect( emuSchedPrioBox , SIGNAL(activated(int)) , this, SLOT(emuSchedPrioChange(int)) ); - connect( guiSchedPrioBox , SIGNAL(activated(int)) , this, SLOT(guiSchedPrioChange(int)) ); + connect(emuSchedPrioBox, SIGNAL(activated(int)), this, SLOT(emuSchedPrioChange(int))); + connect(guiSchedPrioBox, SIGNAL(activated(int)), this, SLOT(guiSchedPrioChange(int))); #else - connect( emuSchedPolicyBox , SIGNAL(activated(int)) , this, SLOT(emuSchedPolicyChange(int)) ); - connect( emuSchedNiceSlider , SIGNAL(valueChanged(int)), this, SLOT(emuSchedNiceChange(int)) ); - connect( emuSchedPrioSlider , SIGNAL(valueChanged(int)), this, SLOT(emuSchedPrioChange(int)) ); - connect( guiSchedPolicyBox , SIGNAL(activated(int)) , this, SLOT(guiSchedPolicyChange(int)) ); - connect( guiSchedNiceSlider , SIGNAL(valueChanged(int)), this, SLOT(guiSchedNiceChange(int)) ); - connect( guiSchedPrioSlider , SIGNAL(valueChanged(int)), this, SLOT(guiSchedPrioChange(int)) ); + connect(emuSchedPolicyBox, SIGNAL(activated(int)), this, SLOT(emuSchedPolicyChange(int))); + connect(emuSchedNiceSlider, SIGNAL(valueChanged(int)), this, SLOT(emuSchedNiceChange(int))); + connect(emuSchedPrioSlider, SIGNAL(valueChanged(int)), this, SLOT(emuSchedPrioChange(int))); + connect(guiSchedPolicyBox, SIGNAL(activated(int)), this, SLOT(guiSchedPolicyChange(int))); + connect(guiSchedNiceSlider, SIGNAL(valueChanged(int)), this, SLOT(guiSchedNiceChange(int))); + connect(guiSchedPrioSlider, SIGNAL(valueChanged(int)), this, SLOT(guiSchedPrioChange(int))); #endif - connect( emuPrioCtlEna , SIGNAL(stateChanged(int)), this, SLOT(emuSchedCtlChange(int)) ); - connect( timingDevSelBox , SIGNAL(activated(int)) , this, SLOT(emuTimingMechChange(int)) ); + connect(emuPrioCtlEna, SIGNAL(stateChanged(int)), this, SLOT(emuSchedCtlChange(int))); + connect(timingDevSelBox, SIGNAL(activated(int)), this, SLOT(emuTimingMechChange(int))); } //---------------------------------------------------------------------------- TimingConfDialog_t::~TimingConfDialog_t(void) @@ -221,22 +231,22 @@ TimingConfDialog_t::~TimingConfDialog_t(void) //---------------------------------------------------------------------------- void TimingConfDialog_t::closeEvent(QCloseEvent *event) { - printf("Timing Close Window Event\n"); - done(0); + printf("Timing Close Window Event\n"); + done(0); deleteLater(); - event->accept(); + event->accept(); } //---------------------------------------------------------------------------- void TimingConfDialog_t::closeWindow(void) { - //printf("Close Window\n"); - done(0); + //printf("Close Window\n"); + done(0); deleteLater(); } //---------------------------------------------------------------------------- -void TimingConfDialog_t::emuSchedCtlChange( int state ) +void TimingConfDialog_t::emuSchedCtlChange(int state) { - g_config->setOption( "SDL.SetSchedParam", (state != Qt::Unchecked) ); + g_config->setOption("SDL.SetSchedParam", (state != Qt::Unchecked)); } //---------------------------------------------------------------------------- void TimingConfDialog_t::saveValues(void) @@ -244,27 +254,27 @@ void TimingConfDialog_t::saveValues(void) #ifndef WIN32 int policy, prio, nice; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } nice = consoleWindow->emulatorThread->getNicePriority(); - consoleWindow->emulatorThread->getSchedParam( policy, prio ); + consoleWindow->emulatorThread->getSchedParam(policy, prio); - g_config->setOption( "SDL.EmuSchedPolicy", policy ); - g_config->setOption( "SDL.EmuSchedPrioRt", prio ); - g_config->setOption( "SDL.EmuSchedNice" , nice ); + g_config->setOption("SDL.EmuSchedPolicy", policy); + g_config->setOption("SDL.EmuSchedPrioRt", prio); + g_config->setOption("SDL.EmuSchedNice", nice); //printf("EMU Sched: %i %i %i\n", policy, prio, nice ); nice = consoleWindow->getNicePriority(); - consoleWindow->getSchedParam( policy, prio ); + consoleWindow->getSchedParam(policy, prio); - g_config->setOption( "SDL.GuiSchedPolicy", policy ); - g_config->setOption( "SDL.GuiSchedPrioRt", prio ); - g_config->setOption( "SDL.GuiSchedNice" , nice ); + g_config->setOption("SDL.GuiSchedPolicy", policy); + g_config->setOption("SDL.GuiSchedPrioRt", prio); + g_config->setOption("SDL.GuiSchedNice", nice); //printf("GUI Sched: %i %i %i\n", policy, prio, nice ); @@ -275,26 +285,26 @@ void TimingConfDialog_t::saveValues(void) void TimingConfDialog_t::emuSchedNiceChange(int val) { #ifndef WIN32 - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - if ( consoleWindow->emulatorThread->setNicePriority( -val ) ) + if (consoleWindow->emulatorThread->setNicePriority(-val)) { char msg[1024]; - sprintf( msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); updateSliderValues(); } fceuWrapperUnLock(); @@ -303,71 +313,71 @@ void TimingConfDialog_t::emuSchedNiceChange(int val) //---------------------------------------------------------------------------- void TimingConfDialog_t::emuSchedPrioChange(int val) { - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } #ifdef WIN32 - printf("Setting EMU Thread to %i\n", val ); + printf("Setting EMU Thread to %i\n", val); fceuWrapperLock(); - consoleWindow->emulatorThread->setPriority( (QThread::Priority)val); + consoleWindow->emulatorThread->setPriority((QThread::Priority)val); fceuWrapperUnLock(); #else int policy, prio; fceuWrapperLock(); - consoleWindow->emulatorThread->getSchedParam( policy, prio ); + consoleWindow->emulatorThread->getSchedParam(policy, prio); - if ( consoleWindow->emulatorThread->setSchedParam( policy, val ) ) + if (consoleWindow->emulatorThread->setSchedParam(policy, val)) { char msg[1024]; - sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); updateSliderValues(); } fceuWrapperUnLock(); #endif } //---------------------------------------------------------------------------- -void TimingConfDialog_t::emuSchedPolicyChange( int index ) +void TimingConfDialog_t::emuSchedPolicyChange(int index) { #ifndef WIN32 int policy, prio; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - consoleWindow->emulatorThread->getSchedParam( policy, prio ); + consoleWindow->emulatorThread->getSchedParam(policy, prio); - policy = emuSchedPolicyBox->itemData( index ).toInt(); + policy = emuSchedPolicyBox->itemData(index).toInt(); - if ( consoleWindow->emulatorThread->setSchedParam( policy, prio ) ) + if (consoleWindow->emulatorThread->setSchedParam(policy, prio)) { char msg[1024]; - sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); } updatePolicyBox(); @@ -380,26 +390,26 @@ void TimingConfDialog_t::emuSchedPolicyChange( int index ) void TimingConfDialog_t::guiSchedNiceChange(int val) { #ifndef WIN32 - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - if ( consoleWindow->setNicePriority( -val ) ) + if (consoleWindow->setNicePriority(-val)) { char msg[1024]; - sprintf( msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call setPriority Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); updateSliderValues(); } fceuWrapperUnLock(); @@ -409,68 +419,68 @@ void TimingConfDialog_t::guiSchedNiceChange(int val) void TimingConfDialog_t::guiSchedPrioChange(int val) { #ifdef WIN32 - printf("Setting GUI Thread to %i\n", val ); - QThread::currentThread()->setPriority( (QThread::Priority)val); + printf("Setting GUI Thread to %i\n", val); + QThread::currentThread()->setPriority((QThread::Priority)val); #else int policy, prio; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - consoleWindow->getSchedParam( policy, prio ); + consoleWindow->getSchedParam(policy, prio); - if ( consoleWindow->setSchedParam( policy, val ) ) + if (consoleWindow->setSchedParam(policy, val)) { char msg[1024]; - sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); updateSliderValues(); } fceuWrapperUnLock(); #endif } //---------------------------------------------------------------------------- -void TimingConfDialog_t::guiSchedPolicyChange( int index ) +void TimingConfDialog_t::guiSchedPolicyChange(int index) { #ifndef WIN32 int policy, prio; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - consoleWindow->getSchedParam( policy, prio ); + consoleWindow->getSchedParam(policy, prio); - policy = guiSchedPolicyBox->itemData( index ).toInt(); + policy = guiSchedPolicyBox->itemData(index).toInt(); - if ( consoleWindow->setSchedParam( policy, prio ) ) + if (consoleWindow->setSchedParam(policy, prio)) { char msg[1024]; - sprintf( msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno) ); + sprintf(msg, "Error: system call pthread_setschedparam Failed\nReason: %s\n", strerror(errno)); #ifdef __linux__ - strcat( msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); - strcat( msg, " /etc/security/limits.conf \n\n"); - strcat( msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); - strcat( msg, "* - priority 99 \n"); - strcat( msg, "* - rtprio 99 \n"); - strcat( msg, "* - nice -20 \n"); + strcat(msg, "Ensure that your system has the proper resource permissions set in the file:\n\n"); + strcat(msg, " /etc/security/limits.conf \n\n"); + strcat(msg, "Adding the following lines to that file and rebooting will usually fix the issue:\n\n"); + strcat(msg, "* - priority 99 \n"); + strcat(msg, "* - rtprio 99 \n"); + strcat(msg, "* - nice -20 \n"); #endif - printf("%s\n", msg ); - consoleWindow->QueueErrorMsgWindow( msg ); + printf("%s\n", msg); + consoleWindow->QueueErrorMsgWindow(msg); } updatePolicyBox(); @@ -482,7 +492,7 @@ void TimingConfDialog_t::guiSchedPolicyChange( int index ) //---------------------------------------------------------------------------- void TimingConfDialog_t::updatePolicyBox(void) { - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } @@ -491,48 +501,48 @@ void TimingConfDialog_t::updatePolicyBox(void) prio = consoleWindow->emulatorThread->priority(); - printf("EMU Priority %i\n", prio ); - for (int j=0; jcount(); j++) + printf("EMU Priority %i\n", prio); + for (int j = 0; j < emuSchedPrioBox->count(); j++) { - if ( emuSchedPrioBox->itemData(j).toInt() == prio ) + if (emuSchedPrioBox->itemData(j).toInt() == prio) { - printf("EMU Found Priority %i %i\n", j , prio ); - emuSchedPrioBox->setCurrentIndex( j ); + printf("EMU Found Priority %i %i\n", j, prio); + emuSchedPrioBox->setCurrentIndex(j); } } prio = QThread::currentThread()->priority(); - for (int j=0; jcount(); j++) + for (int j = 0; j < guiSchedPrioBox->count(); j++) { - if ( guiSchedPrioBox->itemData(j).toInt() == prio ) + if (guiSchedPrioBox->itemData(j).toInt() == prio) { - printf("GUI Found Priority %i %i\n", j , prio ); - guiSchedPrioBox->setCurrentIndex( j ); + printf("GUI Found Priority %i %i\n", j, prio); + guiSchedPrioBox->setCurrentIndex(j); } } #else int policy, prio; - consoleWindow->emulatorThread->getSchedParam( policy, prio ); + consoleWindow->emulatorThread->getSchedParam(policy, prio); - for (int j=0; jcount(); j++) + for (int j = 0; j < emuSchedPolicyBox->count(); j++) { - if ( emuSchedPolicyBox->itemData(j).toInt() == policy ) + if (emuSchedPolicyBox->itemData(j).toInt() == policy) { //printf("Found Policy %i %i\n", j , policy ); - emuSchedPolicyBox->setCurrentIndex( j ); + emuSchedPolicyBox->setCurrentIndex(j); } } - consoleWindow->getSchedParam( policy, prio ); + consoleWindow->getSchedParam(policy, prio); - for (int j=0; jcount(); j++) + for (int j = 0; j < guiSchedPolicyBox->count(); j++) { - if ( guiSchedPolicyBox->itemData(j).toInt() == policy ) + if (guiSchedPolicyBox->itemData(j).toInt() == policy) { //printf("Found Policy %i %i\n", j , policy ); - guiSchedPolicyBox->setCurrentIndex( j ); + guiSchedPolicyBox->setCurrentIndex(j); } } #endif @@ -544,16 +554,16 @@ void TimingConfDialog_t::updateSliderValues(void) int policy, prio; bool hasNicePerms; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } - consoleWindow->emulatorThread->getSchedParam( policy, prio ); + consoleWindow->emulatorThread->getSchedParam(policy, prio); - emuSchedNiceSlider->setValue( -consoleWindow->emulatorThread->getNicePriority() ); - emuSchedPrioSlider->setValue( prio ); + emuSchedNiceSlider->setValue(-consoleWindow->emulatorThread->getNicePriority()); + emuSchedPrioSlider->setValue(prio); - if ( (policy == SCHED_RR) || (policy == SCHED_FIFO) ) + if ((policy == SCHED_RR) || (policy == SCHED_FIFO)) { emuSchedPrioLabel->setEnabled(true); emuSchedPrioSlider->setEnabled(true); @@ -563,17 +573,17 @@ void TimingConfDialog_t::updateSliderValues(void) emuSchedPrioLabel->setEnabled(false); emuSchedPrioSlider->setEnabled(false); } - hasNicePerms = hasNicePermissions( consoleWindow->emulatorThread->getNicePriority() ); + hasNicePerms = hasNicePermissions(consoleWindow->emulatorThread->getNicePriority()); - emuSchedNiceLabel->setEnabled( hasNicePerms ); - emuSchedNiceSlider->setEnabled( hasNicePerms ); + emuSchedNiceLabel->setEnabled(hasNicePerms); + emuSchedNiceSlider->setEnabled(hasNicePerms); - consoleWindow->getSchedParam( policy, prio ); + consoleWindow->getSchedParam(policy, prio); - guiSchedNiceSlider->setValue( -consoleWindow->getNicePriority() ); - guiSchedPrioSlider->setValue( prio ); + guiSchedNiceSlider->setValue(-consoleWindow->getNicePriority()); + guiSchedPrioSlider->setValue(prio); - if ( (policy == SCHED_RR) || (policy == SCHED_FIFO) ) + if ((policy == SCHED_RR) || (policy == SCHED_FIFO)) { guiSchedPrioLabel->setEnabled(true); guiSchedPrioSlider->setEnabled(true); @@ -583,47 +593,46 @@ void TimingConfDialog_t::updateSliderValues(void) guiSchedPrioLabel->setEnabled(false); guiSchedPrioSlider->setEnabled(false); } - hasNicePerms = hasNicePermissions( consoleWindow->getNicePriority() ); + hasNicePerms = hasNicePermissions(consoleWindow->getNicePriority()); - guiSchedNiceLabel->setEnabled( hasNicePerms ); - guiSchedNiceSlider->setEnabled( hasNicePerms ); + guiSchedNiceLabel->setEnabled(hasNicePerms); + guiSchedNiceSlider->setEnabled(hasNicePerms); #endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::updateSliderLimits(void) { - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } #ifndef WIN32 - emuSchedNiceSlider->setMinimum( -20 ); - emuSchedNiceSlider->setMaximum( 20 ); - emuSchedPrioSlider->setMinimum( consoleWindow->emulatorThread->getMinSchedPriority() ); - emuSchedPrioSlider->setMaximum( consoleWindow->emulatorThread->getMaxSchedPriority() ); + emuSchedNiceSlider->setMinimum(-20); + emuSchedNiceSlider->setMaximum(20); + emuSchedPrioSlider->setMinimum(consoleWindow->emulatorThread->getMinSchedPriority()); + emuSchedPrioSlider->setMaximum(consoleWindow->emulatorThread->getMaxSchedPriority()); - guiSchedNiceSlider->setMinimum( -20 ); - guiSchedNiceSlider->setMaximum( 20 ); - guiSchedPrioSlider->setMinimum( consoleWindow->getMinSchedPriority() ); - guiSchedPrioSlider->setMaximum( consoleWindow->getMaxSchedPriority() ); + guiSchedNiceSlider->setMinimum(-20); + guiSchedNiceSlider->setMaximum(20); + guiSchedPrioSlider->setMinimum(consoleWindow->getMinSchedPriority()); + guiSchedPrioSlider->setMaximum(consoleWindow->getMaxSchedPriority()); #endif - } //---------------------------------------------------------------------------- -void TimingConfDialog_t::emuTimingMechChange( int index ) +void TimingConfDialog_t::emuTimingMechChange(int index) { int mode; - if ( consoleWindow == NULL ) + if (consoleWindow == NULL) { return; } fceuWrapperLock(); - mode = timingDevSelBox->itemData( index ).toInt(); + mode = timingDevSelBox->itemData(index).toInt(); - setTimingMode( mode ); + setTimingMode(mode); RefreshThrottleFPS(); @@ -636,11 +645,11 @@ void TimingConfDialog_t::updateTimingMech(void) { int mode = getTimingMode(); - for (int j=0; jcount(); j++) + for (int j = 0; j < timingDevSelBox->count(); j++) { - if ( timingDevSelBox->itemData(j).toInt() == mode ) + if (timingDevSelBox->itemData(j).toInt() == mode) { - timingDevSelBox->setCurrentIndex( j ); + timingDevSelBox->setCurrentIndex(j); } } } diff --git a/src/drivers/Qt/TimingConf.h b/src/drivers/Qt/TimingConf.h index 99c54d69..55debfbd 100644 --- a/src/drivers/Qt/TimingConf.h +++ b/src/drivers/Qt/TimingConf.h @@ -21,50 +21,49 @@ class TimingConfDialog_t : public QDialog { - Q_OBJECT + Q_OBJECT - public: - TimingConfDialog_t(QWidget *parent = 0); - ~TimingConfDialog_t(void); +public: + TimingConfDialog_t(QWidget *parent = 0); + ~TimingConfDialog_t(void); - protected: - void closeEvent(QCloseEvent *event); +protected: + void closeEvent(QCloseEvent *event); - QCheckBox *emuPrioCtlEna; + QCheckBox *emuPrioCtlEna; #ifdef WIN32 - QComboBox *emuSchedPrioBox; - QComboBox *guiSchedPrioBox; + QComboBox *emuSchedPrioBox; + QComboBox *guiSchedPrioBox; #else - QComboBox *emuSchedPolicyBox; - QSlider *emuSchedPrioSlider; - QSlider *emuSchedNiceSlider; - QLabel *emuSchedPrioLabel; - QLabel *emuSchedNiceLabel; - QComboBox *guiSchedPolicyBox; - QSlider *guiSchedPrioSlider; - QSlider *guiSchedNiceSlider; - QLabel *guiSchedPrioLabel; - QLabel *guiSchedNiceLabel; + QComboBox *emuSchedPolicyBox; + QSlider *emuSchedPrioSlider; + QSlider *emuSchedNiceSlider; + QLabel *emuSchedPrioLabel; + QLabel *emuSchedNiceLabel; + QComboBox *guiSchedPolicyBox; + QSlider *guiSchedPrioSlider; + QSlider *guiSchedNiceSlider; + QLabel *guiSchedPrioLabel; + QLabel *guiSchedNiceLabel; #endif - QComboBox *timingDevSelBox; + QComboBox *timingDevSelBox; - private: - void updatePolicyBox(void); - void updateSliderLimits(void); - void updateSliderValues(void); - void updateTimingMech(void); - void saveValues(void); - - public slots: - void closeWindow(void); - private slots: - void emuSchedCtlChange( int state ); - void emuSchedNiceChange( int val ); - void emuSchedPrioChange( int val ); - void emuSchedPolicyChange( int index ); - void guiSchedNiceChange( int val ); - void guiSchedPrioChange( int val ); - void guiSchedPolicyChange( int index ); - void emuTimingMechChange( int index ); +private: + void updatePolicyBox(void); + void updateSliderLimits(void); + void updateSliderValues(void); + void updateTimingMech(void); + void saveValues(void); +public slots: + void closeWindow(void); +private slots: + void emuSchedCtlChange(int state); + void emuSchedNiceChange(int val); + void emuSchedPrioChange(int val); + void emuSchedPolicyChange(int index); + void guiSchedNiceChange(int val); + void guiSchedPrioChange(int val); + void guiSchedPolicyChange(int index); + void emuTimingMechChange(int index); };