Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/accessible/qplatformaccessibility.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | #include "qplatformaccessibility.h" | - | ||||||||||||
34 | #include <private/qfactoryloader_p.h> | - | ||||||||||||
35 | #include "qaccessibleplugin.h" | - | ||||||||||||
36 | #include "qaccessibleobject.h" | - | ||||||||||||
37 | #include "qaccessiblebridge.h" | - | ||||||||||||
38 | #include <QtGui/QGuiApplication> | - | ||||||||||||
39 | - | |||||||||||||
40 | #include <QDebug> | - | ||||||||||||
41 | - | |||||||||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||||||||
43 | - | |||||||||||||
44 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
45 | - | |||||||||||||
46 | /* accessiblebridge plugin discovery stuff */ | - | ||||||||||||
47 | #ifndef QT_NO_LIBRARY | - | ||||||||||||
48 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, bridgeloader, never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||||||||
49 | (QAccessibleBridgeFactoryInterface_iid, QLatin1String("/accessiblebridge"))) | - | ||||||||||||
50 | #endif | - | ||||||||||||
51 | - | |||||||||||||
52 | Q_GLOBAL_STATIC(QVector<QAccessibleBridge *>, bridges) never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||||||||
53 | - | |||||||||||||
54 | /*! | - | ||||||||||||
55 | \class QPlatformAccessibility | - | ||||||||||||
56 | \since 5.0 | - | ||||||||||||
57 | \internal | - | ||||||||||||
58 | \preliminary | - | ||||||||||||
59 | \ingroup qpa | - | ||||||||||||
60 | \ingroup accessibility | - | ||||||||||||
61 | - | |||||||||||||
62 | \brief The QPlatformAccessibility class is the base class for | - | ||||||||||||
63 | integrating accessibility backends | - | ||||||||||||
64 | - | |||||||||||||
65 | \sa QAccessible | - | ||||||||||||
66 | */ | - | ||||||||||||
67 | QPlatformAccessibility::QPlatformAccessibility() | - | ||||||||||||
68 | : m_active(false) | - | ||||||||||||
69 | { | - | ||||||||||||
70 | } never executed: end of block | 0 | ||||||||||||
71 | - | |||||||||||||
72 | QPlatformAccessibility::~QPlatformAccessibility() | - | ||||||||||||
73 | { | - | ||||||||||||
74 | } | - | ||||||||||||
75 | - | |||||||||||||
76 | void QPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) | - | ||||||||||||
77 | { | - | ||||||||||||
78 | initialize(); | - | ||||||||||||
79 | - | |||||||||||||
80 | if (!bridges() || bridges()->isEmpty())
| 0 | ||||||||||||
81 | return; never executed: return; | 0 | ||||||||||||
82 | - | |||||||||||||
83 | for (int i = 0; i < bridges()->count(); ++i)
| 0 | ||||||||||||
84 | bridges()->at(i)->notifyAccessibilityUpdate(event); never executed: bridges()->at(i)->notifyAccessibilityUpdate(event); | 0 | ||||||||||||
85 | } never executed: end of block | 0 | ||||||||||||
86 | - | |||||||||||||
87 | void QPlatformAccessibility::setRootObject(QObject *o) | - | ||||||||||||
88 | { | - | ||||||||||||
89 | initialize(); | - | ||||||||||||
90 | if (bridges()->isEmpty())
| 0 | ||||||||||||
91 | return; never executed: return; | 0 | ||||||||||||
92 | - | |||||||||||||
93 | if (!o)
| 0 | ||||||||||||
94 | return; never executed: return; | 0 | ||||||||||||
95 | - | |||||||||||||
96 | for (int i = 0; i < bridges()->count(); ++i) {
| 0 | ||||||||||||
97 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); | - | ||||||||||||
98 | bridges()->at(i)->setRootObject(iface); | - | ||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||
100 | } never executed: end of block | 0 | ||||||||||||
101 | - | |||||||||||||
102 | void QPlatformAccessibility::initialize() | - | ||||||||||||
103 | { | - | ||||||||||||
104 | static bool isInit = false; | - | ||||||||||||
105 | if (isInit)
| 0 | ||||||||||||
106 | return; never executed: return; | 0 | ||||||||||||
107 | isInit = true; // ### not atomic | - | ||||||||||||
108 | - | |||||||||||||
109 | #ifndef QT_NO_LIBRARY | - | ||||||||||||
110 | typedef QMultiMap<int, QString> PluginKeyMap; | - | ||||||||||||
111 | typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; | - | ||||||||||||
112 | - | |||||||||||||
113 | const PluginKeyMap keyMap = bridgeloader()->keyMap(); | - | ||||||||||||
114 | QAccessibleBridgePlugin *factory = 0; | - | ||||||||||||
115 | int i = -1; | - | ||||||||||||
116 | const PluginKeyMapConstIterator cend = keyMap.constEnd(); | - | ||||||||||||
117 | for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
| 0 | ||||||||||||
118 | if (it.key() != i) {
| 0 | ||||||||||||
119 | i = it.key(); | - | ||||||||||||
120 | factory = qobject_cast<QAccessibleBridgePlugin*>(bridgeloader()->instance(i)); | - | ||||||||||||
121 | } never executed: end of block | 0 | ||||||||||||
122 | if (factory)
| 0 | ||||||||||||
123 | if (QAccessibleBridge *bridge = factory->create(it.value()))
| 0 | ||||||||||||
124 | bridges()->append(bridge); never executed: bridges()->append(bridge); | 0 | ||||||||||||
125 | } never executed: end of block | 0 | ||||||||||||
126 | #endif | - | ||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||
128 | - | |||||||||||||
129 | void QPlatformAccessibility::cleanup() | - | ||||||||||||
130 | { | - | ||||||||||||
131 | qDeleteAll(*bridges()); | - | ||||||||||||
132 | } never executed: end of block | 0 | ||||||||||||
133 | - | |||||||||||||
134 | void QPlatformAccessibility::setActive(bool active) | - | ||||||||||||
135 | { | - | ||||||||||||
136 | m_active = active; | - | ||||||||||||
137 | QAccessible::setActive(active); | - | ||||||||||||
138 | } never executed: end of block | 0 | ||||||||||||
139 | - | |||||||||||||
140 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||
141 | - | |||||||||||||
142 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |