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.
This commit is contained in:
parent
1c52dc86ee
commit
a78ea2c0b2
Notes:
sideshowbarker
2024-07-18 20:31:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a78ea2c0b28
1 changed files with 35 additions and 0 deletions
|
@ -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));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue