summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp10
-rw-r--r--src/speedcheck.cpp9
-rw-r--r--src/speedcheck.h4
3 files changed, 18 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d5b71fb..5d9a396 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,11 +5,17 @@
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- if (argc != 2) {
+ bool autoStart = false;
+ if (argc < 2) {
QMessageBox::critical(NULL, "Error", "Need one argument: file name");
return 1;
}
- SpeedCheck main(QString::fromLocal8Bit(argv[1]));
+ if (argc >= 3 && strcmp(argv[1], "--auto") == 0) {
+ autoStart = true;
+ argc--;
+ argv++;
+ }
+ SpeedCheck main(QString::fromLocal8Bit(argv[1]), autoStart);
main.show();
app.exec();
return 0;
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 <QDebug>
#include <QTimer>
-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);
}
diff --git a/src/speedcheck.h b/src/speedcheck.h
index fd54605..c89e3f1 100644
--- a/src/speedcheck.h
+++ b/src/speedcheck.h
@@ -14,7 +14,7 @@ class SpeedCheck : public QMainWindow
{
Q_OBJECT
public:
- SpeedCheck(QString fileName);
+ SpeedCheck(QString fileName, bool autoStart);
virtual ~SpeedCheck();
private slots:
@@ -27,7 +27,7 @@ private slots:
private:
Ui::MainWindow *_ui;
CopyThread *_thread;
- volatile bool _doQuit;
+ bool _doQuit;
QString _fileName;
QTimer _timer;
};