current revision
This commit is contained in:
46
ui/LoggerUI.h
Normal file
46
ui/LoggerUI.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef LOGGERUI_H
|
||||
#define LOGGERUI_H
|
||||
|
||||
#include <QApplication>
|
||||
#include "debug/InfoWidget.h"
|
||||
#include <Indoor/misc/log/Logger.h>
|
||||
|
||||
/** send all log-messages to the UI */
|
||||
class LoggerUI : public Logger {
|
||||
|
||||
private:
|
||||
|
||||
InfoWidget* iw;
|
||||
|
||||
std::vector<QString> lines;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the main-menu to show the log within */
|
||||
LoggerUI(InfoWidget* iw) : iw(iw) {
|
||||
lines.push_back("");
|
||||
}
|
||||
|
||||
void add(const std::string& str, const bool nl) override {
|
||||
lines.back() += QString(str.c_str());
|
||||
if (nl) {lines.push_back("");}
|
||||
while(lines.size() > 4) {lines.erase(lines.begin());}
|
||||
QString qs = getStr();
|
||||
QMetaObject::invokeMethod(iw, "showLog", Qt::QueuedConnection, Q_ARG(const QString&, qs));
|
||||
QApplication::processEvents();
|
||||
//mm->showActivity(getStr());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QString getStr() const {
|
||||
QString str;
|
||||
for (const QString& line : lines) {str += line + "\n";}
|
||||
str.remove(str.length()-1, 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGGERUI_H
|
||||
Reference in New Issue
Block a user