#include <qlabel.h>
#include <qmultilineedit.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qfile.h>
#include <qtextstream.h>
IrTest::IrTest(QWidget *parent, const char *name) : IrBase(parent, name, true) {
connect(sendTextButton, SIGNAL(clicked()), this, SLOT(sendText()));
connect(sendFileButton, SIGNAL(clicked()), this, SLOT(sendFile()));
Ir test;
if(!test.supported()){
irStatus->setText("Ir is: Not present");
this->setEnabled(false);
}
else
irStatus->setText("Ir is: Present");
}
void IrTest::sendText(){
if(textToSend->text().length() == 0){
QMessageBox::critical(this, "Message", "Please enter text" ,QString("Ok") );
return;
}
QFile f("/tmp/example.txt");
if ( f.open(IO_ReadWrite) ) { // file opened successfull
QTextStream t( &f ); // use a text stream
t << textToSend->text();
f.close();
}
Ir *file = new Ir(this, "IR");
//connect(file, SIGNAL(done ( Ir * ir )), this, SLOT(sent( Ir * ir )));
file->send("/tmp/example.txt", textToSend->text(),"text/plain");
}
void IrTest::sendFile(){
if(!QFile::exists(fileLocation->text())){
QMessageBox::critical(this, "Message", "File doesn't exist." ,QString("Ok") );
return;
}
Ir *file = new Ir(this, "IR");
//connect(file, SIGNAL(done(Ir*)), this, SLOT(sent( Ir * )));
file->send(fileLocation->text(), fileLocation->text(),"text/plain");
}
void IrTest::sent(Ir *){
QMessageBox::critical(this, "Message", "Ir sent." ,QString("Ok") );
}