Skip to content

Commit

Permalink
Merge pull request #13 from IT-Students-Web-Project/Jacek
Browse files Browse the repository at this point in the history
Added charts
  • Loading branch information
Voxislav authored Sep 13, 2021
2 parents e0bca70 + 83b1a6d commit a7793ea
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Server/Server.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QT += core gui
QT += network

QT += charts
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11
Expand Down
2 changes: 1 addition & 1 deletion Server/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void MainWindow::appendToSocketList(QTcpSocket* socket)
connect(socket, &QTcpSocket::readyRead, this, &MainWindow::readSocket);
connect(socket, &QTcpSocket::disconnected, this, &MainWindow::discardSocket);
connect(socket, &QAbstractSocket::errorOccurred, this, &MainWindow::displayError);
displayMessage(QString("INFO :: Client with sockd:%1 has just entered the room").arg(socket->socketDescriptor()));
displayMessage(QString("INFO :: Client with sockd:%1 has just connected").arg(socket->socketDescriptor()));
resourcesSocketMap.insert(socket,new Resources());

}
Expand Down
29 changes: 29 additions & 0 deletions Server/selectedclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@ SelectedClient::SelectedClient(Resources* r) : QDialog(nullptr),
ui->labelDisk->setText(QString::number(resources->getDiskFreeSpacePercentage())+ "%");
ui->labelMemory->setText(QString::number(resources->getTotalMemory()));
ui->labelUsedMemory->setText(QString::number(1.0*resources->getMemoryLoad()/resources->getTotalMemory()) + "%");
int iter = 1;
for (float cpuLoad : resources->getCpuLoadList()){
lineSeries[0]->append(iter, cpuLoad);
iter++;
}
iter = 1;
for (float diskSpace : resources->getDiskFreeSpacePercentageList()){
lineSeries[1]->append(iter, diskSpace);
iter++;
}
iter = 1;
for (float memoryLoad : resources->getMemoryLoadListReference()){
lineSeries[2]->append(iter, 1.0 * memoryLoad/resources->getTotalMemory());
iter++;
}
charts[0]->setTitle("Cpu load");
charts[1]->setTitle("Free disk space");
charts[2]->setTitle("Free memory");
for (int i = 0; i < 3; i++) {
charts[i]->addSeries(lineSeries[i]);
charts[i]->legend()->hide();
charts[i]->createDefaultAxes();
}
ui->graphicsView_chart0->setChart(charts[0]);
ui->graphicsView_chart1->setChart(charts[1]);
ui->graphicsView_chart2->setChart(charts[2]);
ui->graphicsView_chart0->setRenderHint(QPainter::Antialiasing);
ui->graphicsView_chart1->setRenderHint(QPainter::Antialiasing);
ui->graphicsView_chart2->setRenderHint(QPainter::Antialiasing);
}

SelectedClient::~SelectedClient()
Expand Down
4 changes: 4 additions & 0 deletions Server/selectedclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QDialog>
#include "resources.h"
#include "runningprocesses.h"
#include <QtCharts/QLineSeries>
#include <QtCharts/QChart>

namespace Ui {
class SelectedClient;
Expand All @@ -24,6 +26,8 @@ private slots:
private:
Ui::SelectedClient *ui;
Resources* resources;
QLineSeries *lineSeries[3] = {new QLineSeries, new QLineSeries, new QLineSeries};
QChart *charts[3] = {new QChart(), new QChart(), new QChart()};
};

#endif // SELECTEDCLIENT_H
40 changes: 34 additions & 6 deletions Server/selectedclient.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>951</width>
<height>537</height>
<height>781</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -16,8 +16,8 @@
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>850</x>
<y>500</y>
<x>10</x>
<y>740</y>
<width>81</width>
<height>32</height>
</rect>
Expand All @@ -35,7 +35,7 @@
<x>9</x>
<y>9</y>
<width>321</width>
<height>161</height>
<height>311</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -128,8 +128,8 @@
<widget class="QPushButton" name="pushButtonProcesses">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<x>100</x>
<y>350</y>
<width>161</width>
<height>41</height>
</rect>
Expand All @@ -138,7 +138,35 @@
<string>Show running processes</string>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>349</x>
<y>9</y>
<width>581</width>
<height>761</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QChartView" name="graphicsView_chart0"/>
</item>
<item>
<widget class="QChartView" name="graphicsView_chart1"/>
</item>
<item>
<widget class="QChartView" name="graphicsView_chart2"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QChartView</class>
<extends>QGraphicsView</extends>
<header>QtCharts</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
Expand Down

0 comments on commit a7793ea

Please sign in to comment.