2023-03-20 01:32:19 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
#include "shelldbusclient.h"
|
|
|
|
|
|
|
|
|
|
#include <QDBusServiceWatcher>
|
|
|
|
|
|
|
|
|
|
ShellDBusClient::ShellDBusClient(QObject *parent)
|
|
|
|
|
: QObject{parent}
|
|
|
|
|
, m_interface{new OrgKdePlasmashellInterface{QStringLiteral("org.kde.plasmashell"), QStringLiteral("/Mobile"), QDBusConnection::sessionBus(), this}}
|
|
|
|
|
, m_connected{false}
|
|
|
|
|
{
|
2025-03-19 01:21:46 +00:00
|
|
|
// Check if the service is already running
|
|
|
|
|
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.plasmashell"))) {
|
2023-03-20 01:32:19 +00:00
|
|
|
m_connected = true;
|
|
|
|
|
if (m_interface->isValid()) {
|
|
|
|
|
connectSignals();
|
|
|
|
|
}
|
2025-03-19 01:21:46 +00:00
|
|
|
}
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2025-03-19 01:21:46 +00:00
|
|
|
connect(QDBusConnection::sessionBus().interface(), &QDBusConnectionInterface::serviceOwnerChanged, this, [this](const QString &service, const QString &oldOwner, const QString &newOwner) {
|
|
|
|
|
Q_UNUSED(oldOwner);
|
|
|
|
|
if (service == QStringLiteral("org.kde.plasmashell")) {
|
|
|
|
|
if (!newOwner.isEmpty() && !m_connected) {
|
|
|
|
|
m_connected = true;
|
|
|
|
|
if (m_interface->isValid()) {
|
|
|
|
|
connectSignals();
|
|
|
|
|
}
|
|
|
|
|
} else if (newOwner.isEmpty() && m_connected) {
|
|
|
|
|
m_connected = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-20 01:32:19 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::connectSignals()
|
|
|
|
|
{
|
2024-11-25 17:30:47 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::panelStateChanged, this, &ShellDBusClient::updatePanelState);
|
2023-03-20 01:32:19 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::isActionDrawerOpenChanged, this, &ShellDBusClient::updateIsActionDrawerOpen);
|
2025-03-19 01:21:46 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::isVolumeOSDOpenChanged, this, &ShellDBusClient::updateIsVolumeOSDOpen);
|
|
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::isNotificationPopupDrawerOpenChanged, this, &ShellDBusClient::updateIsNotificationPopupDrawerOpen);
|
2023-03-20 01:32:19 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::doNotDisturbChanged, this, &ShellDBusClient::updateDoNotDisturb);
|
2023-03-25 06:29:40 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::isTaskSwitcherVisibleChanged, this, &ShellDBusClient::updateIsTaskSwitcherVisible);
|
2023-03-20 01:32:19 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::openActionDrawerRequested, this, &ShellDBusClient::openActionDrawerRequested);
|
|
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::closeActionDrawerRequested, this, &ShellDBusClient::closeActionDrawerRequested);
|
2024-03-10 03:50:55 +00:00
|
|
|
connect(m_interface,
|
2024-07-13 16:30:07 +00:00
|
|
|
&OrgKdePlasmashellInterface::appLaunchMaximizePanelAnimationTriggered,
|
2024-03-10 03:50:55 +00:00
|
|
|
this,
|
2024-07-13 16:30:07 +00:00
|
|
|
&ShellDBusClient::appLaunchMaximizePanelAnimationTriggered);
|
2023-03-20 01:32:19 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::openHomeScreenRequested, this, &ShellDBusClient::openHomeScreenRequested);
|
|
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::resetHomeScreenPositionRequested, this, &ShellDBusClient::resetHomeScreenPositionRequested);
|
2023-03-20 04:10:14 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::showVolumeOSDRequested, this, &ShellDBusClient::showVolumeOSDRequested);
|
2025-07-02 14:27:33 +00:00
|
|
|
connect(m_interface, &OrgKdePlasmashellInterface::openLockScreenKeypadRequested, this, &ShellDBusClient::openLockScreenKeypadRequested);
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2025-08-08 22:08:46 +00:00
|
|
|
// Initial state fetch
|
|
|
|
|
updatePanelState();
|
|
|
|
|
updateIsActionDrawerOpen();
|
|
|
|
|
updateIsVolumeOSDOpen();
|
|
|
|
|
updateIsNotificationPopupDrawerOpen();
|
2023-03-20 01:32:19 +00:00
|
|
|
updateDoNotDisturb();
|
2023-03-25 06:29:40 +00:00
|
|
|
updateIsTaskSwitcherVisible();
|
2023-03-20 01:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
2024-11-25 17:30:47 +00:00
|
|
|
QString ShellDBusClient::panelState() const
|
|
|
|
|
{
|
|
|
|
|
return m_panelState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::setPanelState(QString state)
|
|
|
|
|
{
|
|
|
|
|
m_interface->setPanelState(state);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 06:29:40 +00:00
|
|
|
bool ShellDBusClient::doNotDisturb() const
|
2023-03-20 01:32:19 +00:00
|
|
|
{
|
|
|
|
|
return m_doNotDisturb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::setDoNotDisturb(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_interface->setDoNotDisturb(value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 06:29:40 +00:00
|
|
|
bool ShellDBusClient::isActionDrawerOpen() const
|
2023-03-20 01:32:19 +00:00
|
|
|
{
|
|
|
|
|
return m_isActionDrawerOpen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::setIsActionDrawerOpen(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_interface->setIsActionDrawerOpen(value);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 01:21:46 +00:00
|
|
|
bool ShellDBusClient::isVolumeOSDOpen() const
|
|
|
|
|
{
|
|
|
|
|
return m_isVolumeOSDOpen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::setIsVolumeOSDOpen(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_interface->setIsVolumeOSDOpen(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ShellDBusClient::isNotificationPopupDrawerOpen() const
|
|
|
|
|
{
|
|
|
|
|
return m_isNotificationPopupDrawerOpen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::setIsNotificationPopupDrawerOpen(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_interface->setIsNotificationPopupDrawerOpen(value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 01:32:19 +00:00
|
|
|
void ShellDBusClient::openActionDrawer()
|
|
|
|
|
{
|
|
|
|
|
m_interface->openActionDrawer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::closeActionDrawer()
|
|
|
|
|
{
|
|
|
|
|
m_interface->closeActionDrawer();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 06:29:40 +00:00
|
|
|
bool ShellDBusClient::isTaskSwitcherVisible() const
|
|
|
|
|
{
|
|
|
|
|
return m_isTaskSwitcherVisible;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-13 16:30:07 +00:00
|
|
|
void ShellDBusClient::openAppLaunchAnimationWithPosition(int screen,
|
|
|
|
|
QString splashIcon,
|
|
|
|
|
QString title,
|
|
|
|
|
QString storageId,
|
|
|
|
|
qreal x,
|
|
|
|
|
qreal y,
|
|
|
|
|
qreal sourceIconSize)
|
2023-03-20 01:32:19 +00:00
|
|
|
{
|
2024-07-13 16:30:07 +00:00
|
|
|
m_interface->openAppLaunchAnimationWithPosition(screen, splashIcon, title, storageId, x, y, sourceIconSize);
|
2024-03-10 03:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-13 16:30:07 +00:00
|
|
|
void ShellDBusClient::triggerAppLaunchMaximizePanelAnimation(int screen, QString color)
|
2024-03-10 03:50:55 +00:00
|
|
|
{
|
2024-07-13 16:30:07 +00:00
|
|
|
m_interface->triggerAppLaunchMaximizePanelAnimation(screen, color);
|
2023-03-20 01:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::openHomeScreen()
|
|
|
|
|
{
|
|
|
|
|
m_interface->openHomeScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::resetHomeScreenPosition()
|
|
|
|
|
{
|
|
|
|
|
m_interface->resetHomeScreenPosition();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 04:10:14 +00:00
|
|
|
void ShellDBusClient::showVolumeOSD()
|
|
|
|
|
{
|
|
|
|
|
m_interface->showVolumeOSD();
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
void ShellDBusClient::openLockScreenKeypad()
|
|
|
|
|
{
|
|
|
|
|
m_interface->openLockScreenKeypad();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-25 17:30:47 +00:00
|
|
|
void ShellDBusClient::updatePanelState()
|
|
|
|
|
{
|
|
|
|
|
auto reply = m_interface->panelState();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<QString> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
QString panelState = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (panelState != m_panelState) {
|
|
|
|
|
m_panelState = panelState;
|
|
|
|
|
Q_EMIT panelStateChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2024-11-25 17:30:47 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 01:32:19 +00:00
|
|
|
void ShellDBusClient::updateDoNotDisturb()
|
|
|
|
|
{
|
2023-03-26 17:18:06 +00:00
|
|
|
auto reply = m_interface->doNotDisturb();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<bool> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
bool doNotDisturb = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (doNotDisturb != m_doNotDisturb) {
|
|
|
|
|
m_doNotDisturb = doNotDisturb;
|
|
|
|
|
Q_EMIT doNotDisturbChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2023-03-26 17:18:06 +00:00
|
|
|
});
|
2023-03-20 01:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::updateIsActionDrawerOpen()
|
|
|
|
|
{
|
2023-03-26 17:18:06 +00:00
|
|
|
auto reply = m_interface->isActionDrawerOpen();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<bool> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
bool isActionDrawerOpen = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (isActionDrawerOpen != m_isActionDrawerOpen) {
|
|
|
|
|
m_isActionDrawerOpen = isActionDrawerOpen;
|
|
|
|
|
Q_EMIT isActionDrawerOpenChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2023-03-26 17:18:06 +00:00
|
|
|
});
|
2023-03-20 01:32:19 +00:00
|
|
|
}
|
2023-03-25 06:29:40 +00:00
|
|
|
|
2025-03-19 01:21:46 +00:00
|
|
|
void ShellDBusClient::updateIsVolumeOSDOpen()
|
|
|
|
|
{
|
|
|
|
|
auto reply = m_interface->isVolumeOSDOpen();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<bool> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
bool isVolumeOSDOpen = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (isVolumeOSDOpen != m_isVolumeOSDOpen) {
|
|
|
|
|
m_isVolumeOSDOpen = isVolumeOSDOpen;
|
|
|
|
|
Q_EMIT isVolumeOSDOpenChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2025-03-19 01:21:46 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellDBusClient::updateIsNotificationPopupDrawerOpen()
|
|
|
|
|
{
|
|
|
|
|
auto reply = m_interface->isNotificationPopupDrawerOpen();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<bool> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
bool isNotificationPopupDrawerOpen = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (isNotificationPopupDrawerOpen != m_isNotificationPopupDrawerOpen) {
|
|
|
|
|
m_isNotificationPopupDrawerOpen = isNotificationPopupDrawerOpen;
|
|
|
|
|
Q_EMIT isNotificationPopupDrawerOpenChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2025-03-19 01:21:46 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 06:29:40 +00:00
|
|
|
void ShellDBusClient::updateIsTaskSwitcherVisible()
|
|
|
|
|
{
|
2023-03-26 17:18:06 +00:00
|
|
|
auto reply = m_interface->isTaskSwitcherVisible();
|
|
|
|
|
auto watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
|
|
|
|
|
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](auto watcher) {
|
|
|
|
|
QDBusPendingReply<bool> reply = *watcher;
|
2025-08-08 22:08:46 +00:00
|
|
|
bool isTaskSwitcherVisible = reply.argumentAt<0>();
|
|
|
|
|
|
|
|
|
|
if (isTaskSwitcherVisible != m_isTaskSwitcherVisible) {
|
|
|
|
|
m_isTaskSwitcherVisible = isTaskSwitcherVisible;
|
|
|
|
|
Q_EMIT isTaskSwitcherVisibleChanged();
|
|
|
|
|
}
|
2025-08-18 16:56:07 +00:00
|
|
|
|
|
|
|
|
watcher->deleteLater();
|
2023-03-26 17:18:06 +00:00
|
|
|
});
|
2023-03-25 06:29:40 +00:00
|
|
|
}
|