-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d77a4
commit 3afa862
Showing
4 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use eframe::egui::Window; | ||
use tokio::task::block_in_place; | ||
|
||
use crate::{app::AppDrawContext, task_manager::DownloadStatus}; | ||
|
||
#[derive(Default)] | ||
pub struct DownloadWindow { | ||
pub open: bool, | ||
} | ||
|
||
impl DownloadWindow { | ||
pub fn draw(&mut self, context: &mut AppDrawContext) { | ||
Window::new("Downloads") | ||
.open(&mut self.open) | ||
.collapsible(false) | ||
.resizable(false) | ||
.show(context.ui.ctx(), |ui| { | ||
ui.spinner(); | ||
block_in_place(|| { | ||
let lock = context.task_manager.http.state.blocking_lock(); | ||
|
||
lock.rom_downloads.iter().for_each(|(key, value)| { | ||
match value.download_status { | ||
DownloadStatus::Starting => { | ||
ui.label(format!("{key}: Starting...")); | ||
} | ||
DownloadStatus::InProgress { | ||
bytes_downloaded, | ||
total_bytes, | ||
} => { | ||
ui.label(format!( | ||
"{key}: {}", | ||
bytes_downloaded as f32 / total_bytes as f32 | ||
)); | ||
} | ||
DownloadStatus::Done(_) => { | ||
ui.label(format!("{key}: Done")); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters