mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
calculate redirection milliseconds
This commit is contained in:
parent
ff906181a2
commit
c6a8175685
1 changed files with 16 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ use adw::{
|
||||||
ActionRow, PreferencesDialog, PreferencesGroup, PreferencesPage,
|
ActionRow, PreferencesDialog, PreferencesGroup, PreferencesPage,
|
||||||
prelude::{ActionRowExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt},
|
prelude::{ActionRowExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt},
|
||||||
};
|
};
|
||||||
|
use gtk::glib::gformat;
|
||||||
|
|
||||||
pub trait Dialog {
|
pub trait Dialog {
|
||||||
fn info(info: &Info) -> Self;
|
fn info(info: &Info) -> Self;
|
||||||
|
|
@ -75,9 +76,23 @@ impl Dialog for PreferencesDialog {
|
||||||
chain(&mut b, info);
|
chain(&mut b, info);
|
||||||
b.reverse();
|
b.reverse();
|
||||||
let l = b.len(); // calculate once
|
let l = b.len(); // calculate once
|
||||||
|
let t = b[0].event[0].time();
|
||||||
for (i, r) in b.iter().enumerate() {
|
for (i, r) in b.iter().enumerate() {
|
||||||
g.add(&{
|
g.add(&{
|
||||||
let a = ActionRow::builder().title(r.request().unwrap()).build();
|
let a = ActionRow::builder().title(r.request().unwrap()).build();
|
||||||
|
if i == 0 {
|
||||||
|
a.set_subtitle(&t.format_iso8601().unwrap())
|
||||||
|
} else {
|
||||||
|
a.set_subtitle(&gformat!(
|
||||||
|
"{} ms",
|
||||||
|
r.event
|
||||||
|
.last()
|
||||||
|
.unwrap()
|
||||||
|
.time()
|
||||||
|
.difference(t)
|
||||||
|
.as_milliseconds()
|
||||||
|
))
|
||||||
|
}
|
||||||
a.add_prefix(&{
|
a.add_prefix(&{
|
||||||
let c = i + 1;
|
let c = i + 1;
|
||||||
gtk::Button::builder()
|
gtk::Button::builder()
|
||||||
|
|
@ -118,7 +133,7 @@ impl Dialog for PreferencesDialog {
|
||||||
for e in &info.event[1..] {
|
for e in &info.event[1..] {
|
||||||
g.add(
|
g.add(
|
||||||
&ActionRow::builder()
|
&ActionRow::builder()
|
||||||
.subtitle(gtk::glib::gformat!(
|
.subtitle(gformat!(
|
||||||
"{} ms",
|
"{} ms",
|
||||||
e.time().difference(t).as_milliseconds()
|
e.time().difference(t).as_milliseconds()
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue