Skip to content

Commit 93a173d

Browse files
author
Jacek Barc
committed
Added process list display in client view
1 parent b160ea1 commit 93a173d

File tree

8 files changed

+154
-2
lines changed

8 files changed

+154
-2
lines changed

Server/mainwindow.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<item row="0" column="1">
3232
<widget class="QLabel" name="label_clients">
3333
<property name="text">
34-
<string>Clients</string>
34+
<string>Clients (double click client for resource monitoring)</string>
3535
</property>
3636
</widget>
3737
</item>

Server/resources.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ void Resources::DeserializeJson(json resourcesJson)
2727
memoryLoad = resourcesJson["memoryLoad"];
2828
diskFreeSpacePercentage = resourcesJson["diskFreeSpacePercentage"];
2929
cpuLoad = resourcesJson["cpuLoad"];
30-
processesMap= resourcesJson["processesMap"].get<std::map<int, std::string>>();
30+
processesMap = resourcesJson["processesMap"].get<std::map<int, std::string>>();
3131
updateLists();
3232
}

Server/runningprocesses.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "runningprocesses.h"
2+
#include "ui_runningprocesses.h"
3+
4+
RunningProcesses::RunningProcesses(QWidget *parent) :
5+
QDialog(parent),
6+
ui(new Ui::RunningProcesses)
7+
{
8+
ui->setupUi(this);
9+
}
10+
11+
RunningProcesses::RunningProcesses(std::map<int, std::string> i_processesMap) :
12+
QDialog(nullptr),
13+
ui(new Ui::RunningProcesses)
14+
{
15+
ui->setupUi(this);
16+
processesMap = i_processesMap;
17+
for (const auto& [key, value] : processesMap) {
18+
ui->listWidgetProcesses->addItem(QString::number(key) + " \t" + QString::fromStdString(value));
19+
}
20+
}
21+
22+
RunningProcesses::~RunningProcesses()
23+
{
24+
delete ui;
25+
}

Server/runningprocesses.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef RUNNINGPROCESSES_H
2+
#define RUNNINGPROCESSES_H
3+
4+
#include <QDialog>
5+
6+
namespace Ui {
7+
class RunningProcesses;
8+
}
9+
10+
class RunningProcesses : public QDialog
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit RunningProcesses(QWidget *parent = nullptr);
16+
RunningProcesses(std::map<int, std::string> i_processesMap);
17+
~RunningProcesses();
18+
19+
private:
20+
Ui::RunningProcesses *ui;
21+
std::map<int, std::string> processesMap;
22+
};
23+
24+
#endif // RUNNINGPROCESSES_H

Server/runningprocesses.ui

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>RunningProcesses</class>
4+
<widget class="QDialog" name="RunningProcesses">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>488</width>
10+
<height>587</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Dialog</string>
15+
</property>
16+
<widget class="QDialogButtonBox" name="buttonBox">
17+
<property name="geometry">
18+
<rect>
19+
<x>120</x>
20+
<y>550</y>
21+
<width>341</width>
22+
<height>32</height>
23+
</rect>
24+
</property>
25+
<property name="orientation">
26+
<enum>Qt::Horizontal</enum>
27+
</property>
28+
<property name="standardButtons">
29+
<set>QDialogButtonBox::Close</set>
30+
</property>
31+
</widget>
32+
<widget class="QListWidget" name="listWidgetProcesses">
33+
<property name="geometry">
34+
<rect>
35+
<x>20</x>
36+
<y>10</y>
37+
<width>441</width>
38+
<height>531</height>
39+
</rect>
40+
</property>
41+
</widget>
42+
</widget>
43+
<resources/>
44+
<connections>
45+
<connection>
46+
<sender>buttonBox</sender>
47+
<signal>accepted()</signal>
48+
<receiver>RunningProcesses</receiver>
49+
<slot>accept()</slot>
50+
<hints>
51+
<hint type="sourcelabel">
52+
<x>248</x>
53+
<y>254</y>
54+
</hint>
55+
<hint type="destinationlabel">
56+
<x>157</x>
57+
<y>274</y>
58+
</hint>
59+
</hints>
60+
</connection>
61+
<connection>
62+
<sender>buttonBox</sender>
63+
<signal>rejected()</signal>
64+
<receiver>RunningProcesses</receiver>
65+
<slot>reject()</slot>
66+
<hints>
67+
<hint type="sourcelabel">
68+
<x>316</x>
69+
<y>260</y>
70+
</hint>
71+
<hint type="destinationlabel">
72+
<x>286</x>
73+
<y>274</y>
74+
</hint>
75+
</hints>
76+
</connection>
77+
</connections>
78+
</ui>

Server/selectedclient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ SelectedClient::~SelectedClient()
2525
{
2626
delete ui;
2727
}
28+
29+
void SelectedClient::on_pushButtonProcesses_clicked()
30+
{
31+
//<QTcpSocket*,Resources> resourcesSocketMap
32+
RunningProcesses* p = new RunningProcesses(resources->getProcessesMap());
33+
p->show();
34+
}
35+

Server/selectedclient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <QDialog>
55
#include "resources.h"
6+
#include "runningprocesses.h"
67

78
namespace Ui {
89
class SelectedClient;
@@ -17,6 +18,9 @@ class SelectedClient : public QDialog
1718
SelectedClient(Resources* r);
1819
~SelectedClient();
1920

21+
private slots:
22+
void on_pushButtonProcesses_clicked();
23+
2024
private:
2125
Ui::SelectedClient *ui;
2226
Resources* resources;

Server/selectedclient.ui

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@
125125
</item>
126126
</layout>
127127
</widget>
128+
<widget class="QPushButton" name="pushButtonProcesses">
129+
<property name="geometry">
130+
<rect>
131+
<x>10</x>
132+
<y>180</y>
133+
<width>161</width>
134+
<height>41</height>
135+
</rect>
136+
</property>
137+
<property name="text">
138+
<string>Show running processes</string>
139+
</property>
140+
</widget>
128141
</widget>
129142
<resources/>
130143
<connections>

0 commit comments

Comments
 (0)