Browse Source

SystemMonitor: Register GraphWidget

kleines Filmröllchen 3 năm trước cách đây
mục cha
commit
abf2ed4c52

+ 6 - 0
Userland/Applications/SystemMonitor/GraphWidget.cpp

@@ -13,6 +13,10 @@
 #include <LibGfx/Path.h>
 #include <LibGfx/SystemTheme.h>
 
+REGISTER_WIDGET(SystemMonitor, GraphWidget)
+
+namespace SystemMonitor {
+
 void GraphWidget::add_value(Vector<u64, 1>&& value)
 {
     m_values.enqueue(move(value));
@@ -143,3 +147,5 @@ void GraphWidget::paint_event(GUI::PaintEvent& event)
         }
     }
 }
+
+}

+ 4 - 0
Userland/Applications/SystemMonitor/GraphWidget.h

@@ -11,6 +11,8 @@
 #include <LibGUI/Frame.h>
 #include <LibGfx/SystemTheme.h>
 
+namespace SystemMonitor {
+
 class GraphWidget final : public GUI::Frame {
     C_OBJECT(GraphWidget)
 public:
@@ -46,3 +48,5 @@ private:
 
     Vector<Gfx::IntPoint, 1> m_calculated_points;
 };
+
+}

+ 1 - 1
Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp

@@ -24,7 +24,7 @@ MemoryStatsWidget* MemoryStatsWidget::the()
     return s_the;
 }
 
-MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
+MemoryStatsWidget::MemoryStatsWidget(SystemMonitor::GraphWidget& graph)
     : m_graph(graph)
 {
     VERIFY(!s_the);

+ 4 - 2
Userland/Applications/SystemMonitor/MemoryStatsWidget.h

@@ -9,7 +9,9 @@
 
 #include <LibGUI/Widget.h>
 
+namespace SystemMonitor {
 class GraphWidget;
+}
 
 class MemoryStatsWidget final : public GUI::Widget {
     C_OBJECT(MemoryStatsWidget)
@@ -21,9 +23,9 @@ public:
     void refresh();
 
 private:
-    MemoryStatsWidget(GraphWidget& graph);
+    MemoryStatsWidget(SystemMonitor::GraphWidget& graph);
 
-    GraphWidget& m_graph;
+    SystemMonitor::GraphWidget& m_graph;
     RefPtr<GUI::Label> m_user_physical_pages_label;
     RefPtr<GUI::Label> m_user_physical_pages_committed_label;
     RefPtr<GUI::Label> m_supervisor_physical_pages_label;

+ 3 - 3
Userland/Applications/SystemMonitor/main.cpp

@@ -687,14 +687,14 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
     auto cpu_graph_rows = ceil_div(ProcessModel::the().cpus().size(), cpu_graphs_per_row);
     cpu_graph_group_box.set_fixed_height(120u * cpu_graph_rows);
 
-    Vector<GraphWidget&> cpu_graphs;
+    Vector<SystemMonitor::GraphWidget&> cpu_graphs;
     for (auto row = 0u; row < cpu_graph_rows; ++row) {
         auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
         cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>();
         cpu_graph_row.layout()->set_margins(6);
         cpu_graph_row.set_fixed_height(108);
         for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
-            auto& cpu_graph = cpu_graph_row.add<GraphWidget>();
+            auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>();
             cpu_graph.set_max(100);
             cpu_graph.set_value_format(0, {
                                               .graph_color_role = ColorRole::SyntaxPreprocessorStatement,
@@ -725,7 +725,7 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
     memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
     memory_graph_group_box.layout()->set_margins(6);
     memory_graph_group_box.set_fixed_height(120);
-    auto& memory_graph = memory_graph_group_box.add<GraphWidget>();
+    auto& memory_graph = memory_graph_group_box.add<SystemMonitor::GraphWidget>();
     memory_graph.set_stack_values(true);
     memory_graph.set_value_format(0, {
                                          .graph_color_role = ColorRole::SyntaxComment,