Add colour to logging!

creator-widgets
Phil Taylor 2023-11-26 16:23:16 +00:00
rodzic c3975ef492
commit 6e8eb23dea
5 zmienionych plików z 20 dodań i 9 usunięć

Wyświetl plik

@ -58,10 +58,21 @@ void loggingWindow::setInitialDebugState(bool debugModeEnabled)
ui->debugBtn->blockSignals(false);
}
void loggingWindow::acceptLogText(QString text)
void loggingWindow::acceptLogText(QPair<QtMsgType,QString> text)
{
QMutexLocker lock(&textMutex);
ui->logTextDisplay->appendPlainText(text);
QString colour = "white";
if (text.first == QtDebugMsg)
{
colour = "grey";
} else if (text.first == QtWarningMsg)
{
colour = "yellow";
} else if (text.first == QtCriticalMsg || text.first == QtFatalMsg)
{
colour = "red";
}
ui->logTextDisplay->appendHtml(QString("<p><span style='color:%0'>%1</span></p>").arg(colour).arg(text.second));
if(vertLogScroll->value() == vertLogScroll->maximum())
{
horizLogScroll->setValue(horizLogScroll->minimum());

Wyświetl plik

@ -27,7 +27,7 @@ class loggingWindow : public QWidget
public:
explicit loggingWindow(QString logFilename, QWidget *parent = 0);
~loggingWindow();
void acceptLogText(QString text);
void acceptLogText(QPair<QtMsgType,QString> text);
public slots:
void setInitialDebugState(bool debugModeEnabled);

Wyświetl plik

@ -803,7 +803,7 @@ void rigCommander::parseCommand()
}
case funcVFOBandMS:
value.setValue(payloadIn[0]);
value.setValue(static_cast<bool>(payloadIn[0]));
break;
case funcSatelliteMemory:
memParser=rigCaps.satParser;

Wyświetl plik

@ -14,7 +14,7 @@
QScopedPointer<QFile> m_logFile;
QMutex logMutex;
QMutex logTextMutex;
QVector<QString> logStringBuffer;
QVector<QPair<QtMsgType,QString>> logStringBuffer;
#ifdef QT_DEBUG
bool debugModeLogging = true;
#else
@ -5116,10 +5116,10 @@ void wfmain::logCheck()
}
}
void wfmain::handleLogText(QString text)
void wfmain::handleLogText(QPair<QtMsgType,QString> logMessage)
{
// This function is just a pass-through
logWindow->acceptLogText(text);
logWindow->acceptLogText(logMessage);
}
void wfmain::setDebugLogging(bool debugModeOn)
@ -5177,7 +5177,7 @@ void wfmain::messageHandler(QtMsgType type, const QMessageLogContext& context, c
text.append(": ");
text.append(msg);
logTextMutex.lock();
logStringBuffer.push_front(text);
logStringBuffer.push_front(QPair<QtMsgType,QString>(type,text));
logTextMutex.unlock();
}

Wyświetl plik

@ -95,7 +95,7 @@ public:
explicit wfmain(const QString settingsFile, const QString logFile, bool debugMode, QWidget *parent = 0);
~wfmain();
static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
void handleLogText(QString text);
void handleLogText(QPair<QtMsgType,QString> logMessage);
#ifdef USB_HOTPLUG
#if defined(Q_OS_WIN)