Added an error message window to the GUI. Added About Qt window to GUI.

This commit is contained in:
Matthew Budd 2020-07-26 21:31:32 -04:00
parent 0112782eab
commit e918f8562a
4 changed files with 70 additions and 5 deletions

View File

@ -4,6 +4,8 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox>
#include <QErrorMessage>
#include "../../fceu.h" #include "../../fceu.h"
#include "../../fds.h" #include "../../fds.h"
@ -35,10 +37,13 @@ consoleWin_t::consoleWin_t(QWidget *parent)
{ {
int use_SDL_video = false; int use_SDL_video = false;
errorMsgBox = QErrorMessage::qtHandler();
createMainMenu(); createMainMenu();
g_config->getOption( "SDL.VideoDriver", &use_SDL_video ); g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
errorMsgValid = false;
viewport_GL = NULL; viewport_GL = NULL;
viewport_SDL = NULL; viewport_SDL = NULL;
@ -72,6 +77,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
emulatorThread->start(); emulatorThread->start();
gamePadConfWin = NULL; gamePadConfWin = NULL;
} }
consoleWin_t::~consoleWin_t(void) consoleWin_t::~consoleWin_t(void)
@ -116,6 +122,26 @@ void consoleWin_t::setCyclePeriodms( int ms )
//printf("Period Set to: %i ms \n", ms ); //printf("Period Set to: %i ms \n", ms );
} }
void consoleWin_t::showErrorMsgWindow()
{
//QErrorMessage msgBox;
fceuWrapperLock();
//msgBox.setIcon( QMessageBox::Warning );
//msgBox.showMessage( tr(errorMsg.c_str()) );
qWarning( errorMsg.c_str() );
errorMsg.clear();
fceuWrapperUnLock();
//msgBox.exec();
}
void consoleWin_t::QueueErrorMsgWindow( const char *msg )
{
errorMsg.append( msg );
errorMsg.append("\n");
errorMsgValid = true;
}
void consoleWin_t::closeEvent(QCloseEvent *event) void consoleWin_t::closeEvent(QCloseEvent *event)
{ {
//printf("Main Window Close Event\n"); //printf("Main Window Close Event\n");
@ -489,12 +515,20 @@ void consoleWin_t::createMainMenu(void)
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Help // Help
helpMenu = menuBar()->addMenu(tr("Help")); helpMenu = menuBar()->addMenu(tr("Help"));
aboutAct = new QAction(tr("About"), this); // Help -> About FCEUX
aboutAct = new QAction(tr("About FCEUX"), this);
aboutAct->setStatusTip(tr("About FCEUX")); aboutAct->setStatusTip(tr("About FCEUX"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutFCEUX(void)) ); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutFCEUX(void)) );
helpMenu->addAction(aboutAct); helpMenu->addAction(aboutAct);
// Help -> About Qt
aboutActQt = new QAction(tr("About Qt"), this);
aboutActQt->setStatusTip(tr("About Qt"));
connect(aboutActQt, SIGNAL(triggered()), this, SLOT(aboutQt(void)) );
helpMenu->addAction(aboutActQt);
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void consoleWin_t::closeApp(void) void consoleWin_t::closeApp(void)
@ -1331,6 +1365,16 @@ void consoleWin_t::aboutFCEUX(void)
return; return;
} }
void consoleWin_t::aboutQt(void)
{
//printf("About Qt Window\n");
QMessageBox::aboutQt(this);
//printf("About Qt Destroyed\n");
return;
}
void consoleWin_t::syncActionConfig( QAction *act, const char *property ) void consoleWin_t::syncActionConfig( QAction *act, const char *property )
{ {
if ( act->isCheckable() ) if ( act->isCheckable() )
@ -1373,6 +1417,12 @@ void consoleWin_t::updatePeriodic(void)
} }
} }
if ( errorMsgValid )
{
showErrorMsgWindow();
errorMsgValid = false;
}
return; return;
} }

View File

