mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Change redirectMessageOutputToMainWindow to a member function
This commit is contained in:
parent
4a78968251
commit
3e2f2e94be
@ -3,44 +3,12 @@
|
||||
// USE THIS ONLY FOR redirectMessageOutputToMainWindow
|
||||
static ScreenPlaySDK* global_sdkPtr = nullptr;
|
||||
|
||||
void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
if (global_sdkPtr == nullptr)
|
||||
return;
|
||||
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
QByteArray file = "File: " + QByteArray(context.file) + ", ";
|
||||
QByteArray line = "in line " + QByteArray::number(context.line) + ", ";
|
||||
//QByteArray function = "function " + QByteArray(context.function) + ", Message: ";
|
||||
|
||||
//localMsg = file + line + localMsg;
|
||||
global_sdkPtr->redirectMessage(localMsg);
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
//localMsg = " SDK START: " /*+ QByteArray::fromStdString(global_sdkPtr->contentType().toStdString()) + " "*/ + localMsg;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
//fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
//fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
//fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
//(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenPlaySDK::ScreenPlaySDK(QQuickItem* parent)
|
||||
: QQuickItem(parent)
|
||||
{
|
||||
// Redirect all messages from this to ScreenPlay
|
||||
global_sdkPtr = this;
|
||||
qInstallMessageHandler(redirectMessageOutputToMainWindow);
|
||||
qInstallMessageHandler(ScreenPlaySDK::redirectMessageOutputToMainWindow);
|
||||
|
||||
m_socket.setServerName("ScreenPlay");
|
||||
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
|
||||
@ -104,3 +72,35 @@ void ScreenPlaySDK::redirectMessage(QByteArray& msg)
|
||||
m_socket.waitForBytesWritten();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
if (global_sdkPtr == nullptr)
|
||||
return;
|
||||
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
QByteArray file = "File: " + QByteArray(context.file) + ", ";
|
||||
QByteArray line = "in line " + QByteArray::number(context.line) + ", ";
|
||||
//QByteArray function = "function " + QByteArray(context.function) + ", Message: ";
|
||||
|
||||
//localMsg = file + line + localMsg;
|
||||
global_sdkPtr->redirectMessage(localMsg);
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
//localMsg = " SDK START: " /*+ QByteArray::fromStdString(global_sdkPtr->contentType().toStdString()) + " "*/ + localMsg;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
//fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
//fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
//fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
//(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ public slots:
|
||||
m_socket.waitForBytesWritten();
|
||||
}
|
||||
|
||||
static void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
|
||||
signals:
|
||||
void incommingMessage(QString key, QString value);
|
||||
void incommingMessageError(QString msg);
|
||||
|
Loading…
Reference in New Issue
Block a user