feat(audio): respect amplification config
This commit is contained in:
parent
c54bf8e189
commit
5a4f4c2018
3 changed files with 103 additions and 68 deletions
|
|
@ -8,7 +8,7 @@ use std::sync::LazyLock;
|
|||
use std::time::Duration;
|
||||
|
||||
use crate::{localize::localize, pulse::DeviceInfo};
|
||||
use config::AudioAppletConfig;
|
||||
use config::{AudioAppletConfig, amplification_sink, amplification_source};
|
||||
use cosmic::{
|
||||
Element, Renderer, Task, Theme, app,
|
||||
applet::{
|
||||
|
|
@ -63,9 +63,11 @@ pub struct Audio {
|
|||
output_volume: f64,
|
||||
output_volume_debounce: bool,
|
||||
output_volume_text: String,
|
||||
output_amplification: bool,
|
||||
input_volume: f64,
|
||||
input_volume_debounce: bool,
|
||||
input_volume_text: String,
|
||||
input_amplification: bool,
|
||||
current_output: Option<DeviceInfo>,
|
||||
current_input: Option<DeviceInfo>,
|
||||
outputs: Vec<DeviceInfo>,
|
||||
|
|
@ -338,6 +340,9 @@ impl cosmic::Application for Audio {
|
|||
self.popup.replace(new_id);
|
||||
self.timeline = Timeline::new();
|
||||
|
||||
self.output_amplification = amplification_sink();
|
||||
self.input_amplification = amplification_source();
|
||||
|
||||
let popup_settings = self.core.applet.get_popup_settings(
|
||||
self.core.main_window_id().unwrap(),
|
||||
new_id,
|
||||
|
|
@ -758,6 +763,23 @@ impl cosmic::Application for Audio {
|
|||
.align_x(Alignment::Center)
|
||||
)]
|
||||
} else {
|
||||
let output_slider = if self.output_amplification {
|
||||
slider(0.0..=150.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.])
|
||||
} else {
|
||||
slider(0.0..=100.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
};
|
||||
let input_slider = if self.input_amplification {
|
||||
slider(0.0..=150.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.])
|
||||
} else {
|
||||
slider(0.0..=100.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
};
|
||||
|
||||
column![
|
||||
padded_control(
|
||||
row![
|
||||
|
|
@ -770,9 +792,7 @@ impl cosmic::Application for Audio {
|
|||
.icon_size(24)
|
||||
.line_height(24)
|
||||
.on_press(Message::SetOutputMute(!out_mute)),
|
||||
slider(0.0..=150.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.]),
|
||||
output_slider,
|
||||
container(text(&self.output_volume_text).size(16))
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Alignment::End)
|
||||
|
|
@ -791,9 +811,7 @@ impl cosmic::Application for Audio {
|
|||
.icon_size(24)
|
||||
.line_height(24)
|
||||
.on_press(Message::SetInputMute(!in_mute)),
|
||||
slider(0.0..=150.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.]),
|
||||
input_slider,
|
||||
container(text(&self.input_volume_text).size(16))
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Alignment::End)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue