Files
qt-migration-legatus/qt5-before/dlbo/Lts/Application/THP/main.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

167 lines
4.3 KiB
C++

/**
* @RDE_HEADER@
* Main entry for thp viewer
* $Id$
* $HeadURL$
* $Author$
*/
#include <nglapplication/nglsingleapplication.h>
#include <QUrl>
#include <QDir>
#include <QMessageBox>
#include <QNetworkProxy>
#include <QSplashScreen>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include "thp_viewer.h"
#include <NGLLogger/INGLLogger.h>
#include <ngltranslator/ngltranslator.h>
#ifdef Q_OS_WIN
# include <windows.h>
#endif
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser(ProvideCommandLineParameterOptions::None)
{
addOption({{QStringLiteral("l"), QStringLiteral("lang")},
QStringLiteral("Language iso code to use (de_DE, en_GB, en_US)"),
QStringLiteral("<locale iso code>")
});
addOption({{QStringLiteral("t"), QStringLiteral("alwaysontop")},
QStringLiteral("Set as always on top window")
});
}
bool useAsAlwaysOnTop() const
{
return isSet(QStringLiteral("t"));
}
QString langIsoCode() const { return value(QStringLiteral("l")); }
};
int main(int argc, char **argv)
{
QNetworkProxy::setApplicationProxy(QNetworkProxy());
NGLSingleApplication app(argc, argv);
app.createLogger("THP", "log4cxx_thp_viewer.props");
app.setOrganizationName(QStringLiteral("RME"));
app.setApplicationName(QStringLiteral("thp_viewer"));
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
QDir::setSearchPaths(QLatin1String("icon"), QStringList(QLatin1String(":/style/")));
Q_INIT_RESOURCE(rme_light_style);
// Parse Options
CmdLineParser options;
if (!options.init())
return -1;
// Set Translation
QString langIsoCode = options.langIsoCode();
if (langIsoCode.isEmpty())
langIsoCode = QLocale::system().name();
NGL::setTranslationLocale(langIsoCode.toLatin1());
//check for optional alyways on top flag
bool alwaysOnTop = options.useAsAlwaysOnTop();
QString index;
const QStringList args = options.positionalArguments();
// QString searchDir = QCoreApplication::applicationDirPath();
QString searchDir(QDir::currentPath());
if (args.count() == 1)
{
QFileInfo fi(args.first());
if (fi.isDir())
searchDir = fi.absolutePath();
else
index = fi.absoluteFilePath();
}
if (index.isEmpty())
{
const auto indexFiles = { QStringLiteral("index_%1.html").arg(langIsoCode),
QStringLiteral("index.html") };
for (const QString &indexFile : indexFiles)
{
QDir d(searchDir);
index = d.absoluteFilePath(indexFile);
while (!d.exists(index))
{
if (!d.cdUp())
break;
index = d.absoluteFilePath(indexFile);
}
if (d.exists(index))
break;
}
}
QFileInfo fi(index);
QString basePath = fi.path() + QLatin1Char('/');
if (!fi.exists() || !fi.isFile())
{
fprintf(stderr, "%s <path_to_html> basePath=%s\n", argv[0], basePath.toStdString().c_str());
QMessageBox::critical(nullptr,
QObject::tr("File missing"),
QObject::tr("Could not find a valid index.html - aborting"));
return -1;
}
index = fi.absoluteFilePath();
if (app.sendMessage(index))
return 0;
int ret = 1;
{
QString splashfile = basePath;
static const auto extension = {QStringLiteral("gif"),
QStringLiteral("jpg"),
QStringLiteral("png")};
for (const auto &ext : extension)
{
const QString fn = splashfile + QStringLiteral("/wappen.") + ext;
if (!QFile::exists(fn))
continue;
splashfile = fn;
break;
}
const QPixmap splashPixmap(splashfile);
QSplashScreen splash((splashPixmap));
if (!splashPixmap.isNull())
splash.show();
#ifdef BUILD_STATIC_LIBRARIES
Q_INIT_RESOURCE(libsymbol);
Q_INIT_RESOURCE(nglresources);
#endif
NGL::ThpViewer view(QUrl::fromLocalFile(index));
if (alwaysOnTop)
{
view.setWindowFlag(Qt::WindowStaysOnTopHint, true);
view.setWindowFlag(Qt::WindowMinimizeButtonHint, false);
}
if (!view.init())
return ret;
view.center();
QObject::connect(&app, &NGLSingleApplication::messageReceived,
&view, &NGL::ThpViewer::onNewThp);
view.show();
splash.finish(&view);
ret = app.exec();
}
return ret;
}