2017-02-24 20:58:21 +02:00
/*
2021-05-27 15:01:00 +00:00
SPDX - FileCopyrightText : 2016 Marco Martin < mart @ kde . org >
SPDX - License - Identifier : LGPL - 2.0 - or - later
*/
2017-02-24 20:58:21 +02:00
# ifndef SCREENPOOL_H
# define SCREENPOOL_H
2021-02-17 12:02:52 +02:00
// local
# include "data/screendata.h"
2018-12-02 02:05:52 +02:00
// Qt
2017-02-24 20:58:21 +02:00
# include <QObject>
# include <QHash>
2017-06-11 23:55:34 +03:00
# include <QScreen>
2017-02-24 20:58:21 +02:00
# include <QString>
# include <QTimer>
2018-12-02 02:05:52 +02:00
// KDE
2017-02-24 20:58:21 +02:00
# include <KConfigGroup>
# include <KSharedConfig>
2022-05-08 13:52:55 +03:00
class PrimaryOutputWatcher ;
2018-02-03 11:34:13 +02:00
namespace Latte {
2022-05-08 13:52:55 +03:00
class ScreenPool : public QObject
2018-07-03 22:15:45 +03:00
{
2017-02-24 20:58:21 +02:00
Q_OBJECT
public :
2021-03-20 18:57:28 +02:00
static const int FIRSTSCREENID = 10 ;
2021-12-11 17:39:44 +02:00
static const int NOSCREENID = - 1 ;
2021-03-20 18:57:28 +02:00
2017-02-24 20:58:21 +02:00
ScreenPool ( KSharedConfig : : Ptr config , QObject * parent = nullptr ) ;
~ ScreenPool ( ) override ;
2022-05-08 13:52:55 +03:00
void load ( ) ;
2021-02-17 12:24:36 +02:00
bool hasScreenId ( int screenId ) const ;
bool isScreenActive ( int screenId ) const ;
2018-01-08 19:21:34 +02:00
int primaryScreenId ( ) const ;
2021-12-11 17:39:44 +02:00
QList < int > secondaryScreenIds ( ) const ;
2018-01-08 19:21:34 +02:00
2021-02-17 14:20:44 +02:00
void insertScreenMapping ( const QString & connector ) ;
2017-06-26 23:24:27 +03:00
void reload ( QString path ) ;
2021-06-06 08:57:30 +03:00
void removeScreens ( const Latte : : Data : : ScreensTable & obsoleteScreens ) ;
2017-02-24 20:58:21 +02:00
int id ( const QString & connector ) const ;
QString connector ( int id ) const ;
2017-06-11 23:55:34 +03:00
QScreen * screenForId ( int id ) ;
2022-05-08 13:52:55 +03:00
QScreen * primaryScreen ( ) const ;
2017-06-11 23:55:34 +03:00
2021-04-04 12:25:20 +03:00
Latte : : Data : : ScreensTable screensTable ( ) ;
2017-02-26 02:43:41 +02:00
signals :
2022-05-08 13:52:55 +03:00
void primaryScreenChanged ( QScreen * screen ) ;
2021-12-12 14:34:28 +02:00
void screenGeometryChanged ( ) ;
2017-02-26 02:43:41 +02:00
protected :
2021-02-17 14:20:44 +02:00
int firstAvailableId ( ) const ;
private slots :
2021-02-17 15:12:27 +02:00
void updateScreenGeometry ( const QScreen * screen ) ;
2022-05-08 13:52:55 +03:00
void onPrimaryOutputNameChanged ( const QString & oldOutputName , const QString & newOutputName ) ;
2021-02-17 15:12:27 +02:00
void onScreenAdded ( const QScreen * screen ) ;
void onScreenRemoved ( const QScreen * screen ) ;
2021-02-17 14:20:44 +02:00
2017-02-24 20:58:21 +02:00
private :
void save ( ) ;
2021-02-17 15:12:27 +02:00
void updateScreenGeometry ( const int & screenId , const QRect & screenGeometry ) ;
private :
2021-02-17 12:02:52 +02:00
Latte : : Data : : ScreensTable m_screensTable ;
2017-02-24 20:58:21 +02:00
KConfigGroup m_configGroup ;
2021-02-17 12:24:36 +02:00
2017-02-24 20:58:21 +02:00
QTimer m_configSaveTimer ;
2022-05-08 13:52:55 +03:00
PrimaryOutputWatcher * m_primaryWatcher ;
2017-02-24 20:58:21 +02:00
} ;
2018-02-03 11:34:13 +02:00
}
2017-02-24 20:58:21 +02:00
# endif // SCREENPOOL_H