
We also change the structure of the settings ui macro. The trait is still a requirement on the Settings trait implementation, but it returns a SettingUIItemVariant now, which the settings ui crate will take adventage of to generate UI This allows us to get around circular dependency errors and still get the type system to ensure all settings fulfill the settings UI crate Co-authored-by: Ben Kunkle <ben@zed.dev>
33 lines
1 KiB
Rust
33 lines
1 KiB
Rust
use anyhow::Result;
|
|
use gpui::App;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::{SettingsUI, Settings, SettingsSources};
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUI)]
|
|
pub struct AudioSettings {
|
|
/// Opt into the new audio system.
|
|
#[serde(rename = "experimental.rodio_audio", default)]
|
|
pub rodio_audio: bool, // default is false
|
|
}
|
|
|
|
/// Configuration of audio in Zed.
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
#[serde(default)]
|
|
pub struct AudioSettingsContent {
|
|
/// Whether to use the experimental audio system
|
|
#[serde(rename = "experimental.rodio_audio", default)]
|
|
pub rodio_audio: bool,
|
|
}
|
|
|
|
impl Settings for AudioSettings {
|
|
const KEY: Option<&'static str> = Some("audio");
|
|
|
|
type FileContent = AudioSettingsContent;
|
|
|
|
fn load(sources: SettingsSources<Self::FileContent>, _cx: &mut App) -> Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
|
|
fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
|
|
}
|