Singleton that manages pyproject.toml-based plugin packages.
More...
#include <packagemanager.h>
|
| void | packagesInstalled () |
| void | featureRegistered (const QString &type, const QString &packageDir, const QString &command, const QString &identifier, const QVariantMap &metadata) |
| void | featureRemoved (const QString &type, const QString &packageDir, const QString &command, const QString &identifier) |
|
|
static PackageManager * | instance () |
| static QStringList | featureTypes () |
| static QString | packageFeatureKey (const QString &packageDir, const QString &command, const QString &identifier) |
| static QJsonObject | loadOptionsFromFile (const QString &userOptionsPath) |
| static void | mergeOptionsFromFile (QJsonObject &opts, const QString &userOptionsPath) |
| static QJsonObject | loadOptionsFromScript (const QString &packageDir, const QString &command, const QString &identifier) |
| static QJsonObject | resolveUserOptions (const QString &userOptionsValue, const QString &packageDir, const QString &command, const QString &identifier) |
Packages are registered once (at download time or manually) and cached in QSettings. On startup, loadRegisteredPackages() replays the cached registrations as featureRegistered() signals so that consumer plugins (Command, ScriptCharges, Forcefield, etc.) can create their actions and models without re-parsing TOML or calling scripts.
During a session, registerPackage() can be called at any time (e.g. after the plugin downloader installs a new package) and signals fire immediately.
◆ featureTypes()
| QStringList featureTypes |
( |
| ) |
|
|
static |
Known feature-type strings (TOML table names under [tool.avogadro]).
◆ packageFeatureKey()
| QString packageFeatureKey |
( |
const QString & | packageDir, |
|
|
const QString & | command, |
|
|
const QString & | identifier ) |
|
static |
Build a stable key for one package-provided feature. Consumers can use this as a map key to track registrations and removals. Components must not be empty.
◆ loadOptionsFromFile()
| QJsonObject loadOptionsFromFile |
( |
const QString & | userOptionsPath | ) |
|
|
static |
Load package user-options from JSON or TOML (selected by extension). Returns an empty object on error.
◆ mergeOptionsFromFile()
| void mergeOptionsFromFile |
( |
QJsonObject & | opts, |
|
|
const QString & | userOptionsPath ) |
|
static |
Merge package user-options into opts. Keys from the file override existing values in opts.
◆ loadOptionsFromScript()
| QJsonObject loadOptionsFromScript |
( |
const QString & | packageDir, |
|
|
const QString & | command, |
|
|
const QString & | identifier ) |
|
static |
Run the package script with --user-options and parse the JSON output. Uses pixi (preferred) or the venv-installed script as fallback. Returns an empty object on error.
◆ resolveUserOptions()
| QJsonObject resolveUserOptions |
( |
const QString & | userOptionsValue, |
|
|
const QString & | packageDir, |
|
|
const QString & | command, |
|
|
const QString & | identifier ) |
|
static |
Resolve user-options for a package feature. If userOptionsValue is the literal string "dynamic", runs the script with --user-options via loadOptionsFromScript(). Otherwise treats it as a relative file path and loads via loadOptionsFromFile(). Returns an empty object on error or if userOptionsValue is empty.
◆ installPackages()
| void installPackages |
( |
const QStringList & | packageDirs | ) |
|
Asynchronously run pixi (preferred) or pip install in each directory, then call registerPackage() for each. Emits packagesInstalled() when the background thread finishes. Safe to call from the main thread.
◆ registerPackage()
| bool registerPackage |
( |
const QString & | packageDir | ) |
|
Parse pyproject.toml in packageDir, cache the result in QSettings, and emit featureRegistered() for every feature found.
- Returns
- true on success.
◆ unregisterPackage()
| bool unregisterPackage |
( |
const QString & | packageName | ) |
|
Remove a package and all its feature registrations from the cache. Emits featureRemoved() for each feature that was registered.
◆ loadRegisteredPackages()
| void loadRegisteredPackages |
( |
const QString & | typeFilter = QString() | ) |
|
Load all previously-registered packages from QSettings and emit featureRegistered() for each cached feature. Call this once after all consumer plugins have connected.
◆ scanDirectory()
| QStringList scanDirectory |
( |
const QString & | directoryPath | ) |
|
Scan directoryPath for subdirectories that contain a pyproject.toml. Each discovered package is compared against the cached hash of its pyproject.toml; new or modified packages are returned as a list of absolute directory paths. The caller is responsible for calling registerPackage() on any directories it wants to install.
- Returns
- list of package directories that are new or have been modified.
◆ packageFeatureTypes()
| QStringList packageFeatureTypes |
( |
const QString & | packageName | ) |
const |
Return the distinct feature-type strings (e.g. "menu-commands", "file-formats") for a registered package, read from the QSettings cache.
◆ packagesInstalled
| void packagesInstalled |
( |
| ) |
|
|
signal |
Emitted after installPackages() finishes installing and registering all requested packages.
◆ featureRegistered
| void featureRegistered |
( |
const QString & | type, |
|
|
const QString & | packageDir, |
|
|
const QString & | command, |
|
|
const QString & | identifier, |
|
|
const QVariantMap & | metadata ) |
|
signal |
Emitted for each feature found in a package.
- Parameters
-
| type | One of the featureTypes() strings, e.g. "menu-commands", "electrostatic-models", etc. |
| packageDir | Absolute path to the package directory. |
| command | Entry-point name from [project.scripts]. |
| identifier | The feature's unique identifier. |
| metadata | Remaining TOML sub-table fields as a QVariantMap. |
◆ featureRemoved
| void featureRemoved |
( |
const QString & | type, |
|
|
const QString & | packageDir, |
|
|
const QString & | command, |
|
|
const QString & | identifier ) |
|
signal |
Emitted when a feature is removed (so consumers can clean up).
- Parameters
-
| type | One of the featureTypes() strings. |
| packageDir | Absolute path to the package directory. |
| command | Entry-point name from [project.scripts]. |
| identifier | The feature's unique identifier. |
The documentation for this class was generated from the following file: