mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
Applications: Run clang-format on everything.
This commit is contained in:
parent
e09c3a1ae8
commit
fd604a7c68
24 changed files with 350 additions and 294 deletions
|
@ -1,8 +1,8 @@
|
|||
#include "MemoryStatsWidget.h"
|
||||
#include "GraphWidget.h"
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -21,7 +21,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
|
|||
layout()->set_margins({ 0, 8, 0, 0 });
|
||||
layout()->set_spacing(3);
|
||||
|
||||
auto build_widgets_for_label = [this] (const String& description) -> GLabel* {
|
||||
auto build_widgets_for_label = [this](const String& description) -> GLabel* {
|
||||
auto* container = new GWidget(this);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "GraphWidget.h"
|
||||
#include <LibCore/CFile.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ProcessModel::ProcessModel(GraphWidget& graph)
|
||||
: m_graph(graph)
|
||||
|
@ -42,34 +42,56 @@ int ProcessModel::column_count(const GModelIndex&) const
|
|||
String ProcessModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return "";
|
||||
case Column::PID: return "PID";
|
||||
case Column::State: return "State";
|
||||
case Column::User: return "User";
|
||||
case Column::Priority: return "Pr";
|
||||
case Column::Linear: return "Linear";
|
||||
case Column::Physical: return "Physical";
|
||||
case Column::CPU: return "CPU";
|
||||
case Column::Name: return "Name";
|
||||
case Column::Syscalls: return "Syscalls";
|
||||
default: ASSERT_NOT_REACHED();
|
||||
case Column::Icon:
|
||||
return "";
|
||||
case Column::PID:
|
||||
return "PID";
|
||||
case Column::State:
|
||||
return "State";
|
||||
case Column::User:
|
||||
return "User";
|
||||
case Column::Priority:
|
||||
return "Pr";
|
||||
case Column::Linear:
|
||||
return "Linear";
|
||||
case Column::Physical:
|
||||
return "Physical";
|
||||
case Column::CPU:
|
||||
return "CPU";
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
case Column::Syscalls:
|
||||
return "Syscalls";
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata ProcessModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return { 16, TextAlignment::CenterLeft };
|
||||
case Column::PID: return { 32, TextAlignment::CenterRight };
|
||||
case Column::State: return { 75, TextAlignment::CenterLeft };
|
||||
case Column::Priority: return { 16, TextAlignment::CenterLeft };
|
||||
case Column::User: return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Linear: return { 65, TextAlignment::CenterRight };
|
||||
case Column::Physical: return { 65, TextAlignment::CenterRight };
|
||||
case Column::CPU: return { 32, TextAlignment::CenterRight };
|
||||
case Column::Name: return { 140, TextAlignment::CenterLeft };
|
||||
case Column::Syscalls: return { 60, TextAlignment::CenterRight };
|
||||
default: ASSERT_NOT_REACHED();
|
||||
case Column::Icon:
|
||||
return { 16, TextAlignment::CenterLeft };
|
||||
case Column::PID:
|
||||
return { 32, TextAlignment::CenterRight };
|
||||
case Column::State:
|
||||
return { 75, TextAlignment::CenterLeft };
|
||||
case Column::Priority:
|
||||
return { 16, TextAlignment::CenterLeft };
|
||||
case Column::User:
|
||||
return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Linear:
|
||||
return { 65, TextAlignment::CenterRight };
|
||||
case Column::Physical:
|
||||
return { 65, TextAlignment::CenterRight };
|
||||
case Column::CPU:
|
||||
return { 32, TextAlignment::CenterRight };
|
||||
case Column::Name:
|
||||
return { 140, TextAlignment::CenterLeft };
|
||||
case Column::Syscalls:
|
||||
return { 60, TextAlignment::CenterRight };
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,10 +109,14 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
|
|||
|
||||
if (role == Role::Sort) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return 0;
|
||||
case Column::PID: return process.current_state.pid;
|
||||
case Column::State: return process.current_state.state;
|
||||
case Column::User: return process.current_state.user;
|
||||
case Column::Icon:
|
||||
return 0;
|
||||
case Column::PID:
|
||||
return process.current_state.pid;
|
||||
case Column::State:
|
||||
return process.current_state.state;
|
||||
case Column::User:
|
||||
return process.current_state.user;
|
||||
case Column::Priority:
|
||||
if (process.current_state.priority == "Idle")
|
||||
return 0;
|
||||
|
@ -102,23 +128,32 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
|
|||
return 3;
|
||||
ASSERT_NOT_REACHED();
|
||||
return 3;
|
||||
case Column::Linear: return (int)process.current_state.linear;
|
||||
case Column::Physical: return (int)process.current_state.physical;
|
||||
case Column::CPU: return process.current_state.cpu_percent;
|
||||
case Column::Name: return process.current_state.name;
|
||||
case Column::Linear:
|
||||
return (int)process.current_state.linear;
|
||||
case Column::Physical:
|
||||
return (int)process.current_state.physical;
|
||||
case Column::CPU:
|
||||
return process.current_state.cpu_percent;
|
||||
case Column::Name:
|
||||
return process.current_state.name;
|
||||
// FIXME: GVariant with unsigned?
|
||||
case Column::Syscalls: return (int)process.current_state.syscalls;
|
||||
case Column::Syscalls:
|
||||
return (int)process.current_state.syscalls;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return *m_generic_process_icon;
|
||||
case Column::PID: return process.current_state.pid;
|
||||
case Column::State: return process.current_state.state;
|
||||
case Column::User: return process.current_state.user;
|
||||
case Column::Icon:
|
||||
return *m_generic_process_icon;
|
||||
case Column::PID:
|
||||
return process.current_state.pid;
|
||||
case Column::State:
|
||||
return process.current_state.state;
|
||||
case Column::User:
|
||||
return process.current_state.user;
|
||||
case Column::Priority:
|
||||
if (process.current_state.priority == "Idle")
|
||||
return String::empty();
|
||||
|
@ -129,16 +164,21 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
|
|||
if (process.current_state.priority == "Normal")
|
||||
return *m_normal_priority_icon;
|
||||
return process.current_state.priority;
|
||||
case Column::Linear: return pretty_byte_size(process.current_state.linear);
|
||||
case Column::Physical: return pretty_byte_size(process.current_state.physical);
|
||||
case Column::CPU: return process.current_state.cpu_percent;
|
||||
case Column::Name: return process.current_state.name;
|
||||
case Column::Linear:
|
||||
return pretty_byte_size(process.current_state.linear);
|
||||
case Column::Physical:
|
||||
return pretty_byte_size(process.current_state.physical);
|
||||
case Column::CPU:
|
||||
return process.current_state.cpu_percent;
|
||||
case Column::Name:
|
||||
return process.current_state.name;
|
||||
// FIXME: It's weird that GVariant doesn't support unsigned ints. Should it?
|
||||
case Column::Syscalls: return (int)process.current_state.syscalls;
|
||||
case Column::Syscalls:
|
||||
return (int)process.current_state.syscalls;
|
||||
}
|
||||
}
|
||||
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
void ProcessModel::update()
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include <LibCore/CTimer.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GToolBar.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GGroupBox.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GTabWidget.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "ProcessTableView.h"
|
||||
#include "MemoryStatsWidget.h"
|
||||
#include "GraphWidget.h"
|
||||
#include "MemoryStatsWidget.h"
|
||||
#include "ProcessTableView.h"
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GGroupBox.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GTabWidget.h>
|
||||
#include <LibGUI/GToolBar.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ int main(int argc, char** argv)
|
|||
cpu_graph->set_max(100);
|
||||
cpu_graph->set_text_color(Color::Green);
|
||||
cpu_graph->set_graph_color(Color::from_rgb(0x00bb00));
|
||||
cpu_graph->text_formatter = [] (int value, int) {
|
||||
cpu_graph->text_formatter = [](int value, int) {
|
||||
return String::format("%d%%", value);
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char** argv)
|
|||
auto* memory_graph = new GraphWidget(memory_graph_group_box);
|
||||
memory_graph->set_text_color(Color::Cyan);
|
||||
memory_graph->set_graph_color(Color::from_rgb(0x00bbbb));
|
||||
memory_graph->text_formatter = [] (int value, int max) {
|
||||
memory_graph->text_formatter = [](int value, int max) {
|
||||
return String::format("%d / %d KB", value, max);
|
||||
};
|
||||
|
||||
|
@ -78,19 +78,19 @@ int main(int argc, char** argv)
|
|||
memory_stats_widget->refresh();
|
||||
});
|
||||
|
||||
auto kill_action = GAction::create("Kill process", GraphicsBitmap::load_from_file("/res/icons/kill16.png"), [process_table_view] (const GAction&) {
|
||||
auto kill_action = GAction::create("Kill process", GraphicsBitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GAction&) {
|
||||
pid_t pid = process_table_view->selected_pid();
|
||||
if (pid != -1)
|
||||
kill(pid, SIGKILL);
|
||||
});
|
||||
|
||||
auto stop_action = GAction::create("Stop process", GraphicsBitmap::load_from_file("/res/icons/stop16.png"), [process_table_view] (const GAction&) {
|
||||
auto stop_action = GAction::create("Stop process", GraphicsBitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GAction&) {
|
||||
pid_t pid = process_table_view->selected_pid();
|
||||
if (pid != -1)
|
||||
kill(pid, SIGSTOP);
|
||||
});
|
||||
|
||||
auto continue_action = GAction::create("Continue process", GraphicsBitmap::load_from_file("/res/icons/continue16.png"), [process_table_view] (const GAction&) {
|
||||
auto continue_action = GAction::create("Continue process", GraphicsBitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GAction&) {
|
||||
pid_t pid = process_table_view->selected_pid();
|
||||
if (pid != -1)
|
||||
kill(pid, SIGCONT);
|
||||
|
@ -102,7 +102,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("Process Manager");
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
@ -115,25 +115,25 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(process_menu));
|
||||
|
||||
auto frequency_menu = make<GMenu>("Frequency");
|
||||
frequency_menu->add_action(GAction::create("0.25 sec", [refresh_timer] (auto&) {
|
||||
frequency_menu->add_action(GAction::create("0.25 sec", [refresh_timer](auto&) {
|
||||
refresh_timer->restart(250);
|
||||
}));
|
||||
frequency_menu->add_action(GAction::create("0.5 sec", [refresh_timer] (auto&) {
|
||||
frequency_menu->add_action(GAction::create("0.5 sec", [refresh_timer](auto&) {
|
||||
refresh_timer->restart(500);
|
||||
}));
|
||||
frequency_menu->add_action(GAction::create("1 sec", [refresh_timer] (auto&) {
|
||||
frequency_menu->add_action(GAction::create("1 sec", [refresh_timer](auto&) {
|
||||
refresh_timer->restart(1000);
|
||||
}));
|
||||
frequency_menu->add_action(GAction::create("3 sec", [refresh_timer] (auto&) {
|
||||
frequency_menu->add_action(GAction::create("3 sec", [refresh_timer](auto&) {
|
||||
refresh_timer->restart(3000);
|
||||
}));
|
||||
frequency_menu->add_action(GAction::create("5 sec", [refresh_timer] (auto&) {
|
||||
frequency_menu->add_action(GAction::create("5 sec", [refresh_timer](auto&) {
|
||||
refresh_timer->restart(5000);
|
||||
}));
|
||||
menubar->add_menu(move(frequency_menu));
|
||||
|
||||
auto help_menu = make<GMenu>("Help");
|
||||
help_menu->add_action(GAction::create("About", [] (const GAction&) {
|
||||
help_menu->add_action(GAction::create("About", [](const GAction&) {
|
||||
dbgprintf("FIXME: Implement Help/About\n");
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue