diff --git a/components/mobileshell/qml/homescreen/HomeScreen.qml b/components/mobileshell/qml/homescreen/HomeScreen.qml index f9c70f43..9a5674d9 100644 --- a/components/mobileshell/qml/homescreen/HomeScreen.qml +++ b/components/mobileshell/qml/homescreen/HomeScreen.qml @@ -107,6 +107,19 @@ Item { //END API implementation + Connections { + target: MobileShellState.LockscreenDBusClient + + function onLockscreenActiveChanged() { + // run zoom animation after login + if (!MobileShellState.LockscreenDBusClient.lockscreenActive) { + itemContainer.opacity = 0; + itemContainer.zoomScale = 0.8; + itemContainer.zoomIn(); + } + } + } + Component.onCompleted: { // determine the margins used evaluateMargins(); diff --git a/components/mobileshellstate/CMakeLists.txt b/components/mobileshellstate/CMakeLists.txt index a4c797be..22fac592 100644 --- a/components/mobileshellstate/CMakeLists.txt +++ b/components/mobileshellstate/CMakeLists.txt @@ -8,6 +8,7 @@ set(mobileshellstateplugin_SRCS mobileshellstateplugin.cpp shelldbusobject.cpp shelldbusclient.cpp + lockscreendbusclient.cpp ) qt_generate_dbus_interface( diff --git a/components/mobileshellstate/lockscreendbusclient.cpp b/components/mobileshellstate/lockscreendbusclient.cpp new file mode 100644 index 00000000..47225ba4 --- /dev/null +++ b/components/mobileshellstate/lockscreendbusclient.cpp @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "lockscreendbusclient.h" + +#include +#include +#include +#include + +LockscreenDBusClient::LockscreenDBusClient(QObject *parent) + : QObject{parent} +{ + QDBusMessage request = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), + QStringLiteral("/ScreenSaver"), + QStringLiteral("org.freedesktop.ScreenSaver"), + QStringLiteral("GetActive")); + const QDBusReply response = QDBusConnection::sessionBus().call(request); + + m_lockscreenActive = response.isValid() ? response.value() : false; + Q_EMIT lockscreenActiveChanged(); + + QDBusConnection::sessionBus().connect(QStringLiteral("org.freedesktop.ScreenSaver"), + QStringLiteral("/ScreenSaver"), + QStringLiteral("org.freedesktop.ScreenSaver"), + QStringLiteral("ActiveChanged"), + this, + SLOT(slotLockscreenActiveChanged)); +} + +LockscreenDBusClient *LockscreenDBusClient::self() +{ + static LockscreenDBusClient *instance = new LockscreenDBusClient; + return instance; +} + +bool LockscreenDBusClient::lockscreenActive() const +{ + return m_lockscreenActive; +} + +void LockscreenDBusClient::slotLockscreenActiveChanged(bool active) +{ + if (active != m_lockscreenActive) { + m_lockscreenActive = active; + Q_EMIT lockscreenActiveChanged(); + } +} diff --git a/components/mobileshellstate/lockscreendbusclient.h b/components/mobileshellstate/lockscreendbusclient.h new file mode 100644 index 00000000..bc1ca110 --- /dev/null +++ b/components/mobileshellstate/lockscreendbusclient.h @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include + +class LockscreenDBusClient : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool lockscreenActive READ lockscreenActive NOTIFY lockscreenActiveChanged); + +public: + explicit LockscreenDBusClient(QObject *parent = nullptr); + static LockscreenDBusClient *self(); + + bool lockscreenActive() const; + +Q_SIGNALS: + void lockscreenActiveChanged(); + +public Q_SLOTS: + void slotLockscreenActiveChanged(bool active); + +private: + bool m_lockscreenActive; +}; diff --git a/components/mobileshellstate/mobileshellstateplugin.cpp b/components/mobileshellstate/mobileshellstateplugin.cpp index 6b951c6d..5044f419 100644 --- a/components/mobileshellstate/mobileshellstateplugin.cpp +++ b/components/mobileshellstate/mobileshellstateplugin.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "mobileshellstateplugin.h" +#include "lockscreendbusclient.h" #include "shelldbusclient.h" #include "shelldbusobject.h" @@ -23,4 +24,7 @@ void MobileShellStatePlugin::registerTypes(const char *uri) qmlRegisterSingletonType(uri, 1, 0, "ShellDBusObject", [](QQmlEngine *, QJSEngine *) -> QObject * { return ShellDBusObject::self(); }); + qmlRegisterSingletonType(uri, 1, 0, "LockscreenDBusClient", [](QQmlEngine *, QJSEngine *) -> QObject * { + return LockscreenDBusClient::self(); + }); }