fix: 无声卡输出设备时,tips 显示静音,音量为0

需求:
无声卡时,图标显示静音,音量条显示在0%且置灰,tips显示“静音”

Log: 无声卡时,图标显示静音,音量条显示在0%且置灰,tips显示“静音”
Bug: https://pms.uniontech.com/zentao/bug-view-106166.html
Influence: dock栏声音显示
Change-Id: Iec1712b82a5492ae750e96b0683f1e9eef8c74a2
This commit is contained in:
liaohanqin 2021-12-17 13:11:00 +08:00 committed by guoyao
parent 507a8fcc99
commit 6586c84b90
2 changed files with 4 additions and 3 deletions

View File

@ -296,7 +296,8 @@ void SoundApplet::onDefaultSinkChanged()
}
activePort(portId,cardId);
onVolumeChanged(m_defSinkInter->volume());
//无声卡状态下会有伪sink设备显示音量为0
onVolumeChanged(findPort(portId, cardId) != nullptr ? m_defSinkInter->volume() : 0);
emit defaultSinkChanged(m_defSinkInter);
}

View File

@ -231,8 +231,8 @@ void SoundItem::refreshTips(const int volume, const bool force)
if (!force && !m_tipsLabel->isVisible())
return;
QString value;
if (m_sinkInter->mute()) {
const bool mute = m_applet->existActiveOutputDevice() ? m_sinkInter->mute() : true;
if (mute) {
m_tipsLabel->setText(QString(tr("Mute")));
} else {
m_tipsLabel->setText(QString(tr("Volume %1").arg(QString::number(volume) + '%')));