summaryrefslogtreecommitdiffstats
path: root/src/speedcheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/speedcheck.cpp')
-rw-r--r--src/speedcheck.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/speedcheck.cpp b/src/speedcheck.cpp
index fae4b88..f4c7985 100644
--- a/src/speedcheck.cpp
+++ b/src/speedcheck.cpp
@@ -19,20 +19,16 @@ 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)));
connect(_ui->btnselect, SIGNAL(clicked(bool)), this, SLOT(selectClicked(bool)));
+ connect(_ui->btnrefreshNetwork, SIGNAL(clicked(bool)), this, SLOT(networkrefreshClicked(bool)));
+ connect(_ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateNetworkInfos(int)));
_ui->filelabel->setText("Selected File: " + _fileName);
_timer.setInterval(200);
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateTimer()));
qsrand((uint)QCoreApplication::applicationPid());
+ networkrefreshClicked(true);
}
SpeedCheck::~SpeedCheck()
@@ -93,7 +89,33 @@ void SpeedCheck::testFinished()
_ui->btnselect->setEnabled(true);
_ui->comboBox->setEnabled(true);
}
-
+void SpeedCheck::networkrefreshClicked(bool)
+{
+ while (_ui->comboBox->count() > 0) {
+ _ui->comboBox->removeItem(0);
+ }
+ 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());
+ }
+ }
+}
+void SpeedCheck::updateNetworkInfos(int) {
+ QString path = "/sys/class/net/" + _ui->comboBox->currentText();
+ QFile file(path + "/speed");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+ QByteArray speed = file.readLine();
+ // Remove new line at End of the line
+ speed.remove(speed.length() - 1, 1);
+ if (speed.toInt() < 1000) {
+ QMessageBox::warning(NULL, "Warning","Link Speed Slow");
+ _ui->networkSpeed->setStyleSheet("QLabel {color:orange;}");
+ _ui->networkSpeed->setToolTip("Networkspeed slow!");
+ }
+ _ui->networkSpeed->setText(speed + " MB/s");
+}
void SpeedCheck::updateTimer()
{
_ui->picCpu->readNextValue();