summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-11 12:50:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-11 12:52:42 +0200
commita78ea2c0b28863aa22c2b4ad6f9fd63a9b3bf70c (patch)
tree838c385a567610316dfcb2db1e576d6ab4d3e14c
parent1c52dc86eede604726e67155bf383e251b873beb (diff)
downloadserenity-a78ea2c0b28863aa22c2b4ad6f9fd63a9b3bf70c.zip
SystemMonitor: Add a little header to the process properties window
Show a larger (32x32) version of the executable icon and the process name + PID above the various property tabs.
-rw-r--r--Userland/Applications/SystemMonitor/main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp
index 8f37cee457..11838a2c60 100644
--- a/Userland/Applications/SystemMonitor/main.cpp
+++ b/Userland/Applications/SystemMonitor/main.cpp
@@ -41,6 +41,7 @@
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
+#include <LibGUI/FileIconProvider.h>
#include <LibGUI/GroupBox.h>
#include <LibGUI/Icon.h>
#include <LibGUI/JsonArrayModel.h>
@@ -58,6 +59,7 @@
#include <LibGUI/ToolBar.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
+#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibPCIDB/Database.h>
#include <serenity.h>
@@ -433,6 +435,39 @@ NonnullRefPtr<GUI::Window> build_process_window(pid_t pid)
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
+ auto& hero_container = main_widget.add<GUI::Widget>();
+ hero_container.set_shrink_to_fit(true);
+ hero_container.set_layout<GUI::HorizontalBoxLayout>();
+ hero_container.layout()->set_margins({ 4, 4, 4, 4 });
+ hero_container.layout()->set_spacing(8);
+
+ auto& icon_label = hero_container.add<GUI::Label>();
+ icon_label.set_fixed_size(32, 32);
+
+ GUI::ModelIndex process_index;
+ for (int row = 0; row < ProcessModel::the().row_count({}); ++row) {
+ auto index = ProcessModel::the().index(row, ProcessModel::Column::PID);
+ if (index.data().to_i32() == pid) {
+ process_index = index;
+ break;
+ }
+ }
+
+ VERIFY(process_index.is_valid());
+ if (auto icon_data = process_index.sibling_at_column(ProcessModel::Column::Icon).data(); icon_data.is_icon()) {
+ icon_label.set_icon(icon_data.as_icon().bitmap_for_size(32));
+ }
+
+ auto& process_name_label = hero_container.add<GUI::Label>();
+ process_name_label.set_font(Gfx::FontDatabase::default_bold_font());
+ process_name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
+ process_name_label.set_text(String::formatted("{} (PID {})",
+ process_index.sibling_at_column(ProcessModel::Column::Name).data().to_string(),
+ pid));
+
+ auto& separator = main_widget.add<GUI::HorizontalSeparator>();
+ separator.set_fixed_height(2);
+
auto& widget_stack = main_widget.add<GUI::StackWidget>();
auto& unavailable_process_widget = widget_stack.add<UnavailableProcessWidget>(String::formatted("Unable to access PID {}", pid));