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 <cstdlib>
#include <QFileDialog>
#include <QMessageBox>
#include <QErrorMessage>
#include "../../fceu.h"
#include "../../fds.h"
@ -35,10 +37,13 @@ consoleWin_t::consoleWin_t(QWidget *parent)
{
int use_SDL_video = false;
errorMsgBox = QErrorMessage::qtHandler();
createMainMenu();
g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
errorMsgValid = false;
viewport_GL = NULL;
viewport_SDL = NULL;
@ -72,6 +77,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
emulatorThread->start();
gamePadConfWin = NULL;
}
consoleWin_t::~consoleWin_t(void)
@ -116,6 +122,26 @@ void consoleWin_t::setCyclePeriodms( int 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)
{
//printf("Main Window Close Event\n");
@ -489,12 +515,20 @@ void consoleWin_t::createMainMenu(void)
//-----------------------------------------------------------------------
// 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"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutFCEUX(void)) );
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)
@ -1331,6 +1365,16 @@ void consoleWin_t::aboutFCEUX(void)
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 )
{
if ( act->isCheckable() )
@ -1373,6 +1417,12 @@ void consoleWin_t::updatePeriodic(void)
}
}
if ( errorMsgValid )
{
showErrorMsgWindow();
errorMsgValid = false;
}
return;
}

View File

@ -6,6 +6,7 @@
#include <QApplication>
#include <QMainWindow>
#include <QErrorMessage>
#include <QWidget>
#include <QPushButton>
#include <QMenu>
@ -46,6 +47,8 @@ class consoleWin_t : public QMainWindow
QMutex *mutex;
void QueueErrorMsgWindow( const char *msg );
protected:
QMenu *fileMenu;
QMenu *optMenu;
@ -72,6 +75,7 @@ class consoleWin_t : public QMainWindow
QAction *autoResume;
QAction *fullscreen;
QAction *aboutAct;
QAction *aboutActQt;
QAction *state[10];
QAction *powerAct;
QAction *resetAct;
@ -88,16 +92,23 @@ class consoleWin_t : public QMainWindow
QAction *recMovAct;
QAction *recAsMovAct;
QErrorMessage *errorMsgBox;
QTimer *gameTimer;
emulatorThread_t *emulatorThread;
GamePadConfDialog_t *gamePadConfWin;
std::string errorMsg;
bool errorMsgValid;
protected:
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void syncActionConfig( QAction *act, const char *property );
void showErrorMsgWindow(void);
private:
void createMainMenu(void);
@ -112,6 +123,7 @@ class consoleWin_t : public QMainWindow
void quickSave(void);
void closeROMCB(void);
void aboutFCEUX(void);
void aboutQt(void);
void openGamePadConfWin(void);
void openGameSndConfWin(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++)
{
sprintf( stmp, "SDL.Input.GamePad.%u.", i );
sprintf( stmp, "SDL.Input.GamePad.%i.", i );
prefix = stmp;
g_config->getOption(prefix + "Profile", &lcl[i].profile );
@ -813,6 +813,7 @@ void GamePadConfDialog_t::promptToSave(void)
}
msg.append(".");
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr(msg.c_str()) );
msgBox.show();

View File

@ -80,20 +80,22 @@ int mutecapture = 0;
void FCEUD_Message(const char *text)
{
fputs(text, stdout);
fprintf(stdout, "\n");
//fprintf(stdout, "\n");
}
/**
* Shows an error message in a message box.
* (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.
**/
void FCEUD_PrintError(const char *errormsg)
{
fprintf(stderr, "%s\n", errormsg);
consoleWindow->QueueErrorMsgWindow( errormsg );
}
/**