Skip to content

Commit

Permalink
change: window icon
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed Jun 24, 2023
1 parent d31f982 commit f056c94
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde_json = "1.0"
serde_with = { version = "3.0", features = ["json"] }
tokio = { version = "1", features = ["full"] }
iced_native = "0.10.3"
image = "0.24.6"

[build-dependencies]
embed-resource = "2.1"
Binary file added assets/icon@2x_r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod lcu;
pub mod source;
pub mod styles;
pub mod ui;
pub mod util;
pub mod web;

use std::collections::HashMap;
Expand Down Expand Up @@ -90,6 +91,7 @@ pub fn main() -> iced::Result {
});
});

let window_icon = util::load_icon();
ChampR::run(Settings {
id: None,
window: window::Settings {
Expand All @@ -102,7 +104,7 @@ pub fn main() -> iced::Result {
decorations: true,
transparent: false,
always_on_top: false,
icon: None,
icon: Some(window_icon),
platform_specific: PlatformSpecific::default(),
},
default_font: Some(fonts::SARSA_MONO_REGULAR_BYTES),
Expand Down Expand Up @@ -158,7 +160,7 @@ impl Application for ChampR {
}

fn title(&self) -> String {
String::from("ChampR - Builds, Runes, All in One. v2.0.2-b3")
String::from("ChampR - Builds, Runes, All in One. v2.0.2-b4")
}

fn update(&mut self, message: Message) -> Command<Message> {
Expand All @@ -182,7 +184,9 @@ impl Application for ChampR {
}
}
Message::ApplyBuilds => {
if (*self.auth_url.lock().unwrap()).is_empty() || !(*self.fetched_remote_data.lock().unwrap()) {
if (*self.auth_url.lock().unwrap()).is_empty()
|| !(*self.fetched_remote_data.lock().unwrap())
{
return Command::none();
}

Expand Down Expand Up @@ -419,7 +423,7 @@ impl Application for ChampR {
fn subscription(&self) -> Subscription<Message> {
let time_subscription =
iced::time::every(Duration::from_millis(100)).map(|_| Message::TickRun);

let ev_subscription = iced_native::subscription::events().map(Message::EventOccurred);

Subscription::batch([time_subscription, ev_subscription])
Expand Down
12 changes: 12 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use iced_native::window::{Icon, icon};

const ICON_IMAGE: &[u8] = include_bytes!("../assets/icon@2x_r.png");

pub fn load_icon() -> Icon {
let image = image::load_from_memory(ICON_IMAGE)
.expect("Failed to open icon path")
.into_rgba8();
let (width, height) = image.dimensions();
let rgba = image.into_raw();
icon::from_rgba(rgba, width, height).expect("Failed to load icon")
}

0 comments on commit f056c94

Please sign in to comment.