This commit is contained in:
2019-06-11 11:29:45 +02:00
parent d2d25cdd69
commit 111c48e3fa
2 changed files with 9 additions and 57 deletions

View File

@ -1,72 +1,28 @@
#pragma once
#include "qDefs.h"
#include "qDebugStream.h"
class qDetectorMain;
#include <QWidget>
#include <QTextEdit>
#include <QEvent>
#include <QPushButton>
class QTextEdit;
class QPushButton;
/**
*@short sets up the Messages parameters
*/
class qTabMessages:public QWidget{
Q_OBJECT
public:
/**
* The constructor
* @param parent parent widget
*/
qTabMessages(QWidget* parent);
/**
* Destructor
*/
~qTabMessages();
private slots:
/**
* Stream log to textedit in GUI
*/
void customEvent(QEvent *e);
/**
* Save Log to File
*/
void SaveLog();
/**
* Clear Log to File
*/
void ClearLog();
private:
/**
* Sets up the widget
*/
void SetupWidgetWindow();
/**
* Sets up all the slots and signals
*/
void Initialization();
/** The qDetectorMain object */
qDetectorMain *myMainTab;
/** Log of executed commands */
QTextEdit *dispLog;
/** To save the log to file */
QPushButton *btnSave;
/** To clear the log to file */
QPushButton *btnClear;
};

View File

@ -1,6 +1,10 @@
#include "qTabMessages.h"
#include "qDetectorMain.h"
#include "qDefs.h"
#include <QWidget>
#include <QTextEdit>
#include <QPushButton>
#include <QEvent>
#include <QFile>
#include <QFileDialog>
#include <QGridLayout>
@ -9,21 +13,17 @@
#include <iostream>
#include <string>
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Messages ready";
}
qTabMessages::~qTabMessages() {
delete dispLog;
}
void qTabMessages::SetupWidgetWindow() {
/** Layout */
QGridLayout *gridLayout = new QGridLayout(this);
dispLog = new QTextEdit(this);
@ -47,17 +47,15 @@ void qTabMessages::SetupWidgetWindow() {
gridLayout->addItem(new QSpacerItem(15, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 2, 0);
gridLayout->addWidget(dispLog, 3, 0, 1, 5);
qDebugStream *qout = new qDebugStream(std::cout, this);
qDebugStream *qerr = new qDebugStream(std::cerr, this);
qDebugStream(std::cout, this);
qDebugStream(std::cerr, this);
}
void qTabMessages::Initialization() {
connect(btnSave, SIGNAL(clicked()), this, SLOT(SaveLog()));
connect(btnClear, SIGNAL(clicked()), this, SLOT(ClearLog()));
}
void qTabMessages::customEvent(QEvent *e) {
if (e->type() == (STREAMEVENT)) {
QString temp = ((qStreamEvent *)e)->getString();
@ -65,7 +63,6 @@ void qTabMessages::customEvent(QEvent *e) {
}
}
void qTabMessages::SaveLog() {
QString fName = QString(""); //FIXME:current directory?
fName = fName + "/LogFile.txt";
@ -88,7 +85,6 @@ void qTabMessages::SaveLog() {
}
}
void qTabMessages::ClearLog() {
dispLog->clear();
FILE_LOG(logINFO) << "Log Cleared";