From ffb9b659d5149e56321267683e5879ea3d6bc124 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Wed, 28 Dec 2022 09:11:23 +0100 Subject: [PATCH] Remove "download all" and move import button (#287) * Remove download all on specific images * Remove unusued id field * Move import button to left menu to save on vertical space * Update version to 1.7.9 --- Cargo.lock | 2 +- Cargo.toml | 2 +- flatpak/io.github.philipk.boilr.appdata.xml | 8 ++ src/ui/ui_image_download.rs | 62 +++++----- src/ui/uiapp.rs | 127 ++++++++++---------- 5 files changed, 107 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2fff3bb..5a8ed92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,7 +265,7 @@ dependencies = [ [[package]] name = "boilr" -version = "1.7.8" +version = "1.7.9" dependencies = [ "base64 0.20.0", "chrono", diff --git a/Cargo.toml b/Cargo.toml index b49eef8..065787f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "boilr" -version = "1.7.8" +version = "1.7.9" [dependencies] base64 = "^0.20.0" diff --git a/flatpak/io.github.philipk.boilr.appdata.xml b/flatpak/io.github.philipk.boilr.appdata.xml index 25cc2eb..fb37ab6 100644 --- a/flatpak/io.github.philipk.boilr.appdata.xml +++ b/flatpak/io.github.philipk.boilr.appdata.xml @@ -25,6 +25,14 @@ https://hughsie.github.io/oars/index.html --> + + +
    +
  • Fix import button hidden on steam deck in game mode
  • +
+
+
+
    diff --git a/src/ui/ui_image_download.rs b/src/ui/ui_image_download.rs index 2e9a0bc..582a5f3 100644 --- a/src/ui/ui_image_download.rs +++ b/src/ui/ui_image_download.rs @@ -72,7 +72,6 @@ pub struct PossibleImage { thumbnail_url: String, mime: MimeTypes, full_url: String, - id: u32, } impl Default for ImageSelectState { @@ -180,26 +179,26 @@ impl MyEguiApp { } else if let Some(action) = render_steam_game_select(ui, state) { return action; } - } - match *self.status_reciever.borrow() { - crate::sync::SyncProgress::FindingImages => { - ui.spinner(); - ui.label("Finding images to download"); - ui.ctx().request_repaint(); - } - crate::sync::SyncProgress::DownloadingImages { to_download } => { - ui.spinner(); - ui.label(format!("Downloading {to_download} images")); - ui.ctx().request_repaint(); - } - crate::sync::SyncProgress::Done => { - ui.ctx().request_repaint(); - return UserAction::RefreshImages; - } - _ => { - if ui.button("Download images for all games").clicked() { - return UserAction::DownloadAllImages; + match *self.status_reciever.borrow() { + crate::sync::SyncProgress::FindingImages => { + ui.spinner(); + ui.label("Finding images to download"); + ui.ctx().request_repaint(); + } + crate::sync::SyncProgress::DownloadingImages { to_download } => { + ui.spinner(); + ui.label(format!("Downloading {to_download} images")); + ui.ctx().request_repaint(); + } + crate::sync::SyncProgress::Done => { + ui.ctx().request_repaint(); + return UserAction::RefreshImages; + } + _ => { + if ui.button("Download images for all games").clicked() { + return UserAction::DownloadAllImages; + } } } } @@ -515,23 +514,22 @@ impl MyEguiApp { self.status_reciever = reciever; let mut sender_op = Some(sender); let settings = self.settings.clone(); - let users = users.clone(); + let users = users.clone(); self.rt.spawn_blocking(move || { let task = download_images(&settings, &users, &mut sender_op); block_on(task); let _ = sender_op.unwrap().send(SyncProgress::Done); }); - } } UserAction::RefreshImages => { - let (_, reciever) = watch::channel(SyncProgress::NotStarted); + let (_, reciever) = watch::channel(SyncProgress::NotStarted); let user = self.image_selected_state.steam_user.clone(); - if let Some(user) = &user{ - load_image_grids(user,&mut self.image_selected_state,ui); + if let Some(user) = &user { + load_image_grids(user, &mut self.image_selected_state, ui); } - self.status_reciever = reciever; - }, + self.status_reciever = reciever; + } }; } @@ -619,7 +617,8 @@ impl MyEguiApp { self.rt.spawn_blocking(move || { let thumbnails_folder = get_thumbnails_folder(); let client = steamgriddb_api::Client::new(auth_key); - let query = get_query_type(false, &image_type, settings.steamgrid_db.allow_nsfw); + let query = + get_query_type(false, &image_type, settings.steamgrid_db.allow_nsfw); let search_res = block_on(client.get_images_for_id(grid_id, &query)); if let Ok(possible_images) = search_res { let mut result = vec![]; @@ -632,7 +631,6 @@ impl MyEguiApp { mime: possible_image.mime.clone(), thumbnail_url: possible_image.thumb.clone(), full_url: possible_image.url.clone(), - id: possible_image.id, }); } let _ = tx.send(FetcStatus::Fetched(result)); @@ -775,7 +773,11 @@ impl MyEguiApp { } } -fn load_image_grids(user: &SteamUsersInfo, state: &mut ImageSelectState, ui: &mut egui::Ui) -> Vec { +fn load_image_grids( + user: &SteamUsersInfo, + state: &mut ImageSelectState, + ui: &mut egui::Ui, +) -> Vec { let user_info = crate::steam::get_shortcuts_for_user(user); let mut user_folder = user_info.path.clone(); user_folder.pop(); diff --git a/src/ui/uiapp.rs b/src/ui/uiapp.rs index 0bd7b8a..3c7d2d3 100644 --- a/src/ui/uiapp.rs +++ b/src/ui/uiapp.rs @@ -90,6 +90,51 @@ impl MyEguiApp { platforms, } } + + fn render_import_button(&mut self, ui: &mut egui::Ui) { + let (status_string, syncing) = match &*self.status_reciever.borrow() { + SyncProgress::NotStarted => ("".to_string(), false), + SyncProgress::Starting => ("Starting Import".to_string(), true), + SyncProgress::FoundGames { games_found } => { + (format!("Found {} games to import", games_found), true) + } + SyncProgress::FindingImages => ("Searching for images".to_string(), true), + SyncProgress::DownloadingImages { to_download } => { + (format!("Downloading {} images ", to_download), true) + } + SyncProgress::Done => ("Done importing games".to_string(), false), + }; + if syncing { + ui.ctx().request_repaint(); + } + if !status_string.is_empty() { + if syncing { + ui.horizontal(|c| { + c.spinner(); + c.label(&status_string); + }); + } else { + ui.label(&status_string); + } + } + let all_ready = all_ready(&self.games_to_sync); + let texture = self.get_import_image(ui); + let size = texture.size_vec2(); + let image_button = ImageButton::new(texture, size * 0.40); + if all_ready && !syncing{ + if ui + .add(image_button) + .on_hover_text("Import your games into steam") + .clicked(){ +save_settings(&self.settings, &self.platforms); + self.run_sync(false); + } + }else{ + ui + .add(image_button) + .on_hover_text("Waiting for sync to finish"); + } + } } fn get_rename_map() -> HashMap { @@ -174,7 +219,11 @@ impl App for MyEguiApp { || ui .selectable_value(&mut self.selected_menu, Menues::Disconnect, "Disconnect") .changed(); - + if self.selected_menu == Menues::Import { + ui.with_layout(egui::Layout::bottom_up(egui::Align::Center), |ui| { + self.render_import_button(ui); + }); + } if changed { self.backup_state.available_backups = None; } @@ -187,66 +236,6 @@ impl App for MyEguiApp { } }); - if self.selected_menu == Menues::Settings { - egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel") - .frame(frame) - .show(ctx, |ui| { - let texture = self.get_save_image(ui); - let size = texture.size_vec2(); - let save_button = ImageButton::new(texture, size * 0.5); - - if ui.add(save_button).on_hover_text("Save settings").clicked() { - save_settings(&self.settings, &self.platforms); - } - }); - } - if self.selected_menu == Menues::Import { - egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel") - .frame(frame) - .show(ctx, |ui| { - let (status_string, syncing) = match &*self.status_reciever.borrow() { - SyncProgress::NotStarted => ("".to_string(), false), - SyncProgress::Starting => ("Starting Import".to_string(), true), - SyncProgress::FoundGames { games_found } => { - (format!("Found {} games to import", games_found), true) - } - SyncProgress::FindingImages => ("Searching for images".to_string(), true), - SyncProgress::DownloadingImages { to_download } => { - (format!("Downloading {} images ", to_download), true) - } - SyncProgress::Done => ("Done importing games".to_string(), false), - }; - if syncing { - ui.ctx().request_repaint(); - } - if !status_string.is_empty() { - if syncing { - ui.horizontal(|c| { - c.spinner(); - c.label(&status_string); - }); - } else { - ui.label(&status_string); - } - } - let all_ready = all_ready(&self.games_to_sync); - - let texture = self.get_import_image(ui); - let size = texture.size_vec2(); - let image_button = ImageButton::new(texture, size * 0.5); - if all_ready - && ui - .add(image_button) - .on_hover_text("Import your games into steam") - .clicked() - && !syncing - { - save_settings(&self.settings, &self.platforms); - self.run_sync(false); - } - }); - } - egui::CentralPanel::default().show(ctx, |ui| { match self.selected_menu { Menues::Import => { @@ -266,6 +255,20 @@ impl App for MyEguiApp { } }; }); + + if self.selected_menu == Menues::Settings { + egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel") + .frame(frame) + .show(ctx, |ui| { + let texture = self.get_save_image(ui); + let size = texture.size_vec2(); + let save_button = ImageButton::new(texture, size * 0.5); + + if ui.add(save_button).on_hover_text("Save settings").clicked() { + save_settings(&self.settings, &self.platforms); + } + }); + } } } @@ -353,7 +356,7 @@ pub fn run_ui(args: Vec) { let fullscreen = args.contains(&"--fullscreen".to_string()); let native_options = eframe::NativeOptions { fullscreen, - maximized:true, + maximized: true, //initial_window_size: Some(egui::Vec2 { x: 1280., y: 800. }), icon_data: Some(get_logo_icon()), vsync: !no_v_sync,