feat(auto-theme): add V2 commands for theme generation and system detection
Six new commands: - v2_detect_desktop_environment: detect current DE - v2_get_system_wallpaper: get wallpaper path - v2_get_system_accent_color: get DE accent color - v2_generate_theme_from_image: generate theme from any image - v2_generate_theme_from_wallpaper: generate theme from system wallpaper - v2_extract_palette: extract color palette for preview All are pure functions (no State needed), registered in invoke_handler. cc
This commit is contained in:
2 files changed
+54
No files matched your search
@@ -10125,3 +10125,50 @@ pub async fn v2_dynamic_suggest_raw(
|
||||
.await
|
||||
.map_err(|e| format!("Failed to fetch raw dynamic suggestions: {}", e))
|
||||
}
|
||||
|
||||
// ── Auto-Theme commands ─────────────────────────────────────────────────────
|
||||
|
||||
#[tauri::command]
|
||||
pub fn v2_detect_desktop_environment() -> crate::auto_theme::system::DesktopEnvironment {
|
||||
crate::auto_theme::system::detect_desktop_environment()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn v2_get_system_wallpaper() -> Result<String, String> {
|
||||
crate::auto_theme::system::get_system_wallpaper()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn v2_get_system_accent_color() -> Result<crate::auto_theme::PaletteColor, String> {
|
||||
crate::auto_theme::system::get_system_accent_color()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[allow(non_snake_case)]
|
||||
pub fn v2_generate_theme_from_image(
|
||||
imagePath: String,
|
||||
) -> Result<crate::auto_theme::GeneratedTheme, String> {
|
||||
let palette = crate::auto_theme::palette::extract_palette(&imagePath)?;
|
||||
Ok(crate::auto_theme::generator::generate_theme(
|
||||
&palette,
|
||||
&imagePath,
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn v2_generate_theme_from_wallpaper() -> Result<crate::auto_theme::GeneratedTheme, String> {
|
||||
let wallpaper = crate::auto_theme::system::get_system_wallpaper()?;
|
||||
let palette = crate::auto_theme::palette::extract_palette(&wallpaper)?;
|
||||
Ok(crate::auto_theme::generator::generate_theme(
|
||||
&palette,
|
||||
&wallpaper,
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[allow(non_snake_case)]
|
||||
pub fn v2_extract_palette(
|
||||
imagePath: String,
|
||||
) -> Result<crate::auto_theme::ThemePalette, String> {
|
||||
crate::auto_theme::palette::extract_palette(&imagePath)
|
||||
}
|
||||
@@ -1104,6 +1104,13 @@ pub fn run() {
|
||||
commands_v2::v2_check_qobuzapp_handler,
|
||||
commands_v2::v2_register_qobuzapp_handler,
|
||||
commands_v2::v2_deregister_qobuzapp_handler,
|
||||
// Auto-theme
|
||||
commands_v2::v2_detect_desktop_environment,
|
||||
commands_v2::v2_get_system_wallpaper,
|
||||
commands_v2::v2_get_system_accent_color,
|
||||
commands_v2::v2_generate_theme_from_image,
|
||||
commands_v2::v2_generate_theme_from_wallpaper,
|
||||
commands_v2::v2_extract_palette,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in new issue
Block a user