Changeset View
Changeset View
Standalone View
Standalone View
shell/screenpool.h
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #ifndef SCREENPOOL_H | 20 | #ifndef SCREENPOOL_H | ||
21 | #define SCREENPOOL_H | 21 | #define SCREENPOOL_H | ||
22 | 22 | | |||
23 | #include <QObject> | 23 | #include <QObject> | ||
24 | #include <QHash> | 24 | #include <QHash> | ||
25 | #include <QString> | 25 | #include <QString> | ||
26 | #include <QTimer> | 26 | #include <QTimer> | ||
27 | #include <QAbstractNativeEventFilter> | ||||
27 | 28 | | |||
28 | #include <KConfigGroup> | 29 | #include <KConfigGroup> | ||
29 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
30 | 31 | | |||
31 | class ScreenPool : public QObject { | 32 | class ScreenPool : public QObject, public QAbstractNativeEventFilter | ||
33 | { | ||||
32 | Q_OBJECT | 34 | Q_OBJECT | ||
33 | 35 | | |||
34 | public: | 36 | public: | ||
35 | ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr); | 37 | ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr); | ||
36 | void load(); | 38 | void load(); | ||
37 | ~ScreenPool() override; | 39 | ~ScreenPool() override; | ||
38 | 40 | | |||
39 | QString primaryConnector() const; | 41 | QString primaryConnector() const; | ||
40 | void setPrimaryConnector(const QString &primary); | 42 | void setPrimaryConnector(const QString &primary); | ||
41 | 43 | | |||
42 | void insertScreenMapping(int id, const QString &connector); | 44 | void insertScreenMapping(int id, const QString &connector); | ||
43 | 45 | | |||
44 | int id(const QString &connector) const; | 46 | int id(const QString &connector) const; | ||
45 | 47 | | |||
46 | QString connector(int id) const; | 48 | QString connector(int id) const; | ||
47 | 49 | | |||
48 | int firstAvailableId() const; | 50 | int firstAvailableId() const; | ||
49 | 51 | | |||
50 | //all ids that are known, included screens not enabled at the moment | 52 | //all ids that are known, included screens not enabled at the moment | ||
51 | QList <int> knownIds() const; | 53 | QList <int> knownIds() const; | ||
52 | 54 | | |||
55 | protected: | ||||
56 | bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) Q_DECL_OVERRIDE; | ||||
57 | | ||||
53 | private: | 58 | private: | ||
54 | void save(); | 59 | void save(); | ||
55 | 60 | | |||
56 | KConfigGroup m_configGroup; | 61 | KConfigGroup m_configGroup; | ||
57 | QString m_primaryConnector; | 62 | QString m_primaryConnector; | ||
58 | //order is important | 63 | //order is important | ||
59 | QMap<int, QString> m_connectorForId; | 64 | QMap<int, QString> m_connectorForId; | ||
60 | QHash<QString, int> m_idForConnector; | 65 | QHash<QString, int> m_idForConnector; | ||
61 | 66 | | |||
62 | QTimer m_configSaveTimer; | 67 | QTimer m_configSaveTimer; | ||
63 | }; | 68 | }; | ||
64 | 69 | | |||
65 | #endif // SCREENPOOL_H | 70 | #endif // SCREENPOOL_H |