diff --git a/Cargo.lock b/Cargo.lock index 4e864e81..4dd69a13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -904,6 +904,34 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cookie_store" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4934e6b7e8419148b6ef56950d277af8561060b56afd59e2aadf98b59fce6baa" +dependencies = [ + "cookie", + "idna 0.5.0", + "log", + "publicsuffix", + "serde", + "serde_derive", + "serde_json", + "time", + "url", +] + [[package]] name = "core-foundation" version = "0.7.0" @@ -1100,6 +1128,12 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + [[package]] name = "deranged" version = "0.3.11" @@ -1972,6 +2006,25 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -2096,6 +2149,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2", "http", "http-body", "httparse", @@ -2183,6 +2237,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.5.0" @@ -3617,6 +3681,12 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "psl-types" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" + [[package]] name = "ptr_meta" version = "0.1.4" @@ -3637,6 +3707,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "publicsuffix" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457" +dependencies = [ + "idna 0.3.0", + "psl-types", +] + [[package]] name = "qoi" version = "0.4.1" @@ -3976,8 +4056,12 @@ checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", + "cookie", + "cookie_store", + "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", @@ -3999,6 +4083,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", + "system-configuration", "tokio", "tokio-rustls", "tokio-util", @@ -4285,6 +4370,7 @@ dependencies = [ "tauri-plugin-deep-link", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-http", "tauri-plugin-log", "tauri-plugin-process", "tauri-plugin-shell", @@ -4772,6 +4858,27 @@ dependencies = [ "windows 0.52.0", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys 0.8.6", + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -5061,6 +5168,28 @@ dependencies = [ "uuid", ] +[[package]] +name = "tauri-plugin-http" +version = "2.0.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eef17218eaa8bd0fc6cafb7831c63d82ef83b3950d59dc817d92d5320c4f20c" +dependencies = [ + "data-url", + "http", + "regex", + "reqwest", + "schemars", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror", + "tokio", + "url", + "urlpattern", +] + [[package]] name = "tauri-plugin-log" version = "2.0.0-rc.0" @@ -5372,10 +5501,22 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "socket2", + "tokio-macros", "tracing", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -5709,7 +5850,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna", + "idna 0.5.0", "percent-encoding", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index ec3eeba6..224de042 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ tauri-plugin-process = "2.0.0-beta.2" tauri-plugin-log = "2.0.0-beta.2" tauri-plugin-updater = "2.0.0-beta.2" tauri-plugin-deep-link = "2.0.0-beta.10" +tauri-plugin-http = "2.0.0-beta.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9.34" diff --git a/changelog.md b/changelog.md index 6167a043..0b4d9039 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## [Unreleased] ### features - .slu and uri now are loaded correctly on seelen ui. +- allow change wallpaper from seelen settings. ### enhancements - add file associations for .slu files diff --git a/src/apps/settings/components/SettingsBox/index.module.css b/src/apps/settings/components/SettingsBox/index.module.css index 08732743..ef928702 100644 --- a/src/apps/settings/components/SettingsBox/index.module.css +++ b/src/apps/settings/components/SettingsBox/index.module.css @@ -5,6 +5,10 @@ overflow: hidden; position: relative; + &:last-child { + margin-bottom: 10px; + } + > div { position: absolute; /* for noise and blur */ top: 0; diff --git a/src/apps/settings/components/monitor/index.module.css b/src/apps/settings/components/monitor/index.module.css new file mode 100644 index 00000000..c22ddd05 --- /dev/null +++ b/src/apps/settings/components/monitor/index.module.css @@ -0,0 +1,28 @@ +.monitor { + height: 144px; + width: 256px; + border-radius: 12px; + background-color: var(--color-persist-gray-800); + padding: 8px; + + .screen { + position: relative; + border-radius: 8px; + background: linear-gradient( + 40deg, + var(--color-blue-500) 2%, + var(--color-blue-300) 60%, + var(--color-blue-100) 100% + ); + width: 100%; + height: 100%; + overflow: hidden; + + .wallpaper { + width: 100%; + height: 100%; + object-fit: cover; + position: absolute; + } + } +} diff --git a/src/apps/settings/components/monitor/index.tsx b/src/apps/settings/components/monitor/index.tsx new file mode 100644 index 00000000..d2f9f3c8 --- /dev/null +++ b/src/apps/settings/components/monitor/index.tsx @@ -0,0 +1,22 @@ +import { convertFileSrc } from '@tauri-apps/api/core'; +import { PropsWithChildren } from 'react'; +import { useSelector } from 'react-redux'; + +import { newSelectors } from '../../modules/shared/store/app/reducer'; + +import cs from './index.module.css'; + +interface Props extends PropsWithChildren {} + +export function Monitor({ children }: Props) { + const wallpaper = useSelector(newSelectors.wallpaper); + + return ( +
+
+ {wallpaper ? : null} + {children} +
+
+ ); +} diff --git a/src/apps/settings/i18n/translations/en.yml b/src/apps/settings/i18n/translations/en.yml index f743d2cc..5afdb97d 100644 --- a/src/apps/settings/i18n/translations/en.yml +++ b/src/apps/settings/i18n/translations/en.yml @@ -44,6 +44,8 @@ general: selected: Selected icon_pack: label: Icon Packs + wallpaper: + select: Select Wallpaper accent_color: Accent Color toolbar: enable: Enable Fancy Toolbar diff --git a/src/apps/settings/modules/general/main/infra/Wallpaper.tsx b/src/apps/settings/modules/general/main/infra/Wallpaper.tsx new file mode 100644 index 00000000..b22f8a16 --- /dev/null +++ b/src/apps/settings/modules/general/main/infra/Wallpaper.tsx @@ -0,0 +1,38 @@ +import { Monitor } from '../../../../components/monitor'; +import { SettingsOption } from '../../../../components/SettingsBox'; +import { invoke } from '@tauri-apps/api/core'; +import { Button } from 'antd'; +import { useTranslation } from 'react-i18next'; +import { useDispatch } from 'react-redux'; + +import { dialog } from '../../../shared/tauri/infra'; + +import { RootActions } from '../../../shared/store/app/reducer'; + +export function Wallpaper() { + const { t } = useTranslation(); + const dispatch = useDispatch(); + + async function loadWallpaper() { + const file = await dialog.open({ + title: t('general.wallpaper.select'), + filters: [{ name: 'images', extensions: ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tif', 'tiff'] }], + }); + + if (!file) { + return; + } + + await invoke('state_set_wallpaper', { path: file.path }); + dispatch(RootActions.setWallpaper(file.path)); + } + + return ( + <> + + + + + + ); +} diff --git a/src/apps/settings/modules/general/main/infra/index.tsx b/src/apps/settings/modules/general/main/infra/index.tsx index ca5a53ac..6d921a22 100644 --- a/src/apps/settings/modules/general/main/infra/index.tsx +++ b/src/apps/settings/modules/general/main/infra/index.tsx @@ -2,6 +2,7 @@ import { LanguageList } from '../../../../../shared/lang'; import { SettingsGroup, SettingsOption } from '../../../../components/SettingsBox'; import { Colors } from './Colors'; import { Themes } from './Themes'; +import { Wallpaper } from './Wallpaper'; import { Select, Switch } from 'antd'; import { useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; @@ -35,9 +36,6 @@ export function General() { {t('general.startup')} - - - {t('general.language')}: