ProcessUnveiledPathsWidget.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include "ProcessUnveiledPathsWidget.h"
  8. #include <LibGUI/BoxLayout.h>
  9. #include <LibGUI/JsonArrayModel.h>
  10. #include <LibGUI/SortingProxyModel.h>
  11. #include <LibGUI/TableView.h>
  12. #include <LibGUI/Widget.h>
  13. REGISTER_WIDGET(SystemMonitor, ProcessUnveiledPathsWidget)
  14. namespace SystemMonitor {
  15. ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget()
  16. {
  17. set_layout<GUI::VerticalBoxLayout>(4);
  18. m_table_view = add<GUI::TableView>();
  19. Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
  20. pid_unveil_fields.empend("path", "Path", Gfx::TextAlignment::CenterLeft);
  21. pid_unveil_fields.empend("permissions", "Permissions", Gfx::TextAlignment::CenterLeft);
  22. m_model = GUI::JsonArrayModel::create({}, move(pid_unveil_fields));
  23. m_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_model)));
  24. }
  25. void ProcessUnveiledPathsWidget::set_pid(pid_t pid)
  26. {
  27. if (m_pid == pid)
  28. return;
  29. m_pid = pid;
  30. m_model->set_json_path(DeprecatedString::formatted("/proc/{}/unveil", m_pid));
  31. }
  32. }