view widgets/SpeechRecognitionUI.cpp @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents a9af42a93073
children
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;
	
	_comboLanguage = new QComboBox;
	_comboLanguage->addItem(QIcon(":icons/english.png"),"English");
	_comboLanguage->addItem(QIcon(":icons/hungarian.png"),"Hungarian");

	
	_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(_comboLanguage,2,2,1,1,Qt::AlignRight);

	
	layout->addWidget(_bRect,3,1,1,1,Qt::AlignTop);
	//layout->addWidget(_bPlay,2,1,1,1,Qt::AlignTop);
	layout->addWidget(_bSend,4,1,1,1,Qt::AlignTop);
	layout->addLayout(truc,5,1,1,1,Qt::AlignTop);
	layout->addWidget(_textEdit,3,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);
}

QString SpeechRecognitionUI::getLanguage(){
	return _comboLanguage->currentText();
}