GUI Error level WARN class

This commit is contained in:
Krad
2021-12-20 13:23:28 +08:00
parent b6c272181e
commit f9b6edce17
2 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
//
// Created by Krad on 2021/12/17.
//
#include <src/event/EventCenter.h>
#include "GUIErrorLW.h"
#include <QChar>
void GUIErrorLW::parse(const QString &errorMsg) {
char s[4];
s[0] = errorMsg.data()[0].toLatin1();
s[1] = errorMsg.data()[1].toLatin1();
s[2] = errorMsg.data()[2].toLatin1();
s[3] = errorMsg.data()[3].toLatin1();
int * v = (int*)s;
value = *v;
}
void GUIErrorLW::handle() {
EventCenter::Default()->triggerEvent(WarnStateFlagChange, nullptr,(QObject*)&value);
}

View File

@@ -0,0 +1,42 @@
//
// Created by Krad on 2021/12/17.
//
#ifndef GUI_GUIERRORLW_H
#define GUI_GUIERRORLW_H
#include "GUIErrorBase.h"
#include <QVariant>
class GUIErrorLW :public GUIErrorBase {
public:
GUIErrorLW() =default;
static const QStringList& getWARNMessages(){
static QStringList message;
if (message.isEmpty())
{
for (int i = 0; i < 32; ++i) {
message<<QString("message %1!").arg(i);
}
}
return message;
}
/**
* parse error object from error msg
* @param errorMsg
*/
void parse(const QString& errorMsg) override ;
/**
* handle error, should be implement in sub class
*/
void handle() override;
private:
QVariant value;
};
#endif //GUI_GUIERRORLW_H