mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 修复音量插件调节最小刻度不是%2的问题
原有的功能,新需求做的时候并没有考虑到继承 Log: 修复音量插件调节最小刻度不是%2的问题 Influence: 音量插件调节 Bug: https://pms.uniontech.com/bug-view-172417.html Change-Id: Ia10448abb3e872ad47a46d34d1e179538c585c49
This commit is contained in:
parent
58ed354c39
commit
224b0a9cb9
@ -71,6 +71,8 @@ void SoundWidget::initUi()
|
||||
QPixmap rightPixmap = ImageUtil::loadSvg(rightIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 12);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||
m_sliderContainer->setRange(0, 100);
|
||||
m_sliderContainer->setPageStep(2);
|
||||
|
||||
SliderProxyStyle *proxy = new SliderProxyStyle;
|
||||
m_sliderContainer->setSliderProxyStyle(proxy);
|
||||
@ -80,14 +82,14 @@ void SoundWidget::initUi()
|
||||
|
||||
void SoundWidget::initConnection()
|
||||
{
|
||||
connect(m_defaultSink, &DBusSink::VolumeChanged, this, [ this ](double value) { m_sliderContainer->updateSliderValue(value * 100); });
|
||||
connect(m_defaultSink, &DBusSink::VolumeChanged, this, [ this ](double value) {m_sliderContainer->updateSliderValue(std::round(value * 100.00));});
|
||||
|
||||
connect(m_dbusAudio, &DBusAudio::DefaultSinkChanged, this, [ this ](const QDBusObjectPath &value) {
|
||||
if (m_defaultSink)
|
||||
delete m_defaultSink;
|
||||
|
||||
m_defaultSink = new DBusSink("org.deepin.daemon.Audio1", value.path(), QDBusConnection::sessionBus(), this);
|
||||
m_sliderContainer->updateSliderValue(m_defaultSink->volume() * 100);
|
||||
m_sliderContainer->updateSliderValue(std::round(m_defaultSink->volume() * 100.00));
|
||||
connect(m_defaultSink, &DBusSink::VolumeChanged, m_sliderContainer, &SliderContainer::updateSliderValue);
|
||||
});
|
||||
|
||||
|
@ -181,6 +181,16 @@ void SliderContainer::setIcon(const SliderContainer::IconPosition &iconPosition,
|
||||
}
|
||||
}
|
||||
|
||||
void SliderContainer::setPageStep(int step)
|
||||
{
|
||||
return m_slider->setPageStep(step);
|
||||
}
|
||||
|
||||
void SliderContainer::setRange(int min, int max)
|
||||
{
|
||||
return m_slider->setRange(min, max);
|
||||
}
|
||||
|
||||
bool SliderContainer::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
|
@ -55,6 +55,9 @@ public:
|
||||
void setIcon(const IconPosition &iconPosition, const QIcon &icon);
|
||||
void setIcon(const IconPosition &iconPosition, const QPixmap &icon, const QSize &shadowSize, int space);
|
||||
|
||||
void setPageStep(int step);
|
||||
void setRange(int min, int max);
|
||||
|
||||
Q_SIGNALS:
|
||||
void iconClicked(const IconPosition &);
|
||||
void sliderValueChanged(int value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user