From 587fe92f7a37ad0661c18152c746ee7df1b848f7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 20 Jun 2022 18:45:47 +0200 Subject: Add --auto option to start immediately and quit when done --- src/speedcheck.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/speedcheck.cpp') diff --git a/src/speedcheck.cpp b/src/speedcheck.cpp index aa02d47..428be75 100644 --- a/src/speedcheck.cpp +++ b/src/speedcheck.cpp @@ -10,7 +10,7 @@ #include #include -SpeedCheck::SpeedCheck(QString fileName) +SpeedCheck::SpeedCheck(QString fileName, bool autoStart) : _ui(new Ui::MainWindow), _thread(NULL), _doQuit(false), @@ -21,6 +21,12 @@ SpeedCheck::SpeedCheck(QString fileName) connect(_ui->btnQuit, SIGNAL(clicked(bool)), this, SLOT(quitClicked(bool))); _timer.setInterval(200); connect(&_timer, SIGNAL(timeout()), this, SLOT(updateTimer())); + if (autoStart) { + _doQuit = true; + QTimer::singleShot(1, [this]() { + this->startClicked(true); + }); + } } SpeedCheck::~SpeedCheck() @@ -70,6 +76,7 @@ void SpeedCheck::testFinished() _thread = NULL; if (_doQuit) { QCoreApplication::instance()->quit(); + return; } _ui->btnStart->setEnabled(true); } -- cgit v1.2.3-55-g7522