Qt6 Migration: Merge latest Qt5 devel content and apply migration fixes
- Merged 292 changed files from dlbo snapshot - Fixed IDL enum collisions (PortType, PdmEventType) - Fixed Grantlee template for C++11 scoped enums - Fixed CMake VERSION_GREATER syntax - Added missing directories (THP, LtsRestClient, etc.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
310 files changed
+2823
-740
No files matched your search
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(QtPluginSystemDemo CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
|
||||
# Ausgabepfad für Plugins definieren
|
||||
set(PLUGIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/plugins")
|
||||
|
||||
add_subdirectory(plugins)
|
||||
add_subdirectory(app)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
add_executable(DlboTestPluginApp main.cpp)
|
||||
target_link_libraries(DlboTestPluginApp PRIVATE Qt5::Widgets)
|
||||
|
||||
# Kopiert die Interfaces virtuell via Include-Pfad (keine statische Link-Abhängigkeit zu .cpp Dateien)
|
||||
target_include_directories(DlboTestPluginApp PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QMainWindow>
|
||||
#include <QMap>
|
||||
#include <QPluginLoader>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../interfaces/child_interface.h"
|
||||
#include "../interfaces/parent_interface.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QMainWindow mainWindow;
|
||||
QWidget *centralWidget = new QWidget(&mainWindow);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
|
||||
mainWindow.setCentralWidget(centralWidget);
|
||||
|
||||
// Ordnerstruktur auflösen (.../build-.../plugins/)
|
||||
QDir baseDir(QCoreApplication::applicationDirPath());
|
||||
baseDir.cdUp();
|
||||
QDir pluginsDir = baseDir;
|
||||
if (!pluginsDir.cd(QStringLiteral("plugins")))
|
||||
{
|
||||
qCritical() << "Plugins-Ordner nicht gefunden!";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QMap<QString, ParentInterface *> parentPlugins;
|
||||
QList<ChildInterface *> childPlugins;
|
||||
|
||||
// Nur .so-Dateien auflisten (verhindert das Einlesen von cmake_install.cmake)
|
||||
QStringList filters;
|
||||
filters << QStringLiteral("*.so");
|
||||
#ifdef Q_OS_WIN
|
||||
filters << QStringLiteral("*.dll");
|
||||
#else
|
||||
filters << QStringLiteral("*.so");
|
||||
#endif
|
||||
|
||||
// 1. Durchlauf: Plugins laden und katalogisieren
|
||||
for (const QString &fileName : pluginsDir.entryList(filters, QDir::Files))
|
||||
{
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *pluginInstance = loader.instance();
|
||||
|
||||
if (!pluginInstance)
|
||||
{
|
||||
qDebug() << "Überspringe Datei:" << fileName << loader.errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ist es ein Parent?
|
||||
auto *parent = qobject_cast<ParentInterface *>(pluginInstance);
|
||||
if (parent)
|
||||
{
|
||||
parentPlugins[parent->pluginName()] = parent;
|
||||
mainLayout->addWidget(parent->widget());
|
||||
qDebug() << "Eltern-Plugin registriert:" << parent->pluginName();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ist es ein Child?
|
||||
auto *child = qobject_cast<ChildInterface *>(pluginInstance);
|
||||
if (child)
|
||||
{
|
||||
childPlugins.append(child);
|
||||
qDebug() << "Kind-Plugin zwischengespeichert:" << child->childName();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Durchlauf: Zuordnen, Daten übergeben und Signale verbinden
|
||||
for (ChildInterface *child : childPlugins)
|
||||
{
|
||||
QString target = child->targetParentName();
|
||||
|
||||
if (parentPlugins.contains(target))
|
||||
{
|
||||
ParentInterface *parent = parentPlugins[target];
|
||||
|
||||
// A. Widget zuweisen
|
||||
parent->addChildWidget(child->widget());
|
||||
qDebug() << "Kind" << child->childName() << "wurde" << target << "zugeordnet.";
|
||||
|
||||
// B. Initiale Parameterübergabe
|
||||
child->setParentData(QStringLiteral("Konfig-Paket via %1").arg(parent->pluginName()));
|
||||
|
||||
// C. Dynamische Signal-Slot Live-Verbindung (Absturzsicher via Pointer-Check)
|
||||
QObject *parentObj = parent->qobjectInstance();
|
||||
QObject *childObj = dynamic_cast<QObject *>(child);
|
||||
|
||||
if (parentObj && childObj)
|
||||
{
|
||||
bool connected = QObject::connect(parentObj, SIGNAL(dataChangedLive(QString)), childObj, SLOT(updateLiveData(QString)));
|
||||
if (connected)
|
||||
qDebug() << "Live-Signal verbunden für:" << child->childName();
|
||||
else
|
||||
qWarning() << "Verbindung fehlgeschlagen für:" << child->childName();
|
||||
}
|
||||
else
|
||||
qWarning() << "Fehler beim Casten des Plugins" << child->childName() << "zu QObject!";
|
||||
}
|
||||
else
|
||||
qDebug() << "Warnung: Kein Parent gefunden für" << child->childName();
|
||||
}
|
||||
|
||||
mainWindow.resize(500, 450);
|
||||
mainWindow.show();
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class ChildInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ChildInterface() = default;
|
||||
virtual QString childName() const = 0;
|
||||
virtual QString targetParentName() const = 0;
|
||||
virtual QWidget* widget() = 0;
|
||||
|
||||
// Für die einmalige Übergabe direkt nach dem Laden
|
||||
virtual void setParentData(const QString& data) = 0;
|
||||
|
||||
// Für die dynamischen Live-Updates zur Laufzeit
|
||||
virtual void updateLiveData(const QString& text) = 0;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_INTERFACE(ChildInterface, "gui:3:ChildInterface")
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QtPlugin>
|
||||
|
||||
class ParentInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ParentInterface() = default;
|
||||
virtual QString pluginName() const = 0;
|
||||
virtual QWidget *widget() = 0;
|
||||
virtual void addChildWidget(QWidget *childWidget) = 0;
|
||||
|
||||
// Ermöglicht der App den Zugriff auf das QObject für connect()
|
||||
virtual QObject *qobjectInstance() = 0;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_INTERFACE(ParentInterface, "gui:3:ParentInterface")
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
add_subdirectory(parent_alpha)
|
||||
add_subdirectory(child_beta)
|
||||
add_subdirectory(child_gamma)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(childBetaGui MODULE child_beta.cpp child_beta.h)
|
||||
target_link_libraries(childBetaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(childBetaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(childBetaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "child_beta.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ChildBeta::ChildBeta()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 1px solid green; background-color: #f0fff0; margin: 5px;"));
|
||||
|
||||
QLabel *title = new QLabel(QStringLiteral("Kind-Widget 1"));
|
||||
title->setStyleSheet(QStringLiteral("font-weight: bold; color: green;"));
|
||||
|
||||
m_staticLabel = new QLabel(QStringLiteral("Warte auf Init-Daten..."));
|
||||
m_liveLabel = new QLabel(QStringLiteral("Warte auf Live-Text..."));
|
||||
|
||||
layout->addWidget(title);
|
||||
layout->addWidget(m_staticLabel);
|
||||
layout->addWidget(m_liveLabel);
|
||||
}
|
||||
|
||||
void ChildBeta::setParentData(const QString &data)
|
||||
{
|
||||
if (m_staticLabel)
|
||||
m_staticLabel->setText(QStringLiteral("Init-Wert: %1").arg(data));
|
||||
}
|
||||
|
||||
void ChildBeta::updateLiveData(const QString &text)
|
||||
{
|
||||
if (m_liveLabel)
|
||||
{
|
||||
m_liveLabel->setText(text.isEmpty() ? QStringLiteral("Warte auf Live-Text...") : QStringLiteral("Beta Live: ") + text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/child_interface.h"
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ChildBeta
|
||||
: public QObject
|
||||
, public ChildInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ChildInterface")
|
||||
Q_INTERFACES(ChildInterface)
|
||||
|
||||
public:
|
||||
ChildBeta();
|
||||
QString childName() const override { return QStringLiteral("BetaChild"); }
|
||||
QString targetParentName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
|
||||
void setParentData(const QString &data) override;
|
||||
|
||||
public slots:
|
||||
void updateLiveData(const QString &text) override;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QLabel *m_staticLabel;
|
||||
QLabel *m_liveLabel;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["child_beta"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(childGammaGui MODULE child_gamma.cpp child_gamma.h)
|
||||
target_link_libraries(childGammaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(childGammaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(childGammaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "child_gamma.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ChildGamma::ChildGamma()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 1px solid purple; background-color: #faf0ff; margin: 5px;"));
|
||||
|
||||
QLabel *title = new QLabel(QStringLiteral("Kind-Widget 2"));
|
||||
title->setStyleSheet(QStringLiteral("font-weight: bold; color: purple;"));
|
||||
|
||||
m_staticLabel = new QLabel(QStringLiteral("Warte auf Init-Daten..."));
|
||||
m_liveLabel = new QLabel(QStringLiteral("Warte auf Live-Text..."));
|
||||
|
||||
layout->addWidget(title);
|
||||
layout->addWidget(m_staticLabel);
|
||||
layout->addWidget(m_liveLabel);
|
||||
}
|
||||
|
||||
void ChildGamma::setParentData(const QString &data)
|
||||
{
|
||||
if (m_staticLabel)
|
||||
m_staticLabel->setText(QStringLiteral("Init-Wert: %1").arg(data));
|
||||
}
|
||||
|
||||
void ChildGamma::updateLiveData(const QString &text)
|
||||
{
|
||||
if (m_liveLabel)
|
||||
{
|
||||
m_liveLabel->setText(text.isEmpty() ? QStringLiteral("Warte auf Live-Text...") : QStringLiteral("Gamma Live: ") + text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/child_interface.h"
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ChildGamma
|
||||
: public QObject
|
||||
, public ChildInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ChildInterface")
|
||||
Q_INTERFACES(ChildInterface)
|
||||
|
||||
public:
|
||||
ChildGamma();
|
||||
QString childName() const override { return QStringLiteral("GammaChild"); }
|
||||
QString targetParentName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
|
||||
void setParentData(const QString &data) override;
|
||||
|
||||
public slots:
|
||||
void updateLiveData(const QString &text) override;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QLabel *m_staticLabel;
|
||||
QLabel *m_liveLabel;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["child_gamma"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(parentAlphaGui MODULE parent_alpha.cpp parent_alpha.h)
|
||||
target_link_libraries(parentAlphaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(parentAlphaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(parentAlphaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "parent_alpha.h"
|
||||
#include <QLabel>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ParentAlpha::ParentAlpha()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
m_layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 2px solid blue; padding: 10px; margin: 5px;"));
|
||||
|
||||
QLabel *label = new QLabel(QStringLiteral("Eltern-Widget (AlphaParent)\nBsp.: Tln-Info-Fenster"));
|
||||
label->setStyleSheet(QStringLiteral("font-weight: bold; color: blue; font-size: 14px;"));
|
||||
m_layout->addWidget(label);
|
||||
|
||||
m_inputField = new QLineEdit();
|
||||
m_inputField->setPlaceholderText(QStringLiteral("Live-Eingabe für alle Kinder..."));
|
||||
m_layout->addWidget(m_inputField);
|
||||
|
||||
connect(m_inputField, &QLineEdit::textChanged, this, &ParentAlpha::dataChangedLive);
|
||||
}
|
||||
|
||||
void ParentAlpha::addChildWidget(QWidget *childWidget)
|
||||
{
|
||||
if (childWidget)
|
||||
{
|
||||
m_layout->addWidget(childWidget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/parent_interface.h"
|
||||
#include <QLineEdit>
|
||||
#include <QObject>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ParentAlpha
|
||||
: public QObject
|
||||
, public ParentInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ParentInterface")
|
||||
Q_INTERFACES(ParentInterface)
|
||||
|
||||
public:
|
||||
ParentAlpha();
|
||||
QString pluginName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
void addChildWidget(QWidget *childWidget) override;
|
||||
QObject *qobjectInstance() override { return this; }
|
||||
|
||||
signals:
|
||||
void dataChangedLive(const QString &text);
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QVBoxLayout *m_layout;
|
||||
QLineEdit *m_inputField;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["parent_alpha"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Confluence: https://confluence-classified.rh-int.de/spaces/GUEZDLBO/pages/186346247/Plugin+Konzept
|
||||
|
||||
Jira: https://devhub.defence-elec.de/jira/browse/LS-671
|
||||
Reference in new issue
Block a user