Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
add loggerevents
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-tushevg committed Dec 7, 2018
1 parent c8818a6 commit 9e03126
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
6 changes: 4 additions & 2 deletions BrainATUMtome/BrainATUMtome.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ SOURCES += \
videoproducer.cpp \
videoconverter.cpp \
videoviewer.cpp \
videowriter.cpp
videowriter.cpp \
loggerevents.cpp

HEADERS += \
mainwindow.h \
Expand All @@ -44,7 +45,8 @@ HEADERS += \
videoproducer.h \
videoconverter.h \
videoviewer.h \
videowriter.h
videowriter.h \
loggerevents.h

FORMS += \
mainwindow.ui
Expand Down
38 changes: 38 additions & 0 deletions BrainATUMtome/loggerevents.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "loggerevents.h"

LoggerEvents::LoggerEvents(QWidget *parent) : QPlainTextEdit (parent)
{

}

LoggerEvents::~LoggerEvents()
{

}

void LoggerEvents::addMessageToBoard(const QString &message, QBrush brush)
{
QTextCharFormat textFormat =this->currentCharFormat();
textFormat.setForeground(brush);
this->setCurrentCharFormat(textFormat);
this->appendPlainText(message);
this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
}

void LoggerEvents::on_notify(const QString &message)
{
QBrush brush = QBrush(Qt::black);
addMessageToBoard(message, brush);
}

void LoggerEvents::on_log(const QString &message)
{
QBrush brush = QBrush(Qt::gray);
addMessageToBoard(message, brush);
}

void LoggerEvents::on_warn(const QString &message)
{
QBrush brush = QBrush(Qt::red);
addMessageToBoard(message, brush);
}
26 changes: 26 additions & 0 deletions BrainATUMtome/loggerevents.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef LOGGEREVENTS_H
#define LOGGEREVENTS_H

#include <QObject>
#include <QWidget>
#include <QPlainTextEdit>
#include <QScrollBar>

class LoggerEvents : public QPlainTextEdit
{
Q_OBJECT

public:
explicit LoggerEvents(QWidget *parent = nullptr);
~LoggerEvents();

private:
void addMessageToBoard(const QString &message, QBrush brush);

public slots:
void on_notify(const QString &message);
void on_log(const QString &message);
void on_warn(const QString &message);
};

#endif // LOGGEREVENTS_H

0 comments on commit 9e03126

Please sign in to comment.