GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
capslock.h
1 /* capslock.h - Helper to check whether Caps Lock is on
2  * Copyright (C) 2021 g10 Code GmbH
3  *
4  * Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  * SPDX-License-Identifier: GPL-2.0+
19  */
20 
21 #ifndef __PINENTRY_QT_CAPSLOCK_H__
22 #define __PINENTRY_QT_CAPSLOCK_H__
23 
24 #include <QObject>
25 #include <memory>
26 
27 enum class LockState { Unknown = -1, Off, On };
28 
29 LockState capsLockState();
30 
31 #ifdef PINENTRY_QT_WAYLAND
32 namespace KWayland {
33 namespace Client {
34 class Registry;
35 class Seat;
36 } // namespace Client
37 } // namespace KWayland
38 #endif
39 
40 class CapsLockWatcher : public QObject {
41  Q_OBJECT
42 
43  public:
44  explicit CapsLockWatcher(QObject *parent = nullptr);
45 
46  Q_SIGNALS:
47  void stateChanged(bool locked);
48 
49  private:
50  class Private;
51  std::unique_ptr<Private> d;
52 };
53 
55  public:
56  explicit Private(CapsLockWatcher *);
57 #ifdef PINENTRY_QT_WAYLAND
58  void watchWayland();
59 #endif
60 
61  private:
62 #ifdef PINENTRY_QT_WAYLAND
63  void registry_seatAnnounced(quint32, quint32);
64  void seat_hasKeyboardChanged(bool);
65  void keyboard_modifiersChanged(quint32);
66 #endif
67 
68  private:
69  CapsLockWatcher *const q;
70 
71 #ifdef PINENTRY_QT_WAYLAND
72  KWayland::Client::Registry *registry = nullptr;
73  KWayland::Client::Seat *seat = nullptr;
74 #endif
75 };
76 
77 #endif // __PINENTRY_QT_CAPSLOCK_H__
Definition: capslock.h:54
Definition: capslock.h:40