diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 04:38:31 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 04:38:31 +0200 |
commit | ac19fabaaf2927b86cedef089142805524761496 (patch) | |
tree | 32333d90082cd5570a886e5edd2689ac50ee5e4c /Applications/ProcessManager | |
parent | d73ed74d1cf4537cbca78a7de0326f722323f94c (diff) | |
download | serenity-ac19fabaaf2927b86cedef089142805524761496.zip |
ProcessManager: Use a single timer for refreshing the view.
Also add a menu for changing the update frequency to some nice values.
Diffstat (limited to 'Applications/ProcessManager')
-rw-r--r-- | Applications/ProcessManager/MemoryStatsWidget.cpp | 1 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessTableView.cpp | 5 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessTableView.h | 5 | ||||
-rw-r--r-- | Applications/ProcessManager/main.cpp | 22 |
4 files changed, 25 insertions, 8 deletions
diff --git a/Applications/ProcessManager/MemoryStatsWidget.cpp b/Applications/ProcessManager/MemoryStatsWidget.cpp index d74e8c1e78..5aad30cd92 100644 --- a/Applications/ProcessManager/MemoryStatsWidget.cpp +++ b/Applications/ProcessManager/MemoryStatsWidget.cpp @@ -37,7 +37,6 @@ MemoryStatsWidget::MemoryStatsWidget(GWidget* parent) m_kmalloc_label = build_widgets_for_label("Kernel heap:"); m_kmalloc_count_label = build_widgets_for_label("Calls kmalloc/kfree:"); - start_timer(1000); refresh(); } diff --git a/Applications/ProcessManager/ProcessTableView.cpp b/Applications/ProcessManager/ProcessTableView.cpp index ded044c485..0c7cee7526 100644 --- a/Applications/ProcessManager/ProcessTableView.cpp +++ b/Applications/ProcessManager/ProcessTableView.cpp @@ -8,15 +8,14 @@ ProcessTableView::ProcessTableView(GWidget* parent) { set_model(GSortingProxyModel::create(ProcessModel::create())); model()->set_key_column_and_sort_order(ProcessModel::Column::CPU, GSortOrder::Descending); - start_timer(1000); - model()->update(); + refresh(); } ProcessTableView::~ProcessTableView() { } -void ProcessTableView::timer_event(CTimerEvent&) +void ProcessTableView::refresh() { model()->update(); } diff --git a/Applications/ProcessManager/ProcessTableView.h b/Applications/ProcessManager/ProcessTableView.h index ec57c2df73..c5a0b5c3a4 100644 --- a/Applications/ProcessManager/ProcessTableView.h +++ b/Applications/ProcessManager/ProcessTableView.h @@ -13,10 +13,9 @@ public: pid_t selected_pid() const; -protected: - virtual void model_notification(const GModelNotification&) override; + void refresh(); private: - virtual void timer_event(CTimerEvent&) override; + virtual void model_notification(const GModelNotification&) override; }; diff --git a/Applications/ProcessManager/main.cpp b/Applications/ProcessManager/main.cpp index f10126bcff..9382f59c7c 100644 --- a/Applications/ProcessManager/main.cpp +++ b/Applications/ProcessManager/main.cpp @@ -1,3 +1,4 @@ +#include <LibCore/CTimer.h> #include <LibGUI/GWindow.h> #include <LibGUI/GWidget.h> #include <LibGUI/GBoxLayout.h> @@ -20,8 +21,12 @@ int main(int argc, char** argv) auto* toolbar = new GToolBar(widget); auto* process_table_view = new ProcessTableView(widget); + auto* memory_stats_widget = new MemoryStatsWidget(widget); - new MemoryStatsWidget(widget); + auto* refresh_timer = new CTimer(1000, [&] { + process_table_view->refresh(); + memory_stats_widget->refresh(); + }); 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(); @@ -59,6 +64,21 @@ int main(int argc, char** argv) process_menu->add_action(continue_action.copy_ref()); menubar->add_menu(move(process_menu)); + auto frequency_menu = make<GMenu>("Frequency"); + 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&) { + refresh_timer->restart(1000); + })); + 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&) { + 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&) { dbgprintf("FIXME: Implement Help/About\n"); |