Skip to content

Commit

Permalink
chore: fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhelvetican committed Oct 3, 2024
1 parent 7e5cc1a commit a042cf5
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rdev = { git = "https://github.com/rustdesk-org/rdev", branch = "master"}
rfd = { version = "0.14", features = ["gtk3", "tokio"], default-features = false }
serde = { version = "1.0", features = ["derive"] }
tiny-skia = "0.11"
tokio = { version = "1.39", features = ["full", "rt"] }
tokio = { version = "1.40", features = ["full", "rt"] }
toml = "0.8"
tray-icon = "0.17"
xcap = "0.0"
Expand Down
8 changes: 4 additions & 4 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pub const APPNAME: &str = "Capter";

pub const FONT_MEDIUM: &[u8; 86616] = include_bytes!("../assets/fonts/SpaceGrotesk-Medium.ttf");
pub const FONT_MEDIUM: &[u8] = include_bytes!("../assets/fonts/SpaceGrotesk-Medium.ttf");

pub const FONT_BOLD: &[u8; 86520] = include_bytes!("../assets/fonts/SpaceGrotesk-Bold.ttf");
pub const FONT_BOLD: &[u8] = include_bytes!("../assets/fonts/SpaceGrotesk-Bold.ttf");

pub const FONT_ICONS: &[u8; 2336] = include_bytes!("../assets/fonts/icons.ttf");
pub const FONT_ICONS: &[u8] = include_bytes!("../assets/fonts/icons.ttf");

pub const APPICON: &[u8; 1358] = include_bytes!("../assets/icons/icon.png");
pub const APPICON: &[u8] = include_bytes!("../assets/icons/icon.png");

use iced::Font;

Expand Down
17 changes: 16 additions & 1 deletion src/entities/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@ use crate::entities::{
};

pub struct App {
pub _tray_icon: TrayIcon,
#[expect(dead_code)]
tray_icon: TrayIcon,
pub config: Config,
pub windows: BTreeMap<Id, WindowType>,
}

impl App {
pub(crate) fn new_internal(
tray_icon: TrayIcon,
config: Config,
windows: BTreeMap<Id, WindowType>,
) -> Self {
Self {
tray_icon,
config,
windows,
}
}
}

#[derive(Debug, Clone)]
pub enum AppEvent {
OpenConfigureWindow,
Expand Down
4 changes: 2 additions & 2 deletions src/entities/window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::entities::{capture::CaptureWindow, config::ConfigureWindow};

pub enum WindowType {
Configure(ConfigureWindow),
Capture(CaptureWindow),
Configure(Box<ConfigureWindow>),
Capture(Box<CaptureWindow>),
}
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use entities::{
theme::Theme,
window::WindowType,
};

use iced::{
advanced::graphics::image::image_rs::ImageFormat,
application::DefaultStyle,
Expand Down Expand Up @@ -43,6 +44,7 @@ pub fn main() -> Result<(), iced::Error> {
if interprocess::local_socket::Stream::connect(name).is_ok() {
return Ok(());
};

daemon(App::title, App::update, App::view)
.font(FONT_MEDIUM)
.font(FONT_BOLD)
Expand All @@ -58,13 +60,9 @@ pub fn main() -> Result<(), iced::Error> {
impl App {
pub fn new() -> (App, Task<AppEvent>) {
let (config, is_initial) = Config::new();
let _tray_icon = tray_icon();
let tray_icon = tray_icon();
(
App {
_tray_icon,
config,
windows: BTreeMap::new(),
},
App::new_internal(tray_icon, config, BTreeMap::new()),
if is_initial {
Task::done(AppEvent::OpenConfigureWindow)
} else {
Expand Down Expand Up @@ -108,10 +106,10 @@ impl App {
});
self.windows.insert(
id,
WindowType::Configure(ConfigureWindow::new(
WindowType::Configure(Box::new(ConfigureWindow::new(
shorten_path(self.config.directory.clone()),
self.config.theme.clone(),
)),
))),
);
return open_task.discard().chain(gain_focus(id));
}
Expand Down Expand Up @@ -153,7 +151,8 @@ impl App {
..Default::default()
});
let capture_window = CaptureWindow::new();
self.windows.insert(id, WindowType::Capture(capture_window));
self.windows
.insert(id, WindowType::Capture(Box::new(capture_window)));
return open_task
.discard()
.chain(gain_focus(id))
Expand Down
1 change: 1 addition & 0 deletions src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Config {
return File::options()
.read(true)
.create(true)
.truncate(true)
.write(true)
.open(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tray_icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn tray_icon_listener() -> impl Stream<Item = AppEvent> {
});

loop {
if let Some(event) = reciever.recv().await {
if let Some(event) = reciever.recv().await {
match event {
TrayIconEvent::Click { button: Left, .. } => {
output.send(AppEvent::OpenConfigureWindow).await.unwrap()
Expand Down
5 changes: 4 additions & 1 deletion src/windows/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ impl ConfigureWindow {
match message {
ConfigEvent::UpdateFolderPath => Task::done(AppEvent::UpdateDirectory(id)),
ConfigEvent::OpenFolder => Task::done(AppEvent::OpenDirectory),
ConfigEvent::UpdateTheme(event) => self.theme.update(event).into(),
ConfigEvent::UpdateTheme(event) => {
self.theme.update(event);
().into()
}
ConfigEvent::RequestExit => Task::done(AppEvent::ExitApp),
}
}
Expand Down

0 comments on commit a042cf5

Please sign in to comment.