示例#1
0
文件: main.cpp 项目: KDE/simon-tools
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    SimondConnector connector;
    QMLSimoneView view;

    QObject::connect(&view, SIGNAL(connectToServer()), &connector, SLOT(connectToServer()));
    QObject::connect(&view, SIGNAL(disconnectFromServer()), &connector, SLOT(disconnectFromServer()));
    QObject::connect(&view, SIGNAL(startRecording()), &connector, SLOT(startRecording()));
    QObject::connect(&view, SIGNAL(commitRecording()), &connector, SLOT(commitRecording()));
    QObject::connect(&view, SIGNAL(configurationChanged()), &connector, SLOT(configurationChanged()));

    QObject::connect(&connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
    QObject::connect(&connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
    QObject::connect(&connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
    QObject::connect(&connector, SIGNAL(listening()), &view, SLOT(displayListening()));
    QObject::connect(&connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
    QObject::connect(&connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
    QObject::connect(&connector, SIGNAL(recognized(RecognitionResultList)), &view, SLOT(recognized(RecognitionResultList)));

    view.show();
    connector.init();

    return app.exec();
}
示例#2
0
SimondConnector::SimondConnector(QObject *parent) :
    QObject(parent), state(Unconnected),
    socket(new QSslSocket(this)),
    timeoutTimer(new QTimer(this)),
    response(new QDataStream(socket)),
    mic(new SoundInput(SOUND_CHANNELS, SOUND_SAMPLERATE, this)),
    passThroughSound(false)
{
    connect(this, SIGNAL(connectionState(ConnectionState)), this, SLOT(setCurrentState(ConnectionState)));
    connect(socket, SIGNAL(readyRead()), this, SLOT(messageReceived()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()));
    connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(socketError()));
    connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(encrypted()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(connectionLost()));

    connect(mic, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
    connect(mic, SIGNAL(microphoneLevel(int,int,int)), this, SIGNAL(microphoneLevel(int,int,int)));
    connect(mic, SIGNAL(listening()), this, SLOT(startRecording()));
    connect(mic, SIGNAL(complete()), this, SLOT(commitRecording()));
    connect(mic, SIGNAL(readyRead()), this, SLOT(soundDataAvailable()));

    connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(timeoutReached()));
    timeoutTimer->setSingleShot(true);
    timeoutTimer->setInterval(SOCKET_TIMEOUT);
}
示例#3
0
文件: main.cpp 项目: bedahr/recomment
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath("app/native/plugins");
    QApplication app(argc, argv);

    bool voiceControlled = true;
    SimondConnector *connector;
    if (voiceControlled)
        connector = new SimondConnector;
    else
        connector = 0;

    Recomment recomment;
    QMLRecommentView view(&recomment, voiceControlled);

    if (voiceControlled) {
        QObject::connect(&view, SIGNAL(connectToServer()), connector, SLOT(connectToServer()));
        QObject::connect(&view, SIGNAL(disconnectFromServer()), connector, SLOT(disconnectFromServer()));
        QObject::connect(&view, SIGNAL(startRecording()), connector, SLOT(startRecording()));
        QObject::connect(&view, SIGNAL(commitRecording()), connector, SLOT(commitRecording()));
        QObject::connect(&view, SIGNAL(configurationChanged()), connector, SLOT(configurationChanged()));

        QObject::connect(connector, SIGNAL(connectionState(ConnectionState)), &view, SLOT(displayConnectionState(ConnectionState)));
        QObject::connect(connector, SIGNAL(status(QString)), &view, SLOT(displayStatus(QString)));
        QObject::connect(connector, SIGNAL(error(QString)), &view, SLOT(displayError(QString)));
        QObject::connect(connector, SIGNAL(listening()), &view, SLOT(displayListening()));
        QObject::connect(connector, SIGNAL(recognizing()), &view, SLOT(displayRecognizing()));
        QObject::connect(connector, SIGNAL(microphoneLevel(int,int,int)), &view, SLOT(displayMicrophoneLevel(int,int,int)));
        //QObject::connect(connector, SIGNAL(recognized(QString)), &view, SLOT(displayExecutedAction(QString)));
        QObject::connect(connector, SIGNAL(recognized(QString)), &recomment, SLOT(critique(QString)));
    }

    QObject::connect(&recomment, SIGNAL(recommend(const Offer*, QString)), &view, SLOT(displayRecommendation(const Offer*, QString)));
    QObject::connect(&recomment, SIGNAL(noMatchFor(QString)), &view, SLOT(displayNoMatch(QString)));

    view.show();
    if (voiceControlled)
        connector->init();
    if (!recomment.init()) {
        qWarning() << "Failed to initialize Recomment; Aborting";
        return -1;
    }

    int ret = app.exec();
    delete connector;
    return ret;
}