diff --git a/CHANGELOG.md b/CHANGELOG.md index 14dfc90..1fe13db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next - Use Shift instead of Alt for Videos/Channels page shortcuts +- Add option to disable window decorations - Fix keyboard input working when modal is open - Remove old YouTube Email Notifier migration diff --git a/bindings.ts b/bindings.ts index c8dcf0c..c4eeb5f 100644 --- a/bindings.ts +++ b/bindings.ts @@ -40,9 +40,9 @@ async addChannel(options: AddChannelOptions) : Promise> { else return { status: "error", error: e as any }; } }, -async setGeneralSettings(apiKey: string, maxConcurrentRequests: number, checkInBackground: boolean) : Promise> { +async setGeneralSettings(apiKey: string, maxConcurrentRequests: number, checkInBackground: boolean, noWindowDecorations: boolean) : Promise> { try { - return { status: "ok", data: await TAURI_INVOKE("set_general_settings", { apiKey, maxConcurrentRequests, checkInBackground }) }; + return { status: "ok", data: await TAURI_INVOKE("set_general_settings", { apiKey, maxConcurrentRequests, checkInBackground, noWindowDecorations }) }; } catch (e) { if(e instanceof Error) throw e; else return { status: "error", error: e as any }; @@ -105,7 +105,7 @@ export type AddChannelOptions = { url: string; from_time: number; refresh_rate_m export type After = { publishTimeMs: number; id: string } export type Channel = { id: string; name: string; icon: string; uploads_playlist_id: string; from_time: number; refresh_rate_ms: number; tags: string[] } export type Options = { show_all: boolean; show_archived: boolean; channel_filter: string; tag: string | null; limit: number } -export type Settings = { api_key: string; max_concurrent_requests: number; channels: Channel[]; check_in_background: boolean } +export type Settings = { api_key: string; max_concurrent_requests: number; channels: Channel[]; check_in_background: boolean; no_window_decorations?: boolean } export type UndoHistory = { entries: ([number, Action])[] } export type Video = { id: string; title: string; description: string; publishTimeMs: number; /** diff --git a/src-tauri/src/api.rs b/src-tauri/src/api.rs index 8deedfd..43d9751 100644 --- a/src-tauri/src/api.rs +++ b/src-tauri/src/api.rs @@ -155,6 +155,7 @@ pub mod videos { } #[derive(Deserialize, Debug)] pub struct Thumbnail { + #[allow(dead_code)] pub url: String, } } diff --git a/src-tauri/src/data.rs b/src-tauri/src/data.rs index 06100f4..c439215 100644 --- a/src-tauri/src/data.rs +++ b/src-tauri/src/data.rs @@ -13,7 +13,7 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; -use tauri::{command, Config, Error, State}; +use tauri::{command, Config, Error, Manager, State}; use tokio::sync::Mutex; use url::Url; @@ -283,15 +283,23 @@ pub async fn add_channel(options: AddChannelOptions, data: DataState<'_>) -> Res #[command] #[specta::specta] pub async fn set_general_settings( + app_handle: tauri::AppHandle, api_key: String, max_concurrent_requests: u32, check_in_background: bool, + no_window_decorations: bool, data: DataState<'_>, ) -> Result<(), String> { let mut data = data.0.lock().await; data.settings().set_api_key(api_key); data.settings().max_concurrent_requests = max_concurrent_requests; data.settings().check_in_background = check_in_background; + data.settings().no_window_decorations = no_window_decorations; + app_handle + .get_webview_window("main") + .unwrap() + .set_decorations(!no_window_decorations) + .unwrap(); data.save_settings()?; Ok(()) } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index e85c07a..0e63895 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -114,6 +114,7 @@ pub async fn run() { .title("Kadium") .inner_size(900.0, 800.0) .min_inner_size(400.0, 150.0) + .decorations(!settings.unwrap_ref().no_window_decorations) .theme(Some(tauri::Theme::Dark)); #[cfg(target_os = "macos")] diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 5a7ee27..a3f6bba 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -25,6 +25,7 @@ impl Default for VersionedSettings { max_concurrent_requests: 5, channels: Vec::new(), check_in_background: true, + no_window_decorations: false, }) } } @@ -91,8 +92,11 @@ pub struct Settings { pub max_concurrent_requests: u32, pub channels: Vec, pub check_in_background: bool, + #[serde(default)] + pub no_window_decorations: bool, } impl Settings { + #[allow(dead_code)] pub fn wrap(self) -> VersionedSettings { VersionedSettings::V1(self) } diff --git a/src/lib/data.ts b/src/lib/data.ts index 9013125..71f3e7c 100644 --- a/src/lib/data.ts +++ b/src/lib/data.ts @@ -76,5 +76,6 @@ export function enableSampleData() { return channels })(), check_in_background: true, + no_window_decorations: true, }) } diff --git a/src/lib/modals/Settings.svelte b/src/lib/modals/Settings.svelte index 8188ca4..e44e0ca 100644 --- a/src/lib/modals/Settings.svelte +++ b/src/lib/modals/Settings.svelte @@ -9,12 +9,18 @@ export let apiKey: string export let maxConcurrentRequests: number export let checkInBackground: boolean + export let noWindowDecorations: boolean export let visible = false let keyGuideVisible = false async function setGeneralSettings() { - await commands.setGeneralSettings(apiKey, maxConcurrentRequests, checkInBackground) + await commands.setGeneralSettings( + apiKey, + maxConcurrentRequests, + checkInBackground, + noWindowDecorations, + ) await loadSettings() visible = false } @@ -43,6 +49,12 @@ +
+ + +
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a50fcb8..40503df 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -70,6 +70,7 @@ apiKey={$settings.api_key} maxConcurrentRequests={$settings.max_concurrent_requests} checkInBackground={$settings.check_in_background} + noWindowDecorations={$settings.no_window_decorations ?? false} bind:visible={$settingsOpen} />