mobileshellstate: Make sure DBus calls are async

This commit is contained in:
Devin Lin 2023-03-26 10:18:06 -07:00
parent cadc5db962
commit e16bdea17e
2 changed files with 27 additions and 7 deletions

View file

@ -113,18 +113,36 @@ void ShellDBusClient::showVolumeOSD()
void ShellDBusClient::updateDoNotDisturb()
{
m_doNotDisturb = m_interface->doNotDisturb();
Q_EMIT doNotDisturbChanged();
auto reply = m_interface->doNotDisturb();
auto watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
QDBusPendingReply<bool> reply = *watcher;
m_doNotDisturb = reply.argumentAt<0>();
Q_EMIT doNotDisturbChanged();
});
}
void ShellDBusClient::updateIsActionDrawerOpen()
{
m_isActionDrawerOpen = m_interface->isActionDrawerOpen();
Q_EMIT isActionDrawerOpenChanged();
auto reply = m_interface->isActionDrawerOpen();
auto watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
QDBusPendingReply<bool> reply = *watcher;
m_isActionDrawerOpen = reply.argumentAt<0>();
Q_EMIT isActionDrawerOpenChanged();
});
}
void ShellDBusClient::updateIsTaskSwitcherVisible()
{
m_isTaskSwitcherVisible = m_interface->isTaskSwitcherVisible();
Q_EMIT isTaskSwitcherVisibleChanged();
auto reply = m_interface->isTaskSwitcherVisible();
auto watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
QDBusPendingReply<bool> reply = *watcher;
m_isTaskSwitcherVisible = reply.argumentAt<0>();
Q_EMIT isTaskSwitcherVisibleChanged();
});
}

View file

@ -263,6 +263,8 @@ void MobileTaskSwitcherEffect::setDBusState(bool active)
QStringLiteral("org.kde.plasmashell"),
QStringLiteral("setIsTaskSwitcherVisible"));
request.setArguments({active});
const QDBusReply<bool> response = QDBusConnection::sessionBus().call(request, QDBus::NoBlock);
// this does not block, so it won't necessarily be called before the method returns
QDBusConnection::sessionBus().send(request);
}
}