File indexing completed on 2021-12-21 14:17:28

0001 /********************************************************************
0002  KSld - the KDE Screenlocker Daemon
0003  This file is part of the KDE project.
0004 
0005  Copyright (C) 1999 Martin R. Jones <mjones@kde.org>
0006  Copyright (C) 2002 Luboš Luňák <l.lunak@kde.org>
0007  Copyright (C) 2003 Oswald Buddenhagen <ossi@kde.org>
0008  Copyright (C) 2008 Chani Armitage <chanika@gmail.com>
0009  Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
0010  Copyright (C) 2015 Bhushan Shah <bhush94@gmail.com>
0011 
0012 This program is free software; you can redistribute it and/or modify
0013 it under the terms of the GNU General Public License as published by
0014 the Free Software Foundation; either version 2 of the License, or
0015 (at your option) any later version.
0016 
0017 This program is distributed in the hope that it will be useful,
0018 but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0020 GNU General Public License for more details.
0021 
0022 You should have received a copy of the GNU General Public License
0023 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0024 *********************************************************************/
0025 
0026 #ifndef ABSTRACTLOCKER_H
0027 #define ABSTRACTLOCKER_H
0028 
0029 #include <QObject>
0030 #include <QRasterWindow>
0031 
0032 class GlobalAccel;
0033 
0034 namespace ScreenLocker
0035 {
0036 class AbstractLocker;
0037 
0038 class BackgroundWindow : public QRasterWindow
0039 {
0040     Q_OBJECT
0041 public:
0042     explicit BackgroundWindow(AbstractLocker *lock);
0043     ~BackgroundWindow() override;
0044 
0045     void emergencyShow();
0046 
0047 protected:
0048     void paintEvent(QPaintEvent *) override;
0049 
0050 private:
0051     AbstractLocker *m_lock;
0052     bool m_greeterFailure = false;
0053 };
0054 
0055 class AbstractLocker : public QObject
0056 {
0057     Q_OBJECT
0058 public:
0059     explicit AbstractLocker(QObject *parent);
0060     ~AbstractLocker() override;
0061 
0062     virtual void showLockWindow() = 0;
0063     virtual void hideLockWindow() = 0;
0064 
0065     virtual void addAllowedWindow(quint32 window);
0066 
0067     void setGlobalAccel(GlobalAccel *ga)
0068     {
0069         m_globalAccel = ga;
0070     }
0071 
0072     void emergencyShow();
0073 
0074 Q_SIGNALS:
0075     void userActivity();
0076     void lockWindowShown();
0077 
0078 protected:
0079     virtual void stayOnTop() = 0;
0080 
0081     GlobalAccel *globalAccel()
0082     {
0083         return m_globalAccel;
0084     }
0085     QScopedPointer<BackgroundWindow> m_background;
0086 
0087 private:
0088     GlobalAccel *m_globalAccel = nullptr;
0089 
0090     friend class BackgroundWindow;
0091 };
0092 
0093 }
0094 
0095 #endif // ABSTRACTLOCKER_H