Adds q2 repos to migrate

This commit is contained in:
torsten committed 2026-07-14 12:07:36 +02:00
1 parent ad1f62c4ee
commit 17f1c61c9e
991 files changed
+178451

No files matched your search

+134
View File
@@ -0,0 +1,134 @@
#
# $Id$
# $HeadURL$
# $Author$
#
#
# nglapplication
#
SET(nglapplication_SRCS
nglapplication.cpp
nglapplication.h
nglloggerhandler.cpp
nglloggerhandler.h
ngl_qt_msg_handler.inc
ngl_signal_handler.inc
)
NGL_ADD_LIBRARY(WS AAR SV HLA nglapplication SHARED ${nglapplication_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(nglapplication
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(nglapplication
PRIVATE
NGLLogger
nglsettings
PUBLIC
Qt5::Core
Qt5::Widgets
)
NGL_INSTALL_TARGET(nglapplication)
#
# nglsingleapplication
#
SET(nglsingleapplication_SRCS
nglsingleapplication.cpp
nglsingleapplication.h
nglloggerhandler.cpp
nglloggerhandler.h
ngl_qt_msg_handler.inc
ngl_signal_handler.inc
)
NGL_ADD_LIBRARY(WS nglsingleapplication SHARED ${nglsingleapplication_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(nglsingleapplication
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(nglsingleapplication
PRIVATE
NGLLogger
nglsettings
PUBLIC
qtsingleapplication
)
NGL_INSTALL_TARGET(nglsingleapplication)
#
# nglcoreapplication
#
SET(nglcoreapplication_SRCS
nglcoreapplication.cpp
nglcoreapplication.h
nglloggerhandler.cpp
nglloggerhandler.h
ngl_qt_msg_handler.inc
ngl_signal_handler.inc
)
NGL_ADD_LIBRARY(ALL nglcoreapplication SHARED ${nglcoreapplication_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(nglcoreapplication
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(nglcoreapplication
PRIVATE
NGLLogger
nglsettings
PUBLIC
Qt5::Core
)
NGL_INSTALL_TARGET(nglcoreapplication)
#
# nglsinglecoreapplication
#
SET(nglsinglecoreapplication_SRCS
nglsinglecoreapplication.cpp
nglsinglecoreapplication.h
nglloggerhandler.cpp
nglloggerhandler.h
ngl_qt_msg_handler.inc
ngl_signal_handler.inc
)
NGL_ADD_LIBRARY(AAR SV nglsinglecoreapplication SHARED ${nglsinglecoreapplication_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(nglsinglecoreapplication
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(nglsinglecoreapplication
PRIVATE
NGLLogger
nglsettings
PUBLIC
qtsinglecoreapplication
)
NGL_INSTALL_TARGET(nglsinglecoreapplication)
#
# nglguiapplication
#
SET(nglguiapplication_SRCS
nglguiapplication.cpp
nglguiapplication.h
nglloggerhandler.cpp
nglloggerhandler.h
ngl_qt_msg_handler.inc
ngl_signal_handler.inc
)
NGL_ADD_LIBRARY(ALL nglguiapplication SHARED ${nglguiapplication_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(nglguiapplication
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(nglguiapplication
PRIVATE
NGLLogger
nglsettings
PUBLIC
Qt5::Gui
)
NGL_INSTALL_TARGET(nglguiapplication)
+64
View File
@@ -0,0 +1,64 @@
/**
* @RDE_HEADER@
* callback to catch qt log messages
* $Id$
* $HeadURL$
* $Author$
*/
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QtCore/qglobal.h>
static void qtMsgHandler(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
// pulse audio connect errors are important but can be very annoying - so only print it ONE time only and also as an error
static bool pulseAudioMessageSent = false;
static QString pulseAudioMessage = QStringLiteral("PulseAudioService: pa_context_connect() failed");
if (msg.startsWith(pulseAudioMessage))
{
if (pulseAudioMessageSent)
{
return;
}
type = QtCriticalMsg;
pulseAudioMessageSent = true;
}
try
{
NGL::INGLLogger &l = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger( "NGL.Qt" );
switch (type) {
case QtDebugMsg:
DEBUG_LOG(l) << msg ;
break;
case QtInfoMsg:
INFO_LOG(l) << msg ;
break;
case QtWarningMsg:
WARNING_LOG(l) << msg ;
break;
case QtCriticalMsg:
ERROR_LOG(l) << msg ;
break;
case QtFatalMsg:
FATAL_LOG(l) << msg ;
break;
}
} catch (...) {
switch (type)
{
case QtDebugMsg:
case QtInfoMsg:
fputs(qPrintable(msg), stdout);
break;
case QtWarningMsg:
case QtCriticalMsg:
case QtFatalMsg:
fputs(qPrintable(msg), stderr);
break;
}
}
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @RDE_HEADER@
* small stub to catch SIGTERM for proper shutdown
* $Id$
* $HeadURL$
* $Author$
*/
#include <signal.h>
#include <QtCore/QCoreApplication>
#ifdef Q_OS_WIN
#include <QtCore/QAbstractNativeEventFilter>
#include <windows.h>
class MyEventFilter final : public QAbstractNativeEventFilter
{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override
{
Q_UNUSED(eventType);
Q_UNUSED(result);
const MSG *msg = reinterpret_cast<const MSG*>(message);
if (msg->message == WM_CLOSE && msg->hwnd == nullptr)
QCoreApplication::quit();
return false;
}
};
#endif
#ifndef SIGTERM
# define SIGTERM 15
#endif
static void signalHandler(int signal_number)
{
if(signal_number != SIGTERM)
return;
QCoreApplication::quit();
}
+31
View File
@@ -0,0 +1,31 @@
#include "nglapplication.h"
#include "ngl_signal_handler.inc"
NGLApplication::NGLApplication(int &argc, char **argv)
: QApplication(argc, argv)
{
signal(SIGTERM, &signalHandler);
#ifdef Q_OS_WIN
installNativeEventFilter(new MyEventFilter);
#endif
}
bool NGLApplication::notify(QObject *o, QEvent *e)
{
bool bRet = false;
try
{
bRet = QApplication::notify(o, e);
}
catch (const std::exception &e)
{
fprintf(stderr, "exception %s\n", e.what());
}
return bRet;
}
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <QApplication>
#include "nglloggerhandler.h"
#ifndef NGLAPPLICATION_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define NGLAPPLICATION_EXPORT
# else
# ifdef MAKE_NGLAPPLICATION_LIB
# define NGLAPPLICATION_EXPORT Q_DECL_EXPORT
# else
# define NGLAPPLICATION_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
}
class NGLAPPLICATION_EXPORT NGLApplication : public QApplication, public NGL::LoggerHandler
{
Q_OBJECT
public:
NGLApplication(int &argc, char **argv);
protected:
bool notify(QObject *o, QEvent *e) override;
};
#define nglApp static_cast<NGLApplication*>(NGLApplication::instance())
+17
View File
@@ -0,0 +1,17 @@
#include "nglcoreapplication.h"
#include "ngl_signal_handler.inc"
NGLCoreApplication::NGLCoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
signal(SIGTERM, &signalHandler);
#ifdef Q_OS_WIN
installNativeEventFilter(new MyEventFilter);
#endif
}
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include <QtCore/QCoreApplication>
#include "nglloggerhandler.h"
#ifndef NGLCOREAPPLICATION_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define NGLCOREAPPLICATION_EXPORT
# else
# ifdef MAKE_NGLCOREAPPLICATION_LIB
# define NGLCOREAPPLICATION_EXPORT Q_DECL_EXPORT
# else
# define NGLCOREAPPLICATION_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
}
class NGLCOREAPPLICATION_EXPORT NGLCoreApplication : public QCoreApplication, public NGL::LoggerHandler
{
Q_OBJECT
public:
NGLCoreApplication(int &argc, char **argv);
};
+17
View File
@@ -0,0 +1,17 @@
#include "nglguiapplication.h"
#include "ngl_signal_handler.inc"
NGLGuiApplication::NGLGuiApplication(int &argc, char **argv)
: QGuiApplication(argc, argv)
{
signal(SIGTERM, &signalHandler);
#ifdef Q_OS_WIN
installNativeEventFilter(new MyEventFilter);
#endif
}
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <QtGui/QGuiApplication>
#include "nglloggerhandler.h"
#ifndef NGLGUIAPPLICATION_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define NGLGUIAPPLICATION_EXPORT
# else
# ifdef MAKE_NGLGUIAPPLICATION_LIB
# define NGLGUIAPPLICATION_EXPORT Q_DECL_EXPORT
# else
# define NGLGUIAPPLICATION_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
}
class NGLGUIAPPLICATION_EXPORT NGLGuiApplication : public QGuiApplication, public NGL::LoggerHandler
{
Q_OBJECT
public:
NGLGuiApplication(int &argc, char **argv);
};
#define nglGuiApp static_cast<NGLGuiApplication*>(NGLGuiApplication::instance())
+91
View File
@@ -0,0 +1,91 @@
#include "nglloggerhandler.h"
#include "ngl_qt_msg_handler.inc"
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <nglsettings/nglsettings_settings.h>
#include <nglcoreapplication.h>
namespace NGL
{
static QByteArray username()
{
#ifdef Q_OS_WIN
return qgetenv("USERNAME");
#else
return qgetenv("USER");
#endif
}
static void setEnvVars()
{
const QString logPath = NGL::Settings::logPath();
qputenv("LOG4QT_LOGDIR", logPath.toLocal8Bit());
qputenv("LOG4QT_USER", username());
}
void LoggerHandler::createLogger(const QByteArray &baseName, const char *configFileName, bool quiet)
{
setEnvVars();
m_baseLoggerName = baseName;
const QString bnStr(QString::fromLatin1(baseName.toLower()));
const QString logPath = NGL::Settings::logPath();
m_loggerFilenamePostfix = logPath + QLatin1Char('/') + QString::fromLocal8Bit(username()) + QLatin1Char('_') + bnStr;
m_loggerFilenamePrefix = QLatin1String(".log");
const QString logOutputName = m_loggerFilenamePostfix + m_loggerFilenamePrefix;
NGL::NGLLoggerBootstrap::createNGLRootLogger(QString::fromLatin1(configFileName), false, logOutputName, quiet);
qInstallMessageHandler(&qtMsgHandler);
}
void LoggerHandler::createLogger(const QByteArray &baseName, int exerciseId, int additionalId, bool quiet)
{
setEnvVars();
const QString bnStr(QString::fromLatin1(baseName.toLower()));
const QString configFileName = QLatin1String("log4cxx_") + bnStr + QLatin1String(".props");
const QString logPath = NGL::Settings::logPath();
m_loggerFilenamePostfix = logPath + QLatin1Char('/') + QString::fromLocal8Bit(username()) + QLatin1Char('_') + bnStr;
if (exerciseId > 0)
m_loggerFilenamePostfix += QLatin1Char('_') + QString::number(exerciseId);
if (additionalId > 0)
m_loggerFilenamePostfix += QLatin1Char('_') + QString::number(additionalId);
m_loggerFilenamePrefix = QLatin1String(".log");
m_baseLoggerName = baseName + QByteArray(".main");
const QString logOutputName = m_loggerFilenamePostfix + m_loggerFilenamePrefix;
NGL::NGLLoggerBootstrap::createNGLRootLogger(configFileName, false, logOutputName, quiet);
qInstallMessageHandler(&qtMsgHandler);
}
NGL::INGLLogger &LoggerHandler::baseLogger() const
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(m_baseLoggerName.data());
}
NGL::INGLLogger &LoggerHandler::logger(const char *loggerName) const
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
}
LoggerHandler *LoggerHandler::getLoggerHandler()
{
return dynamic_cast<LoggerHandler*>(QCoreApplication::instance());
}
}
+67
View File
@@ -0,0 +1,67 @@
#pragma once
#include <QByteArray>
#include <QString>
#ifndef LOGGERHANDLER_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define LOGGERHANDLER_EXPORT
# else
# if defined(MAKE_NGLCOREAPPLICATION_LIB) || defined(MAKE_NGLGUIAPPLICATION_LIB) || defined(MAKE_NGLAPPLICATION_LIB) || defined(MAKE_NGLSINGLECOREAPPLICATION_LIB) || defined(MAKE_NGLSINGLEAPPLICATION_LIB)
# define LOGGERHANDLER_EXPORT Q_DECL_EXPORT
# else
# define LOGGERHANDLER_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
class LOGGERHANDLER_EXPORT LoggerHandler
{
public:
LoggerHandler() = default;
~LoggerHandler() = default;
void createLogger(const QByteArray &baseName,
const char *configFileName,
bool quiet = false);
void createLogger(const QByteArray &baseName,
int exerciseId = 0,
int additionalId = 0,
bool quiet = false);
NGL::INGLLogger &baseLogger() const;
NGL::INGLLogger &logger(const char *loggerName) const;
QString loggerNamePostfix() const { return m_loggerFilenamePostfix; }
QString loggerNamePrefix() const { return m_loggerFilenamePrefix; }
static LoggerHandler *getLoggerHandler();
private:
QByteArray m_baseLoggerName;
QString m_loggerFilenamePostfix;
QString m_loggerFilenamePrefix;
};
}
+32
View File
@@ -0,0 +1,32 @@
#include "nglsingleapplication.h"
#include "ngl_signal_handler.inc"
NGLSingleApplication::NGLSingleApplication(int &argc, char **argv)
: QtSingleApplication(argc, argv)
{
signal(SIGTERM, &signalHandler);
#ifdef Q_OS_WIN
installNativeEventFilter(new MyEventFilter);
#endif
}
bool NGLSingleApplication::notify(QObject *o, QEvent *e)
{
bool bRet = false;
try
{
bRet = QtSingleApplication::notify(o, e);
}
catch (const std::exception &e)
{
fprintf(stderr, "exception %s\n", e.what());
}
return bRet;
}
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <QtSingleApplication/QtSingleApplication>
#include "nglloggerhandler.h"
#ifndef NGLSINGLEAPPLICATION_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define NGLSINGLEAPPLICATION_EXPORT
# else
# ifdef MAKE_NGLSINGLEAPPLICATION_LIB
# define NGLSINGLEAPPLICATION_EXPORT Q_DECL_EXPORT
# else
# define NGLSINGLEAPPLICATION_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
}
class NGLSINGLEAPPLICATION_EXPORT NGLSingleApplication : public QtSingleApplication, public NGL::LoggerHandler
{
Q_OBJECT
public:
NGLSingleApplication(int &argc, char **argv);
protected:
bool notify(QObject *o, QEvent *e) override;
};
#define nglApp static_cast<NGLSingleApplication*>(NGLSingleApplication::instance())
+17
View File
@@ -0,0 +1,17 @@
#include "nglsinglecoreapplication.h"
#include "ngl_signal_handler.inc"
NGLSingleCoreApplication::NGLSingleCoreApplication(int &argc, char **argv)
: QtSingleCoreApplication(argc, argv)
{
signal(SIGTERM, &signalHandler);
#ifdef Q_OS_WIN
installNativeEventFilter(new MyEventFilter);
#endif
}
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include <QtSingleApplication/QtSingleCoreApplication>
#include "nglloggerhandler.h"
#ifndef NGLSINGLECOREAPPLICATION_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define NGLSINGLECOREAPPLICATION_EXPORT
# else
# ifdef MAKE_NGLSINGLECOREAPPLICATION_LIB
# define NGLSINGLECOREAPPLICATION_EXPORT Q_DECL_EXPORT
# else
# define NGLSINGLECOREAPPLICATION_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
}
class NGLSINGLECOREAPPLICATION_EXPORT NGLSingleCoreApplication : public QtSingleCoreApplication, public NGL::LoggerHandler
{
Q_OBJECT
public:
NGLSingleCoreApplication(int &argc, char **argv);
};