From af3f7b2473f1206f1a9ecb429084670cc4661923 Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Tue, 7 Jun 2022 14:39:24 +0300 Subject: Button to restart tasks --- src/application.rs | 1 + src/gtk/preferences_window.ui | 1 + src/gtk/task_row.ui | 26 ++++++++++++++++++-------- src/ui/preferences_window.rs | 1 + src/ui/task_row.rs | 9 +++++++-- src/ui/window.rs | 3 ++- 6 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 6050af3..ad6ee51 100755 --- a/src/application.rs +++ b/src/application.rs @@ -302,3 +302,4 @@ impl Default for FurtheranceApplication { } } + diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_window.ui index be331b7..e6fd65b 100755 --- a/src/gtk/preferences_window.ui +++ b/src/gtk/preferences_window.ui @@ -210,3 +210,4 @@ + diff --git a/src/gtk/task_row.ui b/src/gtk/task_row.ui index f5de3a5..7184bc3 100755 --- a/src/gtk/task_row.ui +++ b/src/gtk/task_row.ui @@ -4,8 +4,8 @@ horizontal - 10 - 10 + 5 + 5 12 12 True @@ -40,13 +40,23 @@ - + end - Time - True - + + + Time + True + + + + + + view-refresh-symbolic + false + + diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index d034a9f..d9495fd 100755 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -253,3 +253,4 @@ impl FurPreferencesWindow { } } + diff --git a/src/ui/task_row.rs b/src/ui/task_row.rs index 0e46d81..cccc827 100755 --- a/src/ui/task_row.rs +++ b/src/ui/task_row.rs @@ -42,6 +42,8 @@ mod imp { pub task_tags_label: TemplateChild, #[template_child] pub total_time_label: TemplateChild, + #[template_child] + pub restart_task_btn: TemplateChild, pub tasks: Lazy>>, pub total_time: RefCell, @@ -116,8 +118,6 @@ impl FurTaskRow { } else { let task_tags = format!("#{}", task_list[0].tags); imp.task_tags_label.set_text(&task_tags); - imp.row_box.set_margin_top(5); - imp.row_box.set_margin_bottom(5); } // Create right-click gesture @@ -131,6 +131,11 @@ impl FurTaskRow { self.add_controller(&gesture); + imp.restart_task_btn.connect_clicked(clone!(@strong task_list => move |_| { + let window = FurtheranceWindow::default(); + window.duplicate_task(task_list[0].clone()); + })); + // Add up all durations for task of said name to create total_time for task in &task_list { if task.task_name == task.task_name { diff --git a/src/ui/window.rs b/src/ui/window.rs index 5b7d647..992bc9f 100755 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -752,7 +752,7 @@ impl FurtheranceWindow { } } - pub fn refresh_timer (&self) { + pub fn refresh_timer(&self) { let imp = imp::FurtheranceWindow::from_instance(self); if settings_manager::get_bool("pomodoro") { let mut mins = settings_manager::get_int("pomodoro-time"); @@ -778,3 +778,4 @@ impl Default for FurtheranceWindow { .unwrap() } } + -- cgit 1.4.1 From 37b9ca0cfa9c5a83dde96cf4018dc400a67a8688 Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Tue, 7 Jun 2022 15:30:25 +0300 Subject: Use locale date format (#54) --- src/ui/task_details.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/task_details.rs b/src/ui/task_details.rs index 0ca40ce..37eced3 100755 --- a/src/ui/task_details.rs +++ b/src/ui/task_details.rs @@ -113,7 +113,7 @@ impl FurTaskDetails { imp.task_name_label.set_text(&task_group[0].task_name); let this_day_str = DateTime::parse_from_rfc3339(&task_group[0].start_time).unwrap(); - *imp.this_day.borrow_mut() = this_day_str.format("%h %d %Y").to_string(); + *imp.this_day.borrow_mut() = this_day_str.format("%x").to_string(); *imp.orig_tags.borrow_mut() = task_group[0].tags.clone(); for task in task_group.clone() { @@ -193,13 +193,13 @@ impl FurTaskDetails { let times_box = gtk::Box::new(gtk::Orientation::Horizontal, 5); times_box.set_homogeneous(true); - let mut start_time_w_year = start_time.format("%h %d %Y %H:%M:%S").to_string(); + let mut start_time_w_year = start_time.format("%x %H:%M:%S").to_string(); if !settings_manager::get_bool("show-seconds") { - start_time_w_year = start_time.format("%h %d %Y %H:%M").to_string(); + start_time_w_year = start_time.format("%x %H:%M").to_string(); } - let mut stop_time_w_year = stop_time.format("%h %d %Y %H:%M:%S").to_string(); + let mut stop_time_w_year = stop_time.format("%x %H:%M:%S").to_string(); if !settings_manager::get_bool("show-seconds") { - stop_time_w_year = stop_time.format("%h %d %Y %H:%M").to_string(); + stop_time_w_year = stop_time.format("%x %H:%M").to_string(); } let start_time_edit = gtk::Entry::new(); start_time_edit.set_text(&start_time_w_year); @@ -207,9 +207,9 @@ impl FurTaskDetails { stop_time_edit.set_text(&stop_time_w_year); let instructions = gtk::Label::new(Some( - &gettext("*Use the format MMM DD YYYY HH:MM:SS"))); + &gettext("*Use your local format XX/XX/XX HH:MM:SS"))); if !settings_manager::get_bool("show-seconds") { - instructions.set_text(&gettext("*Use the format MMM DD YYYY HH:MM")); + instructions.set_text(&gettext("*Use your local format XX/XX/XX HH:MM")); } instructions.set_visible(false); instructions.add_css_class("error_message"); @@ -309,11 +309,11 @@ impl FurTaskDetails { if settings_manager::get_bool("show-seconds") { new_start_time = NaiveDateTime::parse_from_str( &new_start_time_str, - "%h %d %Y %H:%M:%S"); + "%x %H:%M:%S"); } else { new_start_time = NaiveDateTime::parse_from_str( &new_start_time_str, - "%h %d %Y %H:%M"); + "%x %H:%M"); } if let Err(_) = new_start_time { instructions.set_visible(true); @@ -330,11 +330,11 @@ impl FurTaskDetails { if settings_manager::get_bool("show-seconds") { new_stop_time = NaiveDateTime::parse_from_str( &new_stop_time_str, - "%h %d %Y %H:%M:%S"); + "%x %H:%M:%S"); } else { new_stop_time = NaiveDateTime::parse_from_str( &new_stop_time_str, - "%h %d %Y %H:%M"); + "%x %H:%M"); } if let Err(_) = new_stop_time { instructions.set_visible(true); @@ -435,7 +435,7 @@ impl FurTaskDetails { updated_list.retain(|task| { let delete = { let start_time = DateTime::parse_from_rfc3339(&task.start_time).unwrap(); - let start_time_str = start_time.format("%h %d %Y").to_string(); + let start_time_str = start_time.format("%x").to_string(); if imp.this_day.borrow().to_string() != start_time_str || imp.task_name_label.text() != task.task_name || imp.orig_tags.borrow().to_string() != task.tags { -- cgit 1.4.1