1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 06:54:57 +00:00
serenity/Userland/Applications/SystemMonitor/InterruptsWidget.cpp
sin-ack e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00

48 lines
1.6 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "InterruptsWidget.h"
#include <LibGUI/BoxLayout.h>
#include <LibGUI/GroupBox.h>
#include <LibGUI/JsonArrayModel.h>
#include <LibGUI/SortingProxyModel.h>
#include <LibGUI/TableView.h>
InterruptsWidget::InterruptsWidget()
{
on_first_show = [this](auto&) {
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
Vector<GUI::JsonArrayModel::FieldSpec> interrupts_field;
interrupts_field.empend("interrupt_line", "Line", Gfx::TextAlignment::CenterRight);
interrupts_field.empend("purpose", "Purpose", Gfx::TextAlignment::CenterLeft);
interrupts_field.empend("controller", "Controller", Gfx::TextAlignment::CenterLeft);
interrupts_field.empend("cpu_handler", "CPU Handler", Gfx::TextAlignment::CenterRight);
interrupts_field.empend("device_sharing", "# Devices Sharing", Gfx::TextAlignment::CenterRight);
interrupts_field.empend("call_count", "Call Count", Gfx::TextAlignment::CenterRight);
m_interrupt_table_view = add<GUI::TableView>();
m_interrupt_model = GUI::JsonArrayModel::create("/proc/interrupts", move(interrupts_field));
m_interrupt_table_view->set_model(GUI::SortingProxyModel::create(*m_interrupt_model));
m_update_timer = add<Core::Timer>(
1000, [this] {
update_model();
});
update_model();
};
}
InterruptsWidget::~InterruptsWidget()
{
}
void InterruptsWidget::update_model()
{
m_interrupt_model->invalidate();
}