UI for image download refactor and fixes (#98)

This commit is contained in:
Philip Kristoffersen
2022-04-24 21:44:27 +02:00
committed by GitHub
parent 5721c8d47b
commit d2ccef8b9b
7 changed files with 404 additions and 320 deletions
+4 -3
View File
@@ -20,10 +20,11 @@ impl<'a> CachedSearch<'a> {
save_search_map(&self.search_map);
}
pub fn set_cache<S>(&mut self, app_id: u32, name:S, new_grid_id:usize)
pub fn set_cache<S>(&mut self, app_id: u32, name: S, new_grid_id: usize)
where
S: Into<String>{
self.search_map.insert(app_id,(name.into(),new_grid_id));
S: Into<String>,
{
self.search_map.insert(app_id, (name.into(), new_grid_id));
self.save();
}
+5 -5
View File
@@ -248,9 +248,12 @@ async fn get_images_for_ids(
image_search_result.map_err(|e| format!("Image search failed {:?}", e))
}
const BIG_PICTURE_DIMS : [GridDimentions;2] = [GridDimentions::D920x430, GridDimentions::D460x215];
const BIG_PICTURE_DIMS: [GridDimentions; 2] = [GridDimentions::D920x430, GridDimentions::D460x215];
pub fn get_query_type(download_animated: bool, image_type: &ImageType) -> steamgriddb_api::QueryType {
pub fn get_query_type(
download_animated: bool,
image_type: &ImageType,
) -> steamgriddb_api::QueryType {
let anymation_type = if download_animated {
Some(&[steamgriddb_api::query_parameters::AnimtionType::Animated][..])
} else {
@@ -366,6 +369,3 @@ pub struct ToDownload {
pub app_name: String,
pub image_type: ImageType,
}
unsafe impl Send for ToDownload {
}
+11 -6
View File
@@ -1,4 +1,4 @@
#[derive(Debug, Clone, Copy,PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ImageType {
Hero,
Grid,
@@ -8,16 +8,21 @@ pub enum ImageType {
Icon,
}
pub const ALL_TYPES : [ImageType;6] =
[ImageType::Hero,ImageType::Grid,ImageType::WideGrid,ImageType::Logo,ImageType::BigPicture,ImageType::Icon];
pub const ALL_TYPES: [ImageType; 6] = [
ImageType::Hero,
ImageType::Grid,
ImageType::WideGrid,
ImageType::Logo,
ImageType::BigPicture,
ImageType::Icon,
];
impl ImageType {
pub fn all() -> &'static [ImageType;6]{
pub fn all() -> &'static [ImageType; 6] {
&ALL_TYPES
}
pub fn name(&self) -> &str{
pub fn name(&self) -> &str {
match self {
ImageType::Hero => "Hero",
ImageType::Grid => "Grid",