Add a few command line options to run the tests automatically.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
900c9ab40b
commit
20852fcb2a
3 changed files with 74 additions and 14 deletions
|
@ -1,15 +1,48 @@
|
|||
#include "qapple.h"
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include "linux/version.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QApplication::setOrganizationName("AndSoft");
|
||||
QApplication::setApplicationName("QAppleEmulator");
|
||||
const QString qversion = QString::fromStdString(getVersion());
|
||||
QApplication::setApplicationVersion(qversion);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("Qt Apple Emulator");
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
QCommandLineOption runOption("r", "start immeditaely");
|
||||
parser.addOption(runOption);
|
||||
|
||||
QCommandLineOption logStateOption("load-state", "load state file", "file");
|
||||
parser.addOption(logStateOption);
|
||||
|
||||
parser.process(app);
|
||||
|
||||
QApple w;
|
||||
|
||||
const bool run = parser.isSet(runOption);
|
||||
const QString stateFile = parser.value(logStateOption);
|
||||
if (!stateFile.isEmpty())
|
||||
{
|
||||
w.loadStateFile(stateFile);
|
||||
}
|
||||
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
if (run)
|
||||
{
|
||||
QTimer::singleShot(0, &w, SLOT(startEmulator()));
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QStyle>
|
||||
#include <QSettings>
|
||||
#include <QAudioOutput>
|
||||
#include <QLabel>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -61,7 +62,7 @@ namespace
|
|||
*
|
||||
*/
|
||||
|
||||
void startEmulator(QWidget * window, Emulator * emulator, const GlobalOptions & options)
|
||||
void loadEmulator(QWidget * window, Emulator * emulator, const GlobalOptions & options)
|
||||
{
|
||||
LoadConfiguration();
|
||||
|
||||
|
@ -206,6 +207,9 @@ QApple::QApple(QWidget *parent) :
|
|||
ui->actionSave_state->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
|
||||
ui->actionLoad_state->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
|
||||
|
||||
mySaveStateLabel = new QLabel;
|
||||
statusBar()->addPermanentWidget(mySaveStateLabel);
|
||||
|
||||
myPreferences = new Preferences(this);
|
||||
|
||||
myEmulator = new Emulator(ui->mdiArea);
|
||||
|
@ -218,7 +222,7 @@ QApple::QApple(QWidget *parent) :
|
|||
|
||||
on_actionPause_triggered();
|
||||
initialiseEmulator();
|
||||
startEmulator(myEmulatorWindow, myEmulator, myOptions);
|
||||
loadEmulator(myEmulatorWindow, myEmulator, myOptions);
|
||||
}
|
||||
|
||||
QApple::~QApple()
|
||||
|
@ -233,6 +237,11 @@ void QApple::closeEvent(QCloseEvent *)
|
|||
uninitialiseEmulator();
|
||||
}
|
||||
|
||||
void QApple::startEmulator()
|
||||
{
|
||||
ui->actionStart->trigger();
|
||||
}
|
||||
|
||||
void QApple::on_stateChanged(QAudio::State state)
|
||||
{
|
||||
AudioGenerator::instance().stateChanged(state);
|
||||
|
@ -350,8 +359,9 @@ void QApple::on_action4_3_triggered()
|
|||
void QApple::on_actionReboot_triggered()
|
||||
{
|
||||
emit endEmulator();
|
||||
mySaveStateLabel->clear();
|
||||
stopEmulator();
|
||||
startEmulator(myEmulatorWindow, myEmulator, myOptions);
|
||||
loadEmulator(myEmulatorWindow, myEmulator, myOptions);
|
||||
myEmulatorWindow->setWindowTitle(QString::fromStdString(g_pAppTitle));
|
||||
myEmulator->updateVideo();
|
||||
restartTimeCounters();
|
||||
|
@ -428,6 +438,9 @@ void QApple::on_actionLoad_state_triggered()
|
|||
Snapshot_LoadState();
|
||||
SetWindowTitle();
|
||||
myEmulatorWindow->setWindowTitle(QString::fromStdString(g_pAppTitle));
|
||||
const std::string & filename = Snapshot_GetFilename();
|
||||
QString message = QString("State file: %1").arg(QString::fromStdString(filename));
|
||||
mySaveStateLabel->setText(message);
|
||||
myEmulator->updateVideo();
|
||||
}
|
||||
|
||||
|
@ -500,15 +513,7 @@ void QApple::on_actionLoad_state_from_triggered()
|
|||
if (files.size() == 1)
|
||||
{
|
||||
const QString & filename = files[0];
|
||||
const QFileInfo file(filename);
|
||||
const QString path = file.absoluteDir().canonicalPath();
|
||||
|
||||
// this is useful as snapshots from the test
|
||||
// have relative disk location
|
||||
SetCurrentImageDir(path.toStdString().c_str());
|
||||
|
||||
Snapshot_SetFilename(filename.toStdString().c_str());
|
||||
ui->actionLoad_state->trigger();
|
||||
loadStateFile(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,3 +531,16 @@ void QApple::on_actionNext_video_mode_triggered()
|
|||
VideoReinitialize();
|
||||
VideoRedrawScreen();
|
||||
}
|
||||
|
||||
void QApple::loadStateFile(const QString & filename)
|
||||
{
|
||||
const QFileInfo file(filename);
|
||||
const QString path = file.absoluteDir().canonicalPath();
|
||||
|
||||
// this is useful as snapshots from the test
|
||||
// have relative disk location
|
||||
SetCurrentImageDir(path.toStdString().c_str());
|
||||
|
||||
Snapshot_SetFilename(filename.toStdString().c_str());
|
||||
ui->actionLoad_state->trigger();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace Ui {
|
|||
class QApple;
|
||||
}
|
||||
|
||||
class QLabel;
|
||||
|
||||
class QApple : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -27,9 +29,14 @@ public:
|
|||
explicit QApple(QWidget *parent = nullptr);
|
||||
~QApple();
|
||||
|
||||
void loadStateFile(const QString & stateFile);
|
||||
|
||||
signals:
|
||||
void endEmulator();
|
||||
|
||||
public slots:
|
||||
void startEmulator();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent * event);
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
|
@ -96,6 +103,8 @@ private:
|
|||
int myTimerID;
|
||||
Preferences * myPreferences;
|
||||
|
||||
QLabel * mySaveStateLabel;
|
||||
|
||||
QElapsedTimer myElapsedTimer;
|
||||
QMdiSubWindow * myEmulatorWindow;
|
||||
Emulator * myEmulator;
|
||||
|
|
Loading…
Add table
Reference in a new issue