mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
SystemMonitor: Save configuration of columns
Save the columns configuration from the last run in the respective config file, and add a function to check whether a column should be visible by default.
This commit is contained in:
parent
290920222a
commit
d8474805e8
3 changed files with 32 additions and 10 deletions
|
@ -528,3 +528,19 @@ void ProcessModel::update()
|
||||||
// It would be good if GUI::Model had a way to orchestrate removal/insertion while preserving indices.
|
// It would be good if GUI::Model had a way to orchestrate removal/insertion while preserving indices.
|
||||||
did_update(previous_tid_count == m_threads.size() ? GUI::Model::UpdateFlag::DontInvalidateIndices : GUI::Model::UpdateFlag::InvalidateAllIndices);
|
did_update(previous_tid_count == m_threads.size() ? GUI::Model::UpdateFlag::DontInvalidateIndices : GUI::Model::UpdateFlag::InvalidateAllIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProcessModel::is_default_column(int index) const
|
||||||
|
{
|
||||||
|
switch (index) {
|
||||||
|
case Column::PID:
|
||||||
|
case Column::TID:
|
||||||
|
case Column::Name:
|
||||||
|
case Column::CPU:
|
||||||
|
case Column::User:
|
||||||
|
case Column::Virtual:
|
||||||
|
case Column::DirtyPrivate:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, GUI::ModelIndex const& = GUI::ModelIndex()) override;
|
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, GUI::ModelIndex const& = GUI::ModelIndex()) override;
|
||||||
virtual bool is_column_sortable(int column_index) const override { return column_index != Column::Icon; }
|
virtual bool is_column_sortable(int column_index) const override { return column_index != Column::Icon; }
|
||||||
void update();
|
void update();
|
||||||
|
bool is_default_column(int index) const;
|
||||||
|
|
||||||
struct CpuInfo {
|
struct CpuInfo {
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
|
@ -293,15 +293,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
auto& process_table_view = *process_table_container.find_child_of_type_named<GUI::TreeView>("process_table");
|
auto& process_table_view = *process_table_container.find_child_of_type_named<GUI::TreeView>("process_table");
|
||||||
process_table_view.set_model(TRY(GUI::SortingProxyModel::create(process_model)));
|
process_table_view.set_model(TRY(GUI::SortingProxyModel::create(process_model)));
|
||||||
for (auto column = 0; column < ProcessModel::Column::__Count; ++column)
|
|
||||||
process_table_view.set_column_visible(column, false);
|
for (auto column = 0; column < ProcessModel::Column::__Count; ++column) {
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::PID, true);
|
process_table_view.set_column_visible(column,
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::TID, true);
|
Config::read_bool("SystemMonitor"sv, "ProcessTableColumns"sv, process_model->column_name(column),
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::Name, true);
|
process_model->is_default_column(column)));
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::CPU, true);
|
}
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::User, true);
|
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::Virtual, true);
|
|
||||||
process_table_view.set_column_visible(ProcessModel::Column::DirtyPrivate, true);
|
|
||||||
|
|
||||||
process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending);
|
process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending);
|
||||||
process_model->update();
|
process_model->update();
|
||||||
|
@ -490,7 +487,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
else if (args_tab_view == "network")
|
else if (args_tab_view == "network")
|
||||||
tabwidget.set_active_widget(tabwidget.find_descendant_of_type_named<GUI::Widget>("network"));
|
tabwidget.set_active_widget(tabwidget.find_descendant_of_type_named<GUI::Widget>("network"));
|
||||||
|
|
||||||
return app->exec();
|
int exec = app->exec();
|
||||||
|
|
||||||
|
// When exiting the application, save the configuration of the columns
|
||||||
|
// to be loaded the next time the application is opened.
|
||||||
|
auto& process_table_header = process_table_view.column_header();
|
||||||
|
for (auto column = 0; column < ProcessModel::Column::__Count; ++column)
|
||||||
|
Config::write_bool("SystemMonitor"sv, "ProcessTableColumns"sv, process_model->column_name(column), process_table_header.is_section_visible(column));
|
||||||
|
|
||||||
|
return exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
|
ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue