1 | /* This file is part of the KDE project |
2 | * Copyright (C) 2010 Sebastian Sauer <sebsauer@kdab.com> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | #ifndef KACCESSIBLEBRIDGE_H |
20 | #define KACCESSIBLEBRIDGE_H |
21 | |
22 | #include <QDBusAbstractAdaptor> |
23 | #include <QAccessibleBridgePlugin> |
24 | |
25 | class Bridge; |
26 | class BridgePlugin; |
27 | |
28 | /** |
29 | * This class implements a QAccessibleBridge that will be created |
30 | * by the \a BridgePlugin factory. |
31 | */ |
32 | class Bridge : public QObject, public QAccessibleBridge |
33 | { |
34 | Q_OBJECT |
35 | public: |
36 | Bridge(BridgePlugin *plugin, const QString& key); |
37 | virtual ~Bridge(); |
38 | |
39 | /** |
40 | * This function is called by Qt to notify the bridge about a change in the accessibility |
41 | * information for object wrapped by the given interface. |
42 | * |
43 | * \param reason specifies the cause of the change. It can take values of type QAccessible::Event. |
44 | * \param child is the (1-based) index of the child element that has changed. When child is 0, |
45 | * the object itself has changed. |
46 | */ |
47 | virtual void notifyAccessibilityUpdate(int reason, QAccessibleInterface *interface, int child); |
48 | |
49 | /** |
50 | * This function is called by Qt at application startup to set the root accessible object |
51 | * of the application to object. All other accessible objects in the application can be |
52 | * reached by the client using object navigation. |
53 | */ |
54 | virtual void setRootObject(QAccessibleInterface *interface); |
55 | |
56 | private Q_SLOTS: |
57 | |
58 | /** |
59 | * \internal slot for testing. See in the \a setRootObject method the commented out code |
60 | * that connects the KAccessibleApp's focusChanged dbus signal to this method and prints |
61 | * the arguments. |
62 | * |
63 | * \code |
64 | * //for testing; |
65 | * //QDBusConnection::sessionBus().connect("org.kde.kaccessibleapp", "/Adaptor", "org.kde.kaccessibleapp.Adaptor", "focusChanged", this, SLOT(focusChanged(int,int,int,int,int,int))); |
66 | * \endcode |
67 | */ |
68 | void focusChanged(int px, int py, int rx, int ry, int rwidth, int rheight); |
69 | |
70 | private: |
71 | class Private; |
72 | Private *const d; |
73 | }; |
74 | |
75 | /** |
76 | * This class implements a QAccessibleBridgePlugin which will be loaded |
77 | * by the QAccessible framework at runtime. The plugin hooks then into |
78 | * the application, evaluates accessibility updates and calls the talks |
79 | * the KAccessibleApp's over dbus to broadcast information around. |
80 | */ |
81 | class BridgePlugin : public QAccessibleBridgePlugin |
82 | { |
83 | public: |
84 | explicit BridgePlugin(QObject *parent = 0); |
85 | virtual ~BridgePlugin(); |
86 | |
87 | /** |
88 | * Creates and returns the QAccessibleBridge object corresponding to the given key. Keys |
89 | * are case sensitive. |
90 | */ |
91 | virtual QAccessibleBridge* create(const QString &key); |
92 | |
93 | /** |
94 | * Returns the list of keys this plugins supports. These keys must be the names of the |
95 | * bridges that this plugin provides. |
96 | */ |
97 | virtual QStringList keys() const; |
98 | }; |
99 | |
100 | #endif |
101 | |