mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
feat: add audio switch ui
This commit is contained in:
@@ -1252,6 +1252,27 @@ impl LoginConfigHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the audio mode option.
|
||||
/// Return [`AudioMode`] if the option is valid, otherwise return `None`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `q` - The audio mode option.
|
||||
/// * `ignore_default` - Ignore the default value.
|
||||
fn get_audio_mode_enum(&self, q: &str, ignore_default: bool) -> Option<AudioMode> {
|
||||
if q == "guest-to-host" {
|
||||
Some(AudioMode::GuestToHost)
|
||||
} else if q == "two-way" {
|
||||
Some(AudioMode::TwoWay)
|
||||
} else {
|
||||
if ignore_default {
|
||||
None
|
||||
} else {
|
||||
Some(AudioMode::GuestToHost)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the status of a toggle option.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -1338,6 +1359,24 @@ impl LoginConfigHandler {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn save_audio_mode(&mut self, value: String) -> Option<Message> {
|
||||
let mut res = None;
|
||||
if let Some(q) = self.get_audio_mode_enum(&value, false) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_option(OptionMessage {
|
||||
audio_mode: q.into(),
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_misc(misc);
|
||||
res = Some(msg_out);
|
||||
}
|
||||
let mut config = self.load_config();
|
||||
config.audio_mode = value;
|
||||
self.save_config(config);
|
||||
res
|
||||
}
|
||||
|
||||
/// Create a [`Message`] for saving custom fps.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
Reference in New Issue
Block a user