@ -6,6 +6,7 @@
#include <QApplication> #include <QApplication>
#include <QMainWindow> #include <QMainWindow>
#include <QErrorMessage>
#include <QWidget> #include <QWidget>
#include <QPushButton> #include <QPushButton>
#include <QMenu> #include <QMenu>
@ -46,6 +47,8 @@ class consoleWin_t : public QMainWindow
QMutex *mutex; QMutex *mutex;
void QueueErrorMsgWindow( const char *msg );
protected: protected:
QMenu *fileMenu; QMenu *fileMenu;
QMenu *optMenu; QMenu *optMenu;
@ -72,6 +75,7 @@ class consoleWin_t : public QMainWindow
QAction *autoResume; QAction *autoResume;
QAction *fullscreen; QAction *fullscreen;
QAction *aboutAct; QAction *aboutAct;
QAction *aboutActQt;
QAction *state[10]; QAction *state[10];
QAction *powerAct; QAction *powerAct;
QAction *resetAct; QAction *resetAct;
@ -88,16 +92,23 @@ class consoleWin_t : public QMainWindow
QAction *recMovAct; QAction *recMovAct;
QAction *recAsMovAct; QAction *recAsMovAct;
QErrorMessage *errorMsgBox;
QTimer *gameTimer; QTimer *gameTimer;
emulatorThread_t *emulatorThread; emulatorThread_t *emulatorThread;
GamePadConfDialog_t *gamePadConfWin; GamePadConfDialog_t *gamePadConfWin;
std::string errorMsg;
bool errorMsgValid;
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
void syncActionConfig( QAction *act, const char *property ); void syncActionConfig( QAction *act, const char *property );
void showErrorMsgWindow(void);
private: private:
void createMainMenu(void); void createMainMenu(void);
@ -112,6 +123,7 @@ class consoleWin_t : public QMainWindow
void quickSave(void); void quickSave(void);
void closeROMCB(void); void closeROMCB(void);
void aboutFCEUX(void); void aboutFCEUX(void);
void aboutQt(void);
void openGamePadConfWin(void); void openGamePadConfWin(void);
void openGameSndConfWin(void); void openGameSndConfWin(void);
void openGameVideoConfWin(void); void openGameVideoConfWin(void);

View File

@ -262,7 +262,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
for (int i=0; i<GAMEPAD_NUM_DEVICES; i++) for (int i=0; i<GAMEPAD_NUM_DEVICES; i++)
{ {
sprintf( stmp, "SDL.Input.GamePad.%u.", i ); sprintf( stmp, "SDL.Input.GamePad.%i.", i );
prefix = stmp; prefix = stmp;
g_config->getOption(prefix + "Profile", &lcl[i].profile ); g_config->getOption(prefix + "Profile", &lcl[i].profile );
@ -813,6 +813,7 @@ void GamePadConfDialog_t::promptToSave(void)
} }
msg.append("."); msg.append(".");
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr(msg.c_str()) ); msgBox.setText( tr(msg.c_str()) );
msgBox.show(); msgBox.show();

View File

@ -80,20 +80,22 @@ int mutecapture = 0;
void FCEUD_Message(const char *text) void FCEUD_Message(const char *text)
{ {
fputs(text, stdout); fputs(text, stdout);
fprintf(stdout, "\n"); //fprintf(stdout, "\n");
} }
/** /**
* Shows an error message in a message box. * Shows an error message in a message box.
* (For now: prints to stderr.) * (For now: prints to stderr.)
* *
* If running in GTK mode, display a dialog message box of the error. * If running in Qt mode, display a dialog message box of the error.
* *
* @param errormsg Text of the error message. * @param errormsg Text of the error message.
**/ **/
void FCEUD_PrintError(const char *errormsg) void FCEUD_PrintError(const char *errormsg)
{ {
fprintf(stderr, "%s\n", errormsg); fprintf(stderr, "%s\n", errormsg);
consoleWindow->QueueErrorMsgWindow( errormsg );
} }
/** /**