mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
SystemMonitor: Remove all remaining naked "new" usage
This commit is contained in:
parent
f4b51a63ec
commit
f57cc5873c
7 changed files with 23 additions and 16 deletions
|
@ -2,8 +2,8 @@
|
|||
#include <LibGUI/GFrame.h>
|
||||
|
||||
class GraphWidget final : public GFrame {
|
||||
C_OBJECT(GraphWidget)
|
||||
public:
|
||||
explicit GraphWidget(GWidget* parent);
|
||||
virtual ~GraphWidget() override;
|
||||
|
||||
void set_max(int max) { m_max = max; }
|
||||
|
@ -15,6 +15,8 @@ public:
|
|||
Function<String(int value, int max)> text_formatter;
|
||||
|
||||
private:
|
||||
explicit GraphWidget(GWidget* parent);
|
||||
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
|
||||
int m_max { 100 };
|
||||
|
|
|
@ -7,6 +7,7 @@ class GLabel;
|
|||
class GraphWidget;
|
||||
|
||||
class MemoryStatsWidget final : public GWidget {
|
||||
C_OBJECT(MemoryStatsWidget)
|
||||
public:
|
||||
MemoryStatsWidget(GraphWidget& graph, GWidget* parent);
|
||||
virtual ~MemoryStatsWidget() override;
|
||||
|
|
|
@ -8,10 +8,10 @@ class GTableView;
|
|||
class NetworkStatisticsWidget final : public GWidget {
|
||||
C_OBJECT(NetworkStatisticsWidget)
|
||||
public:
|
||||
explicit NetworkStatisticsWidget(GWidget* parent = nullptr);
|
||||
virtual ~NetworkStatisticsWidget() override;
|
||||
|
||||
private:
|
||||
explicit NetworkStatisticsWidget(GWidget* parent = nullptr);
|
||||
void update_models();
|
||||
|
||||
ObjectPtr<GTableView> m_adapter_table_view;
|
||||
|
|
|
@ -7,12 +7,13 @@ class GTableView;
|
|||
class ProcessFileDescriptorMapWidget final : public GWidget {
|
||||
C_OBJECT(ProcessFileDescriptorMapWidget);
|
||||
public:
|
||||
explicit ProcessFileDescriptorMapWidget(GWidget* parent);
|
||||
virtual ~ProcessFileDescriptorMapWidget() override;
|
||||
|
||||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
explicit ProcessFileDescriptorMapWidget(GWidget* parent);
|
||||
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
};
|
||||
|
|
|
@ -7,12 +7,12 @@ class GTableView;
|
|||
class ProcessMemoryMapWidget final : public GWidget {
|
||||
C_OBJECT(ProcessMemoryMapWidget);
|
||||
public:
|
||||
explicit ProcessMemoryMapWidget(GWidget* parent);
|
||||
virtual ~ProcessMemoryMapWidget() override;
|
||||
|
||||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
explicit ProcessMemoryMapWidget(GWidget* parent);
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
};
|
||||
|
|
|
@ -8,8 +8,8 @@ class GraphWidget;
|
|||
class ProcessModel;
|
||||
|
||||
class ProcessTableView final : public GTableView {
|
||||
C_OBJECT(ProcessTableView)
|
||||
public:
|
||||
ProcessTableView(GraphWidget&, GWidget* parent);
|
||||
virtual ~ProcessTableView() override;
|
||||
|
||||
pid_t selected_pid() const;
|
||||
|
@ -17,4 +17,7 @@ public:
|
|||
void refresh();
|
||||
|
||||
Function<void(pid_t)> on_process_selected;
|
||||
|
||||
private:
|
||||
ProcessTableView(GraphWidget&, GWidget* parent);
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
|||
keeper->set_background_color(Color::WarmGray);
|
||||
keeper->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto* tabwidget = new GTabWidget(keeper);
|
||||
auto tabwidget = GTabWidget::construct(keeper);
|
||||
|
||||
auto process_container_splitter = GSplitter::construct(Orientation::Vertical, nullptr);
|
||||
tabwidget->add_widget("Processes", process_container_splitter);
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
|||
cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
cpu_graph_group_box->set_preferred_size(0, 120);
|
||||
auto* cpu_graph = new GraphWidget(cpu_graph_group_box);
|
||||
auto cpu_graph = GraphWidget::construct(cpu_graph_group_box);
|
||||
cpu_graph->set_max(100);
|
||||
cpu_graph->set_text_color(Color::Green);
|
||||
cpu_graph->set_graph_color(Color::from_rgb(0x00bb00));
|
||||
|
@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
|||
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
memory_graph_group_box->set_preferred_size(0, 120);
|
||||
auto* memory_graph = new GraphWidget(memory_graph_group_box);
|
||||
auto memory_graph = GraphWidget::construct(memory_graph_group_box);
|
||||
memory_graph->set_text_color(Color::Cyan);
|
||||
memory_graph->set_graph_color(Color::from_rgb(0x00bbbb));
|
||||
memory_graph->text_formatter = [](int value, int max) {
|
||||
|
@ -99,7 +99,7 @@ int main(int argc, char** argv)
|
|||
|
||||
tabwidget->add_widget("Devices", build_devices_tab());
|
||||
|
||||
auto* network_stats_widget = new NetworkStatisticsWidget(nullptr);
|
||||
auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr);
|
||||
tabwidget->add_widget("Network", network_stats_widget);
|
||||
|
||||
process_table_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
@ -108,8 +108,8 @@ int main(int argc, char** argv)
|
|||
|
||||
auto toolbar = GToolBar::construct(process_table_container);
|
||||
toolbar->set_has_frame(false);
|
||||
auto* process_table_view = new ProcessTableView(*cpu_graph, process_table_container);
|
||||
auto* memory_stats_widget = new MemoryStatsWidget(*memory_graph, graphs_container);
|
||||
auto process_table_view = ProcessTableView::construct(*cpu_graph, process_table_container);
|
||||
auto memory_stats_widget = MemoryStatsWidget::construct(*memory_graph, graphs_container);
|
||||
|
||||
auto refresh_timer = CTimer::construct(1000, [&] {
|
||||
process_table_view->refresh();
|
||||
|
@ -138,7 +138,7 @@ int main(int argc, char** argv)
|
|||
toolbar->add_action(stop_action);
|
||||
toolbar->add_action(continue_action);
|
||||
|
||||
auto* window = new GWindow;
|
||||
auto window = GWindow::construct();
|
||||
window->set_title("System Monitor");
|
||||
window->set_rect(20, 200, 680, 400);
|
||||
window->set_main_widget(keeper);
|
||||
|
@ -192,15 +192,15 @@ int main(int argc, char** argv)
|
|||
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
auto* process_tab_widget = new GTabWidget(process_container_splitter);
|
||||
auto process_tab_widget = GTabWidget::construct(process_container_splitter);
|
||||
|
||||
auto* open_files_widget = new ProcessFileDescriptorMapWidget(nullptr);
|
||||
auto open_files_widget = ProcessFileDescriptorMapWidget::construct(nullptr);
|
||||
process_tab_widget->add_widget("Open files", open_files_widget);
|
||||
|
||||
auto* memory_map_widget = new ProcessMemoryMapWidget(nullptr);
|
||||
auto memory_map_widget = ProcessMemoryMapWidget::construct(nullptr);
|
||||
process_tab_widget->add_widget("Memory map", memory_map_widget);
|
||||
|
||||
auto* stacks_widget = new ProcessStacksWidget(nullptr);
|
||||
auto stacks_widget = ProcessStacksWidget::construct(nullptr);
|
||||
process_tab_widget->add_widget("Stacks", stacks_widget);
|
||||
|
||||
process_table_view->on_process_selected = [&](pid_t pid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue