summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIoannis Christoforidis2019-12-04 19:51:34 +0100
committerIoannis Christoforidis2019-12-04 19:51:34 +0100
commitd051df78b184f06b137d0d523045ad920fbb5d7b (patch)
tree3b62d4f35aa3504404171d26269ec7a79466159f
parentdivide console output from gui output and also show updates more fluently (diff)
downloadspeedcheck-d051df78b184f06b137d0d523045ad920fbb5d7b.tar.gz
speedcheck-d051df78b184f06b137d0d523045ad920fbb5d7b.tar.xz
speedcheck-d051df78b184f06b137d0d523045ad920fbb5d7b.zip
make Network List refreshable; also add Link Speed of Device and generate warnings if under Gbit
-rw-r--r--src/speedcheck.cpp38
-rw-r--r--src/speedcheck.h4
-rw-r--r--src/ui/speedcheck.ui100
3 files changed, 127 insertions, 15 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();
diff --git a/src/speedcheck.h b/src/speedcheck.h
index 5d885da..1056b0a 100644
--- a/src/speedcheck.h
+++ b/src/speedcheck.h
@@ -22,7 +22,9 @@ private slots:
void logMessage(QString message);
void startClicked(bool);
void selectClicked(bool);
- void quitClicked(bool);
+ void quitClicked(bool);
+ void networkrefreshClicked(bool);
+ void updateNetworkInfos(int);
void testFinished();
void updateTimer();
diff --git a/src/ui/speedcheck.ui b/src/ui/speedcheck.ui
index 2188b31..4c04e69 100644
--- a/src/ui/speedcheck.ui
+++ b/src/ui/speedcheck.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>800</width>
+ <width>768</width>
<height>600</height>
</rect>
</property>
@@ -29,13 +29,101 @@
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox">
- <property name="editable">
- <bool>false</bool>
+ <widget class="QFrame" name="frame">
+ <property name="enabled">
+ <bool>true</bool>
</property>
- <property name="currentText">
- <string/>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
</property>
+ <widget class="QComboBox" name="comboBox">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>100</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="currentText">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btnrefreshNetwork">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>10</y>
+ <width>150</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Refresh Interfaces</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>81</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Link Speed:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="networkSpeed">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>50</y>
+ <width>151</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;test&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="whatsThis">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;test1&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>MB</string>
+ </property>
+ </widget>
</widget>
</item>
<item>