fix: 机器没有声音输出设备时,任务栏音量插件显示异常

获取声音输出设备时增加判断,如果没有设备则把界面置灰,图标显示为静音状态。

Log: 优化任务栏音量插件
Bug: https://pms.uniontech.com/zentao/bug-view-92198.html
Influence: 华为云调节音量
Change-Id: I485ed1432ce1f4bb6439b9cae6d931f305932d80
(cherry picked from commit 73700ce8a095e651afbe8ad1f481f3fa730a70d2)
This commit is contained in:
jiangzhicheng 2021-08-21 16:07:11 +08:00 committed by wubowen
parent 444613357f
commit 531075d5b1
2 changed files with 4 additions and 7 deletions

View File

@ -358,6 +358,8 @@ void SoundApplet::cardsChanged(const QString &cards)
}
onDefaultSinkChanged();//重新获取切换的设备信息
// 判断是否存在激活的输出设备
enableDevice(existActiveOutputDevice());
for (Port *port : m_ports) {
@ -646,12 +648,7 @@ bool SoundApplet::eventFilter(QObject *watcher, QEvent *event)
{
// 当控制中心禁用所有输出设备时,静音按钮置灰,其他情况正常.
if (watcher == m_volumeIconMin && event->type() == QEvent::MouseButtonRelease) {
if (!existActiveOutputDevice()) {
m_volumeIconMin->setEnabled(false);
} else {
m_volumeIconMin->setEnabled(true);
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
}
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
}
return false;
}

View File

@ -185,7 +185,7 @@ void SoundItem::refreshIcon()
const double volmue = m_applet->volumeValue();
const double maxVolmue = m_applet->maxVolumeValue();
const bool mute = m_applet->existActiveOutputDevice() ? m_sinkInter->mute() : true;
const bool mute = m_sinkInter->name().startsWith("auto_null") ? true : m_sinkInter->mute();
const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient;
QString iconString;