Skip to content

Commit 71b6213

Browse files
wyu71fly602
authored andcommitted
fix: reorder login sound playback in sessionmanager
- Move login sound playback logic to the correct position - Ensure sound plays only when conditions are met - Simplify canPlayEvent checks for better readability Log: reorder login sound playback in sessionmanager pms: BUG-309243
1 parent 0f40525 commit 71b6213

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/dde-session/impl/sessionmanager.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ SessionManager::SessionManager(QObject *parent)
8383
// 处理异常退出的情况
8484
handleOSSignal();
8585

86-
// 播放登录提示音
87-
if (canPlayEvent("desktop-login")) {
88-
playLoginSound();
89-
}
90-
9186
auto appearanceConfig = DConfig::create("org.deepin.dde.appearance", "org.deepin.dde.appearance", QString(), this);
9287
m_soundTheme = appearanceConfig->value("Sound_Theme", "deepin").toString();
9388
connect(appearanceConfig, &DConfig::valueChanged, this, [this, appearanceConfig] (const QString &key) {
9489
if (key == "Sound_Theme") {
9590
m_soundTheme = appearanceConfig->value("Sound_Theme", "deepin").toString();
9691
}
9792
});
93+
94+
// 播放登录提示音
95+
if (canPlayEvent("desktop-login")) {
96+
playLoginSound();
97+
}
9898
}
9999

100100
SessionManager::~SessionManager()
@@ -704,13 +704,10 @@ bool SessionManager::canPlayEvent(const QString &event)
704704
const QString methodInterface = "org.deepin.dde.SoundEffect1";
705705

706706
QDBusInterface dbusInterface(service, path, interface, QDBusConnection::sessionBus());
707-
if (!dbusInterface.isValid()) {
708-
return false;
709-
}
710-
711-
QDBusReply<bool> enabledReply = dbusInterface.call("Get", service, "Enabled");
707+
QDBusReply<QDBusVariant> enabledReply = dbusInterface.call("Get", service, "Enabled");
712708
if (enabledReply.isValid()) {
713-
if (!enabledReply.value()) {
709+
QVariant result = enabledReply.value().variant();
710+
if (!result.toBool()) {
714711
return false;
715712
}
716713
} else {

0 commit comments

Comments
 (0)