diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/datasource/networkspeed.cpp | 4 | ||||
-rw-r--r-- | src/speedcheck.cpp | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/datasource/networkspeed.cpp b/src/datasource/networkspeed.cpp index 8888fd4..0ebd26d 100644 --- a/src/datasource/networkspeed.cpp +++ b/src/datasource/networkspeed.cpp @@ -1,9 +1,9 @@ #include "networkspeed.h" -NetworkSpeed::NetworkSpeed() : +NetworkSpeed::NetworkSpeed(QString iface) : _lastBytes(0), _lastMs(0), - _file("/sys/class/net/eth0/statistics/rx_bytes") + _file("/sys/class/net/" + iface + "/statistics/rx_bytes") { _timer.start(); } diff --git a/src/speedcheck.cpp b/src/speedcheck.cpp index b4dd718..882eeab 100644 --- a/src/speedcheck.cpp +++ b/src/speedcheck.cpp @@ -6,6 +6,7 @@ #include <QCoreApplication> #include <QMessageBox> +#include <QNetworkInterface> #include <QFile> #include <QDebug> #include <QTimer> @@ -17,6 +18,13 @@ SpeedCheck::SpeedCheck(QString fileName) _fileName(fileName) { _ui->setupUi(this); + QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); + foreach (QNetworkInterface iface, interfaces) { + if ((iface.flags().testFlag(QNetworkInterface::IsUp)) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) { + _ui->comboBox->addItem(iface.name()); + } + } + connect(_ui->btnStart, SIGNAL(clicked(bool)), this, SLOT(startClicked(bool))); connect(_ui->btnQuit, SIGNAL(clicked(bool)), this, SLOT(quitClicked(bool))); _timer.setInterval(200); @@ -43,7 +51,7 @@ void SpeedCheck::startClicked(bool) return; } _ui->picCpu->setDataSource(new CpuLoad()); - _ui->picSpeed->setDataSource(new NetworkSpeed()); + _ui->picSpeed->setDataSource(new NetworkSpeed(_ui->comboBox->currentText())); _ui->btnStart->setDisabled(true); delete _thread; _thread = new CopyThread(file, this); |