File indexing completed on 2025-01-12 05:11:22
0001 /* 0002 * Copyright 2018 Kai Uwe Broulik <kde@broulik.de> 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * http://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 * 0016 */ 0017 0018 #include <QObject> 0019 #include <QScopedPointer> 0020 0021 class SpeechIntentResultReceiver; 0022 0023 class SpeechIntent : public QObject 0024 { 0025 Q_OBJECT 0026 0027 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) 0028 Q_PROPERTY(bool supported READ isSupported CONSTANT) 0029 0030 public: 0031 explicit SpeechIntent(QObject *parent = nullptr); 0032 ~SpeechIntent() override; 0033 0034 QString title() const; 0035 void setTitle(const QString &title); 0036 0037 bool isSupported() const; 0038 0039 Q_INVOKABLE void start(); 0040 0041 signals: 0042 void titleChanged(const QString &title); 0043 0044 void speechRecognized(const QString &text); 0045 void recognitionFailed(); // TODO forward error code or error string 0046 void recognitionCanceled(); 0047 void nothingRecognized(); 0048 0049 private: 0050 #ifdef Q_OS_ANDROID 0051 QScopedPointer<SpeechIntentResultReceiver> m_receiver; 0052 #endif 0053 0054 QString m_title; 0055 0056 };