From a9b5df0056be8d6dda8151cff0d6f84ed4f0209c Mon Sep 17 00:00:00 2001 From: Ioannis Christoforidis Date: Tue, 23 Mar 2021 09:11:12 +0100 Subject: trivial console mode implemented --- src/copythread.cpp | 5 +++-- src/datasource/networkspeed.cpp | 1 + src/graphwidget.cpp | 2 +- src/main.cpp | 31 ++++++++++++++++++++++--------- src/speedcheck.cpp | 15 ++++++++++----- src/speedcheck.h | 3 ++- src/ui/speedcheck.ui | 4 ++-- 7 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/copythread.cpp b/src/copythread.cpp index 69b5950..44fe39d 100644 --- a/src/copythread.cpp +++ b/src/copythread.cpp @@ -30,7 +30,7 @@ void CopyThread::stop() void CopyThread::run() { - qDebug() << "Entering run method"; + // qDebug() << "Entering run method"; char *buffer = new char[BUFFER_SIZE]; QElapsedTimer timer; qint64 ret; @@ -41,6 +41,7 @@ void CopyThread::run() // Sequential read emit logMessage(trUtf8("Starting sequential read test")); + printf("Starting sequential read test\n"); if (size > 0) { _file->seek(BIGRAND % size); } @@ -68,7 +69,7 @@ void CopyThread::run() if (size > 0) { printf("\n"); fflush(stdout); - emit logMessage(trUtf8("Starting random read test")); + emit logMessage(trUtf8("Starting random read test\n")); timer.restart(); do { _file->seek(BIGRAND % size); diff --git a/src/datasource/networkspeed.cpp b/src/datasource/networkspeed.cpp index 0ebd26d..5660dea 100644 --- a/src/datasource/networkspeed.cpp +++ b/src/datasource/networkspeed.cpp @@ -1,4 +1,5 @@ #include "networkspeed.h" +// #include NetworkSpeed::NetworkSpeed(QString iface) : _lastBytes(0), diff --git a/src/graphwidget.cpp b/src/graphwidget.cpp index ec15026..c44207f 100644 --- a/src/graphwidget.cpp +++ b/src/graphwidget.cpp @@ -30,7 +30,7 @@ void GraphWidget::setDataSource(IDataSource* source) _source = source; memset(_history, 0, sizeof(*_history) * HISTSIZE); _vScale = (float)height() / (float)_source->getMaximum(); - qDebug() << "sDS " << _vScale; + //qDebug() << "sDS " << _vScale; update(); } diff --git a/src/main.cpp b/src/main.cpp index d5b71fb..47140a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,13 +4,26 @@ int main(int argc, char **argv) { - QApplication app(argc, argv); - if (argc != 2) { - QMessageBox::critical(NULL, "Error", "Need one argument: file name"); - return 1; - } - SpeedCheck main(QString::fromLocal8Bit(argv[1])); - main.show(); - app.exec(); - return 0; + QApplication app(argc, argv); + if (argc < 2) { + QMessageBox::critical(NULL, "Error", "Need one argument: file name"); + return 1; + } + bool commandline = false; + for (int var = 0; var < argc; ++var) { + if (strcmp(argv[var], "--console") == 0) { + commandline = true; + } + } + if (!commandline) { + SpeedCheck main(QString::fromLocal8Bit(argv[1]), commandline); + main.show(); + app.exec(); + return 0; + } + else { + SpeedCheck main(QString::fromLocal8Bit(argv[1]), commandline); + app.exec(); + return 0; + } } diff --git a/src/speedcheck.cpp b/src/speedcheck.cpp index 9cde82b..f26bb1e 100644 --- a/src/speedcheck.cpp +++ b/src/speedcheck.cpp @@ -12,7 +12,7 @@ #include #include -SpeedCheck::SpeedCheck(QString fileName) +SpeedCheck::SpeedCheck(QString fileName, bool cml) : _ui(new Ui::MainWindow), _thread(NULL), _doQuit(false), @@ -29,6 +29,7 @@ SpeedCheck::SpeedCheck(QString fileName) connect(&_timer, SIGNAL(timeout()), this, SLOT(updateTimer())); qsrand((uint)QCoreApplication::applicationPid()); networkrefreshClicked(true); + if (cml) startClicked(true); } SpeedCheck::~SpeedCheck() @@ -38,7 +39,6 @@ SpeedCheck::~SpeedCheck() void SpeedCheck::logMessage(QString message) { - // qDebug() << message; _ui->statusBar->showMessage(message); } void SpeedCheck::selectClicked(bool) { @@ -66,7 +66,6 @@ void SpeedCheck::startClicked(bool) _timer.start(); _thread->start(); } - void SpeedCheck::quitClicked(bool) { if (_thread != NULL && _thread->isRunning()) { @@ -90,6 +89,7 @@ void SpeedCheck::testFinished() _ui->btnselect->setEnabled(true); _ui->comboBox->setEnabled(true); _ui->btnrefreshNetwork->setEnabled(true); + quitClicked(true); } void SpeedCheck::networkrefreshClicked(bool) { @@ -114,12 +114,17 @@ void SpeedCheck::updateNetworkInfos(int) { speed.remove(speed.length() - 1, 1); if (!wireless.exists()) { if (speed.toInt() < 1000) { - QMessageBox::warning(NULL, "Warning","Link Speed Slow"); _ui->networkSpeed->setStyleSheet("QLabel {color:orange;}"); _ui->networkSpeed->setToolTip("Networkspeed slow!"); } + else { + _ui->networkSpeed->setStyleSheet("QLabel {color:black;}"); + _ui->networkSpeed->setToolTip(""); + } _ui->connType->setText("wired"); _ui->networkSpeed->setEnabled(true); + _ui->link->setEnabled(true); + _ui->link->setText("Speed: "); _ui->networkSpeed->setText(speed + " MB/s"); } else { @@ -131,6 +136,6 @@ void SpeedCheck::updateNetworkInfos(int) { } void SpeedCheck::updateTimer() { - _ui->picCpu->readNextValue(); + _ui->picCpu->readNextValue(); _ui->picSpeed->readNextValue(); } diff --git a/src/speedcheck.h b/src/speedcheck.h index 1056b0a..37e3a25 100644 --- a/src/speedcheck.h +++ b/src/speedcheck.h @@ -16,7 +16,8 @@ class SpeedCheck : public QMainWindow Q_OBJECT public: SpeedCheck(QString fileName); - virtual ~SpeedCheck(); + SpeedCheck(QString fileName, bool cml); + virtual ~SpeedCheck(); private slots: void logMessage(QString message); diff --git a/src/ui/speedcheck.ui b/src/ui/speedcheck.ui index a795dc1..dfcce4a 100644 --- a/src/ui/speedcheck.ui +++ b/src/ui/speedcheck.ui @@ -95,14 +95,14 @@ - 10 + 80 70 111 19 - Link Speed: + Speed: -- cgit v1.2.3-55-g7522