CCIMXDesktop
 
Loading...
Searching...
No Matches
DesktopWidgetPluginServer Class Reference

Manages the lifecycle of dynamically loaded QWidget-based plugins. More...

#include <DesktopPluginServer.h>

Inheritance diagram for DesktopWidgetPluginServer:
DesktopServerBase

Signals

void pluginLoaded (const QString &pluginName, const QString &pluginPath)
 Signal emitted when a plugin has been successfully loaded.
 
void pluginFailed (const QString &pluginName, const QString &pluginPath, const QString &pluginErrorString)
 Signal emitted when a plugin fails to load.
 
void pluginUnloaded (const QString &pluginName)
 Signal emitted when a plugin has been successfully unloaded.
 
void pluginUnloadedFailed (const QString &pluginName, const QString &pluginErrorString)
 Signal emitted when a plugin fails to unload.
 
- Signals inherited from DesktopServerBase
void server_ready ()
 server ready
 
void server_unload ()
 server unloaded
 
void server_dead ()
 server dead
 

Public Member Functions

 DesktopWidgetPluginServer (const QString &monitoring_dll, DesktopMainWindow *parent)
 Constructs a DesktopWidgetPluginServer instance.
 
 ~DesktopWidgetPluginServer () override
 Destroys the DesktopWidgetPluginServer object.
 
void insertPlugin (const QString &pluginName, const QString &plugin_path)
 Inserts (loads) a plugin into the server.
 
bool unloadPlugin (const QString &plugin_name)
 Unloads a plugin identified by its name.
 
void scanTargetDirent ()
 Scans the target directory for new or updated plugin DLLs.
 
void removeAllPlugins ()
 Unloads and removes all currently loaded plugins.
 
QWidget * queryWidget (const QString &pluginName, QWidget *expected_parent)
 Queries and instantiates a QWidget from a loaded plugin.
 
DesktopMainWindowhooked_window () const
 Returns a pointer to the associated DesktopMainWindow.
 
- Public Member Functions inherited from DesktopServerBase
 DesktopServerBase (QObject *parent)
 DesktopServerBase.
 
 __PROPERTY_GETSET (bool, enabled)
 server en/disable
 
 __PROPERTY_GETSET (QString, serverName)
 server name
 

Additional Inherited Members

- Protected Attributes inherited from DesktopServerBase
bool enabled { true }
 is enabled
 

Detailed Description

Manages the lifecycle of dynamically loaded QWidget-based plugins.

This class extends DesktopServerBase and provides functionalities to load, unload, and manage plugins that expose QWidget instances. It can monitor a specified directory for new or removed plugin DLLs and automatically manage them.

It emits signals to notify about the success or failure of plugin operations.

Constructor & Destructor Documentation

◆ DesktopWidgetPluginServer()

DesktopWidgetPluginServer::DesktopWidgetPluginServer ( const QString &  monitoring_dll,
DesktopMainWindow parent 
)
explicit

Constructs a DesktopWidgetPluginServer instance.

Parameters
monitoring_dllThe path to the directory or specific DLL to monitor for plugins.
parentA pointer to the DesktopMainWindow instance that this server is associated with. This window might be the parent for the loaded widgets.

◆ ~DesktopWidgetPluginServer()

DesktopWidgetPluginServer::~DesktopWidgetPluginServer ( )
override

Destroys the DesktopWidgetPluginServer object.

  • This destructor ensures all loaded plugins are properly unloaded and resources are released.

Member Function Documentation

◆ hooked_window()

DesktopMainWindow * DesktopWidgetPluginServer::hooked_window ( ) const
inline

Returns a pointer to the associated DesktopMainWindow.

Returns
A pointer to the DesktopMainWindow instance that this server is hooked to.

◆ insertPlugin()

void DesktopWidgetPluginServer::insertPlugin ( const QString &  pluginName,
const QString &  plugin_path 
)

Inserts (loads) a plugin into the server.

  • This method attempts to load a plugin from the given path and associates it with a unique plugin name. If the plugin is successfully loaded, the pluginLoaded signal is emitted. Otherwise, pluginFailed is emitted.
    Parameters
    pluginNameA unique name to identify the plugin.
    plugin_pathThe absolute file path to the plugin (DLL/shared library).

◆ pluginFailed

void DesktopWidgetPluginServer::pluginFailed ( const QString &  pluginName,
const QString &  pluginPath,
const QString &  pluginErrorString 
)
signal

Signal emitted when a plugin fails to load.

Parameters
pluginNameThe name of the plugin that failed to load.
pluginPathThe file path of the plugin that failed.
pluginErrorStringA descriptive string detailing the error.

◆ pluginLoaded

void DesktopWidgetPluginServer::pluginLoaded ( const QString &  pluginName,
const QString &  pluginPath 
)
signal

Signal emitted when a plugin has been successfully loaded.

Parameters
pluginNameThe name of the loaded plugin.
pluginPathThe file path from which the plugin was loaded.

◆ pluginUnloaded

void DesktopWidgetPluginServer::pluginUnloaded ( const QString &  pluginName)
signal

Signal emitted when a plugin has been successfully unloaded.

Parameters
pluginNameThe name of the unloaded plugin.

◆ pluginUnloadedFailed

void DesktopWidgetPluginServer::pluginUnloadedFailed ( const QString &  pluginName,
const QString &  pluginErrorString 
)
signal

Signal emitted when a plugin fails to unload.

Parameters
pluginNameThe name of the plugin that failed to unload.
pluginErrorStringA descriptive string detailing the error.

◆ queryWidget()

QWidget * DesktopWidgetPluginServer::queryWidget ( const QString &  pluginName,
QWidget *  expected_parent 
)

Queries and instantiates a QWidget from a loaded plugin.

  • This method attempts to create an instance of a widget provided by the specified plugin. The plugin must expose a creatable QWidget.
    Parameters
    pluginNameThe unique name of the plugin from which to query the widget.
    expected_parentThe parent QWidget for the newly created plugin widget.
    Returns
    A pointer to the newly created QWidget instance, or nullptr if the plugin is not found or the widget cannot be created.

◆ removeAllPlugins()

void DesktopWidgetPluginServer::removeAllPlugins ( )

Unloads and removes all currently loaded plugins.

  • This method iterates through all managed plugins, unloads them, and clears the internal plugin map.

◆ scanTargetDirent()

void DesktopWidgetPluginServer::scanTargetDirent ( )

Scans the target directory for new or updated plugin DLLs.

  • This method is typically called to discover plugins that have been added or modified in the monitoring_dll path since the last scan or initialization. It will load any new plugins found.

◆ unloadPlugin()

bool DesktopWidgetPluginServer::unloadPlugin ( const QString &  plugin_name)

Unloads a plugin identified by its name.

  • This method unloads the specified plugin, removing it from memory. If successful, pluginUnloaded is emitted. If unloading fails, pluginUnloadedFailed is emitted.
    Parameters
    plugin_nameThe unique name of the plugin to unload.
    Returns
    True if the plugin was successfully unloaded, false otherwise.

The documentation for this class was generated from the following files: