diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 7428e5c..56fad3b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1945,6 +1945,25 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "itertools" version = "0.12.1" @@ -2520,6 +2539,7 @@ version = "0.1.9" dependencies = [ "auto-launch", "dunce", + "open 5.0.1", "parking_lot", "rand 0.8.5", "serde", @@ -2552,6 +2572,17 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "open" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90878fb664448b54c4e592455ad02831e23a3f7e157374a8b95654731aac7349" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.63" @@ -4123,7 +4154,7 @@ dependencies = [ "ignore", "objc", "once_cell", - "open", + "open 3.2.0", "percent-encoding", "rand 0.8.5", "raw-window-handle", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8f3b3a7..0facdd6 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -30,6 +30,7 @@ tauri-build = { version = "1.5", features = [] } [dependencies] auto-launch = "0.5" dunce = "1.0" +open = "5.0.1" parking_lot = "0.12" rand = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/src-tauri/src/application_state.rs b/src-tauri/src/application_state.rs index 47c85f3..624b01d 100644 --- a/src-tauri/src/application_state.rs +++ b/src-tauri/src/application_state.rs @@ -66,7 +66,7 @@ pub struct ApplicationState { pub tick_process: Option>, pub pause_after_break: bool, // TODO button on frontend to open this location? - _data_location: PathBuf, + data_location: PathBuf, session_count: u8, settings: ModelSettings, strategies: Vec, @@ -92,7 +92,7 @@ impl ApplicationState { .map(std::borrow::ToOwned::to_owned) .collect::>(); Ok(Self { - _data_location: local_dir, + data_location: local_dir, pause_after_break: false, session_count: 0, session_status: SessionStatus::Work, @@ -136,6 +136,11 @@ impl ApplicationState { (self.current_timer_left(), self.random_strategy()) } + /// Get the directory where the database is stored + pub const fn get_data_location(&self) -> &PathBuf { + &self.data_location + } + /// Return, in seconds, the current amount left of the onoing work - or break - session pub fn current_timer_left(&self) -> u16 { let taken_since = match self.timer { diff --git a/src-tauri/src/internal_message_handler.rs b/src-tauri/src/internal_message_handler.rs index dbc123d..fff48d4 100644 --- a/src-tauri/src/internal_message_handler.rs +++ b/src-tauri/src/internal_message_handler.rs @@ -377,7 +377,7 @@ fn handle_break( menu_enabled(app, true); if state.lock().pause_after_break { sx.send(InternalMessage::Pause).ok(); - // if the app is in fullscreen mode, need to remove the fullscreen, normally this is hanlded by the hide_window function, but it's not being called here + // if the app is in fullscreen mode, need to remove the fullscreen, normally this is hanlded by the hide_window function, but it's not being called here WindowAction::remove_fullscreen(app); } else { WindowAction::hide_window(app, fullscreen); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3b9d16c..32e588b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -105,6 +105,8 @@ async fn main() -> Result<(), ()> { } Ok(app_state) => { let state = Arc::new(Mutex::new(app_state)); + // TODO change this to just an Arc, and use a message bus everywhere? + let init_state = Arc::clone(&state); let internal_state = Arc::clone(&state); @@ -151,6 +153,7 @@ async fn main() -> Result<(), ()> { request_handlers::get_autostart, request_handlers::init, request_handlers::minimize, + request_handlers::open_database_location, request_handlers::pause_after_break, request_handlers::reset_settings, request_handlers::set_autostart, diff --git a/src-tauri/src/request_handlers/mod.rs b/src-tauri/src/request_handlers/mod.rs index a29434c..5c9657c 100644 --- a/src-tauri/src/request_handlers/mod.rs +++ b/src-tauri/src/request_handlers/mod.rs @@ -100,6 +100,18 @@ pub fn set_setting_fullscreen(state: TauriState<'_>, value: bool) { .ok(); } +/// Request to set the full screen setting to the given boolean value +#[tauri::command] +#[allow(clippy::needless_pass_by_value)] +pub fn open_database_location(state: TauriState<'_>) { + open::that(state.lock().get_data_location()).ok(); + state + .lock() + .sx + .send(InternalMessage::Window(WindowVisibility::Hide)) + .ok(); +} + /// Request to set the session length to the given i64 value #[tauri::command] #[allow(clippy::needless_pass_by_value)] diff --git a/src/Views/SettingsView.vue b/src/Views/SettingsView.vue index 6368905..c2d874a 100644 --- a/src/Views/SettingsView.vue +++ b/src/Views/SettingsView.vue @@ -1,13 +1,12 @@ - - + @@ -65,7 +61,7 @@ - + - +
@@ -104,29 +100,33 @@ - - - + + + reset settings - + + + + + database location + + - -