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 KACCESSIBLEAPP_H |
20 | #define KACCESSIBLEAPP_H |
21 | |
22 | #include <QDBusAbstractAdaptor> |
23 | #include <QDebug> |
24 | #include <KAction> |
25 | #include <KMainWindow> |
26 | #include <KUniqueApplication> |
27 | |
28 | /** |
29 | * Highlevel text-to-speech interface. |
30 | */ |
31 | class Speaker : public QObject |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | static Speaker* instance(); |
36 | |
37 | bool isConnected() const; |
38 | void disconnect(); |
39 | bool reconnect(); |
40 | |
41 | bool isSpeaking() const; |
42 | void setSpeaking(bool speaking); |
43 | |
44 | void cancel(); |
45 | |
46 | enum Priority { |
47 | Important = 1, |
48 | Message = 2, |
49 | Text = 3, |
50 | Notification = 4, |
51 | Progress = 5 |
52 | }; |
53 | |
54 | bool say(const QString& text, Priority priority = Text); |
55 | |
56 | char** modules() const; |
57 | char** voices() const; |
58 | QStringList languages() const; |
59 | |
60 | int voiceType() const; |
61 | void setVoiceType(int type); |
62 | |
63 | explicit Speaker(); |
64 | ~Speaker(); |
65 | private slots: |
66 | void sayNext(); |
67 | void clearSayStack(); |
68 | private: |
69 | class Private; |
70 | Private *const d; |
71 | }; |
72 | |
73 | class KAccessibleInterface; |
74 | |
75 | /** |
76 | * The Adaptor class provides a dbus interface for the KAccessibleApp . |
77 | */ |
78 | class Adaptor : public QObject |
79 | { |
80 | Q_OBJECT |
81 | Q_CLASSINFO("D-Bus Interface" , "org.kde.kaccessibleapp.Adaptor" ) |
82 | public: |
83 | explicit Adaptor(QObject *parent = 0); |
84 | virtual ~Adaptor(); |
85 | |
86 | Q_SIGNALS: |
87 | |
88 | /** |
89 | * This signal is emitted if the position of the focus changed. This can |
90 | * be used by client-applications to implement focus tracking. |
91 | * |
92 | * The \p px and \p py arguments can be either undefined, both will be -1, or |
93 | * can define the exact focus point. Additionally provided is a rectangle |
94 | * defined with the start-point \p rx and \p rx and the dimension \p rwidth |
95 | * and \p rheight . That rectangle defines the focus area. |
96 | */ |
97 | void focusChanged(int px, int py, int rx, int ry, int rwidth, int rheight); |
98 | |
99 | //void valueChanged(const QString& name, const QString& value); |
100 | //void alert(const QString& name); |
101 | |
102 | /** |
103 | * This signal is emitted if speech was enabled/disabled using \a setSpeechEnabled . |
104 | */ |
105 | void speechEnabledChanged(bool enabled); |
106 | |
107 | /** |
108 | * |
109 | */ |
110 | void notified(int reason, const KAccessibleInterface& iface); |
111 | |
112 | public Q_SLOTS: |
113 | |
114 | //void notify(int reason, const KAccessibleInterface& iface); |
115 | |
116 | /** |
117 | * This method is called if the focus changed. |
118 | * The method emits the \a focusChanged signal above. |
119 | */ |
120 | void setFocusChanged(const KAccessibleInterface& iface); |
121 | |
122 | /** |
123 | * This method is called if a value changed. |
124 | */ |
125 | void setValueChanged(const KAccessibleInterface& iface); |
126 | |
127 | /** |
128 | * This method is called if an alert happens. |
129 | */ |
130 | void setAlert(const KAccessibleInterface& iface); |
131 | |
132 | /** |
133 | * This method can be called to use the text-to-speech interface to say something. |
134 | */ |
135 | void sayText(const QString& text, int priority = 3); |
136 | |
137 | /** |
138 | * Returns true if automatic text-to-speech is enabled or false if disabled. |
139 | */ |
140 | bool speechEnabled() const; |
141 | |
142 | /** |
143 | * Enable or disable text-to-speech. |
144 | * |
145 | * If enabled then for example the text passed as argument at the \a setFocusChanged method |
146 | * will be read. |
147 | */ |
148 | void setSpeechEnabled(bool enabled); |
149 | |
150 | int voiceType() const; |
151 | void setVoiceType(int type); |
152 | |
153 | //void cancelSpeech(); |
154 | //void speechPaused(); |
155 | //void pauseSpeech(); |
156 | //void resumeSpeech(); |
157 | |
158 | private: |
159 | class Private; |
160 | Private *const d; |
161 | }; |
162 | |
163 | class KAccessibleApp; |
164 | |
165 | class MainWindow : public KMainWindow |
166 | { |
167 | Q_OBJECT |
168 | public: |
169 | explicit MainWindow(KAccessibleApp *app); |
170 | virtual ~MainWindow(); |
171 | virtual void show(); // wishful thinking, it's not virtual. |
172 | bool queryExit(); |
173 | bool queryClose(); |
174 | private Q_SLOTS: |
175 | void notified(int reason, const KAccessibleInterface& iface); |
176 | void enableLogs(int state); |
177 | void enableReaderChanged(int state); |
178 | void voiceTypeChanged(int index); |
179 | private: |
180 | class Private; |
181 | Private *const d; |
182 | }; |
183 | |
184 | /** |
185 | * The unique application instance that will be responsible for redirecting |
186 | * stuff around. |
187 | */ |
188 | class KAccessibleApp : public KUniqueApplication |
189 | { |
190 | Q_OBJECT |
191 | Q_CLASSINFO("D-Bus Interface" , "org.kde.kaccessibleapp" ) |
192 | public: |
193 | KAccessibleApp(); |
194 | virtual ~KAccessibleApp(); |
195 | Adaptor* adaptor() const; |
196 | KAction* action(const QString &name) const; |
197 | private Q_SLOTS: |
198 | void enableScreenreader(bool enabled); |
199 | void speakClipboard(); |
200 | void speakText(); |
201 | private: |
202 | class Private; |
203 | Private *const d; |
204 | }; |
205 | |
206 | #endif |
207 | |