File indexing completed on 2024-04-21 05:27:33

0001 /*
0002 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
0003 
0004 SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include <KPackage/PackageStructure>
0009 #include <PlasmaQuick/SharedQmlEngine>
0010 #include <QGuiApplication>
0011 #include <QUrl>
0012 
0013 namespace KWayland
0014 {
0015 namespace Client
0016 {
0017 class ConnectionThread;
0018 class Registry;
0019 }
0020 }
0021 
0022 namespace PlasmaQuick
0023 {
0024 class QuickViewSharedEngine;
0025 }
0026 
0027 class Authenticator;
0028 
0029 struct org_kde_ksld;
0030 
0031 class PamAuthenticators;
0032 
0033 namespace ScreenLocker
0034 {
0035 class WallpaperIntegration;
0036 class LnFIntegration;
0037 
0038 class UnlockApp : public QGuiApplication
0039 {
0040     Q_OBJECT
0041 public:
0042     explicit UnlockApp(int &argc, char **argv);
0043     ~UnlockApp() override;
0044 
0045     void initialViewSetup();
0046 
0047     void setTesting(bool enable);
0048     void setTheme(const QString &theme);
0049     void setImmediateLock(bool immediateLock);
0050     void lockImmediately();
0051     void setGraceTime(int milliseconds);
0052     void setNoLock(bool noLock);
0053     void setKsldSocket(int socket);
0054     void setDefaultToSwitchUser(bool defaultToSwitchUser);
0055 
0056     void updateCanSuspend();
0057     void updateCanHibernate();
0058 
0059 public Q_SLOTS:
0060     void osdProgress(const QString &icon, int percent, const int maximumPercent, const QString &additionalText);
0061     void osdText(const QString &icon, const QString &additionalText);
0062 
0063 protected:
0064     bool eventFilter(QObject *obj, QEvent *event) override;
0065 
0066 private Q_SLOTS:
0067     void handleScreen(QScreen *screen);
0068     PlasmaQuick::QuickViewSharedEngine *createViewForScreen(QScreen *screen);
0069     void resetRequestIgnore();
0070     void suspendToRam();
0071     void suspendToDisk();
0072     void getFocus();
0073     void markViewsAsVisible(PlasmaQuick::QuickViewSharedEngine *view);
0074     void setLockedPropertyOnViews();
0075 
0076 private:
0077     void initialize();
0078     void shareEvent(QEvent *e, PlasmaQuick::QuickViewSharedEngine *from);
0079     PlasmaQuick::SharedQmlEngine *loadWallpaperPlugin(PlasmaQuick::QuickViewSharedEngine *view);
0080     void setWallpaperItemProperties(PlasmaQuick::SharedQmlEngine *wallpaperObject, PlasmaQuick::QuickViewSharedEngine *view);
0081     void screenGeometryChanged(QScreen *screen, const QRect &geo);
0082     QWindow *getActiveScreen();
0083 
0084     QString m_packageName;
0085     QUrl m_mainQmlPath;
0086     QList<PlasmaQuick::QuickViewSharedEngine *> m_views;
0087     QTimer *m_resetRequestIgnoreTimer;
0088     QTimer *m_delayedLockTimer;
0089     KPackage::Package m_package;
0090     bool m_testing;
0091     bool m_ignoreRequests;
0092     bool m_immediateLock;
0093     bool m_runtimeInitialized;
0094     PamAuthenticators *m_authenticators;
0095     int m_graceTime;
0096     bool m_noLock;
0097     bool m_defaultToSwitchUser;
0098 
0099     bool m_canSuspend = false;
0100     bool m_canHibernate = false;
0101     QString m_userName, m_userImage;
0102 
0103     wl_display *m_display = nullptr;
0104     org_kde_ksld *m_ksldInterface = nullptr;
0105 
0106     KPackage::Package m_wallpaperPackage;
0107     LnFIntegration *m_lnfIntegration;
0108 };
0109 } // namespace