fix(audio): 修复无声卡设备tips显示错误

需求调整,无声卡设备时,tips 提示错误。

Log: 修复无声卡设备tips显示错误
Bug: https://pms.uniontech.com/bug-view-152967.html
Influence: 声音
Change-Id: I2ba075cdd6fb76f15ca31a0dade86cb7421e1422
This commit is contained in:
liaohanqin 2022-08-10 14:23:33 +08:00 committed by wubw
parent 2b9412bdcf
commit 10c57d1b7b
2 changed files with 15 additions and 11 deletions

View File

@ -285,7 +285,7 @@ void SoundApplet::onDefaultSinkChanged()
connect(m_defSinkInter, &DBusSink::VolumeChanged, this, &SoundApplet::onVolumeChanged);
connect(m_defSinkInter, &DBusSink::MuteChanged, this, [ = ] {
onVolumeChanged(m_defSinkInter->volume());
onVolumeChanged(existActiveOutputDevice() ? m_defSinkInter->volume() : 0);
});
QString portId = m_defSinkInter->activePort().name;

View File

@ -88,14 +88,15 @@ const QString SoundItem::contextMenu()
QMap<QString, QVariant> open;
open["itemId"] = MUTE;
if (m_sinkInter->mute()) {
if (!m_applet->existActiveOutputDevice()) {
open["itemText"] = tr("Unmute");
if (!m_applet->existActiveOutputDevice())
open["isActive"] = false;
else
open["isActive"] = true;
open["isActive"] = false;
} else {
open["itemText"] = tr("Mute");
if (m_sinkInter->mute()) {
open["itemText"] = tr("Unmute");
} else {
open["itemText"] = tr("Mute");
}
open["isActive"] = true;
}
items.push_back(open);
@ -229,11 +230,14 @@ void SoundItem::refreshTips(const int volume, const bool force)
if (!force && !m_tipsLabel->isVisible())
return;
const bool mute = m_applet->existActiveOutputDevice() ? m_sinkInter->mute() : true;
if (mute) {
m_tipsLabel->setText(QString(tr("Mute")));
if (!m_applet->existActiveOutputDevice()) {
m_tipsLabel->setText(QString(tr("No output devices")));
} else {
m_tipsLabel->setText(QString(tr("Volume %1").arg(QString::number(volume) + '%')));
if (m_sinkInter->mute()) {
m_tipsLabel->setText(QString(tr("Mute")));
} else {
m_tipsLabel->setText(QString(tr("Volume %1").arg(QString::number(volume) + '%')));
}
}
}