From b882272d3269c988fe706006cb297fb38c60db5d Mon Sep 17 00:00:00 2001 From: donghualin Date: Wed, 9 Nov 2022 02:57:40 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A3=B0=E9=9F=B3?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端返回的声音数值范围是0-1,前端设置的范围是0-100,两者之间需要按照相应的转换关系进行转换 Log: 修复声音设置错误 Influence: 打开快捷设置面板,通过滑动条来调整声音,观察声音是否在设置的范围内,同时观察主面板和子面板两边的声音滑动条是否同步 Task: https://pms.uniontech.com/task-view-210309.html Change-Id: I5a567317ae68b18e4d423830d6f52352d21dabe1 --- plugins/sound/sounddeviceswidget.cpp | 4 ++-- plugins/sound/soundplugin.cpp | 4 ++-- plugins/sound/soundwidget.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/sound/sounddeviceswidget.cpp b/plugins/sound/sounddeviceswidget.cpp index 7557b6511..907b25d00 100644 --- a/plugins/sound/sounddeviceswidget.cpp +++ b/plugins/sound/sounddeviceswidget.cpp @@ -168,14 +168,14 @@ void SoundDevicesWidget::onAudioDevicesChanged() void SoundDevicesWidget::initConnection() { - connect(m_audioSink, &DBusSink::VolumeChanged, m_sliderContainer, &SliderContainer::updateSliderValue); + connect(m_audioSink, &DBusSink::VolumeChanged, this, [ = ](double value) { m_sliderContainer->updateSliderValue(value * 100); }); connect(m_volumeModel, &DBusAudio::DefaultSinkChanged, this, &SoundDevicesWidget::onDefaultSinkChanged); connect(m_delegate, &SettingDelegate::selectIndexChanged, this, &SoundDevicesWidget::onSelectIndexChanged); connect(m_volumeModel, &DBusAudio::PortEnabledChanged, this, &SoundDevicesWidget::onAudioDevicesChanged); connect(m_volumeModel, &DBusAudio::CardsWithoutUnavailableChanged, this, &SoundDevicesWidget::onAudioDevicesChanged); connect(m_sliderContainer, &SliderContainer::sliderValueChanged, this, [ this ](int value) { - m_audioSink->SetVolume(value, true); + m_audioSink->SetVolume(value * 0.01, true); }); } diff --git a/plugins/sound/soundplugin.cpp b/plugins/sound/soundplugin.cpp index c2c8be211..5e97e5f01 100644 --- a/plugins/sound/soundplugin.cpp +++ b/plugins/sound/soundplugin.cpp @@ -101,9 +101,9 @@ QWidget *SoundPlugin::itemTipsWidget(const QString &itemKey) QWidget *SoundPlugin::itemPopupApplet(const QString &itemKey) { - if (itemKey == SOUND_KEY) { + if (itemKey == SOUND_KEY) return m_soundItem->popupApplet(); - } + if (itemKey == QUICK_ITEM_KEY) return m_soundDeviceWidget.data(); diff --git a/plugins/sound/soundwidget.cpp b/plugins/sound/soundwidget.cpp index 3f6fbfbac..df3f6f0ae 100644 --- a/plugins/sound/soundwidget.cpp +++ b/plugins/sound/soundwidget.cpp @@ -80,7 +80,7 @@ void SoundWidget::initUi() void SoundWidget::initConnection() { - connect(m_defaultSink, &DBusSink::VolumeChanged, m_sliderContainer, &SliderContainer::updateSliderValue); + connect(m_defaultSink, &DBusSink::VolumeChanged, this, [ this ](double value) { m_sliderContainer->updateSliderValue(value * 100); }); connect(m_dbusAudio, &DBusAudio::DefaultSinkChanged, this, [ this ](const QDBusObjectPath &value) { if (m_defaultSink) @@ -92,7 +92,7 @@ void SoundWidget::initConnection() }); connect(m_sliderContainer, &SliderContainer::sliderValueChanged, this, [ this ](int value) { - m_defaultSink->SetVolume(value, true); + m_defaultSink->SetVolume(value * 0.01, true); }); connect(m_defaultSink, &DBusSink::MuteChanged, this, [ this ] {