author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qgraphicssystemfactory_p.h" |
|
43 |
#include "qgraphicssystemplugin_p.h" |
|
44 |
#include "private/qfactoryloader_p.h" |
|
45 |
#include "qmutex.h" |
|
46 |
||
47 |
#include "qapplication.h" |
|
48 |
#include "qgraphicssystem_raster_p.h" |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
49 |
#include "qgraphicssystem_runtime_p.h" |
0 | 50 |
#include "qdebug.h" |
51 |
||
52 |
QT_BEGIN_NAMESPACE |
|
53 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
54 |
#ifndef QT_NO_LIBRARY |
0 | 55 |
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, |
56 |
(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive)) |
|
57 |
#endif |
|
58 |
||
59 |
QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key) |
|
60 |
{ |
|
61 |
QGraphicsSystem *ret = 0; |
|
62 |
QString system = key.toLower(); |
|
63 |
||
64 |
#if defined (QT_GRAPHICSSYSTEM_OPENGL) |
|
65 |
if (system.isEmpty()) { |
|
66 |
system = QLatin1String("opengl"); |
|
67 |
} |
|
68 |
#elif defined (QT_GRAPHICSSYSTEM_OPENVG) |
|
69 |
if (system.isEmpty()) { |
|
70 |
system = QLatin1String("openvg"); |
|
71 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
72 |
#elif defined (QT_GRAPHICSSYSTEM_RUNTIME) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
73 |
if (system.isEmpty()) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
74 |
system = QLatin1String("runtime"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
75 |
} |
0 | 76 |
#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) |
77 |
if (system.isEmpty()) { |
|
78 |
system = QLatin1String("raster"); |
|
79 |
} |
|
80 |
#endif |
|
81 |
||
82 |
if (system == QLatin1String("raster")) |
|
83 |
return new QRasterGraphicsSystem; |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
84 |
#if defined (QT_GRAPHICSSYSTEM_RUNTIME) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
85 |
else if (system == QLatin1String("runtime")) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
86 |
return new QRuntimeGraphicsSystem; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
87 |
#endif |
0 | 88 |
else if (system.isEmpty() || system == QLatin1String("native")) |
89 |
return 0; |
|
90 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
91 |
#ifndef QT_NO_LIBRARY |
0 | 92 |
if (!ret) { |
93 |
if (QGraphicsSystemFactoryInterface *factory = qobject_cast<QGraphicsSystemFactoryInterface*>(loader()->instance(system))) |
|
94 |
ret = factory->create(system); |
|
95 |
} |
|
96 |
#endif |
|
97 |
||
98 |
if (!ret) |
|
99 |
qWarning() << "Unable to load graphicssystem" << system; |
|
100 |
||
101 |
return ret; |
|
102 |
} |
|
103 |
||
104 |
/*! |
|
105 |
Returns the list of valid keys, i.e. the keys this factory can |
|
106 |
create styles for. |
|
107 |
||
108 |
\sa create() |
|
109 |
*/ |
|
110 |
QStringList QGraphicsSystemFactory::keys() |
|
111 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
112 |
#ifndef QT_NO_LIBRARY |
0 | 113 |
QStringList list = loader()->keys(); |
114 |
#else |
|
115 |
QStringList list; |
|
116 |
#endif |
|
117 |
if (!list.contains(QLatin1String("Raster"))) |
|
118 |
list << QLatin1String("raster"); |
|
119 |
return list; |
|
120 |
} |
|
121 |
||
122 |
QT_END_NAMESPACE |
|
123 |