mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复控制中心禁用所有声音输出设备后,通过任务栏点击音量的开/关,声音变为输出状态的bug
问题:全部声卡禁用后,任务栏取消静音的情况下,可以听见声音输出, 修复方法:在声卡全部禁用后,置灰静音按钮和右键菜单静音选项,其他情况逻辑不变. Bug: https://pms.uniontech.com/zentao/bug-view-86853.html Log: 优化任务栏声音插件 Change-Id: If32fcada47dd02114a0687e12cf7d0106d2d9682
This commit is contained in:
parent
05e6245262
commit
786d3588e2
@ -531,8 +531,7 @@ void SoundApplet::activePort(const QString &portId, const uint &cardId)
|
||||
|
||||
void SoundApplet::updateCradsInfo()
|
||||
{
|
||||
QDBusInterface inter("com.deepin.daemon.Audio", "/com/deepin/daemon/Audio","com.deepin.daemon.Audio",QDBusConnection::sessionBus(), this);
|
||||
QString info = inter.property("CardsWithoutUnavailable").toString();
|
||||
QString info = m_audioInter->property("CardsWithoutUnavailable").toString();
|
||||
if(m_deviceInfo != info){
|
||||
cardsChanged(info);
|
||||
m_deviceInfo = info;
|
||||
@ -611,11 +610,42 @@ void SoundApplet::updateVolumeSliderStatus(const QString &status)
|
||||
m_volumeIconMax->setVisible(flag);
|
||||
}
|
||||
|
||||
/** 判断是否存在未禁用的声音输出设备
|
||||
* @brief SoundApplet::existActiveOutputDevice
|
||||
* @return 存在返回true,否则返回false
|
||||
*/
|
||||
bool SoundApplet::existActiveOutputDevice()
|
||||
{
|
||||
QString info = m_audioInter->property("CardsWithoutUnavailable").toString();
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(info.toUtf8());
|
||||
QJsonArray jCards = doc.array();
|
||||
for (QJsonValue cV : jCards) {
|
||||
QJsonObject jCard = cV.toObject();
|
||||
QJsonArray jPorts = jCard["Ports"].toArray();
|
||||
|
||||
for (QJsonValue pV : jPorts) {
|
||||
QJsonObject jPort = pV.toObject();
|
||||
if (jPort["Direction"].toInt() == 1 && jPort["Enabled"].toBool())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SoundApplet::eventFilter(QObject *watcher, QEvent *event)
|
||||
{
|
||||
// 当控制中心禁用所有输出设备时,静音按钮置灰,其他情况正常.
|
||||
if (watcher == m_volumeIconMin && event->type() == QEvent::MouseButtonRelease) {
|
||||
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
|
||||
if (!existActiveOutputDevice()) {
|
||||
m_volumeIconMin->setEnabled(false);
|
||||
} else {
|
||||
m_volumeIconMin->setEnabled(true);
|
||||
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,15 @@
|
||||
#include <com_deepin_daemon_audio.h>
|
||||
#include <com_deepin_daemon_audio_sink.h>
|
||||
|
||||
#include <DIconButton>
|
||||
#include <DListView>
|
||||
#include <DApplicationHelper>
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
|
||||
#include <DIconButton>
|
||||
#include <DListView>
|
||||
#include <DApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
using DBusAudio = com::deepin::daemon::Audio;
|
||||
@ -44,7 +44,7 @@ using DBusSink = com::deepin::daemon::audio::Sink;
|
||||
class HorizontalSeperator;
|
||||
class QGSettings;
|
||||
|
||||
namespace Dock{
|
||||
namespace Dock {
|
||||
class TipsWidget;
|
||||
}
|
||||
|
||||
@ -135,6 +135,8 @@ public:
|
||||
void setUnchecked(DStandardItem *pi);
|
||||
void initUi();
|
||||
|
||||
bool existActiveOutputDevice();
|
||||
|
||||
signals:
|
||||
void volumeChanged(const int value) const;
|
||||
void defaultSinkChanged(DBusSink *sink) const;
|
||||
|
@ -19,30 +19,31 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
|
||||
#include <DApplication>
|
||||
#include <DDBusSender>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
#include "sounditem.h"
|
||||
#include "constants.h"
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "../frame/util/imageutil.h"
|
||||
#include "../frame/util/utils.h"
|
||||
|
||||
#include <DApplication>
|
||||
#include <DDBusSender>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QDBusInterface>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
// menu actions
|
||||
#define MUTE "mute"
|
||||
#define SETTINGS "settings"
|
||||
|
||||
|
||||
using namespace Dock;
|
||||
|
||||
SoundItem::SoundItem(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_tipsLabel(new TipsWidget(this))
|
||||
@ -77,18 +78,23 @@ QWidget *SoundItem::popupApplet()
|
||||
return m_applet;
|
||||
}
|
||||
|
||||
const QString SoundItem::contextMenu() const
|
||||
const QString SoundItem::contextMenu()
|
||||
{
|
||||
QList<QVariant> items;
|
||||
items.reserve(2);
|
||||
|
||||
QMap<QString, QVariant> open;
|
||||
open["itemId"] = MUTE;
|
||||
if (m_sinkInter->mute())
|
||||
if (m_sinkInter->mute()) {
|
||||
open["itemText"] = tr("Unmute");
|
||||
else
|
||||
if (!m_applet->existActiveOutputDevice())
|
||||
open["isActive"] = false;
|
||||
else
|
||||
open["isActive"] = true;
|
||||
} else {
|
||||
open["itemText"] = tr("Mute");
|
||||
open["isActive"] = true;
|
||||
open["isActive"] = true;
|
||||
}
|
||||
items.push_back(open);
|
||||
|
||||
if (!QFile::exists(ICBC_CONF_FILE)) {
|
||||
@ -102,7 +108,6 @@ const QString SoundItem::contextMenu() const
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
menu["checkableMenu"] = false;
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
QWidget *tipsWidget();
|
||||
QWidget *popupApplet();
|
||||
|
||||
const QString contextMenu() const;
|
||||
const QString contextMenu();
|
||||
void invokeMenuItem(const QString menuId, const bool checked);
|
||||
|
||||
void refreshIcon();
|
||||
|
Loading…
x
Reference in New Issue
Block a user