Skip to content

Commit 4f9c635

Browse files
committed
[*] update normally
1 parent 41f2223 commit 4f9c635

File tree

17 files changed

+425
-185
lines changed

17 files changed

+425
-185
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/recorder/src/record_speaker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl SpeakerRecorder {
281281
}
282282

283283
fn find_default_output(&self) -> Result<Option<(u32, String)>, SpeakerError> {
284-
log::info!("Star search output audio devices...");
284+
log::info!("Start search output audio devices...");
285285

286286
let registry = self
287287
.core

wayshot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ description.workspace = true
1414
[dependencies]
1515
log.workspace = true
1616
slint.workspace = true
17+
pmacro.workspace = true
1718
once_cell.workspace = true
1819

1920
[target.'cfg(any(target_os = "windows", target_os = "linux", target_os = "macos", target_os = "android"))'.dependencies]

wayshot/src/config.rs

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
//! Configuration management module
2-
//!
2+
//!
33
//! Handles application configuration loading, saving, and management.
44
//! Supports platform-specific configuration directories and automatic
55
//! configuration file creation.
66
7-
use anyhow::{bail, Context, Result};
7+
use crate::slint_generatedAppWindow::{
8+
SettingControl as UISettingControl, SettingRecorder as UISettingRecorder,
9+
};
10+
use anyhow::{Context, Result, bail};
811
use log::debug;
912
use once_cell::sync::Lazy;
13+
use pmacro::SlintFromConvert;
1014
use serde::{Deserialize, Serialize};
1115
use std::{fs, path::PathBuf, sync::Mutex};
1216
use uuid::Uuid;
@@ -21,7 +25,7 @@ const CARGO_TOML: &str = include_str!("../Cargo.toml");
2125
static CONFIG: Lazy<Mutex<Config>> = Lazy::new(|| Mutex::new(Config::default()));
2226

2327
/// Android-specific application directories structure
24-
///
28+
///
2529
/// Provides platform-specific directory paths for Android applications.
2630
#[cfg(feature = "android")]
2731
pub struct AppDirs {
@@ -34,11 +38,11 @@ pub struct AppDirs {
3438
#[cfg(feature = "android")]
3539
impl AppDirs {
3640
/// Creates new Android application directories
37-
///
41+
///
3842
/// # Parameters
3943
/// - `name`: Application package name
4044
/// - `_`: Compatibility parameter (unused)
41-
///
45+
///
4246
/// # Returns
4347
/// - `Some(AppDirs)` if successful, `None` otherwise
4448
pub fn new(name: Option<&str>, _: bool) -> Option<Self> {
@@ -53,7 +57,7 @@ impl AppDirs {
5357
}
5458

5559
/// Main configuration structure containing all application settings
56-
///
60+
///
5761
/// Includes paths, preferences, proxy settings, and AI model configurations.
5862
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
5963
pub struct Config {
@@ -76,17 +80,17 @@ pub struct Config {
7680
pub appid: String,
7781

7882
pub preference: Preference,
79-
pub proxy: Proxy,
80-
pub ai_model: AiModel,
83+
pub recorder: Recorder,
84+
pub control: Control,
8185
}
8286

8387
/// User preference settings for the application
84-
///
88+
///
8589
/// Contains window settings, font preferences, language, and UI options.
8690
#[derive(Serialize, Deserialize, Debug, Clone, Derivative)]
8791
#[derivative(Default)]
8892
pub struct Preference {
89-
#[derivative(Default(value = "1200"))]
93+
#[derivative(Default(value = "1000"))]
9094
pub win_width: u32,
9195

9296
#[derivative(Default(value = "800"))]
@@ -110,40 +114,38 @@ pub struct Preference {
110114
pub is_dark: bool,
111115
}
112116

113-
/// Proxy configuration settings
114-
///
115-
/// Supports both HTTP and SOCKS5 proxy configurations.
116-
#[derive(Serialize, Deserialize, Debug, Clone, Derivative)]
117+
#[derive(Serialize, Deserialize, Default, Debug, Clone, SlintFromConvert)]
118+
#[from("UISettingRecorder")]
119+
pub struct Recorder {
120+
pub save_dir: String,
121+
pub remove_temporary_files: bool,
122+
}
123+
124+
#[derive(Serialize, Deserialize, Debug, Clone, Derivative, SlintFromConvert)]
117125
#[derivative(Default)]
118-
pub struct Proxy {
119-
#[derivative(Default(value = "\"127.0.0.1\".to_string()"))]
120-
pub http_url: String,
126+
#[from("UISettingControl")]
127+
pub struct Control {
128+
pub screen: String,
129+
pub input_audio: String,
121130

122-
#[derivative(Default(value = "3128"))]
123-
pub http_port: u16,
131+
#[derivative(Default(value = "100.0"))]
132+
pub input_audio_sound: f32,
124133

125-
#[derivative(Default(value = "\"127.0.0.1\".to_string()"))]
126-
pub socks5_url: String,
134+
#[derivative(Default(value = "true"))]
135+
pub enable_input_audio: bool,
127136

128-
#[derivative(Default(value = "1080"))]
129-
pub socks5_port: u16,
130-
}
137+
#[derivative(Default(value = "100.0"))]
138+
pub desktop_speaker_sound: f32,
131139

132-
/// AI model configuration settings
133-
///
134-
/// Contains API endpoints, model names, and authentication keys for AI services.
135-
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
136-
pub struct AiModel {
137-
pub api_base_url: String,
138-
pub model_name: String,
139-
pub api_key: String,
140+
#[derivative(Default(value = "true"))]
141+
pub enable_desktop_speaker: bool,
140142
}
141143

142144
impl Config {
143145
/// Initializes the configuration
144-
///
146+
///
145147
/// Loads package metadata, creates directories, and loads configuration file.
146-
///
148+
///
147149
/// # Returns
148150
/// - `Result<()>` indicating success or failure
149151
pub fn init(&mut self) -> Result<()> {
@@ -183,10 +185,10 @@ impl Config {
183185
}
184186

185187
/// Creates application directories and sets up paths
186-
///
188+
///
187189
/// # Parameters
188190
/// - `app_dirs`: Platform-specific application directories
189-
///
191+
///
190192
/// # Returns
191193
/// - `Result<()>` indicating success or failure
192194
fn crate_dirs(&mut self, app_dirs: &AppDirs) -> Result<()> {
@@ -206,7 +208,7 @@ impl Config {
206208
}
207209

208210
/// Loads configuration from file or creates default if not exists
209-
///
211+
///
210212
/// # Returns
211213
/// - `Result<()>` indicating success or failure
212214
fn load(&mut self) -> Result<()> {
@@ -252,7 +254,7 @@ impl Config {
252254
}
253255

254256
/// Saves the current configuration to file
255-
///
257+
///
256258
/// # Returns
257259
/// - `Result<()>` indicating success or failure
258260
pub fn save(&self) -> Result<()> {
@@ -265,33 +267,33 @@ impl Config {
265267
}
266268

267269
/// Generates a default application ID using UUID v4
268-
///
270+
///
269271
/// # Returns
270272
/// - Random UUID string
271273
fn appid_default() -> String {
272274
Uuid::new_v4().to_string()
273275
}
274276

275277
/// Initializes the global configuration
276-
///
278+
///
277279
/// This should be called once at application startup.
278280
pub fn init() {
279281
CONFIG.lock().unwrap().init().unwrap();
280282
}
281283

282284
/// Returns a clone of the current configuration
283-
///
285+
///
284286
/// # Returns
285287
/// - Current configuration instance
286288
pub fn all() -> Config {
287289
CONFIG.lock().unwrap().clone()
288290
}
289291

290292
/// Saves a new configuration and updates the global instance
291-
///
293+
///
292294
/// # Parameters
293295
/// - `conf`: New configuration to save
294-
///
296+
///
295297
/// # Returns
296298
/// - `Result<()>` indicating success or failure
297299
pub fn save(conf: Config) -> Result<()> {

0 commit comments

Comments
 (0)