-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqscreenresources.h
More file actions
147 lines (137 loc) · 4.67 KB
/
qscreenresources.h
File metadata and controls
147 lines (137 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Copyright 2023 Pascal COMBES <pascom@orange.fr>
*
* This file is part of ShutdownMonitor.
*
* ShutdownMonitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ShutdownMonitor 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 General Public License
* along with ShutdownMonitor. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef QSCREENRESOURCES_H
#define QSCREENRESOURCES_H
#include <QMap>
typedef unsigned long QOutputId;
class QOutput;
/*!
* \brief Internal reprsentation for screen resources
*
* This class holds the internal representation for screen resources.
* It also allows to enable and disable the outputs.
*/
class QScreenResources
{
public:
QString name; /*!< Name of the backend */
/*!
* \brief List available backends
*
* This function lists the available backends.
* \return The list of the available backend names.
*/
static QStringList listBackends(void);
/*!
* \brief Creates screen resources
*
* This function creates a new screen resources instance,
* using the given backend, if any, or the prefered backend.
* \param backend The name of the preferred backend
* \return A new screen resource instance.
*/
static QScreenResources* create(const QString& backend);
/*!
* \brief Destructor
*
* Desallocates the internal data and releases the resources.
*/
virtual ~QScreenResources(void);
/*!
* \brief Get all outputs
*
* Get a QList of the identifiers of all outputs.
* Refresh the output cache if needed.
* \param refresh Whether the cached output list should be refreshed.
* \return The list of the identifiers of all outputs.
* \sa outputs()
*/
QList<QOutputId> outputs(bool refresh = false);
/*!
* \brief Get all outputs
*
* Get a QList of the identifiers of all outputs.
* \note Do not refresh the output cache.
* \return The list of the identifiers of all outputs.
* \sa outputs(bool)
*/
inline QList<QOutputId> outputs(void) const {return mOutputs.keys();}
/*!
* \brief Get an output by its id
*
* Get a pointer to the output internal representation corresponding to the given identifier.
* \param outputId The desired output identifier.
* \return The output internal representation corresponding to the given identifier.
*/
QOutput* output(QOutputId outputId) const;
/*!
* \brief Get an output by its name
*
* Get a pointer to the output internal representation corresponding to the given name.
* \param name The desired output name.
* \return The output internal representation corresponding to the given name.
*/
QOutput* output(const QString& name) const;
/*!
* \brief Enable the given output
*
* Enable the given output.
* \param output The output to enable.
* \param grab Whether to grab the X display.
* \return Whether this output was successfully enabled.
* \sa disableOutput()
*/
virtual bool enableOutput(QOutput* output, bool grab = false) = 0;
/*!
* \brief Disable the given output
*
* Disable the given output.
* \param output The output to disable.
* \param grab Whether to grab the X display.
* \return Whether this output was successfully disabled.
* \sa enableOutput()
*/
virtual bool disableOutput(QOutput* output, bool grab = false) = 0;
protected:
/*!
* \brief Constructor
*
* Initialize the class with the given backend name.
* \param name The backend name.
* \sa create()
*/
inline QScreenResources(const QString& name) :
name(name) {}
/*!
* \brief Refresh the cached output list
*
* Refresh the QList of output internal representations.
*/
virtual void refreshOutputs(void) = 0;
QMap<QOutputId, QOutput*> mOutputs; /*!< The list of output internal representations */
private:
/*! The list of available backends */
static QList< QPair< QString, std::function<QScreenResources*(bool)> > > availableBackends;
/*!
* \brief Initialize available backends.
*
* This function is in charge of initializing the list of available backends.
*/
static void initBackends(void);
};
#endif // QSCREENRESOURCES_H