mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreen: Activate animation after screen unlock
This commit is contained in:
parent
b9aad6286f
commit
5f93d0198e
5 changed files with 95 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ set(mobileshellstateplugin_SRCS
|
|||
mobileshellstateplugin.cpp
|
||||
shelldbusobject.cpp
|
||||
shelldbusclient.cpp
|
||||
lockscreendbusclient.cpp
|
||||
)
|
||||
|
||||
qt_generate_dbus_interface(
|
||||
|
|
|
|||
48
components/mobileshellstate/lockscreendbusclient.cpp
Normal file
48
components/mobileshellstate/lockscreendbusclient.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "lockscreendbusclient.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusReply>
|
||||
#include <QTimer>
|
||||
|
||||
LockscreenDBusClient::LockscreenDBusClient(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"),
|
||||
QStringLiteral("/ScreenSaver"),
|
||||
QStringLiteral("org.freedesktop.ScreenSaver"),
|
||||
QStringLiteral("GetActive"));
|
||||
const QDBusReply<bool> 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();
|
||||
}
|
||||
}
|
||||
29
components/mobileshellstate/lockscreendbusclient.h
Normal file
29
components/mobileshellstate/lockscreendbusclient.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
@ -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<ShellDBusObject>(uri, 1, 0, "ShellDBusObject", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return ShellDBusObject::self();
|
||||
});
|
||||
qmlRegisterSingletonType<LockscreenDBusClient>(uri, 1, 0, "LockscreenDBusClient", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return LockscreenDBusClient::self();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue