mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:08:10 +00:00
SystemMonitor: Move process window to GML
Extra stuff done in this commit to facilitate the above (if you want to really push my commit count, ask for more atomicisation): - Register a bunch of widgets that are used in the process window. - Allow setting the pid after the fact for the process state widget.
This commit is contained in:
parent
452bbcaa84
commit
7af87e8e6b
13 changed files with 181 additions and 64 deletions
|
@ -12,9 +12,14 @@
|
|||
#include <LibGUI/HeaderView.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
REGISTER_WIDGET(SystemMonitor, ProcessStateWidget)
|
||||
|
||||
namespace SystemMonitor {
|
||||
|
||||
class ProcessStateModel final
|
||||
: public GUI::Model
|
||||
, public GUI::ModelClient {
|
||||
|
@ -75,18 +80,33 @@ public:
|
|||
did_update(GUI::Model::UpdateFlag::DontInvalidateIndices);
|
||||
}
|
||||
|
||||
void set_pid(pid_t pid)
|
||||
{
|
||||
m_pid = pid;
|
||||
refresh();
|
||||
}
|
||||
pid_t pid() const { return m_pid; }
|
||||
|
||||
private:
|
||||
ProcessModel& m_target;
|
||||
GUI::ModelIndex m_target_index;
|
||||
pid_t m_pid { -1 };
|
||||
};
|
||||
|
||||
ProcessStateWidget::ProcessStateWidget(pid_t pid)
|
||||
ProcessStateWidget::ProcessStateWidget()
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins(4);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), pid)));
|
||||
m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), 0)));
|
||||
m_table_view->column_header().set_visible(false);
|
||||
m_table_view->column_header().set_section_size(0, 90);
|
||||
}
|
||||
|
||||
void ProcessStateWidget::set_pid(pid_t pid)
|
||||
{
|
||||
static_cast<ProcessStateModel*>(m_table_view->model())->set_pid(pid);
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue