view widgets/SpeechRecognitionUI.cpp @ 263:63a485275ed6

Speech recognition is integrated
author benoitrigolleau
date Fri, 20 Jun 2008 14:06:54 +0000
parents 3f41cb822166
children 119d89cb65cb
line wrap: on
line source

#include "SpeechRecognitionUI.h"

#include <QGridLayout>
#include <QVBoxLayout>
#include <QLabel>

#include "../sv/main/MainWindow.h"
#include "../sv/main/EasaierSessionManager.h"




SpeechRecognitionUI::SpeechRecognitionUI(QWidget *parent) : QWidget(parent){

	_audioRecorder = new AudioRecording();
	
	connect(this, SIGNAL(startRect()),_audioRecorder, SLOT(rect()));
	connect(this, SIGNAL(stopRect()),_audioRecorder, SLOT(stopRect()));

	_bRect = new QPushButton;
	_bPlay = new QPushButton;
	_bSend = new QPushButton;

	
	_bRect->setMaximumSize(24,24);
	_bPlay->setMaximumSize(24,24);
	_bSend->setMaximumSize(24,24);

	_bPlay->setEnabled(false);
	_bSend->setEnabled(false);

	_bRect->setIcon(QIcon(":icons/rect.png"));
	_bPlay->setIcon(QIcon(":icons/playpause.png"));
	_bSend->setIcon(QIcon(":icons/addToLayer.png"));
	


	_textEdit = new QTextEdit();
	_textEdit->setMinimumWidth(200);


	QVBoxLayout *truc = new QVBoxLayout();
	truc->addWidget(new QLabel);
	truc->addStretch();


	QGridLayout *layout = new QGridLayout;
	this->setLayout(layout);
	layout->addWidget(new QLabel(tr("Speech Recognition")),1,1,1,2,Qt::AlignTop);
	layout->addWidget(_bRect,2,1,1,1,Qt::AlignTop);
	//layout->addWidget(_bPlay,2,1,1,1,Qt::AlignTop);
	layout->addWidget(_bSend,3,1,1,1,Qt::AlignTop);
	layout->addLayout(truc,4,1,1,1,Qt::AlignTop);
	layout->addWidget(_textEdit,2,2,3,1);


	//SLOTs end SIGNALs
	
	connect(_bRect, SIGNAL(pressed ()), this,SLOT(rect()));
	connect(_bSend, SIGNAL(pressed ()), this,SLOT(sendQuery()));

}


SpeechRecognitionUI::~SpeechRecognitionUI(){

}


void SpeechRecognitionUI::play(){

}

void SpeechRecognitionUI::rect(){
	if(_audioRecorder->isRecording()){
		emit(stopRect());
		_bRect->setIcon(QIcon(":icons/rect.png"));
		_bPlay->setEnabled(true);
		_bSend->setEnabled(true);

	}else{
		emit(startRect());
		_bRect->setIcon(QIcon(":icons/stop.png"));
		_bPlay->setEnabled(false);
		_bSend->setEnabled(false);
	}
}

void SpeechRecognitionUI::sendQuery(){
	MainWindow::instance()->getEasaierSessionManager()->speechRecognition("SpeechRecognition");
}

void SpeechRecognitionUI::setResult(const QString &result){
	_textEdit->setText(result);
}