Add LL_DIALOG log level, which can trigger the GUI to show a message box containing the log message
This commit is contained in:
parent
695ff3c8a0
commit
f1e7ea298f
6 changed files with 71 additions and 88 deletions
50
main.cpp
50
main.cpp
|
|
@ -18,7 +18,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <thread>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "OpenRGBDialog2.h"
|
||||
|
||||
|
|
@ -147,50 +146,6 @@ bool AttemptLocalConnection()
|
|||
return success;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* MessageBoxCallback *
|
||||
* *
|
||||
* Displays a message box when an error occurs. Only call once GUI is initialized *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void MessageBoxCallback(void*, PLogMessage message)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a message box |
|
||||
\*---------------------------------------------------------*/
|
||||
QMessageBox box;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the box main text to the log message text |
|
||||
\*---------------------------------------------------------*/
|
||||
box.setText(QString::fromStdString(message->buffer));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the informative text from the message information |
|
||||
\*---------------------------------------------------------*/
|
||||
QString info = "Occured in ";
|
||||
info += message->filename;
|
||||
info += " on line " + QVariant(message->line).toString();
|
||||
box.setInformativeText(info);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the message box icon according to message level |
|
||||
\*---------------------------------------------------------*/
|
||||
switch(message->level)
|
||||
{
|
||||
case LL_FATAL: box.setIcon(QMessageBox::Critical); break;
|
||||
case LL_ERROR: box.setIcon(QMessageBox::Warning); break;
|
||||
case LL_WARNING: box.setIcon(QMessageBox::Information); break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Show the message box |
|
||||
\*---------------------------------------------------------*/
|
||||
box.exec();
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main *
|
||||
|
|
@ -295,11 +250,6 @@ int main(int argc, char* argv[])
|
|||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication a(argc, argv);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Register the message box callback with the log manager |
|
||||
\*---------------------------------------------------------*/
|
||||
LogManager::get()->registerErrorCallback(&MessageBoxCallback, nullptr);
|
||||
|
||||
Ui::OpenRGBDialog2 dlg;
|
||||
|
||||
if(ret_flags & RET_FLAG_I2C_TOOLS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue