File indexing completed on 2025-04-27 14:21:40
0001 /* 0002 * Copyright 2016 Marco Martin <mart@kde.org> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Library General Public License as 0006 * published by the Free Software Foundation; either version 2, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details 0013 * 0014 * You should have received a copy of the GNU Library General Public 0015 * License along with this program; if not, write to the 0016 * Free Software Foundation, Inc., 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef SCREENPOOL_H 0021 #define SCREENPOOL_H 0022 0023 // Qt 0024 #include <QObject> 0025 #include <QHash> 0026 #include <QScreen> 0027 #include <QString> 0028 #include <QTimer> 0029 #include <QAbstractNativeEventFilter> 0030 0031 // KDE 0032 #include <KConfigGroup> 0033 #include <KSharedConfig> 0034 0035 namespace Latte { 0036 0037 class ScreenPool : public QObject, public QAbstractNativeEventFilter 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr); 0043 void load(); 0044 ~ScreenPool() override; 0045 0046 bool hasId(int id) const; 0047 bool screenExists(int id) const; 0048 int primaryScreenId() const; 0049 0050 QString primaryConnector() const; 0051 void setPrimaryConnector(const QString &primary); 0052 0053 void insertScreenMapping(int id, const QString &connector); 0054 void reload(QString path); 0055 0056 int id(const QString &connector) const; 0057 0058 QString connector(int id) const; 0059 0060 int firstAvailableId() const; 0061 0062 QString reportHtml(const QList<int> &assignedScreens) const; 0063 0064 //all ids that are known, included screens not enabled at the moment 0065 QList <int> knownIds() const; 0066 0067 QScreen *screenForId(int id); 0068 0069 signals: 0070 void primaryPoolChanged(); 0071 0072 protected: 0073 bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; 0074 0075 private: 0076 void save(); 0077 0078 KConfigGroup m_configGroup; 0079 QString m_primaryConnector; 0080 //order is important 0081 QMap<int, QString> m_connectorForId; 0082 QHash<QString, int> m_idForConnector; 0083 0084 QTimer m_configSaveTimer; 0085 }; 0086 0087 } 0088 0089 #endif // SCREENPOOL_H