#include "mainwindow.h" #include #include #include #include #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(); } MainWindow::~MainWindow() { } void MainWindow::setupUi() { // Determine the appropriate plugin extension based on the platform QString pluginExtension; #if defined(Q_OS_WIN) pluginExtension = ".dll"; #elif defined(Q_OS_MAC) pluginExtension = ".dylib"; #else // Linux and other Unix-like systems pluginExtension = ".so"; #endif // Load the chatsdk_ui plugin with the appropriate extension QString pluginPath = QCoreApplication::applicationDirPath() + "/../chatsdk_ui" + pluginExtension; QPluginLoader loader(pluginPath); QWidget* chatWidget = nullptr; if (loader.load()) { QObject* plugin = loader.instance(); if (plugin) { // Try to create the chat widget using the plugin's createWidget method QMetaObject::invokeMethod(plugin, "createWidget", Qt::DirectConnection, Q_RETURN_ARG(QWidget*, chatWidget)); } } if (chatWidget) { setCentralWidget(chatWidget); } else { qWarning() << "================================================"; qWarning() << "Failed to load chat SDK UI plugin from:" << pluginPath; qWarning() << "Error:" << loader.errorString(); qWarning() << "================================================"; // Fallback: show a message when plugin is not found QWidget* fallbackWidget = new QWidget(this); QVBoxLayout* layout = new QVBoxLayout(fallbackWidget); QLabel* messageLabel = new QLabel("Chat SDK UI module not loaded", fallbackWidget); QFont font = messageLabel->font(); font.setPointSize(14); messageLabel->setFont(font); messageLabel->setAlignment(Qt::AlignCenter); layout->addWidget(messageLabel); setCentralWidget(fallbackWidget); } // Set window title and size setWindowTitle("Logos Chat SDK UI App"); resize(1000, 700); }