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>
2017-06-11 23:55:34 +03:00
# include <QScreen>
2017-02-24 21:58:21 +03:00
# include <QString>
# include <QTimer>
2017-02-26 03:43:41 +03:00
# 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>
2018-02-03 12:34:13 +03:00
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 ;
2019-07-14 13:59:02 +03:00
bool hasId ( int id ) const ;
bool screenExists ( int id ) const ;
2018-01-08 20:21:34 +03:00
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 ) ;
2017-06-26 23:24:27 +03:00
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 ;
2019-07-14 13:59:02 +03:00
QString reportHtml ( const QList < int > & assignedScreens ) const ;
2019-07-13 17:00:02 +03:00
2017-02-24 21:58:21 +03:00
//all ids that are known, included screens not enabled at the moment
QList < int > knownIds ( ) const ;
2017-06-11 23:55:34 +03:00
QScreen * screenForId ( int id ) ;
2017-02-26 03:43:41 +03:00
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-26 03:43:41 +03:00
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 ;
} ;
2018-02-03 12:34:13 +03:00
}
2017-02-24 21:58:21 +03:00
# endif // SCREENPOOL_H