1 /***************************************************************************
2 * Copyright (c) 2013 Nikita Mikhaylov <nslqqq@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ***************************************************************************/
19 
20 #ifndef KEYBOARDMODEL_H
21 #define KEYBOARDMODEL_H
22 
23 #include <QList>
24 #include <QObject>
25 #include <QString>
26 
27 namespace SDDM {
28     class KeyboardModelPrivate;
29     class KeyboardBackend;
30 
31     class KeyboardModel : public QObject {
32         Q_OBJECT
33         Q_DISABLE_COPY(KeyboardModel)
34     public:
35         // LED control
36         Q_PROPERTY(bool numLock  READ numLockState  WRITE setNumLockState  NOTIFY numLockStateChanged)
37         Q_PROPERTY(bool capsLock READ capsLockState WRITE setCapsLockState NOTIFY capsLockStateChanged)
38 
39         // Layouts control
40         Q_PROPERTY(int currentLayout READ currentLayout WRITE setCurrentLayout NOTIFY currentLayoutChanged)
41         Q_PROPERTY(QList<QObject*> layouts READ layouts NOTIFY layoutsChanged)
42 
43         Q_PROPERTY(bool enabled READ enabled CONSTANT)
44 
45     public:
46         KeyboardModel();
47         virtual ~KeyboardModel();
48 
49     signals:
50         void numLockStateChanged();
51         void capsLockStateChanged();
52 
53         void currentLayoutChanged();
54         void layoutsChanged();
55 
56     public slots:
57         bool numLockState() const;
58         void setNumLockState(bool state);
59 
60         bool capsLockState() const;
61         void setCapsLockState(bool state);
62 
63         QList<QObject*> layouts() const;
64         int currentLayout() const;
65         void setCurrentLayout(int id);
66 
67         bool enabled() const;
68 
69     private slots:
70         void dispatchEvents();
71 
72     private:
73         KeyboardModelPrivate * d { nullptr };
74         KeyboardBackend * m_backend;
75     };
76 }
77 
78 #endif // KEYBOARDMODEL_H
79