This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8818a6
commit 9e03126
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |