1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00
latte-dock/app/screenpool.h

90 lines
2.2 KiB
C
Raw Normal View History

2017-02-24 21:58:21 +03:00
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SCREENPOOL_H
#define SCREENPOOL_H
2018-12-02 03:05:52 +03:00
// Qt
2017-02-24 21:58:21 +03:00
#include <QObject>
#include <QHash>
#include <QScreen>
2017-02-24 21:58:21 +03:00
#include <QString>
#include <QTimer>
#include <QAbstractNativeEventFilter>
2017-02-24 21:58:21 +03:00
2018-12-02 03:05:52 +03:00
// KDE
2017-02-24 21:58:21 +03:00
#include <KConfigGroup>
#include <KSharedConfig>
namespace Latte {
2018-07-03 22:15:45 +03:00
class ScreenPool : public QObject, public QAbstractNativeEventFilter
{
2017-02-24 21:58:21 +03:00
Q_OBJECT
public:
ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr);
void load();
~ScreenPool() override;
bool hasId(int id) const;
bool screenExists(int id) const;
int primaryScreenId() const;
2017-02-24 21:58:21 +03:00
QString primaryConnector() const;
void setPrimaryConnector(const QString &primary);
void insertScreenMapping(int id, const QString &connector);
void reload(QString path);
2017-02-24 21:58:21 +03:00
int id(const QString &connector) const;
QString connector(int id) const;
int firstAvailableId() const;
QString reportHtml(const QList<int> &assignedScreens) const;
2017-02-24 21:58:21 +03:00
//all ids that are known, included screens not enabled at the moment
QList <int> knownIds() const;
QScreen *screenForId(int id);
signals:
void primaryPoolChanged();
protected:
2017-03-12 23:14:30 +03:00
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
2017-02-24 21:58:21 +03:00
private:
void save();
KConfigGroup m_configGroup;
QString m_primaryConnector;
//order is important
QMap<int, QString> m_connectorForId;
QHash<QString, int> m_idForConnector;
QTimer m_configSaveTimer;
};
}
2017-02-24 21:58:21 +03:00
#endif // SCREENPOOL_H