Skip to content

Commit

Permalink
chore: fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhelvetican committed Oct 4, 2024
1 parent 59d0482 commit c17bbfe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
32 changes: 4 additions & 28 deletions src/entities/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ use std::collections::BTreeMap;
use iced::window::Id;
use tray_icon::TrayIcon;

use crate::entities::{
capture::CaptureEvent,
config::{Config, ConfigEvent},
window::WindowType,
};
pub use crate::entities::events::AppEvent;
use crate::entities::{config::Config, window::WindowType};

pub struct App {
#[expect(dead_code)]
Expand All @@ -17,32 +14,11 @@ pub struct App {
}

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

#[derive(Debug, Clone)]
pub enum AppEvent {
OpenConfigureWindow,
OpenDirectory,
UpdateDirectory(Id),
GetScaleFactor(Id, f32),
OpenCaptureWindow,
Undo,
Done,
Cancel,
RequestClose(Id),
WindowClosed(Id),
ExitApp,
Config(Id, ConfigEvent),
Capture(Id, CaptureEvent),
}
20 changes: 20 additions & 0 deletions src/entities/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use iced::window::Id;

use super::{capture::CaptureEvent, config::ConfigEvent};

#[derive(Debug, Clone)]
pub enum AppEvent {
OpenConfigureWindow,
OpenDirectory,
UpdateDirectory(Id),
GetScaleFactor(Id, f32),
OpenCaptureWindow,
Undo,
Done,
Cancel,
RequestClose(Id),
WindowClosed(Id),
ExitApp,
Config(Id, ConfigEvent),
Capture(Id, CaptureEvent),
}
1 change: 1 addition & 0 deletions src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod app;
pub mod capture;
pub mod config;
mod events;
pub mod style;
pub mod theme;
pub mod window;
8 changes: 3 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ mod theme;
mod utils;
mod windows;

use std::collections::BTreeMap;

use assets::{APPICON, APPNAME, FONT_BOLD, FONT_ICONS, FONT_MEDIUM, MEDIUM};
use entities::{
app::{App, AppEvent},
Expand Down Expand Up @@ -54,15 +52,15 @@ pub fn main() -> Result<(), iced::Error> {
.theme(App::theme)
.subscription(App::subscription)
.antialiasing(true)
.run_with(App::new)
.run_with(App::run)
}

impl App {
pub fn new() -> (App, Task<AppEvent>) {
pub fn run() -> (App, Task<AppEvent>) {
let (config, is_initial) = Config::new();
let tray_icon = tray_icon();
(
App::new_internal(tray_icon, config, BTreeMap::new()),
App::new(tray_icon, config),
if is_initial {
Task::done(AppEvent::OpenConfigureWindow)
} else {
Expand Down

0 comments on commit c17bbfe

Please sign in to comment.