YULTek/Otarcik_CAN/Sources/Gui/GeneralStatusPage.cpp
jfmartel 087245571a Ajout du support pour les fichiers CAN database .dbc
Ajout shortcut pour RDP vers le PC dans le champs
2023-01-09 16:45:23 -05:00

81 lines
2.1 KiB
C++

#include "GeneralStatusPage.h"
#include "ui_GeneralStatusPage.h"
#include "QStringList"
CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::CGeneralStatusPage)
{
ui->setupUi(this);
}
CGeneralStatusPage::~CGeneralStatusPage()
{
delete ui;
}
int CGeneralStatusPage::SetGeneralMsgText(QStringList Txt)
{
/*if you're populating the text box programatically, is to use textEdit->setTextColor(QColor&).You can create the QColor object yourself, or use one of the predefined colours in the Qt namespace (Qt::black, Qt::red, etc). It will apply the specified colour to any text you add, until it is called again with a different one.*/
return RET_OK;
}
int CGeneralStatusPage::AddGeneralMsgBoxLineEntry(QString LineTxt)
{
//Limit the number of lines in the MsgBox to avoid overruns...
if(mGenMsgListBoxTextLines.size() >= GENERAL_MESSAGES_MAX_LOG_LINES)
{
mGenMsgListBoxTextLines.removeFirst();
mGenMsgListBoxTextLines.append(LineTxt);
ui->mGenMsgTextEdit->clear();
for(int i = 0; i < mGenMsgListBoxTextLines.size(); i++)
{
AddColoredLineToGenMsgBox(mGenMsgListBoxTextLines[i]);
}
}
else
{
mGenMsgListBoxTextLines.append(LineTxt);
AddColoredLineToGenMsgBox(LineTxt);
}
}
int CGeneralStatusPage::AddColoredLineToGenMsgBox(QString Line)
{
if(Line.isEmpty())
{
return RET_GENERAL_ERROR;
}
if(Line.at(0) == QChar('%'))
{
if(Line.at(1) == QChar('E')) //The line is describing an error... write it red
{
ui->mGenMsgTextEdit->setTextColor(Qt::red);
}
else if(Line.at(1) == QChar('W')) //The line is describing a warning... write it yellow
{
ui->mGenMsgTextEdit->setTextColor(Qt::blue);
}
else
{
qDebug("GeneralStatusPage: Logic error in general message box line encoding... you should check into that");
return RET_GENERAL_ERROR;
}
Line.remove(0,2);
}
ui->mGenMsgTextEdit->insertPlainText(Line);
ui->mGenMsgTextEdit->setTextColor(Qt::black);
return RET_OK;
}