1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qscreendriverfactory_qws.h"
|
---|
43 |
|
---|
44 | #include "qscreen_qws.h"
|
---|
45 | #include "qapplication.h"
|
---|
46 | #include "qscreenlinuxfb_qws.h"
|
---|
47 | #include "qscreentransformed_qws.h"
|
---|
48 | #include "qscreenvfb_qws.h"
|
---|
49 | #include "qscreenmulti_qws_p.h"
|
---|
50 | #include "qscreenqnx_qws.h"
|
---|
51 | #include <stdlib.h>
|
---|
52 | #include "private/qfactoryloader_p.h"
|
---|
53 | #include "qscreendriverplugin_qws.h"
|
---|
54 | #ifndef QT_NO_QWS_DIRECTFB
|
---|
55 | #include "qdirectfbscreen.h"
|
---|
56 | #endif
|
---|
57 | #ifndef QT_NO_QWS_VNC
|
---|
58 | #include "qscreenvnc_qws.h"
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | QT_BEGIN_NAMESPACE
|
---|
62 |
|
---|
63 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
64 | #ifndef QT_NO_LIBRARY
|
---|
65 |
|
---|
66 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
---|
67 | (QScreenDriverFactoryInterface_iid,
|
---|
68 | QLatin1String("/gfxdrivers"), Qt::CaseInsensitive))
|
---|
69 |
|
---|
70 | #endif //QT_NO_LIBRARY
|
---|
71 | #endif //QT_MAKEDLL
|
---|
72 |
|
---|
73 | /*!
|
---|
74 | \class QScreenDriverFactory
|
---|
75 | \ingroup qws
|
---|
76 |
|
---|
77 | \brief The QScreenDriverFactory class creates screen drivers in
|
---|
78 | Qt for Embedded Linux.
|
---|
79 |
|
---|
80 | Note that this class is only available in \l{Qt for Embedded Linux}.
|
---|
81 |
|
---|
82 | QScreenDriverFactory is used to detect and instantiate the
|
---|
83 | available screen drivers, allowing \l{Qt for Embedded Linux} to load the
|
---|
84 | preferred driver into the server application at runtime. The
|
---|
85 | create() function returns a QScreen object representing the screen
|
---|
86 | driver identified by a given key. The valid keys (i.e. the
|
---|
87 | supported drivers) can be retrieved using the keys() function.
|
---|
88 |
|
---|
89 |
|
---|
90 | \l{Qt for Embedded Linux} provides several built-in screen drivers. In
|
---|
91 | addition, custom screen drivers can be added using Qt's plugin
|
---|
92 | mechanism, i.e. by subclassing the QScreen class and creating a
|
---|
93 | screen driver plugin (QScreenDriverPlugin). See the
|
---|
94 | \l{Qt for Embedded Linux Display Management}{display management}
|
---|
95 | documentation for details.
|
---|
96 |
|
---|
97 | \sa QScreen, QScreenDriverPlugin
|
---|
98 | */
|
---|
99 |
|
---|
100 | /*!
|
---|
101 | Creates the screen driver specified by the given \a key, using the
|
---|
102 | display specified by the given \a displayId.
|
---|
103 |
|
---|
104 | Note that the keys are case-insensitive.
|
---|
105 |
|
---|
106 | \sa keys()
|
---|
107 | */
|
---|
108 | QScreen *QScreenDriverFactory::create(const QString& key, int displayId)
|
---|
109 | {
|
---|
110 | QString driver = key.toLower();
|
---|
111 | #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
|
---|
112 | if (driver == QLatin1String("qnx") || driver.isEmpty())
|
---|
113 | return new QQnxScreen(displayId);
|
---|
114 | #endif
|
---|
115 | #ifndef QT_NO_QWS_QVFB
|
---|
116 | if (driver == QLatin1String("qvfb") || driver.isEmpty())
|
---|
117 | return new QVFbScreen(displayId);
|
---|
118 | #endif
|
---|
119 | #ifndef QT_NO_QWS_LINUXFB
|
---|
120 | if (driver == QLatin1String("linuxfb") || driver.isEmpty())
|
---|
121 | return new QLinuxFbScreen(displayId);
|
---|
122 | #endif
|
---|
123 | #ifndef QT_NO_QWS_DIRECTFB
|
---|
124 | if (driver == QLatin1String("directfb") || driver.isEmpty())
|
---|
125 | return new QDirectFBScreen(displayId);
|
---|
126 | #endif
|
---|
127 | #ifndef QT_NO_QWS_TRANSFORMED
|
---|
128 | if (driver == QLatin1String("transformed"))
|
---|
129 | return new QTransformedScreen(displayId);
|
---|
130 | #endif
|
---|
131 | #ifndef QT_NO_QWS_VNC
|
---|
132 | if (driver == QLatin1String("vnc"))
|
---|
133 | return new QVNCScreen(displayId);
|
---|
134 | #endif
|
---|
135 | #ifndef QT_NO_QWS_MULTISCREEN
|
---|
136 | if (driver == QLatin1String("multi"))
|
---|
137 | return new QMultiScreen(displayId);
|
---|
138 | #endif
|
---|
139 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
140 | #ifndef QT_NO_LIBRARY
|
---|
141 |
|
---|
142 | if (QScreenDriverFactoryInterface *factory = qobject_cast<QScreenDriverFactoryInterface*>(loader()->instance(key)))
|
---|
143 | return factory->create(driver, displayId);
|
---|
144 |
|
---|
145 | #endif
|
---|
146 | #endif
|
---|
147 | return 0;
|
---|
148 | }
|
---|
149 |
|
---|
150 | /*!
|
---|
151 | Returns the list of valid keys, i.e. the available screen drivers.
|
---|
152 |
|
---|
153 | \sa create()
|
---|
154 | */
|
---|
155 | QStringList QScreenDriverFactory::keys()
|
---|
156 | {
|
---|
157 | QStringList list;
|
---|
158 |
|
---|
159 | #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
|
---|
160 | list << QLatin1String("QNX");
|
---|
161 | #endif
|
---|
162 | #ifndef QT_NO_QWS_QVFB
|
---|
163 | list << QLatin1String("QVFb");
|
---|
164 | #endif
|
---|
165 | #ifndef QT_NO_QWS_LINUXFB
|
---|
166 | list << QLatin1String("LinuxFb");
|
---|
167 | #endif
|
---|
168 | #ifndef QT_NO_QWS_TRANSFORMED
|
---|
169 | list << QLatin1String("Transformed");
|
---|
170 | #endif
|
---|
171 | #ifndef QT_NO_QWS_VNC
|
---|
172 | list << QLatin1String("VNC");
|
---|
173 | #endif
|
---|
174 | #ifndef QT_NO_QWS_MULTISCREEN
|
---|
175 | list << QLatin1String("Multi");
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
179 | #ifndef QT_NO_LIBRARY
|
---|
180 | QStringList plugins = loader()->keys();
|
---|
181 | for (int i = 0; i < plugins.size(); ++i) {
|
---|
182 | # ifdef QT_NO_QWS_QVFB
|
---|
183 | // give QVFb top priority for autodetection
|
---|
184 | if (plugins.at(i) == QLatin1String("QVFb"))
|
---|
185 | list.prepend(plugins.at(i));
|
---|
186 | else
|
---|
187 | # endif
|
---|
188 | if (!list.contains(plugins.at(i)))
|
---|
189 | list += plugins.at(i);
|
---|
190 | }
|
---|
191 | #endif //QT_NO_LIBRARY
|
---|
192 | #endif //QT_MAKEDLL
|
---|
193 | return list;
|
---|
194 | }
|
---|
195 |
|
---|
196 | QT_END_NAMESPACE
|
---|