Skip to content

Commit

Permalink
Added process list display in client view
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Barc committed Sep 13, 2021
1 parent b160ea1 commit 93a173d
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Server/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<item row="0" column="1">
<widget class="QLabel" name="label_clients">
<property name="text">
<string>Clients</string>
<string>Clients (double click client for resource monitoring)</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion Server/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ void Resources::DeserializeJson(json resourcesJson)
memoryLoad = resourcesJson["memoryLoad"];
diskFreeSpacePercentage = resourcesJson["diskFreeSpacePercentage"];
cpuLoad = resourcesJson["cpuLoad"];
processesMap= resourcesJson["processesMap"].get<std::map<int, std::string>>();
processesMap = resourcesJson["processesMap"].get<std::map<int, std::string>>();
updateLists();
}
25 changes: 25 additions & 0 deletions Server/runningprocesses.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "runningprocesses.h"
#include "ui_runningprocesses.h"

RunningProcesses::RunningProcesses(QWidget *parent) :
QDialog(parent),
ui(new Ui::RunningProcesses)
{
ui->setupUi(this);
}

RunningProcesses::RunningProcesses(std::map<int, std::string> i_processesMap) :
QDialog(nullptr),
ui(new Ui::RunningProcesses)
{
ui->setupUi(this);
processesMap = i_processesMap;
for (const auto& [key, value] : processesMap) {
ui->listWidgetProcesses->addItem(QString::number(key) + " \t" + QString::fromStdString(value));
}
}

RunningProcesses::~RunningProcesses()
{
delete ui;
}
24 changes: 24 additions & 0 deletions Server/runningprocesses.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef RUNNINGPROCESSES_H
#define RUNNINGPROCESSES_H

#include <QDialog>

namespace Ui {
class RunningProcesses;
}

class RunningProcesses : public QDialog
{
Q_OBJECT

public:
explicit RunningProcesses(QWidget *parent = nullptr);
RunningProcesses(std::map<int, std::string> i_processesMap);
~RunningProcesses();

private:
Ui::RunningProcesses *ui;
std::map<int, std::string> processesMap;
};

#endif // RUNNINGPROCESSES_H
78 changes: 78 additions & 0 deletions Server/runningprocesses.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RunningProcesses</class>
<widget class="QDialog" name="RunningProcesses">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>120</x>
<y>550</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QListWidget" name="listWidgetProcesses">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>441</width>
<height>531</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>RunningProcesses</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>RunningProcesses</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
8 changes: 8 additions & 0 deletions Server/selectedclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ SelectedClient::~SelectedClient()
{
delete ui;
}

void SelectedClient::on_pushButtonProcesses_clicked()
{
//<QTcpSocket*,Resources> resourcesSocketMap
RunningProcesses* p = new RunningProcesses(resources->getProcessesMap());
p->show();
}

4 changes: 4 additions & 0 deletions Server/selectedclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QDialog>
#include "resources.h"
#include "runningprocesses.h"

namespace Ui {
class SelectedClient;
Expand All @@ -17,6 +18,9 @@ class SelectedClient : public QDialog
SelectedClient(Resources* r);
~SelectedClient();

private slots:
void on_pushButtonProcesses_clicked();

private:
Ui::SelectedClient *ui;
Resources* resources;
Expand Down
13 changes: 13 additions & 0 deletions Server/selectedclient.ui
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButtonProcesses">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Show running processes</string>
</property>
</widget>
</widget>
<resources/>
<connections>
Expand Down

0 comments on commit 93a173d

Please sign in to comment.