summaryrefslogtreecommitdiffstats
path: root/src/app.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2021-02-19 01:02:21 -0500
committerGitHub <noreply@github.com>2021-02-19 01:02:21 -0500
commite6c9187928d49b796b7d8a2302c057e229d68805 (patch)
treea938a1ac19cfac23e5a7b4deabf765df2adcf61a /src/app.rs
parente6230ef156efe907f2cf76af4298a7e34df330b4 (diff)
bug: Fix sorting menu and sort shortcuts not syncing in gui (#417)
Fixes sorting menus and shortcuts not syncing correctly if the sorting window is open.
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs89
1 files changed, 28 insertions, 61 deletions
diff --git a/src/app.rs b/src/app.rs
index e980e1a0..019720f0 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -700,8 +700,8 @@ impl App {
.widget_states
.get_mut(&(self.current_widget.widget_id - 2))
{
- self.proc_state.force_update = Some(self.current_widget.widget_id - 2);
proc_widget_state.update_sorting_with_columns();
+ self.proc_state.force_update = Some(self.current_widget.widget_id - 2);
self.toggle_sort();
}
}
@@ -1473,25 +1473,15 @@ impl App {
}
'c' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
- // FIXME: There's a mismatch bug with this and all sorting types when using the keybind vs the sorting menu.
- // If the sorting menu is open, it won't update when using this!
if let Some(proc_widget_state) = self
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
- match proc_widget_state.process_sorting_type {
- processes::ProcessSorting::CpuPercent => {
- proc_widget_state.is_process_sort_descending =
- !proc_widget_state.is_process_sort_descending
- }
- _ => {
- proc_widget_state.process_sorting_type =
- processes::ProcessSorting::CpuPercent;
- proc_widget_state.is_process_sort_descending = true;
- }
- }
+ proc_widget_state
+ .columns
+ .set_to_sorted_index_from_type(&processes::ProcessSorting::CpuPercent);
+ proc_widget_state.update_sorting_with_columns();
self.proc_state.force_update = Some(self.current_widget.widget_id);
-
self.skip_to_first();
}
}
@@ -1502,25 +1492,17 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
- match proc_widget_state.process_sorting_type {
- processes::ProcessSorting::MemPercent
- | processes::ProcessSorting::Mem => {
- proc_widget_state.is_process_sort_descending =
- !proc_widget_state.is_process_sort_descending
- }
-
- _ => {
- proc_widget_state.process_sorting_type = if proc_widget_state
- .columns
- .is_enabled(&processes::ProcessSorting::MemPercent)
- {
- processes::ProcessSorting::MemPercent
- } else {
- processes::ProcessSorting::Mem
- };
- proc_widget_state.is_process_sort_descending = true;
- }
- }
+ proc_widget_state.columns.set_to_sorted_index_from_type(
+ &(if proc_widget_state
+ .columns
+ .is_enabled(&processes::ProcessSorting::MemPercent)
+ {
+ processes::ProcessSorting::MemPercent
+ } else {
+ processes::ProcessSorting::Mem
+ }),
+ );
+ proc_widget_state.update_sorting_with_columns();
self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first();
}
@@ -1534,17 +1516,10 @@ impl App {
{
// Skip if grouped
if !proc_widget_state.is_grouped {
- match proc_widget_state.process_sorting_type {
- processes::ProcessSorting::Pid => {
- proc_widget_state.is_process_sort_descending =
- !proc_widget_state.is_process_sort_descending
- }
- _ => {
- proc_widget_state.process_sorting_type =
- processes::ProcessSorting::Pid;
- proc_widget_state.is_process_sort_descending = false;
- }
- }
+ proc_widget_state
+ .columns
+ .set_to_sorted_index_from_type(&processes::ProcessSorting::Pid);
+ proc_widget_state.update_sorting_with_columns();
self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first();
}
@@ -1585,22 +1560,14 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
- match proc_widget_state.process_sorting_type {
- processes::ProcessSorting::ProcessName
- | processes::ProcessSorting::Command => {
- proc_widget_state.is_process_sort_descending =
- !proc_widget_state.is_process_sort_descending
- }
- _ => {
- proc_widget_state.process_sorting_type =
- if proc_widget_state.is_using_command {
- processes::ProcessSorting::Command
- } else {
- processes::ProcessSorting::ProcessName
- };
- proc_widget_state.is_process_sort_descending = false;
- }
- }
+ proc_widget_state.columns.set_to_sorted_index_from_type(
+ &(if proc_widget_state.is_using_command {
+ processes::ProcessSorting::Command
+ } else {
+ processes::ProcessSorting::ProcessName
+ }),
+ );
+ proc_widget_state.update_sorting_with_columns();
self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first();
}