Skip to content

Commit 14a8cfe

Browse files
committed
fix: sound plugin display incorrect volume tips
mute status changed, then update volume tips, false status revert to zero, so tips show 0 value Log: as title Pms: BUG-313463
1 parent aba0ce2 commit 14a8cfe

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

plugins/dde-dock/sound/soundcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ void SoundController::onDefaultSinkChanged(const QDBusObjectPath &path)
8787

8888
// 音量和静音状态变化时手动获取下另外一个的状态,有时候收不到 changed 信号
8989
connect(m_defaultSinkInter, &DBusSink::MuteChanged, &SoundModel::ref(), [this] (bool value) {
90-
SoundModel::ref().setVolume(m_defaultSinkInter->volume());
9190
SoundModel::ref().setMute(m_defaultSinkInter->mute());
91+
SoundModel::ref().setVolume(m_defaultSinkInter->volume());
9292
});
9393
connect(m_defaultSinkInter, &DBusSink::VolumeChanged, &SoundModel::ref(), [this] (double value) {
9494
SoundModel::ref().setVolume(value);

plugins/dde-dock/sound/soundview.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ SoundView::SoundView(QWidget *parent)
4747
});
4848
connect(m_applet.data(), &SoundApplet::requestHideApplet, this, &SoundView::requestHideApplet);
4949

50-
refresh(SoundModel::ref().volume());
50+
refresh();
5151
}
5252

5353
QWidget *SoundView::tipsWidget()
5454
{
55-
refreshTips(std::min(150, SoundModel::ref().volume()), true);
55+
refreshTips(true);
5656
m_tipsLabel->resize(m_tipsLabel->sizeHint().width() + 10,
5757
m_tipsLabel->sizeHint().height());
5858

@@ -147,10 +147,10 @@ bool SoundView::eventFilter(QObject *watched, QEvent *event)
147147
return QWidget::eventFilter(watched, event);
148148
}
149149

150-
void SoundView::refresh(const int volume)
150+
void SoundView::refresh()
151151
{
152152
refreshIcon();
153-
refreshTips(volume, false);
153+
refreshTips(false);
154154
}
155155

156156
void SoundView::refreshIcon()
@@ -176,7 +176,7 @@ void SoundView::refreshIcon()
176176
m_iconWidget->setIcon(QIcon::fromTheme(iconString));
177177
}
178178

179-
void SoundView::refreshTips(const int volume, const bool force)
179+
void SoundView::refreshTips(const bool force)
180180
{
181181
if (!force && !m_tipsLabel->isVisible())
182182
return;
@@ -187,6 +187,7 @@ void SoundView::refreshTips(const int volume, const bool force)
187187
if (SoundModel::ref().isMute()) {
188188
m_tipsLabel->setText(QString(tr("Mute")));
189189
} else {
190+
auto volume = std::min(150, SoundModel::ref().volume());
190191
m_tipsLabel->setText(QString(tr("Volume %1").arg(QString::number(volume) + '%')));
191192
}
192193
}

plugins/dde-dock/sound/soundview.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SoundView : public QWidget
3535
const QString contextMenu();
3636
void invokeMenuItem(const QString menuId, const bool checked);
3737
void refreshIcon();
38-
void refreshTips(const int volume, const bool force = false);
38+
void refreshTips(const bool force = false);
3939
void setAppletMinHeight(int minHeight);
4040

4141
signals:
@@ -47,7 +47,7 @@ class SoundView : public QWidget
4747
bool eventFilter(QObject *watched, QEvent *event) override;
4848

4949
private slots:
50-
void refresh(const int volume);
50+
void refresh();
5151

5252
private:
5353
Dock::TipsWidget *m_tipsLabel;

0 commit comments

Comments
 (0)