diff options
-rwxr-xr-x | data/com.lakoliu.Furtherance.gschema.xml | 3 | ||||
-rwxr-xr-x | src/gtk/preferences_window.ui | 12 | ||||
-rwxr-xr-x | src/ui/preferences_window.rs | 13 | ||||
-rwxr-xr-x | src/ui/tasks_page.rs | 20 |
4 files changed, 39 insertions, 9 deletions
diff --git a/data/com.lakoliu.Furtherance.gschema.xml b/data/com.lakoliu.Furtherance.gschema.xml index a2d22ae..eb19b87 100755 --- a/data/com.lakoliu.Furtherance.gschema.xml +++ b/data/com.lakoliu.Furtherance.gschema.xml @@ -22,5 +22,8 @@ <key name="show-seconds" type="b"> <default>true</default> </key> + <key name="show-daily-sums" type="b"> + <default>true</default> + </key> </schema> </schemalist> diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_window.ui index a0bb6fb..5c6140c 100755 --- a/src/gtk/preferences_window.ui +++ b/src/gtk/preferences_window.ui @@ -116,6 +116,18 @@ </child> </object> </child> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">Show daily sums</property> + <property name="use_underline">True</property> + <property name="activatable_widget">show_daily_sums_switch</property> + <child> + <object class="GtkSwitch" id="show_daily_sums_switch"> + <property name="valign">center</property> + </object> + </child> + </object> + </child> </object> </child> </object> diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index 36e83dc..1955d09 100755 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -53,6 +53,8 @@ mod imp { pub delete_confirmation_switch: TemplateChild<gtk::Switch>, #[template_child] pub show_seconds_switch: TemplateChild<gtk::Switch>, + #[template_child] + pub show_daily_sums_switch: TemplateChild<gtk::Switch>, } #[glib::object_subclass] @@ -159,6 +161,12 @@ impl FurPreferencesWindow { "active" ); + settings_manager::bind_property( + "show-daily-sums", + &*imp.show_daily_sums_switch, + "active" + ); + imp.dark_theme_switch.connect_active_notify(move |_|{ let app = FurtheranceApplication::default(); app.update_light_dark(); @@ -178,6 +186,11 @@ impl FurPreferencesWindow { let window = FurtheranceWindow::default(); window.reset_history_box(); }); + + imp.show_daily_sums_switch.connect_active_notify(move |_|{ + let window = FurtheranceWindow::default(); + window.reset_history_box(); + }); } } diff --git a/src/ui/tasks_page.rs b/src/ui/tasks_page.rs index ac4e20e..7fb6e63 100755 --- a/src/ui/tasks_page.rs +++ b/src/ui/tasks_page.rs @@ -154,16 +154,18 @@ impl FurTasksPage { group.add_task_model(tasks_sorted_by_day[i].clone()); // Set total time for each day - let day_total_time = group.get_total_day_time(); - // Format total time to readable string - let h = day_total_time / 3600; - let m = day_total_time % 3600 / 60; - let s = day_total_time % 60; - let mut total_time_str = format!("{:02}:{:02}:{:02}", h, m, s); - if !settings_manager::get_bool("show-seconds") { - total_time_str = format!("{:02}:{:02}", h, m); + if settings_manager::get_bool("show-daily-sums") { + let day_total_time = group.get_total_day_time(); + // Format total time to readable string + let h = day_total_time / 3600; + let m = day_total_time % 3600 / 60; + let s = day_total_time % 60; + let mut total_time_str = format!("{:02}:{:02}:{:02}", h, m, s); + if !settings_manager::get_bool("show-seconds") { + total_time_str = format!("{:02}:{:02}", h, m); + } + group.set_description(Some(&total_time_str)); } - group.set_description(Some(&total_time_str)); imp.all_groups.borrow_mut().push(group); } |