diff --git a/components/mobileshell/qml/homescreen/HomeScreen.qml b/components/mobileshell/qml/homescreen/HomeScreen.qml index d94b1943..e1af391f 100644 --- a/components/mobileshell/qml/homescreen/HomeScreen.qml +++ b/components/mobileshell/qml/homescreen/HomeScreen.qml @@ -118,13 +118,15 @@ Item { Connections { target: MobileShellState.LockscreenDBusClient - function onLockscreenActiveChanged() { + function onLockscreenLocked() { + itemContainer.zoomOut(); + } + + function onLockscreenUnlocked() { // run zoom animation after login - if (!MobileShellState.LockscreenDBusClient.lockscreenActive) { - itemContainer.opacity = 0; - itemContainer.zoomScale = 0.8; - itemContainer.zoomIn(); - } + itemContainer.opacity = 0; + itemContainer.zoomScale = 0.8; + itemContainer.zoomIn(); } } diff --git a/components/mobileshellstate/lockscreendbusclient.cpp b/components/mobileshellstate/lockscreendbusclient.cpp index 47225ba4..7c4d8f3f 100644 --- a/components/mobileshellstate/lockscreendbusclient.cpp +++ b/components/mobileshellstate/lockscreendbusclient.cpp @@ -15,17 +15,17 @@ LockscreenDBusClient::LockscreenDBusClient(QObject *parent) 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().callWithCallback(request, this, SLOT(slotLockscreenActiveChanged(bool)), SLOT(dbusError(QDBusError))); QDBusConnection::sessionBus().connect(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("ActiveChanged"), this, - SLOT(slotLockscreenActiveChanged)); + SLOT(slotLockscreenActiveChanged(bool))); } LockscreenDBusClient *LockscreenDBusClient::self() @@ -43,6 +43,19 @@ void LockscreenDBusClient::slotLockscreenActiveChanged(bool active) { if (active != m_lockscreenActive) { m_lockscreenActive = active; + Q_EMIT lockscreenActiveChanged(); + + // we don't want to trigger a lockscreen changing signal for the first property fetch (in constructor), + // since it's just getting the current state + if (m_firstPropertySet) { + m_lockscreenActive ? Q_EMIT lockscreenLocked() : Q_EMIT lockscreenUnlocked(); + } + m_firstPropertySet = true; } } + +void LockscreenDBusClient::dbusError(QDBusError error) +{ + qDebug() << "Error fetching lockscreen state using DBus:" << error.message(); +} \ No newline at end of file diff --git a/components/mobileshellstate/lockscreendbusclient.h b/components/mobileshellstate/lockscreendbusclient.h index bc1ca110..dbfaa395 100644 --- a/components/mobileshellstate/lockscreendbusclient.h +++ b/components/mobileshellstate/lockscreendbusclient.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -20,10 +21,14 @@ public: Q_SIGNALS: void lockscreenActiveChanged(); + void lockscreenUnlocked(); + void lockscreenLocked(); public Q_SLOTS: void slotLockscreenActiveChanged(bool active); + void dbusError(QDBusError error); private: - bool m_lockscreenActive; + bool m_lockscreenActive = false; + bool m_firstPropertySet = false; };