feat: Init of Tauri application with system tray support and configuration

- Added main.rs to set up the Tauri application with a system tray.
- Implemented a basic application state management using Mutex.
- Created a system tray menu with options for "Settings" and "Quit".
- Configured tauri.conf.json with application metadata and window settings.
This commit is contained in:
2026-01-18 16:04:22 +01:00
parent a7b0c6212f
commit cb14fe0989
13 changed files with 12736 additions and 1 deletions

5645
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

32
src-tauri/Cargo.toml Normal file
View File

@@ -0,0 +1,32 @@
[package]
name = "ai-translater-client"
version = "0.1.0"
description = "AI Typist Client"
authors = ["Din Namn"]
edition = "2021"
rust-version = "1.77"
[build-dependencies]
tauri-build = { version = "2.0", features = [] }
[dependencies]
# Tauri Framework
tauri = { version = "2.0", features = ["tray-icon", "image-png"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Async & Network
tokio = { version = "1.0", features = ["full"] }
reqwest = { version = "0.12", features = ["json", "multipart"] }
# AI & LLM
ollama-rs = "0.2"
# System Integration (Input/Clipboard/Hotkeys)
enigo = "0.3" # För tangentbords-mimic
arboard = "3.4" # Clipboard hantering
global-hotkey = "0.6" # Systemomfattande genvägar
# Logging (Strongly recommended for debugging)
log = "0.4"
env_logger = "0.11"

3
src-tauri/build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

81
src-tauri/src/main.rs Normal file
View File

@@ -0,0 +1,81 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, TrayIconBuilder, TrayIconEvent},
Manager,
};
use std::sync::Mutex;
// Placeholder for application state
struct AppState {
// Exempel: Spara status för ollama connection här
ollama_ready: Mutex<bool>,
}
#[tokio::main]
async fn main() {
// Initiera loggning
env_logger::init();
tauri::Builder::default()
.setup(|app| {
// Setup Application State
app.manage(AppState {
ollama_ready: Mutex::new(false),
});
// --- System Tray Setup ---
// Skapa menyalternativ
let quit_i = MenuItem::with_id(app, "quit", "Avsluta", true, None::<&str>)?;
let settings_i = MenuItem::with_id(app, "settings", "Inställningar", true, None::<&str>)?;
// Skapa menyn
let menu = Menu::with_items(app, &[&settings_i, &quit_i])?;
// Bygg Tray-ikonen
let _tray = TrayIconBuilder::new()
.icon(app.default_window_icon().unwrap().clone())
.menu(&menu)
.show_menu_on_left_click(false)
.on_menu_event(|app, event| {
match event.id.as_ref() {
"quit" => {
println!("Avslutar applikationen...");
app.exit(0);
}
"settings" => {
println!("Öppnar inställningar (Placeholder)...");
// Här kan du öppna ditt inställningsfönster:
// if let Some(window) = app.get_webview_window("main") {
// window.show().unwrap();
// window.set_focus().unwrap();
// }
}
_ => {}
}
})
.on_tray_icon_event(|tray, event| {
match event {
TrayIconEvent::Click {
button: MouseButton::Left,
..
} => {
let app = tray.app_handle();
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
}
}
_ => {}
}
})
.build(app)?;
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

34
src-tauri/tauri.conf.json Normal file
View File

@@ -0,0 +1,34 @@
{
"productName": "ai-translater-client",
"version": "0.1.0",
"identifier": "com.ai-translater.client",
"build": {
"beforeDevCommand": "",
"beforeBuildCommand": "",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "AI Typist Inställningar",
"width": 800,
"height": 600,
"visible": false
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}